# README # Building and programming of u-boot and Linux kernel # for AT91SAM9261/AT91SAM9263 based boards PM9261 and PM9263 # # Ronetix GmbH # www.ronetix.at # # How to build and install linux kernel? 1. Ronetix provides several GNU toolchains: ronetix-gnutools-arm-elf-3.2.1-linux.tar.bz2 - gcc 3.2.1, newlib ronetix-gnutools-arm-elf-4.1.1-linux.tar.bz2 - gcc 4.1.1, newlib ronetix-arm-linux-uclibc-4.1.2.tar.bz2 - gcc 4.1.2, uclibc openzaurus-arm-linux-glibc-3.4.4.tar.bz2 - gcc 3.4.4, glibc, ronetix-toolset-arm-elf-4.1.1-windows.exe - gcc 4.1.1, newlib, for Windows and two root file systems: rootfs-pm9261-openzaurus.tar.bz2 - using glibc, home page: http://www.openzaurus.org rootfs-pm9261-buildroot.tar.bz2 - using uclibc, home page: http://buildroot.uclibc.org The rootfs can be found here: http://download.ronetix.info/sk-eb926x/linux/rootfs 2. Installing the GNU toolchain The pre-built GNU toolchains can be found here: http://download.ronetix.info/toolchains/arm/ To compile the Linux kernel you need arm-elf 4.1.1: cd / tar xvfj ronetix-gnutools-arm-elf-4.1.1-linux.tar.bz2 export PATH=/usr/cross/arm-elf/bin:$PATH If you want to use the OpenZaurus roofs and develop applications for it: cd / tar xvfj openzaurus-arm-linux-glibc-3.4.4.tar.bz2 export PATH=/usr/cross/arm-linux/bin:$PATH If you want to use the buildroot roofs and develop applications for it: cd / tar ronetix-arm-linux-uclibc-4.1.2.tar.bz2 export PATH=/usr/cross/arm-linux/bin:$PATH 3. Getting and unpacking the Linux kernel: A. For Linux kernel 2.6.25.4 wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.25.4/linux-2.6.25.4.tar.bz2 wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.25.4/2.6.25-at91.patch wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.25.4/linux-2.6.25.4-ronetix-08-11-02.2228.patch wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.25.4/socketcan-driver-at91.patch tar xvfj linux-2.6.25.4.tar.bz2 cd linux-2.6.25.4 patch -p1 < ../2.6.25-at91.patch patch -p1 < ../linux-2.6.25.4-ronetix-08-11-02.2228.patch patch -p1 < ../socketcan-driver-at91.patch export ARCH=arm export CROSS_COMPILE=arm-elf- B. For Linux kernel 2.6.23.14: wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.23.14/linux-2.6.23.14.tar.bz2 wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.23.14/2.6.23-at91.patch wget http://download.ronetix.info/sk-eb926x/linux/kernel/2.6.23.14/linux-2.6.23.14-ronetix-08-04-29.2136.patch tar xvfj linux-2.6.23.tar.bz2 cd linux-2.6.23.14 patch -p1 < ../2.6.23-at91.patch patch -p1 < ../linux-2.6.23.14-ronetix-08-04-29.2136.patch 4. Kernel config To carry into effect the default kernel configuration you have to do the following: make pm9261_defconfig ; SPI support for MMC/SD or make pm9261_mci_defconfig ; MCI support for MMC/SD or make pm9263_defconfig If you want to change something in the kernel do the following: make menuconfig If you have a 16-bit NAND Flash, select: System type -> Atmel AT91 System-on-Chip -> Enable 16-bit data bus interface to NAND flash To determine what kind of NAND Flash chip do you have, look at the bottom side of the CPU board: U5 - MT29F2G16 - 16-bit NAND Flash U9 - MT29F2G08 - 8-bit NAND Flash On exit save the changes. 5. Kernel build a) if you are using the arm-elf toolchain: make uImage b) if you are using the arm-linux toolchain: CROSS_COMPILE=arm-linux- make uImage or replace in the Makefile: CROSS_COMPILE ?= arm-elf- with: CROSS_COMPILE ?= arm-linux- and then use as usual: make uImage The binary file for programming is: arch/arm/boot/uImage Another way to build compressed binary image of the kernel (recomendded for PM9263 with 2.6.23.14): mkdir image cd image arm-elf-objcopy -O binary -S ../vmlinux vmlinux.bin gzip -f9 vmlinux.bin mkimage -A arm -O linux -T kernel -C gzip -a 0x20008000 -e 0x20008000 -n "PM9263 Linux Kernel Only Image" -d vmlinux.bin.gz vmImage rm vmlinux.bin.gz The binary file for programming is: vmImage 6. Modules build make modules 7. Get a rootfs-pm926x-*.tar.bz2 package. Unpack it as root. su - tar xvfj rootfs-pm926x-*.tar.bz2 package 8. Installation of the Kernel modules make INSTALL_MOD_PATH= modules_install Note: If you get errors, perhaps you have to update your module-tools: http://kernel.org/pub/linux/utils/kernel/module-init-tools 9. Make rootfs image for NAND flash: mkfs.jffs2 -v -n -d --little-endian --pad --eraseblock=131072 --pagesize=2048 -o rootfs.jffs2 10. U-BOOT programming using PEEDI JTAG Flash Programmer (www.ronetix.at/peedi.html) peedi> flash set 0 ; select the first flash profile peedi> flash erase peedi> flash program 11. Programming of the Kernel A. Using PEEDI: Open a telnet console to PEEDI: peedi> flash set 1 ; select the second flash profile peedi> flash program B. Using U-BOOT: Make sure the U-BOOT networking is properly initialized (see 13.) tftp 20020000 vmImage.bin cp.b 20020000 10050000 $(filesize) 12. ROOTFS programming into the NAND flash A. Using PEEDI peedi> flash set 2 peedi> flash erase peedi> flash program B. Using U-BOOT Make sure the U-BOOT networking is properly initialized (see 13.) nand erase clean tftp 20020000 rootfs.jffs2 nand write.jffs2 20020000 0 $(filesize) 13. Setting a u-boot environment Boot board. Stop u-boot autoboot and set: setenv ipaddr setenv serverip setenv gatewayip setenv netmask setenv hostname setenv ethaddr saveenv At this point you can start the Linux from the Flash, start from PEEDI or debug with arm-elf-insight 14. Running the u-boot from PEEDI go 0x10000000 15. Kernel debugging The board should be programmed with the u-boot and the binary version of the vmlinux. Start gdb/insight: arm-elf-insight vmlinux In the console window: (gdb) target remote peedi:2000 (gdb) set $pc = 0x10000040 ; assuming the u-boot is flashed at 0x10000000 (after remap) (gdb) c The board is running: first starts the u-boot, then the Linux kernel. If you have a serial console you can see that the Linux is working. Now you can halt the kernel and set breakpoints where you want. If you want to have a breakpoint before the kernel is running you have to do the following: (gdb) target remote peedi:2000 (gdb) set $pc = 0x10000040 ; assuming the u-boot is flashed at 0x10000000 (gdb) hbreak start_kernel ; hardware breakpoint is used because the MMU is still not active (gdb) c The board is running (u-boot, then the kernel) and will stop at the start_kernel function. (gdb) delete ; delete the hardware breakpoint. Now you can use the software breakpoints. 16. Setup the DNS Edit /etc/resolve.conf considering your network. 17. Compiling a simple Linux application Create a text file main.c: int main() { printf("Hello world\n"); } Compiling: arm-linux-gcc -o main main.c The result is the ELF file main. Transferring the executable file from the PC to the target: The simples way is to use a USB stick - just copy the file main to a USB stick inserted into your PC. Unmount the stick and put it into the target board. After few seconds the USB stick will be automatically mounted: root@pm9263:~# mount /dev/sda1 on /media/sda1 root@pm9263:~# cp /media/sda1/main . root@pm9263:~# chmod +x main root@pm9263:~# ./main Hello world 18. LEDs To see the current state of a LED: cat /sys/class/leds/led<0|1|2>/trigger To change the state of a LED: echo > /sys/class/leds/led<0|1|2>/trigger