28 Sep 2015
A switch to aid in software development from remote sites.
The problem: To develop for some boards like BeagleBone Black, Cubieboard 2 and Banana Pi, eventually a physical reboot is needed, either to reboot a freezed kernel or to develop low level features, within kernels or not.
This isn't too much of a problem on an environment of a good OS, where all kind of memory protections prevent wrong actions. Under the confortable user level, one can't simply soft reboot because sometimes you won't even have a keyboard ready to accept commands. It's easy when the board is under someones nose, where a pull-and-push on the power cable can reboot will then reboot. However, it's very common to have to do this kind of development from a remote site, and without a remote switch like this, it is nearly impossible.
Some high-end systems, like servers, have similar features, usually integrated onto the main board which holds the CPU. It's called BMC, and it stands for baseboard management controller. These are complex systems that do much more than just allow to reboot the computer. But unnecessary complexity is bad. Strive to solve problems with a simple and elegant designs.
To the project itself, the goal was to have 3 channels, but not enough items were available at the workshop. The solution was to order some components for further assembly. The transistors used were 2 Darlington TIP102. In easy words, Darlington transistors have a very high gain, meaning it draws very low current from the microcontroller to make it work in the active mode (as a switch). The third not-assembled-yet channel will feature a MOSFET, either a IRFZ44 or a IRF3205. FET means field effect transistor, and in this type of transistor, there are no current drawing through its gate to bring it to the active mode. It can be driven by very low current ICs without a hassle.
Security is a concern. Since it can turn on and off the boards connected to it, you won't want anyone with access to your network to be able to do this. Although an Ethernet interface was considered, there are a lot of problems that must be solved in a microcontroller very very tiny flash RAM: authentication, cryptography, etc. Of course this is impossible.
Using this module connected directly through USB and accessing the rswtch built-in terminal ends up isolating the module to those who have access to the computer it's connected, which can be accessed (only) through SSH and leverage all the security of such approach.
The source code of the firmware and the CLI utility can be seen here, as well with some operation details.
EDIT: There are some ramifications of this story based on some technical aspects.
How it was supposed to work, or how it was tested
Not all the details were shown on how this was tested. The plan was to have only one host with at least 2 USBs in a configuration as shown on the graph below.
Just note on the red arrows on the graph above. As it turns out, this didn't work as expected. Note that cb2 has 2 ramifications. If both ftdi and rswtch are connected to the USB ports of the same computer, we have one peculiarity which prevents this to work. The common configuration of most, if not all of the computers, is to have a common ground for the USB ports. This do not deserve too much detail, as it's not the point. However, it's important to note that because of this peculiarity, even if the channel is switched off by the rswtch transistor, ftdi keeps the lights on and maintains the USB 5V which rswtch were trying to shut down. FAIL.
One solution is to add an USB isolator. Most of these are sold for industrial applications. As it's common, industrial usually means expensive, and although the robusteness of these solutions are attractive, the point here is to have something cheaper. There are some modules based on an IC from Analog Devices labeled ADuM4160, however it still costs around US$30 + shipping costs + taxes (which means 60% or more in Brazil).
So why worked at the first time? It was tested with this configuration:
Note that the common ground is eliminated. However, one additional computer is used, which is of course undesired.
The third approach was to disregard the security implications explained above and add an Ethernet module on top of the microcontroller plus a very simple protocol on top of the UDP protocol.
More on this later.
23 Aug 2015
I still have this box. And the errata is still available. And this is not RHEL 4.x from 2004. It's from 1997.
More images here, here, here, here and here. One curious detail from the user's guide:
05 Aug 2015
For those who develop firmware for Arduino, OpenBSD provides a CLI interface to do it in its ports system. It's an alternative way to it, faster and you do not have to rely on the crap default Arduino IDE, which pleasures new users but do not attract more advanced users which are used to more powerful editors.
When you run
arduinoproject to bootstrap a new project, it gives you a
Makefile file that you have to tweak to fit your board. pkg-readmes, doc which come included in the package, recommends you to check
/usr/local/share/arduino/boards.txt and then set
Makefile. It's not always obvious, and now and then I have to revisit a note I kept somewhere.
UPLOAD_RATE = 115200
PORT = /dev/cuaU0
AVRDUDE_PROGRAMMER = stk500v2
MCU = atmega2560
F_CPU = 16000000
VARIANT = mega
The detail here is that you have to add a
-D flag to the
AVRDUDE_FLAGS. If you do not do this, you may get the following:
$ sudo make upload
/usr/local/bin/avrdude -V -F -C /etc/avrdude.conf -p atmega2560 -P /dev/cuaU0 -c stk500v2 -b 115200 -U flash:w:applet/blink.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9801
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: stk500v2_command(): command failed
avrdude done. Thank you.
*** Error 255 in /home/dbolgheroni/bghbox/electronics/arduino/blink (Makefile:222 'upload')
Didn't investigate if it's the correct-way-to-do-it, but I'll do this later to send a patch to the project. Maybe it's time to update the port to Arduino 1.5, or to update the examples which comes included in
Makefile to reflect the most common boards used today (e.g. UNO).
Try to upload again and you're done.
15 Jul 2015
A última mudança do sistema do Banco do Brasil quebrou quem utiliza um sistema que não seja Windows, seja Linux, OpenBSD, Mac ou outros. No entanto, em distros Debian-based (Ubuntu, Linux Mint, entre outros), existe uma solução relativamente simples:
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-set-default
Existem diferentes implementações de Java, como OpenJDK, Oracle Java, IBM Java, etc. A "oficial" é a da Oracle (antiga Sun), mas a maioria das distros utiliza como default a OpenJDK, justamente por ser open source. Trocar a OpenJDK pela Oracle Java não deveria ser necessário, e pode quebrar outras aplicações, mas resolve o problema.
18 Nov 2014
I have an iMac G3. It's old. I like it. More than once, I screwed up the OS and had to install again.
You have more than one way to do it. You can boot from a CD-ROM, but mine is broken, as most of the CD-ROMs drives on dated machines. Or boot from the network, but you have to setup the environment. Or boot from an USB flash drive, which I didn't think it was possible until I tried a few days ago.
There are some discussions about how to correctly create a bootable USB install media for OpenBSD. Recently, Chris Cappuccio announced the availability of images ready to be copied to an USB flash drive, but they are for i386 and amd64 ports only.
One way which is very debatable on how to do this is to dd the ISO image directly to the USB flash drive. Not because it doesn't work, but because it may not work on all systems. A .iso, more specifically an ISO 9660 .iso file, is a filesystem suited for optical discs, not USB flash drives. Some firmwares (IBM PC BIOS, Open Firmware) will see them as a disk, but you can't be so sure about this. However, this is not the only problem. If you want to dig about the concerns raised on the mailing lists, you can check the archives here and here.
What I'm putting up here is not what you should do, but instead what have worked for me. It's a Reminder For Myself. OpenBSD team is very rigorous about the project documentation, and what's stated at the INSTALLATION NOTES for OpenBSD/macppc 5.6 should be applicable to all supported machines, not just my case as I'm doing here. So, if you read it here, or any other blog for that matter, don't ask it on the mailing lists. Refer to the official FAQ. Refer to the man pages. If you don't find what you're looking for on these references, then yes, ask on one of the mailing lists.
At the time of this writing, the latest version of OpenBSD is 5.6. So, download the cd56.iso from your preferred mirror:
$ ftp ftp://ftp.openbsd.org/pub/OpenBSD/5.6/macppc/cd56.iso
dd'it to your USB flash drive:
# dd if=cd56.iso of=/dev/sd1c bs=4k
To check, in Open Firmware, at some point you'll see something like this:
0 > dev / ls
If you remove the USB install media, you'll note that this turns out to something like this:
0 > dev / ls
Notice that the disk just below /usb@18 gone. Of course, this can vary depending on the model of your machine, the Open Firmware version, etc, but nonetheless it will be very similar. And you don't need the whole path to indicate from where to boot. You can use the devalias command for this:
0 > devalias
0 > boot usb0/disk@1:,\ofwboot
boot> boot 5.6/macppc/bsd.rd
Also note that cd56.iso doesn't have a bsd.rd right at the root, so you need to specify the path to it. Now install OpenBSD/macppc almost as equal to any platform.