# README-pm9g45 # Creating a working system with Linux kernel and so. # This guide is for PM9G45 on BB9G45 or BB9263 and applies to # boards v1.2 and v1.3. # # Ronetix GmbH # www.ronetix.at # January, 2012 # Table of contents: 1. Before you start 2. Toolchain 3. AT91BootStrap 4. U-Boot 5. Linux kernel 6. OpenEmbedded 7. Develop 8. Kernel debugging 9. PM9G45 pre-built images 1. Before you start The instructions in the README files are meant to be done under GNU/Linux environment. 1.1. Connecting to the boards A serial terminal connection through RS-232 null modem cable is needed to control U-Boot and GNU/Linux. To set up U-Boot run time a serial terminal connection must be used, this is the only way you can get access to the U-Boot command line. The Linux boot messages are transmeeted to the same serial connection. The Serial Debug interface is set to 115200 bps with 8 data bits, one stop bit and no parity. Use the screen command like this "screen /dev/ttyS0 115200 cs8,-cstopb,-parenb" or minicom utility. 1.2. Networking As tftp or ftp servers are needed call your system/network administrator to give you the settings. The IP address can be obtained using DHCP service or set statical IP. After the IP address is set and know, a link to the board running GNU/Linux can be made with telent. 2. Toolchain 2.1. Description The GNU Toolchain, is a combination of multiple projects: * GCC : GCC stands for "GNU Compiler Collection". GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Java, Fortran, and Ada. Currently the Blackfin is supported by C, and C++. * Binutils : GNU Binutils are a collection of binary tools. The main ones are: the GNU linker (ld) and the GNU assembler (as). * Debugger : GNU debugger, allows you to see what is going on `inside’ another program while it executes -- or what another program was doing at the moment it crashed. 2.2. Ronetix provides several GNU toolchains The recommded one is "KaeilOS v2010.1 SDK". KaeilOS v2010.1 SDK at kaeilos-2010.1/ ronetix-arm-elf-4.4.1.tar.bz2 - gcc 4.4.1, newlib, ARM, Cortex ronetix-arm-linux-4.3.3.tar.bz2 - gcc 4.3.3, glibc ronetix-arm-linux-uclibc-4.1.2.tar.bz2 - gcc 4.1.2, uclibc ronetix-gnutools-arm-elf-4.1.1-linux.tar.bz2 - gcc 4.1.1, newlib ronetix-toolset-arm-elf-4.1.1-windows.exe - gcc 4.1.1, newlib, for Windows openzaurus-arm-linux-glibc-3.4.4.tar.bz2 - gcc 3.4.4, glibc ronetix-gnutools-arm-elf-3.2.1-linux.tar.bz2 - gcc 3.2.1, newlib 2.3. GNU toolchain notes The pre-built GNU toolchains can be found http://download.ronetix.info/toolchains/arm/ Linux: The Linux kernel requires a minimal GCC version in order to compile. To check that minimal version take a look at the README file in the Linux source directory. U-Boot: U-Boot can not be compiled with some toolchains because of (E)ABI conformation. The USE_PRIVATE_LIBGCC parameter allows the usage of different run-time support library(libgcc.a). More on using this parameter see README in U-Boot source directory. 2.4. Download and install the GNU toolchain A. Installation of "KaeilOS v2010.1 SDK" This is SDK produced by OpenEmbedded recipes. It includes and package management system opkg. It includes development sources form the packages in KaeilOS. Download the two files and extract them in the "/" directory. They could be extracted in any directory, and then the file "/usr/local/kaeilos/arm/environment-setup" have to be edited and prefix the "SDK_PATH" value with the "work directory". And also remove the line which sets the CPATH environment. Before compiling execute ". /usr/local/kaeilos/arm/environment-setup". The toolchain prefix is "arm-oe-linux-gnueabi-". $ wget http://download.ronetix.info/toolchains/arm/kaeilos-2010.1/kaeilos-2010.1-20110221-i686-linux-armv5te-linux-gnueabi-toolchain-extras.tar.bz2 $ wget http://download.ronetix.info/toolchains/arm/kaeilos-2010.1/kaeilos-2010.1-20110221-i686-linux-armv5te-linux-gnueabi-toolchain.tar.bz2 $ su - # tar -C / -xjf kaeilos-2010.1-20110221-i686-linux-armv5te-linux-gnueabi-toolchain-extras.tar.bz2 # tar -C / -xjf kaeilos-2010.1-20110221-i686-linux-armv5te-linux-gnueabi-toolchain.tar.bz2 # exit $ . /usr/local/kaeilos/arm/environment-setup $ echo '#include int main(int argc, char** argv) { printf("Hello World!\n"); return 0; } ' > hello.c $ arm-oe-linux-gnueabi-gcc hello.c -o hello B. The rest of the toolchains. The toolchains will be installed in the /usr/cross directory. $ wget http://download.ronetix.info/toolchains/arm/ronetix-arm-linux-4.3.3.tar.bz2 $ su - # cd / # tar xvfj ronetix-arm-linux-4.3.3.tar.bz2 # exit Setup the path: $ export PATH=/usr/cross/arm-linux-4.3.3/bin:$PATH 3. AT91BootStrap 3.1. Download AT91BootStrap image file $ wget http://download.ronetix.info/boards/linux/bootstrap/nandflashboot/pm9g45-nandflashboot-2.13.bin 3.2. Installing and building AT91BootStrap 2.13 $ wget http://download.ronetix.info/boards/linux/bootstrap/nandflashboot/at91bootstrap-2.13-src-pm9g45-svn-r370.tar.bz2 $ tar xjvf at91bootstrap-2.13-src-pm9g45-svn-r370.tar.bz2 $ cd at91bootstrap-2.13-pm9g45-svn-r370 $ export ARCH=arm $ export CROSS_ARCH=arm-elf- # or put your ARM toolchain prefix $ make clean $ make pm9g45_defconfig $ make The file is binaries/pm9g45-nandflashboot-2.13.bin 3.2a. Installing and building AT91BootStrap 3.8.12 $ git clone git://github.com/linux4sam/at91bootstrap.git $ cd at91bootstrap $ wget http://download.ronetix.info/boards/linux/bootstrap/nandflashboot/AT91Bootstrap-3.8.12/patches/* $ git checkout -b v3.8.12 v3.8.12 $ git am 0001-at91sam9m10g45eknf_uboot_defconfig-Modify-load-addre.patch $ git am 0001-Makefile-generate-build-date-always-in-english.patch $ git am 0003-main.c-add-target-memory-test.patch $ git am 0004-Do-not-configure-CPU-clock-if-it-is-already-done-by-.patch $ make at91sam9m10g45eknf_uboot_defconfig $ make The file is binaries/at91sam9m10g45ek-nandflashboot--3.8.12.bin 3.3. Programming AT91BootStrap 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 4. U-Boot 4.1. 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 4.2. 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 .. 4.3. 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.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. 4.5. Configure and build A. For pm9g45 on bb9g45 I. on bb9g45 for KaeilOS or another distribution $ make pm9g45_config II. on bb9g45 for Android usage $ make pm9g45_android_config B. For pm9g45 on bb9263 $ make pm9g45_bb9263_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. 4.6. 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 5. Linux kernel 5.1. Getting and unpacking the Linux kernel for PM9G45 $ wget http://download.ronetix.info/boards/linux/kernel/2.6.30/linux-2.6.30.tar.bz2 $ wget http://download.ronetix.info/boards/linux/kernel/2.6.30/patches/2.6.30-at91.patch.gz $ wget http://download.ronetix.info/boards/linux/kernel/2.6.30/patches/2.6.30-at91-exp.5.tar.gz $ wget http://download.ronetix.info/boards/linux/kernel/2.6.30/patches/2.6.30-at91-exp.5-patches-pm9g45-09122011.tar.bz2 $ tar xjf linux-2.6.30.tar.bz2 $ gunzip 2.6.30-at91.patch.gz $ tar xzf 2.6.30-at91-exp.5.tar.gz $ tar xjf 2.6.30-at91-exp.5-patches-pm9g45-09122011.tar.bz2 $ cd linux-2.6.30 $ git init $ git add * $ git add .gitignore .mailmap $ git commit -m "Initial commit after linux-2.6.30.tar.bz2 extraction" $ git checkout -b 2.6.30-at91.patch $ patch -p1 < ../2.6.30-at91.patch $ git add -u $ git add * $ git commit -m "patching with 2.6.30-at91.patch" $ git checkout -b 2.6.30-at91-exp.5 $ for N in ../2.6.30-at91-exp.5/*.patch; do git am $N ; done $ git checkout -b pm9g45 $ for P in ../2.6.30-at91-exp.5-patches-pm9g45-09122011/*.patch ;do git am $P ; done 5.2. Kernel config To carry into effect the default kernel configuration you have to do the following. Common for all boards: $ export ARCH=arm A. For PM9G45 on BB9G45 $ make pm9g45_v1.3-bb9g45_v1.1_defconfig B. For PM9G45 on BB9263 $ make pm9g45_v1.3-bb9263_defconfig 5.3. Kernel build uImage is the Linux kernel packed(U-Boot wrapped zImage) in format for loading by U-Boot. The "mkimage" utility which is part of U-Boot is required to be in the executable search path(environment variable PATH). The "mkimage" can be aken from http://download.ronetix.info/boards/tools/linux/mkimage or obtained after building U-Boot for an ARM board. $ echo Make sure "mkimage" is in the executable search path! $ export CROSS_COMPILE=arm-oe-linux-gnueabi- $ make uImage The binary file for programming is arch/arm/boot/uImage. 5.4. 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 6. OpenEmbedded The OpenEmbedded has been undergoing reorganizations since 2011. All the recipes were on one place, which has caused maintenance issues and fragility. Several clone of OE, like Poky and Yocto Project, were started to fix this. And now, to consolidate forces Yocto and OE are merging in the new OpenEmbedded with layers. The OE before changes is named OpenEmbedded-classic. It is still alive. Its recipes are transferring to the layer structure. The layer structure is still on intensive development process. This readme covers the OpenEmbedded-classic. 6.1. Preparation First you need to prepare your host linux distribution in order to be able to get and build KaeilOS. A list of required packages for variety of host distributions is described in: http://wiki.openembedded.net/index.php/OEandYourDistro http://wiki.openembedded.net/index.php/Main_Page http://www.kaeilos.com/download in Required packages Lets prepare directory structure. Login on your host as ordinary user not as root(root privileges are not needed and a good practice is to avoid being root if not needed). You can login as a user you like. Starting point is being in the home directory. You may choose working directory at your decision, but be aware of the paths. Make directory for doing things and go to it: $ cd $ mkdir -p usr/src/oe $ cd usr/src/oe Now it is time to get bitbake - the building tool. All thing here are done with bitbake version 1.10.2. And don't install bitbake globally, install it as a sibling directory of openembedded/ and build/, more clearly said at ~/usr/src/oe/bitbake. $ git clone git://git.openembedded.org/bitbake.git $ cd bitbake $ git checkout -b _tag_1.10.2 1.10.2 2. Getting openembedded-classic - meta data, packages, relations and more Get it, go to directory openembedded/ and update. $ git clone git://git.openembedded.org/openembedded $ cd openembedded Since KaelOS distribution will be used, check out a tested OE metadata. $ git checkout -b kaeilos-2011 origin/mckoan/kaeilos-2011 As the OE is developing continuously sometimes the OE can not be build successfully so you can keep updating OE until it builds or use a build verified state(commit). The latest stable states can be found at http://www.kaeilos.com/latest-changes. !!! BIG FAT WARNING !!! Warning: even the tested OpenEmbedded/Bitbake metadata state after "some" time the build process can not produce the desired images and fail, due to URL sources are not available, most probably a new version of that resource, and the old one have been removed. Also there is recipes referring to a source in a svn, git or other repositories, which at the build time could be in broken state. 6.3. Get KaeilOS settings and configuration files and then extract them $ wget ftp://ftp.koansoftware.com/public/kaeilos/kaeilos-4.11-config-files.tgz $ tar xzvf kaeilos-4.11-config-files.tgz Get custom-extra-image.bb recipe file and save it in $OEBASE/openembedded/recipes/images: $ wget http://download.ronetix.info/boards/linux/rootfs/custom-extra-image.bb \ -O openembedded/recipes/images/custom-extra-image.bb Edit the files listed below so that they contains the correct paths. Use the absolute path: - in file setup-kaeilos.sh adjust the paths - in build/kaeilos/conf/auto.conf you can select the machine to build KaeilOS for. The default machine is "ronetix-pm9263", to build for pm9g45 change the name "ronetix-pm9263" to "ronetix-pm9g45", and if the case is pm9261 use "ronetix-pm9261" - in build/kaeilos/conf/local.conf remove "ext2" parameter in IMAGE_FSTYPES. Change the SCREEN_TERMCMD to 'xterm -e'. - in build/kaeilos/conf/site.conf adjust the paths, select a Debian mirror near you for higher download speed and in the Debian mirror remove the "pub/" part, also. 6.4. Initial building of the system You should be in $OEBASE directory. Running this command for the first time will take a some hours to finish: $ source setup-kaeilos.sh /home/ivan/usr/src/oe/build/kaeilos $ bitbake --continue console-base-image Warning: custom-extra-image.bb is recipe example, it is useful to to demonstrate how to add stuff you like/want. Doe to continuous change/improvement of OE there could be a time when some packages included in the custom-extra-image.bb are not buildable, and the items in the custom-extra-image.bb have to be adopted. The "x11-image", "console-image" and "console-base-image" are general for OE. Warning: even the tested OpenEmbedded/Bitbake metadata state after "some" time the build process can not produce the desired images and fail, due to URL sources are not available, most probably a new version of that resource, and the old one have been removed. Also there is recipes referring to a source in a svn, git or other repositories, which at the build time could be in broken state. This initial system building is to let the OpenEmbedded build the system(toolchain, tools running on the host and the required packages) and later you can customize the OpenEmbedded. Note that eternal toolchain installation is not required as the OE makes one. There is an option to tell OE to use external toolchains. OE could provide this toolchain as SDK(software development kit) for external usage. 6.5. AT91Bootstrap AT91Bootstrap for PM9G45 is configured and build automatically. The image to program is in the deploy directory. ~/usr/src/oe/build/kaeilos/tmp/deploy/eglibc/images/ronetix-pm9g45/at91bootstrap.bin For more details refer to AT91Bootstrap README. 6.6. U-Boot U-Boot for PM9G45 is configured and build automatically. The image to program is in the deploy directory. ~/usr/src/oe/build/kaeilos/tmp/deploy/eglibc/images/ronetix-pm9g45/u-boot-ronetix-pm9g45.bin For more details refer to U-Boot README. 6.7. Linux Kernel configuring Go to $OEBASE/build/kaeilos to configure and build your linux kernel: $ cd $OEBASE/build/kaeilos $ bitbake virtual/kernel -c menuconfig 6.8. Kernel building Next comes to compile, populate stage directory, install the kernel. Executing these task will compile kernel and modules, make head files to be in the stage directory and finally copy kernel and modules to $DEPLOY directory. $ bitbake virtual/kernel -c compile -f $ bitbake virtual/kernel 6.9. RootFS building To create RootFS go to $OEBASE/build/kaeilos: $ cd $OEBASE/build/kaeilos $ bitbake custom-extra-image The RootFS image is in the $DEPLOY directory. This is the image you should program into the NAND Flash of PM9G45: KaeilOS-custom-extra-image-glibc-ipk-2010.1-20110223-ronetix-pm9g45.rootfs.jffs2 6.10. Export SDK Creating a toolchain(SDK) is the same as creating a rootfs image. From the $OEBASE directory: $ source setup-kaeilos.sh /home/ivan/usr/src/oe/build/kaeilos $ bitbake meta-toolchain and the resulted SDK is in $DEPLOY directory. For reference: http://docs.openembedded.org/usermanual/html/commonuse_qte_sdk.html http://docs.openembedded.org/usermanual/html/ch05s08.html 6.11. 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). 6.12. Tips and tricks 6.12.1. Rotate KaeilOS boot logo In /etc/defaul/psplash add "--angle 90" in psplash arguments variable, so that splash screen is rotated properly. 6.12.2. Enable/Disable mouse pointer in X In /etc/matchbox/session find the line starting with "exec matchbox-window-manager" and change to "-use_cursor no" or to "-use_cursor yes" to hide or show mouse pointer. 6.12.3 To rotate X display properly you can execute this from the command line Take a look at /etc/X11/xorg.conf in Section "Device", and add or change the Option "Roatate", like this: Option "Rotate" "CCW" Adjusting touchscreen axes, in 'Section "InputDevice"' modify or add: Option "SwapAxes" "True" Option "InvertX" "True" Option "InvertY" "True" 6.12.4. Getting eth0 gateway parameter from dhcp In /etc/network/interface add "iface eth0 inet dhcp" before "iface eth0 inet static" line. Form the command line call "udhcpc" or "dhclient eth0" to set network through DHCP server. 6.12.5. Calibrating the touchscren A. From a terminal using keyboard on USB port, run "ts_calibrate" B. In GPE from Settings/Screen Setting press the "start" button in the calibration section. A text from "http://comments.gmane.org/gmane.comp.handhelds.openembedded/32629" with title "[oe] Handling different touchscreen calibration systems" --- citation --- There are several way to calibrate a touchscreen: *ts_calibrate : it uses the framebuffer and so it must be started before xorg(an init script can do that). works only for tslib. *xtscal : works only for kdrive and tslib(if I understood well) *xinput-calibrator: works with xorg and can calibrate many things,but I had huge issues with it with tslib,with /etc/pointercal from ts_calibrate it works fine but without it can't calibrate... Note that it also supports other protocols like evdev,evtouch etc... *other specific uttilities for evtouch etc... --- citation --- 6.12.6. Screen blanking, screen saver and screen DPMI Screen blanking/saver can be controlled with xset utility. To use the "xset" the DISPLAY cariable have to be set: # export DISPLAY=:0.0 To set the timeout time to 30 secund and screen saver change cycle time to 3 secunds use: # sleep 2; xset s 30 3 To see the blank(dark) screen pattern instead of the screen saver(a X like symbow jumping around) use: # sleep 2; xset s blank Screen saver can be shown instead of a dark pattern: # sleep 2; xset s noblank # sleep 2; xset s no To activate the screen saver or blanking at any time: # sleep 2; xset s activate To disable the screen saver and blanking # sleep 2; xset s reset 6.12.7. Enabling the sound To record sound from MIC create file ~/.asoundrc --- .asoundrc --- pcm.copy { type plug slave { pcm hw } route_policy copy } --- .asoundrc --- A. on BB9G45 run "alsamixer --view=capture" then select Mic using Left/Rigt arrows and the space bar. - Run "alsamixer -V capture" and select Mic as input. - Make a record "arecord -d 10 -f cd -t wav -D copy foobar.wav" - Play it "aplay foobar.wav" B. on BB9263 By default in ALSA mixer are enabled the "Jack sensing" for Mic and Headphone, set sensing to off. 6.12.8. 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. 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. 7. Develop 7.1. Compiling a simple GNU/Linux application A. Create a text file example.c with contents: --- example.c --- #include int main(int argc, char** argv){ printf("Hello world\n"); return 0; } --- example.c --- Compiling: Substitute "arm-oe-linux-gnueabi-gcc" with the toolchain used to build kernel and root file system utilities. $ arm-oe-linux-gnueabi-gcc -o example example.c The result is the ELF file called "example". B. Compiling spidev test program which comes with Linux kernel Install the "KaeilOS v2010.1 SDK", see the toolchain README. $ cd linux-2.6.30-git_repo/Documentation/spi $ arm-oe-linux-gnueabi-gcc -I /usr/local/kaeilos/arm/arm-oe-linux-gnueabi/usr/include/ spidev_test.c -o spidev_test Adjust the "-I" path to the installation place of the SDK. 7.2. Transferring the executable file from the PC to the target A. Using USB stick The simples way is to use a USB stick - just copy the file example 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 discovered(most probably). You should have support of the file system on the USB stick, most probably it will be VFAT(FAT32). Take a look at the kernel messages to see the device node of your USB stick. Depending auto-mounter is enabled and installed on the rootfs, the USB stick could be automatically mounted. To see if it is automatically mounted: On target hachine: # mount /dev/sda1 on /media/sda1 In case it is not mounted automatically: On target machine: # mkdir /mnt/sda1 # mount /dev/sda1 /mnt/sda1 -t vfat # cp /mnt/sda1/main . # chmod +x main # ./main Hello world B. Tftp over network A tftp server should work on a host(or any development) computer. On host: $ cp hello tftp_boot_dir/ On target machine: # udhcpc # tftp -g -r tftp_boot_dir/hello -l hello 192.168.3.1 # chmod u+x hello # ./hello Hello world Alternatively to the "udhcpc" you can use "dhclient eth0". 7.3. Debugging application TODO: 8. Kernel debugging Information on ARM Linux kernel boot process take a look at: http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html http://www.arm.linux.org.uk/developer/booting.php http://gicl.cs.drexel.edu/people/sevy/linux/ARM_Linux_boot_sequence.html 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 very 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 commadn line(commands entered by hand do not need a delay). In this case the Linux kernel binary file have been programmed in NAND. (the same note as for Bootloader) The Bootloader except loading the Linux kernel, it also set parameters to the kernel so loading kernel in RAM from PEEDI is complicate. --- .gdbinit --- target remote 192.168.10.42:2000 -attach shell sleep 1s symbol-file pm9g45_bb9g45_vmlinux shell sleep 1s hbreak start_kernel shell sleep 1s continue shell sleep 3s monitor clock 20000 shell sleep 1s delete --- .gdbinit --- Description of each .gdbinit line: Line1: attaches the GDB to PEEDI, when target is at reset state. Line3: tells GDB where are the symbols. Line5: put a hardware breakpoint at the point where kernel is starting. Line7: start the target .... Line8: wait for a while until AT91Bootsrap, and bootloader are gone. Three seconds should be enough. Line9: At this time the kernel break point shloud be hit. Increase the JTAG clock. Line11: delete the hardware breakpoint, it can be useful later. After a gdb command a short delay is needed - delay is determined experimentally. 9. PM9G45 pre-built images Applicable for PM9G45 v1.2 and v1.3 on boards BB9G45 v1.1 and BB9263. AT91Bootsrap: http://download.ronetix.info/boards/linux/bootstrap/nandflashboot/pm9g45-nandflashboot-2.13.bin U-Boot bin/rom: http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9g45_u-boot.bin http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9263_u-boot.bin U-Boot ELF: http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9g45_u-boot http://download.ronetix.info/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9263_u-boot Linux Kernel bin/rom: http://download.ronetix.info/boards/linux/kernel/2.6.30/pm9g45_bb9g45_uImage http://download.ronetix.info/boards/linux/kernel/2.6.30/pm9g45_bb9263_uImage Linux Kernel elf: http://download.ronetix.info/boards/linux/kernel/2.6.30/pm9g45_bb9g45_vmlinux http://download.ronetix.info/boards/linux/kernel/2.6.30/pm9g45_bb9263_vmlinux RootFS: http://download.ronetix.info/boards/linux/rootfs/2.6.30-pm9g45/KaeilOS-custom-extra-image-glibc-ipk-2010.1-20110223-ronetix-pm9g45.rootfs.jffs2