PM9G45-U-BOOT-LINUX-YOCTO

From Ronetix
Jump to navigation Jump to search
Pm9g45 top.png

Contents

PM9G45 User's Manual and Schematics

The User's Manual and the schematics of PM9G45 can be found here:

Before you start

The instructions in this document are meant to be done under GNU/Linux environment.


Connecting to the board

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 transmitted 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

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 static IP.

After the IP address is set and know, a link to the board running GNU/Linux can be made with telnet.

Toolchain

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.
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 rashed.

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

GNU toolchain notes

The pre-built GNU toolchains can be found http://download.ronetix.at/toolchains/arm/

Linux
The Linux kernel reqires 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


Download and install the GNU toolchain

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 "<work directory>/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:

$ . <work directory>/usr/local/kaeilos/arm/environment-setup

The toolchain prefix is "arm-oe-linux-gnueabi-".

$ wget http://download.ronetix.at/toolchains/arm/kaeilos-2010.1/kaeilos-2010.1-20110221-i686-linux-armv5te-linux-gnueabi-toolchain-extras.tar.bz2
$ wget http://download.ronetix.at/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 <stdio.h>
int main(int argc, char** argv) {
   printf("Hello World!\n");
   return 0;
  }
 ' > hello.c
$ arm-oe-linux-gnueabi-gcc hello.c -o hello

The rest of the toolchains

The toolchains will be installed in the /usr/cross directory.

$ wget http://download.ronetix.at/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

AT91BootStrap

Download AT91BootStrap image file

$ wget http://download.ronetix.info/boards/linux/bootstrap/nandflashboot/AT91Bootstrap-2.13/pm9g45-nandflashboot-2.13.bin

Installing and building AT91BootStrap 2.13

$ wget http://download.ronetix.at/boards/linux/bootstrap/nandflashboot/AT91Bootstrap-2.13/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

Installing and building AT91BootStrap 3.8.12

$ git clone git://github.com/linux4sam/at91bootstrap.git
$ cd at91bootstrap
$ wget http://download.ronetix.at/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

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.

Using PEEDI

peedi> flash select 1
peedi> flash program pm9g45-nandflashboot-2.13.bin BIN 0x0 erase

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


U-BOOT

Short introduction

U-BOOT is used for basic initialization of the 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 board:

  • NOR Flash
  • Dataflash
  • NAND flash
  • Ethernet
  • LCD
  • USB

Download and install the U-BOOT

PM9G45 is supported by the mainline U-BOOT.

Alternatively, u-boot-2010.09 + patches can be used.

Get U-Boot as tar.bz2

$ wget http://download.ronetix.at/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 ..

Get U-Boot with git clone

For easy 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 ..


Apply the provided patches

$ wget http://download.ronetix.at/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

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, comment as shown:

/* No need of LCD
* #define	CONFIG_LCD			1
*/

You may leave the configs as they are, test and then change as needed.

Configure and build

$ make pm9g45_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.


Programming U-Boot for PM9G45

The file u-boot.bin must be programmed in the NAND FLASH at address 0x20000.

Using PEEDI

peedi> flash set 1
peedi> fflash program pm9g45_bb9g45_u-boot.bin BIN 0x20000 erase

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


Linux kernel

Getting and unpacking the Linux kernel for PM9G45

$ wget http://download.ronetix.at/boards/linux/kernel/2.6.30/linux-2.6.30.tar.bz2
$ wget http://download.ronetix.at/boards/linux/kernel/2.6.30/patches/2.6.30-at91.patch.gz
$ wget http://download.ronetix.at/boards/linux/kernel/2.6.30/patches/2.6.30-at91-exp.5.tar.gz
$ wget http://download.ronetix.at/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

Kernel config

$ make pm9263_defconfig

To carry into effect the default kernel configuration you have to do the following.

Common for all boards:

$ export ARCH=arm
$ make pm9g45_v1.3-bb9g45_v1.1_defconfig


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 taken from http://download.ronetix.at/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.


Programming of the Kernel for PM9G45

Using PEEDI

peedi> flash select 2
peedi> flash program uImage bin 0x200000 erase

Using U-BOOT

u-boot> tftp 0x70000000 uImage
u-boot> nand erase clean 0x200000 0x200000
u-boot> nand write.jffs2 0x70000000 0x200000 0x200000


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.

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:

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/.

