Date: Tue, 13 Jan 2004 01:50:28 +0100 (CET)
From: Carsten Koester <carsten@ckoester.net>
Subject: U-Boot 1.0 and Linux kernel 2.6.0
Folks,
FYI, I've applied my previous u-Boot patches (which were back in June 2002 on a fairly outdated u-Boot version) to the latest CVS release, currently 1.0.2... and they still seem to work.
I will upload the latest diffs to my homepage (www.ckoester.net/audiotron) later today. Here's a step-by-step howto. This overlaps with what I sent before, but this time is more complete and includes examples
1.) Grab the shoehorn AudioTron hack from
http://www.ckoester.net/audiotron/shoehorn-at.tar.gz
Shoehorn consists of a client-side loader (loader.bin) which receives a file from the serial port, erases the flash and writes the received file to flash; and a host-side utility which configures the serial port, waits for the "<" char, sends the beforementioned loader, waits for the ">" char and then sends the actual bootloader (uboot/bsquare) to the running
loader.bin.
2.) A compiled "loader.bin" is already included in the .tar file, and so is the host-side "shoehorn" utility (renamed to atron-dl). You can re-compile them if you like, just run "make".... NOTE: I used arm-linux-gcc v2.95.4 and binutils 2.12.90.0.1 for this, just in case
ckoester@ckoester-nb2:~/src/shoehorn-3.4$ make
arm-linux-gcc -Wall -fomit-frame-pointer -O2 -nostdlib \
-Wl,-Ttext,0x10000000 -N init.S loader.c -o loader.elf
arm-linux-objcopy -O binary loader.elf loader.bin
cc -g -Wall -c -o eth.o eth.c
cc -g -Wall -c -o serial.o serial.c
cc -g -Wall -c -o shoehorn.o shoehorn.c
cc -g -Wall -c -o util.o util.c
rm -f .setuid.stamp
cc -g -o shoehorn eth.o serial.o shoehorn.o util.o
cc -g -Wall -g -o atron-dl serial.c atron-dl.c util.c
ckoester@ckoester-nb2:~/src/shoehorn-3.4$ ls -l loader.bin atron-dl
-rwxr-xr-x 1 ckoester ckoester 55870 Jan 13 00:40 atron-dl
-rwxr-xr-x 1 ckoester ckoester 1344 Jan 13 00:40 loader.bin
ckoester@ckoester-nb2:~/src/shoehorn-3.4$
3.) Grab the u-Boot sources, either from www.sourceforge.net (v1.0.0) or from CVS (currently v1.0.2). Then, grab the following file:
http://www.ckoester.net/audiotron/u-boot-1.0.2_diff.gz
Then, apply the patch, and build the u-boot loader for the "audiotron" platform.
ckoester@ckoester-nb2:~/tmp$ cvs
-d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/uboot login
ckoester@ckoester-nb2:~/tmp$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/u-boot co u-boot
cvs server: Updating u-boot
[...]
ckoester@ckoester-nb2:~/tmp/u-boot$ zcat ../../u-boot-1.0.2.diff.gz |
patch -p1
patching file MAKEALL
patching file Makefile
patching file board/audiotron/Makefile
patching file board/audiotron/audiotron.c
patching file board/audiotron/config.mk
patching file board/audiotron/flash.c
patching file board/audiotron/memsetup.S
patching file board/audiotron/u-boot.lds
patching file include/configs/audiotron.h
ckoester@ckoester-nb2:~/tmp/u-boot$ make audiotron_config
rm -f include/config.h include/config.mk
Configuring for audiotron board...
ckoester@ckoester-nb2:~/tmp/u-boot$ make
[...]
arm-linux-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin
ckoester@ckoester-nb2:~/tmp/u-boot$ ls -l u-boot.bin
-rwxr-xr-x 1 ckoester ckoester 103092 Jan 13 01:11 u-boot.bin
4.) Use shoehorn to upload u-boot to the audiotron
Ping your running AudioTron and do an ARP lookup, or get the AT's MAC address via some other way. You will need it later!
Power off your AT, connect the serial port, set JP7, power on the AT (at the back).
Then, start atron-dl as shown below, and press the "power" button in the front. This will copy the u-boot binary to the AT flash.
BE AWARE: This erases your AT's flash. After this point, you will need either u-boot or shoehorn working if you want to recover your original TB firmware!
ckoester@ckoester-nb2:~/src/shoehorn-3.4$ ./atron-dl
--image=../../tmp/u-boot/u-boot.bin
loader.bin: 1344 bytes (2048 bytes buffer)
../../tmp/u-boot/u-boot.bin: 103092 bytes
Waiting for target - press Wakeup now.
Writing SRAM loader...
Pinging loader
Initialising Audiotron hardware:
- flushing cache/TLB
- 73MHz core clock
- 64kHz DRAM refresh
- enabling UART2
- Activate LED flasher
- Setting up flash at CS0 and CS1, 32 Bit, 3 Waitstates
Switching to 115200 baud
Pinging loader
Flash ID: 278200bf
Writing 103092 bytes (26 sector(s)) at starting address 70000000
Erasing...
26 sectors erased...
Writing...
102400 bytes written...
Switching back to 9600 baud
Pinging loader
ckoester@ckoester-nb2:~/src/shoehorn-3.4$
5.) Power off the AT, remove JP7, start your favorite terminal client (minicom or whatever), configure 9600bps 8N1, power on the AT, and press the front power button.
If you're lucky, you get to talk to u-Boot. Interrupt the start sequence by pressing any key.
U-Boot 1.0.2 (Jan 13 2004 - 01:11:15)
U-Boot code: C0F00000 -> C0F192B4 BSS: -> C0F1CBD8
RAM Configuration:
Bank #0: c0000000 8 MB
Bank #1: c0800000 8 MB
Flash: 2 MB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
AT #
6.) At this point, during development phase, I set up a TFTP server on my machine so I could tftpboot kernels while I go along, instead of having to update flash over and over again. You can do this by setting a number of environment variables (which u-Boot conveniently allows to store in flash).
AT # setenv ethaddr 11:22:33:44:55:66
AT # setenv ipaddr 10.61.224.172
AT # setenv netmask 255.255.255.248
AT # setenv serverip 10.61.97.156
AT # setenv gatewayip 10.61.224.170
AT # setenv bootfile uImage
AT # setenv bootcmd 'mw 50000000 00020000 ; tftp ; bootm'
AT # setenv bootargs 'console=ttyCL0 mem=16M'
AT # printenv
bootargs=devfs=mount root=ramfs console=ttyS0,9600
bootcmd=bootp;bootm
bootdelay=3
baudrate=9600
stdin=serial
stdout=serial
stderr=serial
ipaddr=10.61.224.172
netmask=255.255.255.248
serverip=10.61.97.156
gatewayip=10.61.224.170
bootfile=uImage
bootcmd=mw 50000000 00020000 ; tftp ; bootm
bootargs=console=ttyCL0 mem=16M
ethaddr=11:22:33:44:55:66
Environment size: 300/131068 bytes
AT # saveenv
Saving Environment to Flash...
Un-Protected 2 sectors
Erasing Flash...
Erasing sector 00020000
Erasing sector 00030000
done
Erased 2 sectors
Writing to Flash... done
Protected 2 sectors
AT #
NOTE1: Obviously, the IP addresses etc. will need to change depending on
your setup. Use the MAC address you wrote down in step 4.) above.
NOTE2: The "mw 50000000 00020000" writes to the front panel LEDs and illuminates the "Stop" button. This has no practical use at this moment; prior to the LCD display and serial console working in the kernel, I am just using these LEDs as a method to "checkpoint" certain steps in the boot process to figure out where it's hanging
7.) Compile a linux kernel
This is the next big task... Today, I have just compiled a kernel for the EP7312 platform just to make sure the bootloader stuff is working (it gets as far as de-compressing the zImage but then hangs because none of the memory configuration is right). I have used kernel 2.6.0 with the arm-linux patches from www.arm.linux.org.uk and a plain configuration...
but again, this is worth nothing at this point.
NOTE: You will proably need a newer/different tool chain (compiler and binutils) than the previously mentioned ones to compile a 2.5.x or 2.6.x kernel...
Once compiled, copy the uImage to the /tftp directory and see what happens:
NOTE2: You can run "make uImage" to build an image suitable for u-Boot. For this to work, you need to copy the "mkimage" tool which got created in the tools/ directory when you compiled u-boot into a directory in $PATH so make can find it:
ckoester@ckoester-nb2:~$ cp ~/tmp/u-boot/tools/mkimage /usr/local/bin/
ckoester@ckoester-nb2:~/src/linux/linux-2.6.0$ make uImage
CC arch/arm/kernel/asm-offsets.s
CHK include/asm-arm/constants.h
[...]
CHK include/linux/compile.h
Kernel: arch/arm/boot/zImage is ready
Image Name: Linux-2.6.0-rmk2
Created: Tue Jan 13 01:39:09 2004
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 705632 Bytes = 689.09 kB = 0.67 MB
Load Address: 0xC0028000
Entry Point: 0xC0028000
Image arch/arm/boot/uImage is ready
ckoester@ckoester-nb2:~/src/linux/linux-2.6.0$
ckoester@ckoester-nb2:~/src/linux/linux-2.6.0$ cp arch/arm/boot/uImage /tftpboot/
ckoester@ckoester-nb2:~/src/linux/linux-2.6.0$ ls -l /tftpboot/uImage
-rw-r--r-- 1 ckoester ckoester 705696 Jan 13 01:42 /tftpboot/uImage
(Back in the terminal client.. do not press any key and let the autoboot run
AT # reset
U-Boot 1.0.2 (Jan 13 2004 - 01:11:15)
U-Boot code: C0F00000 -> C0F192B4 BSS: -> C0F1CBD8
RAM Configuration:
Bank #0: c0000000 8 MB
Bank #1: c0800000 8 MB
Flash: 2 MB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
TFTP from server 10.61.97.156; our IP address is 10.61.224.172; sending through gateway 10.61.224.170
Filename 'uImage'.
Load address: 0xc0500000
Loading: #################################################################
#################################################################
########
done
Bytes transferred = 705696 (ac4a0 hex)
## Booting image at c0500000 ...
Image Name: Linux-2.6.0-rmk2
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 705632 Bytes = 689.1 kB
Load Address: c0028000
Entry Point: c0028000
Verifying Checksum ... OK
OK
Starting kernel ...
Uncompressing Linux................................................. done, booting the kernel.
This is as far as I got tonight. Unless somebody else is quicker, I will try to get a basic kernel running during the next few days/weeks, more to follow....
8.) Restoring the original AT firmware:
If u-boot is working, *theoretically* it should work like this: (Note... I haven't extensively tested this...)
8.1) Restoring the original AT firmware via u-Boot:
AT # tftp c0028000 atron30101.nb0
TFTP from server 10.61.97.156; our IP address is 10.61.224.172; sending
through
gateway 10.61.224.170
Filename 'atron30101.nb0'.
Load address: 0xc0028000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######
done
Bytes transferred = 2031616 (1f0000 hex)
AT # protect off all
Un-Protect Flash Bank # 1
AT # erase all
Erase Flash Bank # 1
Erasing sector 00000000
[...]
Erasing sector 001f0000
done
AT #
AT # cp c0028000 00000000 3e000
Copy to Flash... done
AT #
-> and power-cycle. You probably still need to set the MAC address as
below.
8.2) Restore the original AT firmware via shoehorn
This needs to be done if your u-Boot isn't working or the flash is completely empty. However, shoehorn and the quick loader.bin hack I've done are much too slow to upload the full image... so you want to upload the first 64kB, which are the BSQUARE loader, and then let them do the rest.
Set JP7...
ckoester@ckoester-nb2:~$ cat /tftpboot/atron30101.nb0 | head -c64k > /tmp/bsquare
ckoester@ckoester-nb2:~$ ls -l /tmp/bsquare
-rw-r--r-- 1 ckoester ckoester 65536 Jan 13 02:06 /tmp/bsquare
ckoester@ckoester-nb2:~/src/shoehorn-3.4$ ./atron-dl --image=/tmp/bsquare
loader.bin: 1344 bytes (2048 bytes buffer)
/tmp/bsquare: 65536 bytes
Waiting for target - press Wakeup now.
[...]
and follow the procedure earlier.
Then remove JP7, but set the CTS jumper on your serial port card. Configure your terminal client to 115200bps, 8n1. Power-cycle and hit the front power button.
(In the terminal client):
+Processor Initialization Table read.
Copy to RAM.
Copied to RAM.
+Processor Initialization Table read.
Costello is awake.
** BSQUATING Loader initializing. **
** LCD Init Complete. **
*********************************************************************
* 16MB ATRON V3.1 HW:v2 BSQUARE Loader for Costello *
* CE3.0 Enabled *
*********************************************************************
1] Full Audiotron Test
2] Download Audiotron Firmware
7] Boot from Flash
0] Download over Serial (XModem)
B] Start Windows CE @ c0000000
D] Reset CE Registry
E] Set up Audiotron MAC address(s)
N] Full Menu
Q] Download over Ethernet
>> 2
>> Select Download Method
1] Serial
2] Ethernet
==>1
REMEMBER: This only works with relocated images built with buildupdate v3.0
Normal Boot; Saving Firmware to 0
Select firmware file on PC
Starting Xmodem Init
>>
then start the x-modem transfer....
When done, the loader will prompt you for the AT MAC address, and for a "Permissions" value. So far I always just entered dummy values ("1" in both cases) here as I haven't figured out which format the tool likes the MAC address in and what the permissions are good for.
9.) REMARKS
Especially for the u-Boot part, I'd like to ask you all to intensively test this. My spontaneous impression was that the flash driver is still a little unstable, sometimes not correctly erasing sectors or sometimes writing corrupted data... This might be a timing condition that could possibly resolved by specifying larger values for
#define CFG_FLASH_ERASE_TOUT
#define CFG_FLASH_WRITE_TOUT
in include/configs/audiotron.h, but I haven't gotten around to testing this yet. Please let me know; once this thing is working stable, I'd like to submit the diffs back into the u-Boot release
Cheers,
-Carsten