Trustworthy Systems

PLEB 2 How-To

This document is intended to act as a repository for various information regarding PLEB 2, its bootloader (U-boot), Linux, etc.

Testing a new PLEB 2

This is a rough guide for a safe way to bring up a PLEB 2. At all stages, things might not work as expected, in which case they should be fixed before moving on. If the following procedure is followed, it should be fairly difficult to destroy the entire PCB.
  1. Solder down all components at the power-supply end of the PCB. Leave the components in the vicinity of the PXA255 off so that the screen for the solder paste fits over the top, and the components on the bottom don't fall off while reflowing the BGA. If you're worried about the soldering, don't solder the AVR down either.
  2. Test the power supplies using a current limited power supply. The three capacitors on the bottom of the PCB should have 3.3V, 3.3V and 1.5V respectively.
  3. Solder the PXA255, AVR and the associated series resistors onto the board (this leaves the RAM and flash chips as the only missing components).
  4. Program the AVR's fuse bits to configure for an external high frequency crystal, and 2.7V brown-out detection. To program the AVR, you'll need an AVR programmer such as the STK500 board from Sunswift, as well as a board for the sidecard connector which connects to the AVR's programming pins.
  5. Program the AVR with the code in CVS in the PLEB2/avr module. Make sure you've got the correct code for the version of PLEB 2. Check pleb2_avr.h to make sure the pin-out is the same as the version of the PLEB 2 you've got. At the time of writing there are two versions - the second has the JTAG lines connected to the SPI port and the first doesn't. (There are other changes, but this should be enough to tell the two apart). HEAD in CVS should be appropriate for the most recent PCB revision.
  6. Check that the AVR is running by connecting to the serial port using a terminal at 115200bps. Cycle the power. You should get a prompt from the AVR asking for the PLEB's serial number. Give it one (eight digits). You should then get a prompt from the AVR.
  7. Press '+', and then 'i'. This enables JTAG, and then attempts to read the device ID of the PXA255 via JTAG. You should get something like the below (the device ID should be very similar to the one below).
    +
    - # +JTAG Enabled
    i
    - # i 69264013
  8. Make sure JTAG is enabled (if you have power cycled the board), and test the bus connections to make sure they're working properly and that there are no short circuit or bad solder joints.
    1. Test the CS0 line by typing 'v'. Use a CRO to observe pin 26 on the flash footprint (second from the bottom right). Ensure that it is a square wave.
    2. Test the WE line by typing 'c'. Use a CRO to observe pin 11 on the flash footprint. Ensure that it is a square wave.
    3. Test the OE line by typing 'x'. Use a CRO to observe pin 28 on the flash footprint (fourth from the bottom right). Ensure that it is a square wave.
    4. Test the bus data and address lines by typing 'z'. Use a CRO to observe each of the address and data lines. Each line should have a series of pulses. A0 will have one pulse. A1 will have two pulses. A3 will have two, and so-on. Similarly with the data lines. The data lines can be observed on both the SDRAM and Flash footprints. Use the datasheet for each to work out which pad is which signal.

