diGriz's Chunk of Web

bash$ :(){ :|:&};:


Getting to Grips with the Technologic Systems TS-7800

Booting From an SD Card

Dear god, this is the best feature ever. I love it...

Download flash-mbr.dd and pick up a spare SD card at least 512MiB in size to tinker with. We assume that when you plug the SD card into your laptop it appears as /dev/mmcblk0.

Plug in the SD card and type as root:

 # dd if=/usr/src/ts7800/flash-mbr.dd of=/dev/mmcblk0 

Now unplug the SD card and plug it back in (I cannot remember the command to tell Linux to reprobe a plugged in devices partition table), you should notice that it now has a partition table as well as a MBR slapped onto it. As root type:

 # dd if=/usr/src/ts7800/my-kernel of=/dev/mmcblk0p1
 # # option initrd, I personally zImage my kernel and initramfs
 # dd if=/usr/src/ts7800/my-initrd of=/dev/mmcblk0p2 

For the remaining space I would recommend you use JFS for the filesystem if you want to add further partitions; just leave partition 1 and 2 alone along with the initial 128kiB 'gap'.

Now to boot off the SD card, enable JP1 on the mainboard and off you go.

Getting a Toolchain

Two ways to do this, either download one or build your own. If you plan on being lazy head on over to Martins Crosstool Bits however if you want to build your own read on.

These desctructions were based on the nice simple instructions on over at the emDebian website on their emDebian toolchain building HOWTO page.

More or less the instructions are (amending their's when apprioate as I'm build for an 'armel' target from a Debian 'unstable' box running gcc 4.2.x):

 $ aptitude install dpkg-cross apt-cross fakeroot dpatch gawk flex realpath automake1.7 debhelper cdbs
 $ apt-get source gcc-4.2 binutils glibc
 $ cd binutils-2.x
 # N.B. yes, 'arm' and not 'armel' here
 $ TARGET=arm-linux-gnueabi fakeroot debian/rules binary-cross
 # dpkg -i ../binutils-arm-linux-gnueabi_2.x_i386.deb
 $ cd ..
 $ apt-cross -a armel -v -i libdb1-compat libc6 libc6-dev linux-libc-dev
 $ cd gcc-4.2-x
 $ export GCC_TARGET=armel
 $ debian/rules control
 $ dpkg-buildpackage -b -rfakeroot 

Once that's finished you should be able to install the gcc cross compiler and you are 'cooked'.

Kernel Compiling

To do a basic bog standard kernel recompile, you download the TS 2.6.21 kernel, make sure you have your toolchain to hand and type (amend to suit your toolchain):

 alias amake='make ARCH=arm CROSS_COMPILE=arm-crosstool-linux-gnueabi-'
 amake menuconfig
 amake -j2 Image 

TS's 'Standard' 2.6.21-ts Kernel

To get their 'standard' kernel to compile and work you need:

CONFIG_BLK_DEV_RAM=y

if you do not do this then your kernel will not even begin to boot, even if you are not using an initrd/initramfs. This seems to be really only true (always ture for the NAND but not for the SD card) if you maintain the partition table structure that TS supplied; on my custom kernels I use a zImage'd INITRAMFS and the partition table is MBR (256kB), kernel (4MB) and rootfs (remaining space).

CONFIG_I2C=y

system will not compile overwise

CONFIG_TIMER_STATS=n

tssdcard will not be able to complete scanning the

CONFIG_PREEMPT=y and CONFIG_MODULE_UNLOAD=y

otherwise the binary tssdcard.ko that TS provide will not insmod

If you are not using TS's supplied toolchain (I am not) then you will also find that the compile will fail as in include/linux/kernel.h includes /usr/local/src/mv-kernel/arm-none-linux-gnueabi/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.4/include/stdarg.h. If you edit the file, comment out the borked one and point it to use whatever the result of 'find /usr -name stdarg.h' tells you, it should work.

For me I used:

  #include "/usr/lib/gcc/arm-crosstool-linux-gnueabi/4.1.1/install-tools/include/stdarg.h" 

The ARM Orion Kernel

This is a work in progress but thanks to the work in the Orion ARM platform port (the bulk of which is mainline since 2.6.25-rc1) all the difficult bits already done to get it booting on a TS-7800. I have put together a number of patches together that add the platform specific parts of the TS-7800 to the Orion branch.

The latest patches lurks at http://www.digriz.org.uk/files/ts7800/orion-ts7800/.

The SATA, USB, TS-BOOTROM NOR, RTC and UART serial ports all seem to work fine. The NAND, I have a working driver and if you want it you can email me but it does not have DMA support so it is pretty useless.

My NAND Flash Is Toast

