Sunday, August 8, 2010

Flyswatter JTAG and AVR32

Today I soldered AVR32 adapter for Flyswatter JTAG. Actually it's very simple task - just connect respective pins and make common ground wire. No capacitors, resistors or MOSFETs. Idea was to make it nice and neat but having bought wrong breadboard and soldered first headers in a wrong place I just let it flow and here it is:

 


From aesthetics point of view suck, but it also works and it's everything I need:


Info : JTAG tap: avr32.cpu tap/device found: 0x21e8203f (mfg: 0x01f, part: 0x1e82, ver: 0x2)

Warn : JTAG tap: avr32.cpu UNEXPECTED: 0x21e8203f (mfg: 0x01f, part: 0x1e82, ver: 0x2)

Monday, July 5, 2010

Minor OpenOCD fixes

Back from the land of GUI software. I have bought one more Flyswatter JTAG recently and now have two boards connected to my home box. Unfortunately both Flyswatters got the same USB serial number so stock openocd opens only the first device it stumbles upon. Here is small patch that adds ft2232_index command to OpenOCD FTDI driver that allows to point at specific device to open. Works only with libftdi. In the same directory you can find my configs for AR71XX-based RouterStation Pro and Portwell's CAM-0010 device based on Octeon CN3010

Thursday, February 18, 2010

Writing FreeBSD NIC driver

I've been through writing NIC driver 2.5 times. 0.5 was porting ADM5120 switch driver by Ruslan Ermilov and Vsevolod Lobko from NetBSD. The usual routine for this kind of thing is "take existing driver and rewrite it", e.g. copy selected parts or remove unnecessary ones. So I decided that it would be nice to skip "remove" part of procedure next time.

All cards I had to deal with ("both" wouldn't be that impressive here) had similar design save for registers layout and some quirks. I believe that vast majority of NICs have the same design to some extent: there are circular RX/TX rings of more or less similar structure, interrupt status/mask register, media settings registers, you name it. Not a rocket science.

So I took if_arge driver from Atheros AR71XX SoC and replaced hardware-dependent parts with FIXME comments. Also string "ARGE" was replaced to "ADAPTER" and "arge" to "adapter" so simple s/adapter/xyz/g and s/ADAPTER/XYZ/g would give us a half-baked source base for if_xyz driver.

It's yet to be tested whether this approach would be of any good. I'm planning to try it in next few days :) Meanwhile you can check sources here.

Monday, January 18, 2010

FReeBSD/MIPS & clang/LLVM

Now I know a little bit more about clang. I can't say it's quite useful for MIPS yet, but it's nice to see some progress in this field. My findings might be inaccurate and any corrections are welcome.

- No proper cross-compilation so far. Clang team plans to do it "right way" but so far it's just an item on their ToDo list: Universal driver. There are command-line options like -ccc-host-triple to get target assembler code, but names for assembler/linker are hardcoded to as/ld, which puts some restriction on building target toolchain

UPD: -ccc-host-triple does the trick OK


- No proper march/mabi handlers for MIPS platform. Only ARM and x86 are supported.

I managed to build hello world application in semi-automatic mode on RouterStation booted over NFS:

[root@ /llvm/llvm]# clang -v -fPIC -Wa,-mabi=32,-EB,-KPIC hello.c
clang version 1.1 (trunk)
Target: mips-unknown-freebsd9.0
Thread model: posix
"/opt/bin/clang" -cc1 -triple mips-unknown-freebsd9.0 -S -disable-free -main-file-name hello.c -pic-level 2 -mdisable-fp-elim -v -resource-dir /opt/lib/clang/1.1 -fmessage-length 0 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-tuAxTl.s -x c hello.c
clang -cc1 version 1.1 based upon llvm 2.7svn hosted on mips-unknown-freebsd9.0
#include "..." search starts here:
#include <...> search starts here:
/opt/lib/clang/1.1/include
/usr/local/include
/usr/include
End of search list.
"/usr/bin/as" -mabi=32 -EB -KPIC -o /tmp/cc-LZzHnl.o /tmp/cc-tuAxTl.s
"/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o /tmp/cc-LZzHnl.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
[root@ /llvm/llvm]# ./a.out
Hello world!
[root@ /llvm/llvm]# uname -a
FreeBSD 9.0-CURRENT FreeBSD 9.0-CURRENT #28: Fri Jan 15 16:50:23 PST 2010 gonzo@figaro.bluezbox.com:/src/FreeBSD/obj/head-mips/mips/src/FreeBSD/head/sys/AR71XX mips
[root@ /llvm/llvm]#


So it seems to be nice starting point for some minor compiler hacking :)

Monday, January 11, 2010

projects/mips RIP

All changes from projects/mips has been merged to HEAD. Kudos go to imp@ for sieving through mergeinfo mess projects/mips has been.

Friday, January 8, 2010

FreeBSD/mips and LLVM

Good news: LLVM builds fine on RouterStation Pro with root mounted over NFS.
Bad news: it segfaults on some tests and when trying to build hello world application.

Stay tuned