Building and loading a new bootloader

  1. Obtain the u-boot-1.1.1 source from http://www.denx.de/wiki/U-Boot
  2. Obtain the PLEB2 specific patches for u-boot from the downloads page.
  3. Decompress the U-boot sources:
    bunzip2 u-boot-1.1.1.tar.bz2
    tar xvf u-boot-1.1.1.tar
  4. Apply the PLEB2 specific patch:
    cd u-boot-1.1.1
    patch -p1 < ../u-boot-1.1.1-pleb2.patch
  5. Configure for PLEB2, and build:
    make pleb2_config
    make
  6. Build an ihex file (the terminal utility which communicates with the PLEB2's on-board AVR only understands ihex files, so we need to oblige): make u-boot.hex
  7. Obtain the terminal program for communicating with PLEB2's JTAG facility from the downloads page. Unpack and build it in an appropriate directory: tar xvfz terminal.tar.gz
    cd terminal
    make
  8. Connect a serial cable to PLEB2's AVR port, Run the terminal, set the speed to 115200 bps: ./terminal /dev/ttyS0
    s
    3
  9. Enter interactive mode, and tell the AVR to enable its JTAG pins. Check to see whether JTAG is working by asking the XScale for its ID, then exit interactive mode. If you wish to view the AVR's other available commands, type '?': i
    +
    - # +JTAG Enabled
    i
    - # i 69264013
    ~~~
  10. Flash the u-boot.hex file to the PLEB2 (in my case, u-boot-1.1.1 is in the same director as the terminal directory): t
    ../u-boot-1.1.1/u-boot.hex
  11. Wait for about 10 minutes. Yes, some day I will get around to optimising the AVR's JTAG code. You should see a stream of numbers and commands scrolling up the terminal.
  12. Once the numbers stop scrolling, reset the Xscale processor by entering interactive mode of the terminal and typing '.', if you connect a serial cable to the CPU serial port on the PLEB2 and use minicom at 115200bps you should see the u-boot banner and prompt: i
    .

Booting linux

  1. Either obtain a pre-built linux image from the downloads page, or build your own using the instructions elsewhere in this document.
  2. If it is not already converted to binary and compressed, do so:
    arm-linux-objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
    gzip linux.bin
  3. Make sure u-boot's mkimage tool has been built or is otherwise available. If not, you will need to obtain it by downloading the u-boot sources.
  4. Generate a u-boot image for linux:
    ./mkimage -A arm -O linux -T kernel -C gzip -a a0008000 -e a0008000 -n "Linux Kernel Image" -d linux.bin.gz uImage
  5. Generate an S-Record of the u-boot image:
    objcopy -I binary -O srec uImage uImage.srec
  6. Open a terminal on the XScale's serial port, reset the PLEB2 (either by power cycling, or using the AVR terminal), and interrupt auto-boot process.
  7. Transfer the image to u-boot:
    In the u-boot console:
    loads a1000000
    (a1000000 is a physical address about in the middle of PLEB2's RAM, we just use this as somewhere to put the image before its booted or flashed).
    In another terminal (if the u-boot console is on /dev/ttyS0):
    cat uImage.srec >> /dev/ttyS0 You should see a series of dots appear in the u-boot console as the image is transferred.
  8. Once the image has finished transferring it will give you the details of its start location and the number of bytes, you can write it to flash by executing the following commands (where !number of bytes! is the number of bytes in the image as indicated by u-boot). The location in flash is a convention and is the same as that of the mtd1 partition in the linux map:
    protect off all
    erase 40000 13ffff
    cp.b a1000000 40000 !number of bytes in hex!
  9. Boot using the image which you've just transferred. If you want to boot from an image in ram, then execute the command: bootm a1000000
    If you want to execute from an image in flash, then execute the command:
    bootm 40000
    The boot options can be viewed using the printenv command in u-boot. If you would rather use different options, use the u-boot commands to modify the boot parameters.

Transferring a linux ramdisk

  1. Transfer the kernel (or get it set up in flash) as per instructions elsewhere in this document.
  2. Obtain an appropriate ramdisk. One is available on the downloads page.
  3. Build an image of the ramdisk in a similar manner to the kernel (executing the following commands):
    ./mkimage -A ARM -T ramdisk -C gzip -n 'Simple Embedded Linux Ramdisk' -d pleb2-ramdisk.gz uRamdisk
    objcopy -I binary -O srec uRamdisk uRamdisk.srec
  4. Copy the ramdisk image to the PLEB2:
    In the u-boot console: loads a1200000
    In another terminal (if the u-boot console is connected to /dev/ttyS0):
    cat uRamdisk.srec >> /dev/ttyS0
  5. Change the boot parameters appropriately:
    In the u-boot terminal (This works with linux 2.4.19):
    setenv bootargs root=/dev/ram0 prompt_ramdisk=0 load_ramdisk=1 console=ttyS0,115200
  6. Boot the kernel:
    In the u-boot terminal, assuming your kernel image is in flash at 40000 and your ramdisk image is in RAM at a1200000:
    bootm 40000 a1200000

Pleb2 Memory map

Physical AddressWhat
0 -- 0x3ffff u-boot in flash
0x40000 -- 0x13ffff Kernel Image in Flash
0x140000 -- 0x800000Compressed Root Image
Unmapped Memory
0xa00000000 -- 0xa1FFFFFF Ram