The following was worked out from the flash7800 script.

 / # mkdir /dev/mtd
 / # cd /dev/mtd
 /dev/mtd # ln -s ../mtd0 0
 /dev/mtd # ln -s ../mtd1 1
 /dev/mtd # ln -s ../mtd2 2
 /dev/mtd # ln -s ../mtd3 3
 /dev/mtd # cd /mnt/root
 /mnt/root # dd if=7800.mbr of=/dev/mtdblock0
 /mnt/root # mtdcopy ImageKernel 1 0
 /mnt/root # mtdcopy 7800initrd 2 0
 /mnt/root # eraseall /dev/mtd3
 /mnt/root # mkdir tmp
 /mnt/root # mount /dev/mtd3 tmp
 /mnt/root # cd tmp
 /mnt/root/tmp # tar -xzf ../sarge-7800.tar.gz
 /mnt/root/tmp # md5sum -c ../files.md5
 /mnt/root/tmp # cd ..
 /mnt/root # umount tmp
 /mnt/root # cd ..
 /mnt # umount root 

It's REALLY Poouched

 >> TS-BOOTROM - built Nov 27 2007
 >> Copyright (c) 2007, Technologic Systems
 >> Booting from onboard NAND flash...
 !0000049a>> flash ECC error! 

If even the chunk at the beginning of your NAND is toast (well the ECC at least) then you need to blat the whole thing:

 eraseall /dev/mtd0 

Seemed to work for me, then you follow the usual 'restore NAND' destructions above.

EABI Is Nicer Than OABI

The TS EABI root filesystem is not too hot, it just complained about broken scripts, segfaulted on bits and is of course rather old. Instead I used the Applied Data EABI root filesystems. They are based on Debian, rather function and fast but needs some minor tweaking. I have provided the final download for anyone to use at http://www.digriz.org.uk/files/ts7800/ad-eabi-rootfs/.

N.B. remember to change root password from 'rootme'

The steps I used to produce the files were:

jdg1

  1. Start with armel Debian root FS from Applied Data Systems http://www.applieddata.net/forums/topic.asp?TOPIC_ID=2444&SearchTerms=eabi

  2. Noted the errata (fixed the symlink 'ln -sf /etc/init.d/glibc.sh /etc/rcS.d/S01glibc.sh')

  3. Amended inittab so that:

    • commented out the Ctrl-Alt-Delete hook

    • commented out tty getty

    • T0:23:respawn:/sbin/getty -L ttyS0 115200 vt102

  4. Extracted linuxmodules-2.6.21-ts-oct092007.tar.gz to lib/modules/2.6.21-ts.

jdg2

  1. Trimmed most of /etc/network/interfaces so that it did nothing on bootup

  2. Removed a lot of packages (unselected the 'install recommended packages' option) and most of the other things I deemed useless (nano == only editor!)

  3. dpkg --purge `dpkg --get-selections | grep deinstall | awk '{ print $1 }'`

  4. Changed inittab to go to runlevel 2 (rather than 3)

Remaining packages show in 'package.list'

jdg3

  1. Change to a single apt source 'deb http://ftp.debian-ports.org/debian sid main'

  2.   gpg --keyserver pgpkeys.mit.edu --recv-key 0792182443229C06
      gpg --export 0792182443229C06 -a | apt-key add - 
  3. ntpdate'd (why dear god can't the RTC be 'standard')

  4. aptitude dist-upgrade (20070217 @ 18:43 GMT)

  5. ldconfig (twice, segfaults the first time...)

Installing Your Own Kernel/rootfs to the NAND

Once you grow tired of the regular TS kernel and filesystem you probably will want to put your own onto the NAND. The way to do this is to prep a regular SD bootable card as detailed above and in the fourth partition you place a suitable kernel, optional initrd and your filesystem image.

Boot off it and type on the TS-7800:

 # umount /mnt/root [might have to wait a bit before you can..]
 # mount -o ro /dev/tssdcardb3 /mnt/root
 # mkdir /dump
 # mount -o ro /dev/tssdcardb4 /dump
 # nandwrite /dev/mtd1 /dump/kernel
 # nandwrite /dev/mtd2 /dump/initrd [ignore if you do not have an initrd]
 # nandwrite /dev/mtd3 /dump/fs.img 

Now reboot and your 'cooked'.

Your Own Cross Compiled Userspace Tools

Fortunately 'apt-cross' takes all the hardwork out of this and more so armel is finally in debian.

For example, lets compile the mtd-tools userspace tools:

 $ apt-cross -a armel -v -i libacl1-dev libacl1 libattr1-dev libattr1 zlib1g-dev zlib1g liblzo2-dev liblzo2-2
 $ mkdir mtd-tools
 $ cd mtd-tools
 $ apt-get source mtd-tools
 $ cd mtd-tools-XXXX
 $ CROSS=arm-linux-gnueabi- make