Bootstrapping

This section describes a bootstrapping procedure to get the Linux bootstrap loader and kernel programmed into the flash.  It requires you to construct a RS232C adapter.

You will also need to build a version of gdb with ARM and rdp support.    I build gdb 5.2.1 successfully on a Mandrake 9.0 system using the configuration command:
./configure --target=arm-wrs
Once you have the RS232C interface and gdb built, proceed as follows:
  1. Make sure that the serial port on your host system is set correctly to 9600 baud.   I found that gdb didn't seem to be able to set the baud rate correctly, so I manually had to do this before running gdb.
    stty 9600 < /dev/ttyS0
  2. Start gdb and issue the following command:
    target rdp /dev/ttyS0
  3. Hold down SW2 inside the Webpal and then turn the Webpal on.   Release SW2 and your host system and Webpal should synchronize.   Sometimes this fails, so you may have to try this multiple times.

  4. Issue the following command to gdb to download the flash programmer.   If you built gdb as I described above, it will expect to load srec files, so use prog.srec.   I've also included prog.elf if you built a version of gdb that expects elf format files:
    load prog.srec
    set *(0x188)=0x1001000c
    set $pc=0x10010000
    cont
  5. The host system should now say "Waiting for target...".   Control-Z out of gdb and kill it.

  6. To test out the programmer, use the wpflash program to save a copy of your current flash to a file, in case you ever want to go back to using the original Webpal software:
    wpflash -nowait read all webpal.backup.image
  7. If everything is working, you should see the following messages following by a counter counting from 0 to 1048576 as the flash is read to the file you specified;   The red LED on the Webpal will flash as the flash is read.
    Attempting to contact programmer...done
    Initializing flash...done
    Reading partition 'all' to 'webpal.backup.image'

  8. Its time to overwrite the flash with a Linux image.    Here is one called linux.flash.image.   It contains the bootp bootstrap loader, a parameters file, and a Linux zImage file.    As configured by the parameters file, it will try and boot the root partition from the IDE device.   To write it to flash, enter the following command:
    wpflash -nowait write all linux.flash.image
  9. If all is working, you should see the following messages followed by a counter counting form 0 to 1Megabyte as the flash is programmed.   The red LED on the Webpal will flash as the flash is erased and then programmed.  Note that the erase operation takes a while so be patient.   You should see dots slowly written as the flash is erased.
    Initializing flash...done
    Reading raw object file 'linux.flash.image' ...done
    Data size is 1048576 bytes (100% of 'all' partition used).
    Erasing all sectors...................done

  10. Hook up a monitor and keyboard and hit reset.   You should see the system boot.    It will get to the point where it tries to find the root partition and then panic since you probably don't have an IDE hooked up yet.
You now can modify the parameters file to try other things, such as loading the root from NFS and the IP addresses from bootp. Assuming you have an NE2000 ethernet card like mine (be sure to configure it in a PC to use 0x300 as its address and INT3 as its interrupt pin), the kernel contains enough code to load root from the NFS volume and use a bootp server as its IP address source.     Of course, you could also rebuild the kernel and build your own root partition for your desired application.

Using the flash programmer in the bootstrap loader

Now that you have bootp programmed in the flash, you will use it's programmer.    By default, it assumes that you will be using a parallel port via a parallel Laplink cable.    If so, then run wpflash as follows:
wpflash -p <read/write/erase> <partition-name> <filename>
After you run the command, reboot or power cycle your system.    Sometimes, synchronization using the parallel port will fail.   If this happens to you, hold down the reset button, run the wpflash command, and then release the reset button.

If you'd rather continue to use the serial port for programming, then run the wpflash flash command without the -p or -nowait flags:
wpflash <read/write/erase> <partition-name> <filename>
After you run the command, hold down the SW2 switch and the reboot the system.    Holding down SW2 tells the system to use alternate device, in this case, the serial port, for booting messages and programming.    If you want to the serial port to be the default device for booting messages and programming, add the following line to your parameters file:
serialbootp=1    

Updated: Nov 15, 2002