# README-programming.ronetix # Explains how to program/write files # for AT91SAM9G45/AT91SAM9263/AT91SAM9261 based boards: # PM9G45, PM9263 and PM9261. # # Ronetix GmbH # www.ronetix.at # February, 2011 # Table of Contents: 1. Setting the U-BOOT environment 2. Programming AT91BootStrap 3. Programming U-Boot 4. Programming of the Kernel 5. ROOTFS programming into the NAND flash 6. Tips and tricks Program/Write Address Table(the current one, since 02.01.2012): pm9g45(NAND) pm9263 pm9261 AT91BootStap 0x0 - - U-Boot 0x60000 0x10000000 0x10000000 Kernel 0x200000 0x10050000 0x10050000 RootFS 0x500000 0x0(NAND) 0x0(NAND) Be aware for the OOB info when programming in NAND. WARNING: it is not guaranteed that the first block of the NAND chips is error safe. Second, the NAND chips comes with increased manufactured bad blocks. All this requires that extended reserve gaps between the written data to ensure data integrity. Now(02.01.2012) only the gap between the kernel and the rootfs will be extended. Program/Write Address Table(before 02.01.2012)[obsolate]: pm9g45(NAND) pm9263 pm9261 AT91BootStap 0x0 - - U-Boot 0x20000 0x10000000 0x10000000 Kernel 0x200000 0x10050000 0x10050000 RootFS 0x400000 0x0(NAND) 0x0(NAND) Be aware for the OOB info when programming in NAND. 1. Setting the U-BOOT environment If you are going to use U-Boot to program the memories, the U-Boot first should be configured(setup). To configure the U-Boot, boot the board and stop U-Boot autoboot and set: u-boot> setenv ipaddr u-boot> setenv serverip u-boot> setenv gatewayip u-boot> setenv netmask u-boot> setenv hostname u-boot> setenv ethaddr u-boot> saveenv Change the with the appropriate values. Some parameters could be already set, so check them and change if needed. Except the "ethaddr" all others network parameters can be taken by calling the "dhcp" command. Note: if the ethaddr is changed, it will take effect on the next reboot. U-Boot treat that variable specially, the ethaddr can be overwritten only once(this is a U-Boot configuration option, to make it changeable many times). 2. Programming AT91BootStrap 2.1. Programming AT91BootStrap for PM9G45 Since the U-boot can not fit in the first NAND block, PM9G45 uses AT91BootStrap for initial startup. The file nandflash_pm9g45.bin must be programmed at address 0x0. A. Using PEEDI peedi> flash select 1 peedi> flash program pm9g45-nandflashboot-2.13.bin BIN 0x0 erase B. Using U-Boot u-boot> tftp 0x70000000 pm9g45-nandflashboot-2.13.bin u-boot> nand erase 0x0 0x4000 u-boot> nand write 0x70000000 0x0 0x4000 2.2. Programming AT91BootStrap for PM9263/PM9261 No need to program at91bootstrap in pm926x modules, as the U-Boot runs from NOR Flash. 3. Programming U-Boot 3.1. Programming U-Boot for PM9G45 A. Using PEEDI peedi> flash select 1 peedi> flash program pm9g45_bb9g45_u-boot.bin BIN 0x20000 erase B. Using U-Boot u-boot> tftp 0x70000000 pm9g45_bb9g45_u-boot.bin u-boot> nand erase 0x20000 $filesize u-boot> nand write 0x70000000 0x20000 0x40000 3.2. Programming U-Boot for PM9263/PM9261 The file u-boot.bin must be programmed in the FLASH at address 0x10000000. The environment of U-Boot is at address 0x10040000. If you use PEEDI the command is: A. Using PEEDI peedi> flash set 0 ; select the first flash profile peedi> flash program u-boot.bin bin 0x10000000 erase B. Using U-Boot u-boot> tftp 0x20020000 u-boot.bin u-boot> erase 0x10000000 +${filesize} u-boot> cp.b 0x20020000 0x10000000 ${filesize} 4. Programming of the Kernel 4.1. Programming of the Kernel for PM9G45 A. Using PEEDI peedi> flash select 2 peedi> flash program uImage bin 0x200000 erase B. Using U-BOOT u-boot> tftp 0x70000000 uImage u-boot> nand erase clean 0x200000 0x200000 u-boot> nand write.jffs2 0x70000000 0x200000 0x200000 4.2. Programming of the Kernel for PM9263/PM9261 A. Using PEEDI peedi> flash set 1 ; select the second flash profile peedi> flash program B. Using U-BOOT u-boot> tftp 0x20020000 vmImage.bin u-boot> erase 0x10050000 +${filesize} u-boot> cp.b 0x20020000 0x10050000 ${filesize} 5. ROOTFS programming into the NAND flash Note:The Linux kernel scans the whole rootfs partition, to create the JFFS2 file system summary, and if on that partition there are blocks from the older root file system, the new one could not be mounted properly and most probably will fail. So erase the whole Linux rootfs partition on NAND (MTD partition). PEEDI is not aware of MTD partitions, so erase the that partition size from the start of it. This applies for U-Boot, too. 5.1. ROOTFS programming into the NAND flash for PM9G45 A. Using PEEDI peedi> flash set 3 peedi> flash program rootfs.jffs2 bin 0x500000 erase B. Using U-BOOT Caution: the RootFS image larger than 126MiB can't be programmed by U-BOOT, because it doesn't fit in the SDRAM. u-boot> tftp 0x70000000 rootfs.jffs2 u-boot> nand erase clean 0x500000 $filesize u-boot> nand write.jffs2 0x70000000 0x500000 $filesize Note: Here the variable $filesize can be used because the jffs2 image file is padded to the page size of the NAND, but the sizes of uImage, U-Boot and AT91Bootstrap are not write-page padded(but can be made to be write-page padded). 5.2. ROOTFS programming into the NAND flash for PM9263/PM9261 A. Using PEEDI peedi> flash set 2 peedi> flash erase peedi> flash program B. Using U-BOOT Caution: the RootFS image larger than 62MiB can't be programmed by U-BOOT, because it doesn't fit in the SDRAM. u-boot> nand erase clean u-boot> tftp 0x20020000 rootfs.jffs2 ; the image should less ; than 62MiB u-boot> nand write.jffs2 0x20020000 0 ${filesize} 6. Tips and tricks 6.1. Running the u-boot from PEEDI peedi> go 0x10000000 6.2. Programming images in bare metal PM9G45 A. With JTAG emulator and U-Boot This method of programming is used when you don't have PEEDI Flash Programmer but you have JTAG debugger. The idea is to initialize the NAND and DDR2 memories with JTAG debugger, then load and run U-Boot, and with U-Boot help to program what you need to to bring the metal on. The DDR2 and NAND settings(values in each registers) and also the PLL can be found in the PEEDI configuration file for PM9G45. http://download.ronetix.info/peedi/cfg_examples/arm9/at91sam9g45_pm9g45.cfg The U-Boot elf file is here http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9g45_u-boot * Load the U-Boot elf file at address 0x73f00000 and run it with the JTAG debugger. * When the U-Boot loads in its command prompt do: u-boot> setenv ethaddr 02:01:02:03:04:05 u-boot> setenv ipaddr 192.168.1.2 u-boot> saveenv Note: if the ethaddr is changed, it will take effect on the next reboot. U-Boot treat that variable specially, the ethaddr can be overwritten ony once(this is a U-Boot configuration option, to make it changable many times). * If you have DHCP server then you can run in U-Boot to get the IP address from it. The environment variables may be used and automatically updated by the network boot commands (bootp, dhcp, or tftp), depending the information provided by your boot server: ipaddr, serverip, gatewayip, netmask, hostname. u-boot> dhcp u-boot> saveenv * Load U-Boot again with the JTAG. * Now you can use all the "B."-s mentioned above to program the images. B. With SAM-BA Read the file http://download.ronetix.info/boards/tools/linux/sam-ba_v2.10/README-SAM-BA-pm9g45.ronetix to install and setup SAM-BA for pm9g45. The board must be running RomCode(the monitor program). If it the DataFlash and NAND are empty the board will stay at RomCode. In case there is something in NAND, make a short on resistor R116 (take a look at http://download.ronetix.info/boards/doc/PM9G45/PM9G45-DataSheet.pdf part "Assembly and mechanical") for a few seconds during and after reset or power-on. Sometimes the USB device on AT91SAM9G45 MCU do not works(mentioned in the MCU errata) and to work around it, with USB cable pluged in reset the board untill USB device gets work. Plug the USB cable to the data port if it is not and run SAM-BA_CDC. Choose the "/dev/ttyUSBx" on "Select the connection:" field, and choose "at91sam9m10pm9m10" on "Select your board:". Press "Connect" button. Go to "NandFlash" tab and execute "Enable NandFlash". To write to flash it has to be clean(set to 0xFF). The nand blocks in the programmed are are erased by SAM-BA nandflash ISP when a write is performed. You may erase the whole nand or parts of it. To erase the whole flash execute "Erase All", or to erase part of it edit tcl_lib/pm9m10/pm9m10.tcl and make a script similar to "Erase Blocks 1 and 2" to erase blocks located in the given address area. In the "Send File Name:" field locate the pm9g45_v1.2-nandflashboot-2.13.bin and in the "Address" field type "0x0" then hit the "Send File" button. In the "Send File Name:" field locate the pm9g45_v1.2_u-boot.bin and in the "Address" field type "0x20000" then hit the "Send File" button. In the "Send File Name:" field locate the uImage-2.6.30.10-pm9g45_v1.2 and in the "Address" field type "0x200000" then hit the "Send File" button. In the "Send File Name:" field locate the ce-gpe-rootfs.jffs2 and in the "Address" field type "0x500000" then hit the "Send File" button.