$ git clone git://git.openembedded.org/bitbake.git
$ cd bitbake
$ git pull
$ git checkout -b _tag_1.10.2 1.10.2


Getting openembedded - 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.


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.


Get KaeilOS settings and configuration files

$ 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.at/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.


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 custom-extra-image

Warning: custom-extra-image.bb is recipe example, it is useful to to demonstrate how to add stuff you like/want. It is build-able with the OpenEmbedded/Bitbake latest metadata state mentioned at "2. Getting openembedded - meta data, packages, relations and more". Doe to continuous change/improvement of OE there could be a time when some packages included in the custom-extra-image.bb are not build-able, 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 can not produce the desired images, due to URL sources are not available, most probably a new version, and the old one is removed. Example of this is missing live.2010.10.15.tar.gz from recipe live555_20101015.bb. Also there is recipes referring to a source in a svn, git or other repositories, which at the build time could be with broken sources like mplayer.

This initial system building is to let the OpenEmbedded build the system as it is by default, and later you can customize it.

Note that toolchains installation is not required as the OE makes it. There is an option to tell OE to use external toolchains.

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.


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.

Kernel configuring

Go to $OEBASE/build/kaeilos to configure and build your linux kernel:

$ cd $OEBASE/build/kaeilos
$ bitbake virtual/kernel -c menuconfig


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


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


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:

ROOTFS programming into the NAND flash for PM9G45

Using PEEDI

peedi> flash set 3
peedi> flash erase
peedi> flash program rootfs.jffs2 bin 0x500000

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).

Tips and tricks

In /etc/defaul/psplash add "--angle 90" in psplash arguments variable, so that splash screen is rotated properly.

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.

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"

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.

Calibrating the touchscren

  • From a terminal using keyboard on USB port, run "ts_calibrate"
  • 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"

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

Enabling the sound

To record sound from MIC create file ~/.asoundrc

--- .asoundrc ---
pcm.copy {
  type plug
  slave {
  pcm hw
  }
route_policy copy
}
--- .asoundrc ---
  • 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"
  • on BB9263

By default in ALSA mixer are enabled the "Jack sensing" for Mic and Headphone, set sensing to off.

Programming images in bare metal PM9G45

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.at/peedi/cfg_examples/arm9/at91sam9g45_pm9g45.cfg

The U-Boot elf file is here

http://download.ronetix.at/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.

With SAM-BA

Read the file following file to install and setup SAM-BA for pm9g45:

http://download.ronetix.at/boards/tools/linux/sam-ba_v2.10/README-SAM-BA-pm9g45.ronetix


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.at/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.

Develop

Compiling a simple GNU/Linux application

Create a text file example.c with contents:

--- example.c ---
#include <stdio.h>
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".

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.

Transferring the executable file from the PC to the target

Using USB stick

The simplest 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 machine 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

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".


Kernel debugging

Information on ARM Linux kernel boot process take a look at:

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 ---
<skipped registers>
   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.


PM9G45 pre-built images

Applicable for PM9G45 v1.2 and v1.3 on boards BB9G45 v1.1 and BB9263.

AT91Bootsrap
http://download.ronetix.at/boards/linux/bootstrap/nandflashboot/AT91Bootstrap-2.13/pm9g45-nandflashboot-2.13.bin
U-Boot bin/rom
http://download.ronetix.at/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9g45_u-boot.bin
http://download.ronetix.at/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9263_u-boot.bin
U-Boot ELF
http://download.ronetix.at/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9g45_u-boot
http://download.ronetix.at/boards/linux/bootloader/u-boot-2010.09/pm9g45_bb9263_u-boot
Linux Kernel bin/rom
http://download.ronetix.at/boards/linux/kernel/2.6.30/pm9g45_bb9g45_uImage
http://download.ronetix.at/boards/linux/kernel/2.6.30/pm9g45_bb9263_uImage
Linux Kernel elf
http://download.ronetix.at/boards/linux/kernel/2.6.30/pm9g45_bb9g45_vmlinux
http://download.ronetix.at/boards/linux/kernel/2.6.30/pm9g45_bb9263_vmlinux
RootFS
http://download.ronetix.at/boards/linux/rootfs/2.6.30-pm9g45/KaeilOS-custom-extra-image-glibc-ipk-2010.1-20110223-ronetix-pm9g45.rootfs.jffs2