# README-u-boot.ronetix # Building of U-BOOT for AT91SAM9G45/AT91SAM9263/AT91SAM9261 based boards: # PM9G45, PM9263 and PM9261 # # Ronetix GmbH # www.ronetix.at # February, 2012 # Table of Contents: 1. Download and install the GNU toolchain 2. U-Boot short introduction 3. Download and install the U-BOOT 4. Configuration 5. Building 6. Programming/Writing 7. Debugging 8. Boot log 9. Tip and tricks 1. Download and install the GNU toolchain See the toolchain README 2. U-Boot short introduction U-BOOT is used for basic initialization of the PM9G45/PM9263/PM9261 boards and for loading and starting an Operating system or an user application. The loading can be done via the various FLASH devices or the Ethernet. U-BOOT supports the following devices on the PM9G45/PM9261/PM9263 board: - NOR Flash - Dataflash - NAND flash - Ethernet - LCD - USB 3. Download and install the U-BOOT Some features are not in the U-Boot mainline, so you need to apply them manually. A. Get U-Boot as tar.bz2 $ wget http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/u-boot-2010.09.tar.bz2 $ tar xjf u-boot-2010.09.tar.bz2 $ mv u-boot-2010.09 u-boot $ cd u-boot $ git init $ git add * $ git add .gitignore $ git commit -m "U-Boot v2010.09" $ git checkout -b v2010.09-pm9g45 $ cd .. B. Get U-Boot with git clone For easey code management(trace and history of changes, patch submit and so) it is good to use revision control(in this case GIT). To get U-Boot using git, if you prefer tar.bz2 skip getting U-Boot using git. $ git clone git://git.denx.de/u-boot.git u-boot $ cd u-boot $ git checkout -b v2010.09-pm9g45 v2010.09 $ cd .. 3.1. Apply the provided patches $ wget http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/patches/u-boot-2010.09-patches-ronetix-13012012.tar.bz2 $ tar xjvf u-boot-2010.09-patches-ronetix-13012012.tar.bz2 $ cd u-boot $ for N in ../u-boot-2010.09-ronetix-13012012/*.patch ;do git am $N ; done 4. Configuration The U-Boot configuration files named as the respective Ronetix CPU modules are: - include/configs/pm9g45.h - include/configs/pm9263.h - include/configs/pm9261.h The definitions in these header files are explained in the README file in the U-Boot source. If needed set the lines for the network interface as show. In the config files only the ETHADDR is set, the rest parameters can be obtained runtime in the U-Boot prompt by invoking the command "dhcp". #define CONFIG_ETHADDR 02:00:00:FE:ED:01 #define CONFIG_IPADDR 192.168.3.222 #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_GATEWAYIP 192.168.3.1 #define CONFIG_SERVERIP 192.168.3.1 #define CONFIG_OVERWRITE_ETHADDR_ONCE /* Read Using it! */ These parameters can be modified later and set to a environment variables, except "ethaddr". If you do not want LCD support(initialization), comment as shown: /* No need of LCD * #define CONFIG_LCD 1 */ If you do not want U-Boot to show anything on the screen undefine CONFIG_LCD_LOGO and CONFIG_LCD_INFO. You may leave the configs as they are, test and then change as needed. 5. Building Execute one of these commands depending on the board name A. For pm9g45 I. on bb9g45 for KaeilOS or another distribution $ make pm9g45_config II. on bb9g45 for Android usage $ make pm9g45_android_config B. For pm9263 $ make pm9263_config C. For pm9261 $ make pm9261_config The common part for all boards: $ export USE_PRIVATE_LIBGCC=yes $ export CROSS_COMPILE=arm-oe-linux-gnueabi- $ export ARCH=arm $ make The binary file for programming is u-boot.bin, and the u-boot is the elf file. When building U-Boot, the mkimage is also build. This utility is needed to wrap zImage(Linux kernel) for booting by U-Boot, so put it in a place mentioned by PATH environment. 6. Programming/Writing After successful building the file for programming/writing is u-boot.bin. On how to program it see the README-programming.ronetix. 7. Debugging A. For pm9g45 To debug a code running on PM9G45, PEEDI shall not init the target to let the environment(MCU setting) clean, but left a software in the pm9g45 to do that - AT91Bootstrap can do the boards setup. So in PEEDI configuration file make an empty init section and set COREn_STARTUP_MODE = RESET. The RESET startup mode lets the PEEDI to attach to the target at the veri beginning - the reset state of the CPU. The JTAG clock have to be set as shown "JTAG_CLOCK = 3, 3" this means slow JTAG clock because the PLLs have not been yet initialized. Later when the PLLs and high clock have been turned on JTAG clock can be set higher in the PEEDI command line - "clock 20000". Check if PEEDI has stopped/attached to the target at reset state as executing PEEDI command "info reg" and make sure the registers and state are as shown: --- info reg --- pc : 00000000 cpsr : 000000D3 spsr : 00000000 State: Supervisor --- info reg --- The PEEDI have to be attached to the board, and the board have to be at the reset state, then the GDB can be attached to PEEDI either with the shown .gdbinit script or with the commands entered by hand in the GDB command line(commands entered by hand do not need a delay). In this case the Bootloader have been programmed in NAND. --- .gdbinit --- target remote 192.168.10.42:2000 -attach shell sleep 1s monitor break add hard 0x73f00000 shell sleep 1s monitor go shell sleep 3s monitor clock 20000 shell sleep 1s monitor break del all symbol-file u-boot si --- .gdbinit --- Description of each .gdbinit line: Line1: attaches the GDB to PEEDI, when target is at reset state. Line3: stop at the first instruction of U-Boot/BareBox. 0x73f00000 is where AT91Bootstrap throws the U-Boot/BareBox. Line5: Start the target - target inits itself ... Line6: ... let some time the target to reach the break point and to stop ... Line7: at this point the target has stopped and its PLLs are inited so the PEEDI can raise the JTAG clock for faster communication. Line9: remove the break point to be able to use it later Line10: Load the bootloader symbols from its elf Line11: make a single step to let the GDB refresh(read CPU registers from PEEDI) After a gdb command a short delay is needed - delay is determined experimentally. 8. Boot log Take a look at README-pre-built_images.ronetix. 9. Tip and tricks 9.1. Programming Linux kernel within u-boot (for PM9G45) u-boot-pm9g45> tftp 0x70000000 uImage u-boot-pm9g45> nand erase clean 0x200000 0x200000 u-boot-pm9g45> nand write.jffs2 0x70000000 0x200000 0x200000 9.2. Programming Linux kernel within u-boot (for PM926x) u-boot-pm9263> tftp 0x20200000 uImage u-boot-pm9263> erase 0x10050000 +${filesize} u-boot-pm9263> cp.b 0x20200000 0x10050000 ${filesize} 9.3. Programming ROOTFS for images smaller then 126MiB within u-boot (for PM9G45) u-boot-pm9g45> tftp 0x70000000 rootfs.jffs2 u-boot-pm9g45> nand erase clean 0x500000 $filesize u-boot-pm9g45> nand write.jffs2 0x70000000 0x500000 $filesize For larger images use PEEDI (http://www.ronetix.at/peedi.html) 9.4. Programming ROOTFS for images smaller then 62MiB within u-boot (for PM926x) u-boot-pm9263> nand erase clean u-boot-pm9263> tftp 0x20200000 rootfs.jffs2 u-boot-pm9263> nand write 0x20200000 0 ${filesize} For larger images use PEEDI (http://www.ronetix.at/peedi.html) 9.5. USB initializing u-boot-pm9263> usb start (Re)start USB... USB: scanning bus for devices... 3 USB Device(s) found scanning bus for storage devices... 2 Storage Device(s) found u-boot-pm9263> usb tree Device Tree: 1 Hub (12MBit/s, 0mA) | OHCI Root Hub | +-2 Mass Storage (12MBit/s, 100mA) | SanDisk Corporation Cruzer Contour 000016A078758E48 | +-3 Mass Storage (12MBit/s, 200mA) ClipDrive 075C10905A8A