WL1100 low level programming and debugging
From EnneEnneWiki
|
|---|
Contents |
Here you can find how to setup a GNU/Linux based developing environment for the WL1100.
Downloading the toolchain
You can get the toolchain at:
- My site at EnneEnne.
Just download the tarball and install it with:
giometti@zaigor:~$ cd / giometti@zaigor:/$ tar xvfz tarball.tgz
the software will be installed into /usr/local/arm/ directory.
Managing the boot loader
In this section you can find several information about u-boot which is the WL1100's bootloader.
Downloading the code
You can get u-boot sources at:
- My site at EnneEnne.
To get the code you need to give the command:
git clone git://git.enneenne.com/u-boot-wl1100
of course you need the GIT tools installed on your system.
Compiling the source
To compile the u-boot source you must go into directory u-boot-wl1100 and give the commands:
~/u-boot-wl1100$ make wl1100_config Configuring for wl1100 board... ~/u-boot-wl1100$ make
The compilation process should start. You'll end up with 4 new files:
-
u-boot.binthe binary image (use this file to program the flash). -
u-bootthe ELF image. -
u-boot.srecthe SREC image. -
u-boot.mapthe MAP file (useful to know where u-boot's symbols are mapped).
The standard environment
Here are explained some environment variables that are used by u-boot to perform some useful commands. You may modify them as you wish in order to fit your system configuration.
After rebooting the WL1100 on the serial line you can see the message:
U-Boot 1.2.0-zy-1.0.0-g85f44ea6-dirty (Jul 23 2007 - 10:13:40) DRAM: 128 MB Flash: 128 MB In: serial Out: serial Err: serial Autobooting in 1 second or enter password to stop.
if you press the sequence 12 you'll get the command prompt "wl1100>" and you can start suppling your commands (plese refere to the u-boot documentation for a detailed commands explanation).
The WL1100 factory environment is:
bootargs=video=pxafb:nocursor ETHSYSNAME=wl1100 console=tty0 loglevel=0 bootcmd=usb start ; if fatload usb 0:1 $rambuff $bootfile ; then run usbargs ; b ootm $rambuff; else if iminfo $linuxaddr ; then run flashargs ; bootm $linuxaddr ; else go $winceaddr ; fi ; fi nfsboot=run nfsargs ; loadb $rambuff ; bootm $rambuff bootdelay=1 baudrate=115200 ipaddr=192.168.31.25 serverip=192.168.31.254 rootpath=/exports/nfsroot netmask=255.255.255.0 hostname=wl1100 bootfile=wl1100.uImage loadaddr=0x00080000 ubootaddr=0x00000000 ubootlen=0x00030000 logoaddr=0x00030000 logolen=0x00010000 splashimage=0x00030000 envaddr=0x00040000 envlen=0x00040000 linuxaddr=0x00080000 linuxlen=0x00280000 winceaddr=0x00300000 wincelen=0x03a00000 rambuff=0xa1000000 netdev=usb0 ubootfile=wl1100.u-boot.bin nfsargs=setenv bootargs $bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath i p=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off rootdelay=1 usbargs=setenv bootargs $bootargs mtdparts=WL1100-Flash:- root=/dev/sda2 rw root delay=5 flashargs=setenv bootargs $bootargs root=/dev/mtdblock4 rootfstype=jffs2 ro flashuboot=prot off $ubootaddr +$ubootlen && erase $ubootaddr +$ubootlen && cp.b $rambuff $ubootaddr $filesize && prot on $ubootaddr +$ubootlen ; echo u-boot sa ved. Reset the board to run new u-boot updateuboot=usb start ; if fatload usb 0:1 $rambuff $ubootfile ; then run flashu boot ; then run flashuboot ; fi flashlogo=prot off $logoaddr +$logolen && erase $logoaddr +$logolen && cp.b $ram buff $logoaddr $filesize && prot on $logoaddr +$logolen ; echo logo saved eraseenv=prot off $envaddr +$envlen && erase $envaddr +$envlen flashlinux=prot off $linuxaddr +$linuxlen && erase $linuxaddr +$linuxlen && cp.b $rambuff $linuxaddr $filesize && prot on $linuxaddr +$linuxlen ; echo linux sav ed. stdin=serial stdout=serial stderr=serial
You can modify it by using the setenv command and you can restore it to the factory default buy using the command
run eraseenv
then you need reboot the board to take effect.
If you wish using WL1100 as developing system I suggest you modify the variable rootpath in order to make it points to your NFS server root directory:
setenv rootpath /home/develop/embedded/arm/distro/debian
If you wish using TFTP boot you should also change variable bootcmd as follow:
setenv bootcmd run nfsboot
in order to force TFTP boot at every reboot.
In the end, if you wish using the serial console, you have to use:
setenv bootargs video=pxafb:nocursor ETHSYSNAME=wl1100 console=ttyS0,115200 loglevel=8
Once you have finished save the new environment with the command
saveenv
and reboot the system.
Modifying the standard boot logo
You can modify the standard boot logo with a custom one by simply loading a new BMP image into the flash.
Load a new BMP image at address rambuff. For example if your new logo is on a USB stick you can do:
wl1100> fatload usb 0 $rambuff new_logo_wl1000.bmp.gz reading new_logo_wl1000.bmp.gz . 18241 bytes read
please, note also that your BMP image could be gzipped in order to save space and fit it into a flash sector.
Then save the new logo into flash:
wl1100> run flashlogo . done Un-Protected 1 sectors . done Erased 1 sectors Copy to Flash... done . done Protected 1 sectors logo saved
Reset the board and admire your new logo!
Note: the new logo is valid only into u-boot, if you wish to display it also during linux (or other operative system) boot stage you have to modify your operative system accordingly.
Programming a new image into flash
To (re)program a new u-boot image into WL1100's flash memory you can use u-boot itself.
Once you have recompiled the source you should move file u-boot.bin into your tftp root directory or into the first partition (formatted as VFAT) of an USB stick and renaming it as "wl1100.u-boot.bin", then use the command on the u-boot console:
run updateuboot
The system will first try to load the file "wl1100.u-boot.bin" from the USB stick and, if nothing is found, it will try to download it from the TFTP server (in this case verify that variable "tftppath" is well configured).
If you don't like writing your flash with an automated script you may use, for USB load, the seuqence:
usb start fatload usb 0:1 $rambuff $ubootfile
for TFTP load:
tftp $rambuff $tftppath/$ubootfile
then to erase the u-boot flash sector use:
prot off $ubootaddr +$sectorsize erase $ubootaddr +$sectorsize
and then reprogram the flash and protect it again use:
cp.b $rambuff $ubootaddr $filesize prot on $ubootaddr +$sectorsize
Done! Now you can safely reboot the board.
If something goes wrong during the erasing/reprogramming flash stage you are in a trouble!
First of all do not reset the board but try to erase again the flash and reprogram it insted. If your WL1100 still refuses to collaborate you need a JTAG to reprogram the flash (see section Low level programming and debugging on WL1100#Downloading_a_new_u-boot_image).
Booting options
The WL1100 by default boots from the internal flash memory but, as anticipated above, it's possible to boot from several devices. Here you can find some useful hints expecially if you wish using the WL1100 as developing board.
Booting from flash
Here you have nothing special to do, just turn on your WL1100 and wait! :)
This booting method can work when flash memory is at its default, if you start playing with WL1100's flash this method may fail and then you have to use one of the following alternative methods.
In any case you can force this method by using the commands:
run flashargs bootm $linuxaddr
Booting from USB stick
You can boot a special GNU/Linux system by using an USB stick. This method is useful if you wish reprogram several WL1100 boards in automatic manner.
In order to work this method requires som setting up steps on the USB stick.
First of all you have to make two partitions on the USB stick. You may use the command "fdisk" on a host system as follow:
giometti@gundam:~$ fdisk /dev/sda Command (m for help):
I suppose your USB stick is mapped into device "/dev/sda" and that you have all necessary permissions on it.
Then clean all preexisting partitions by using the "d" command and make two new partitions as follows:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-666, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-666, default 666): +16M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (88-666, default 88): Using default value 88 Last cylinder or +size or +sizeM or +sizeK (88-666, default 666): Using default value 666 Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): d Changed system type of partition 1 to d (Unknown) Command (m for help): p Disk /dev/sda: 6 heads, 63 sectors, 666 cylinders Units = cylinders of 378 * 512 bytes Device Boot Start End Blocks Id System /dev/sda1 1 87 16411+ d Unknown /dev/sda2 88 666 109431 83 Linux
Note that the first partition is "VFAT" and 16M bytes long, the second one is "Linux" and is long at least 32MB.
Now we can save the partition table with the "w" command and then we can start to format the two new partitions:
giometti@gundam:~$ mkfs.vfat /dev/sda1 mkfs.vfat 2.10 (22 Sep 2003) giometti@gundam:~$ mkfs.ext2 /dev/sda2 mke2fs 1.39-WIP (10-Dec-2005) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 27440 inodes, 109428 blocks 5471 blocks (5.00%) reserved for the super user First data block=1 14 block groups 8192 blocks per group, 8192 fragments per group 1960 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Now we have to copy a kernel image into the first partition (see Compiling the source to know how to get a new kernel image) and we have to put a new rootfs into the second partition (see Creating a minimal rootfs).
Booting from USB line
As last resource and expecially for developing stages you can use a USB line to load your preferred GNU/Linux distribution.
To force this method, as already described above, you need a serial console connected with thw WL1100 and use it to stop the booting sequence with the boot password. After that just run:
run nfsboot
In order to work this method needs that both "rootpath" and "tftppath" variable as correctly set up and that your developing system is set up and running (see Setting up a developing environment).
Booting from serial line
As very last resource you can use a serial line (the one you use as serial console) to load your preferred GNU/Linux distribution.
To force this method you need a serial console connected with the WL1100 to stop the booting sequence with the boot password and a kermit program installed on your host system.
After stopping the boot sequence just run:
loadb $rambuff
and the WL1100 will answer you:
## Ready for binary (kermit) download to 0xA1000000 at 115200 bps...
at this time, if you arfe using minicom, just press CTRL+a+k to start kermit. Here what I get on my system:
C-Kermit 8.0.211, 10 Apr 2004, for Linux Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New York. Type ? or HELP for help. (/home/giometti/) C-Kermit>
now go to the directory holding the Linux image:
(/home/giometti/) C-Kermit> cd linux-wl1100/arch/arm/boot/
and then use the following command:
(/home/giometti/linux-wl1100/arch/arm/boot/) C-Kermit>send uImage
If everything goes well you should see something like this:
C-Kermit 8.0.211, 10 Apr 2004, zaigor.enneenne.com
Current Directory: /home/giometti/linux-wl1100/arch/arm/boot/
Communication Device: /dev/ttyUSB0
Communication Speed: 115200
Parity: none
RTT/Timeout: 01 / 02
SENDING: uImage => uImage
File Type: BINARY
File Size: 1212420
Percent Done: 11 /////-
...10...20...30...40...50...60...70...80...90..100
Estimated Time Left: 00:02:06
Transfer Rate, CPS: 8460
Window Slots: 1 of 1
Packet Type: D
Packet Count: 186
Packet Length: 1000
Error Count: 0
Last Error:
Last Message:
X to cancel file, Z to cancel group, <CR> to resend last packet,
E to send Error packet, ^C to quit immediately, ^L to refresh screen.
When finished give the command:
(/home/giometti/linux-wl1100/arch/arm/boot/) C-Kermit>exit
and then:
wl1100> run flashlinux
to save permanently on flash the just downloaded Linux Image.
Managing the kernel
In this section you can find several information about Linux which is the WL1100's kernel.
Downloading the code
You can get linux sources at:
- My site at EnneEnne.
To get the code you need to give the command:
git clone git://git.enneenne.com/linux-wl1100
of course you need the GIT tools installed on your system.
Compiling the source
To compile the Linux source you must go into directory linux-wl1000 and give the commands:
~/linux-wl1000$ make wl1100_defconfig ~/linux-wl1000$ make
The compilation process should start. You'll end up with 3 new files:
-
arch/arm/boot/uImagethe binary image suitable for u-boot (use this file to program the flash). -
vmlinuxthe ELF image suitable for the JTAG. -
System.mapthe Linux symbols map useful for a simple debug.
Doing a custom kernel configuration
TODO
Programming a new Linux image
Once we have our new Linux image we can proceed to put it on the flash. First of all start your preferred GNU/Linux distribution on the WL1100 and after the boot is finished check for device /dev/mtd2:
# ls -l /dev/mtd2 crw-rw---- 1 root root 90, 4 Oct 31 2006 /dev/mtd2
Then verify that the MTD support is enabled on the system:
# cat /proc/mtd dev: size erasesize name mtd0: 00030000 00010000 "u-boot" mtd1: 00040000 00040000 "u-boot_env" mtd2: 00280000 00040000 "kernel" mtd3: 03a00000 00040000 "rootfs" mtd4: 04000000 00040000 "user" mtd5: 00300000 00040000 "etc" mtd6: 00010000 00010000 "boot_image"
Now you should made the file uImage accesible by the WL1100 (using your prefereed method: FTP, NFS, etc.) and then erase the "kernel" partition by using the commands:
# flash_unlock /dev/mtd2 # flash_eraseall /dev/mtd2
Then just copy the Linux image on the erased partition (we suppose the file uImage has been put into /opt directory):
# flashcp /opt/uImage /dev/mtd2
In the end relock the flash partition:
# flash_lock /dev/mtd2 0 -1
Using a JTAG
In this section I'll show some steps in order to use a JTAG support with your WL1100.
Currently supported JTAG is:
- Lauterbach TRACE32
- OCDemon (only for flash programming and u-boot debugging)
Lauterbach TRACE32
Verify the JTAG/System connection
First of all you should follow the Lauterbach's instruction in order to install your TRACE32. After that you can verify that you can connect with the system by using the following commands:
RESET WINCLEAR DATA.LIST SYSTEM.CPU PXA270 SYSTEM.OPTION.RESBREAK OFF SYSTEM.OPTION.WAITRESET ON SYSTEM.UP
You should see that the system is stopped at location 0x00000000.
Setting up the JTAG environment
In order to load the TRACE32 toolkit with a proper environment for the WL1100 you should add an init file to the TRACE32's system directory. Do the following steps:
~$ cat >> $T32SYS/t32.cmm LOCAL &file ENTRY &file if "&file"=="" ( GOTO l_end ) IF !OS.FILE(&file) ( GOTO l_error_fileexist ) DO &file GOTO l_end l_error_fileexist: PRINT "t32: init file &file doesn't exist" GOTO l_end l_end: ENDDO
In this manner your TRACE32 will automatically load a special configuration file if invoked with:
~$ t32marm <filename>
We provide two special configuration for the WL1100. One for debugging u-boot or just for reprogramming the flash and one for debugging Linux (see Lauterbach directory).
As example I report here contents of file u-boot.cmm but consider that this may vary:
; ; --- Reset ------------------------------------------------------------------- ; RESET WINCLEAR FLASH.RESET ; ; --- Setup the CPU ----------------------------------------------------------- ; SYSTEM.CPU PXA270 SYSTEM.OPTION.RESBREAK OFF SYSTEM.OPTION.WAITRESET ON SYS.MODE NODEBUG MAP.BONCHIP 0x00000000--0X08000000 ; ; --- Define flash ------------------------------------------------------------ ;
FLASH.CREATE 1. 0X00000000--0X0003FFFF 0X10000 I28F200K3 LONG FLASH.CREATE 2. 0X00040000--0X03FFFFFF 0X40000 I28F200K3 LONG print "WL1100/u-boot environment loaded"
Now, to load it into TRACE32, you should execute:
~$ cd wl1100 ~/wl1100$ t32marm jtag/lauterbach/u-boot.cmm
If every works well you should see that your TRACE32 displays the string WL1100/u-boot environment loaded into its messages bar.
Managing u-boot
Debugging u-boot
To debug u-boot you should start TRACE32 with the command:
~/wl1100$ t32marm jtag/lauterbach/u-boot.cmm
If everything works well you can see the start location is 0x00000000 by using the data.list command.
Now you can load the bootloader symbols with command:
DATA.LOAD.ELF u-boot/u-boot-wl11001100/u-boot /GNU /NOCODE
Now you can setup hardware or software breakpoints (use hardware ones if you wish block WL1100 during execution of code into flash), run or stop the code ad you wish.
Please, note that u-boot, at some point relocate itself into RAM so the bootloader symbols, after this relocation, are not valid anymore. To resolve this problem you have to inform your JTAG to relocate the symbols with the command:
DATA.LOAD.ELF u-boot/u-boot-wl1000/u-boot /GNU /NOCODE /RELOC .text AT 0x83f94000
Downloading a new u-boot image
First of all you have to (re)compile a new u-boot image with debuggin support enabled. To do it verify that into file u-boot-wl1100/board/wl1100/config.mk you have:
~/u-boot-wl1000$ grep JTAG board/wl1100/config.mk # Enable EJTAG debugging support PLATFORM_CPPFLAGS += -DDEBUG_EJTAG
then you can use make to start compilation. During compilation stage verify that both -g
and -DDEBUG_JTAG are arguments of arm-linux-gcc command.
At the end you should get file u-boot.bin who can be downloaded into WL1100 flash memory (please, note that you can program the flash memory from u-boot itself without using TRACE32, see section Managing_the_boot_loader#Programming_a_new_image_into_flash).
To program the flash memory you should use the following procedure.
Erase u-boot sector and put it into "program" mode:
FLASH.UNLOCK 0x00000000--0x0001ffff FLASH.ERASE 0x00000000--0x0001ffff FLASH.PROGRAM 0x00000000--0x0001ffff
Then load the binary image:
DATA.LOAD.BINARY ~/u-boot-wl1100/u-boot.bin 0x00000000 /LONG
In the end lock the flash memory again:
FLASH.PROGRAM OFF FLASH.UNLOCK OFF
Managing Linux
Debugging Linux
TODO
MacRaigor OCDemon
TODO

