2007-12-19

OpenMoko Debug Board

I've had a problem with my u-boot_env since ever since I flashed a bad u-boot version in early august. The first time I tried to flash a new kernel it wrote right over the environment partition and since then I've been unable to boot without holding in AUX and use Factory Reset. Also, since the u-boot_env was overwritten I had no way to redirect the u-boot serial terminal output to USB because the limited default boot menu only includes Boot and Factory Reset.

Fortunately I managed to get my hands on a debug board. (Thanks abraxa_!) Following the instructions in the wiki I installed libftdi and started looking for an openocd ebuild. Wasn't until later that I realized I didn't need to install openocd in Gentoo at all, since it was a lot easier to use the one built by the Moko Makefile.

Next I connected the debug board to the pc but it just wouldn't show up correctly. Taking a closer look at the debug board page in the wiki I noticed I was missing kernel module. Recompile the kernel to include Device Drivers -> USB -> USB Serial Converter Support -> USB FTDI Single Port Serial Driver as a module, and after a modprobe ftdi_sio vendor=0x1457 product=0x5118 the device was detected the way it should:
drivers/usb/serial/usb-serial.c: USB Serial Driver core
drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI USB Serial Device
ftdi_sio 2-1.1:1.0: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT2232C
usb 2-1.1: FTDI USB Serial Device converter now attached to ttyUSB0
ftdi_sio 2-1.1:1.1: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT2232C
usb 2-1.1: FTDI USB Serial Device converter now attached to ttyUSB1
usbcore: registered new interface driver ftdi_sio
drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver
I updated the openocd.conf according to the wiki and it started without complaints. Did a telnet localhost 4444 and was greeted by the openocd prompt. The only problem now was that I had no real clue how to proceed. I typed help in the prompt and then tried some of the commands. After a mix of a halt and reset commands the Neo1973 went black. Trying to restart from scratch I closed openocd and unplugged the debug board. That turned out to be a bad idea. After reconnecting the USB cable and restarting openocd I constantly got the error:
Info: openocd.c:93 main(): Open On-Chip Debugger (2007-09-05 09:00 CEST)
Info: configuration.c:50 configuration_output_handler(): Command ft2232_vid_pid not found
Info: configuration.c:50 configuration_output_handler(): Command ft2232_layout not found
Error: jtag.c:1461 jtag_init(): No valid jtag interface found (ft2232)
Error: jtag.c:1462 jtag_init(): compiled-in jtag interfaces:
Error: jtag.c:1465 jtag_init(): 0: parport
The reason it failed was probably that the Neo was still on, but halted, and I guess that caused some trouble for the debug board. After disconnecting both devices and taking the battery out of the Neo, then starting over again it worked better.

Asked for some help in #openmoko for how to get that u-boot_env repaired and NineX suggested using the Devirginator since it had worked well for him. At that time the buildhost was down, so I tried to configure it to use my local repository instead. After about an hour or so fighting with the config file, only getting useless error messages, I got tired and gave up for the day.

At the same time as NineX mentioned the devirginator, Mike Montour put together a short list of steps in a pastebin explaining how to do it manually and my plan was to try that next time. While I was away during the weekend, moving to Stockholm, he wrote an awesome wiki page on how to do that manual Unbricking. Thanks a lot for the clear and helpful wiki page Mr Montour!

I followed the steps on that page straight through, using a mix of openocd, dfu-util and cu, I now have a Neo1973 that boots correctly. Rebuilding my Bad Block Table showed that I had a bad block at 0x00004000, the default u-boot_env address. Maybe that, in combination with an early August version of u-boot was the reason I got this problem in the first place.

The Debug Board itself is not so easy to use at first, especially when you're not really familiar with embedded things like JTAG and serial consoles. Despite that it is still very nice to have one around when you experiment with your Neo1973. If I knew this low level stuff was so much fun I would have bought the Advanced Kit from the start.

2 comments:

Anonymous said...

Interesting read, why didn't I see it one planet?

Anonymous said...
This comment has been removed by a blog administrator.