SAM9-L9260 Hacking: Difference between revisions

From Hive76 Wiki
Jump to navigationJump to search
No edit summary
 
(31 intermediate revisions by the same user not shown)
Line 1: Line 1:
A couple of SAM9 Boards are around the space (see http://www.olimex.com/dev/sam9-L9260.html for spec's). Here is how to setup for them.
A couple of SAM9 Boards are around the space (see http://www.olimex.com/dev/sam9-L9260.html for spec's). Here is how to setup for them.
= Setup dev machine (Linux) =
= Setup dev machine (Linux) =
Line 9: Line 8:
the sam-ba_cdc_2.9.linux_cdc CD. That CD contains the linux tools for general Atmel ARM development.
the sam-ba_cdc_2.9.linux_cdc CD. That CD contains the linux tools for general Atmel ARM development.
3) Download some pre-built projects to test. You can download a CD image with a bunch of prebuilt projects from Atmel called at91sam9260-ek That disk will contain a directory 'packages' which is full of pre-built example projects, including the completed binaries.
3) Download some pre-built projects to test. You can download a CD image with a bunch of prebuilt projects from Atmel called at91sam9260-ek That disk will contain a directory 'packages' which is full of pre-built example projects, including the completed binaries.
4) Connecting to the board via SAM-BA is annoyingly complicated, and a bit wonky. It's bad bad design, and took a bit to figure out.  To make a long process short, you have to munge the 'usbserial' kernel module. That means you need to unload it if it's loaded, reload it with some custom settings, and then check it connected ok.  Details on the computer side of that process are at http://www.at91.com/linux4sam/bin/view/Linux4SAM/SoftwareTools.  
4) Connect to the board
For the board itself (the Olimex SAM9-L9260) you will also have to pull a couple of jumpers to get the programmer to connect properly.  
Connecting to the board via SAM-BA is annoyingly complicated, and a bit wonky. It's bad bad design, and took a bit to figure out.  To make a long process short, you have to munge the 'usbserial' kernel module.  
You can see how to setup
4a) setup the machine
OLD VERSION BELOW:
That means you need to unload it if it's loaded, reload it with some custom settings, and then check it connected ok.  Details on the computer side of that process are at http://www.at91.com/linux4sam/bin/view/Linux4SAM/SoftwareTools. ( TODO: add link to /serial_magic_for_sam9-l9260.sh)
=== Bootloader: ===
4b) Setup the board
==== Mac: ====
For the board itself (the Olimex SAM9-L9260) you will also have to pull a couple of jumpers to get the programmer to connect properly. Unplug the board from the computer, and from the wall, and pull off jumper DF_E and jumper NAND_E. AFAIK (check this) that prevents the board from booting from flash or NAND flash, and it will default to a reprorgamming mode(insert photo)
1) Give up on OSX. IT won't work properly, I tried. Well, you can try too, but I found another way...
4c) Run SAM-BA
2) Load linux on your macRock on!
While those jumpers are removed, plug power into the board. The reconenct the jumpers and connect the USB cable from your computer to the SAM9-L9260 board. The check at the command line if '/dev/ttyUSB?' exists. If that is there, If you then run SAM-BA (having done 1 - 4) you should see the /dev/ttyUSB? listed as connection, and you should be able to select the board 'at91sam9260-ek' in the 'select your board' menu. Click connect to connect to the board.
3) Download 'SAM-BA_CDC.zip (Linux - v1.13 current release) (7 MB, revision 1.13, updated 6/09)' from http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3883
5) Load a program:
4) Unzip that package somewhere helpful.  Connect your USB -> Serial connector , and connect your serial to the board.  
TODO
5) run lsusb, and look for 'Bus 004 Device 007: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port'
== SAM9-L9260 ==
5) if that exists, go into the SAM-BA directory, and run ./sam-ba. You should be able to select /dev/ttyUSB0 and connect to it.
The SAM9-L9260 does not seem to run the prebuilt binaries from the Atmel CD. The atmel data comes as binaries SDRam NORFlash. We tried loading them into DFlash, NANDFlash, and other sections of the chip, and it didn't work. Assuming that is because the Olimex board is different from the official Atmel board.
== Linux Development Enviroment setup  ==
* DF_E is linked to SAM-BA memory system Dataflash SPI0 CS1
(for Gentoo  (Gentoo) Gentoo Crossdev works. See http://www.rockbox.org/wiki/CrossCompiler)
* NANDF_E is linked to SAM-BA memory system NandFlash (no chip select for it)
1) download rockbox source "svn co svn://svn.rockbox.org/rockbox/trunk/tools rockbox_tools"
== USB connection ==
2) run 'rockbox_tools/rockboxdev.sh' it will ask for a target, select arm as your target by pressing 'a' when prompted.
Document here how to get a USB -> serial dongle working, using the magic of modeprobe and rmmod, etc. We have a script for it.
=== Setup GDB tools :===
Base it on http://blog.mypapit.net/2008/05/how-to-use-usb-serial-port-converter-in-ubuntu.html
lovingly based on http://code.google.com/p/rockboxplayer/wiki/DevelopmentEnvironmentSetup
= Boot Order Details =
1) sudo apt-get install libncurses5-dev
The 9260 tries to boot in the following order
2) Build GDB for arm-elf manually (it sees there is no package for it?)
*DataFlash CS0
  a) download GDB via 'wget http://ftp.gnu.org/gnu/gdb/gdb-6.8.tar.bz2'
*DataFlash CS1
  b) unpack via 'tar -xvvf gdb-6.8.tar.bz2'
*NandFlash
  c) move into gdb 'cd gdb-6.8'
*Samba Monitor (USB or DBGU) until connection or reboot.
  d) configure gdb './configure --target=arm-elf  --prefix=/usr/local/arm-elf --disable-werror'
= Compile Examples from Atmel for Olimex board =
  e) build via 'make' and install via 'make install'
How to compile code to run off of a flash card or USB drive plugged into a Olimex SAM9-L9260 dev board running linux, based on Debian Lenny
3) When build is done, edit .bashrc so that it includes PATH=$PATH:/usr/local/arm-elf/bin
[http://www.emdebian.org/ EnDebian] is a site dedicated to getting Debian running on embedded devices, they have info on cross compilers and more.
4) get the lyre project source code (as test/reference for SAM9
Cross tool chain binaries are at http://www.emdebian.org/tools/crosstools.html
can be fetched via 'hg clone http://lyre.hg.sourceforge.net:8000/hgroot/lyre/lyre lyre_src'
== Setup the Toolchain (Debian based system) ==
==== Install OpenOCD ====
# Follow the instructions at [http://www.emdebian.org/tools/crosstools.html this emdebian page].
We are using ARM-USB-TINY JTAG hardware but others JTAG hardware should work on a similar way if supported by OpenOCD.
# TODO list wiki and/or static setup page
Actual scripts works with OpenOCD revision 732, so we get and build that revision:
# From the command line, run 'arm-linux-gnueabi-gcc-4.3 -v' to make sure you have it installed and working.
svn checkout -r 732 svn://svn.berlios.de/openocd/trunk
# Find the example 'hello world' program at the end of SAM9-L9260.pdf document from olimex. Save it to a file.
(testing svn checkout svn://svn.berlios.de/openocd/trunk)
# run 'arm-linux-gnueabi-gcc-4.3 -o hello hello.c' to compile the program
We need to enable "ft2232_libftdi" because JTAG ARM-USB-TINY uses it. We may need to install "libftdi dev" using apt-get.
# copy program to a flash drive
  cd trunk
# log into the board using minicom (on linux)
  sudo apt-get-install automake
# run 'mkdir /mnt/DRIVENAME' to make a mount point for the flashdirve.
  sudo apt-get install libtool
# run 'mount /dev/disk/by-label/NEATHACKER /mnt/NEATHACKER -t auto'
  sudo apt-get install libftdi1
== Building the Linux Kernel ==
  sudo apt-get install libftdi-dev
Some tools (SPI for example) are not in the example OS sent by Olimex on the board.  Because SPI is '''wicked keen''' we needed to enable that
  sudo apt-get install texinfo
#get the linux2.6 image from the disk
  ./bootstrap
#apply patches to linux 2.6 as [http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html described here] under 'extract and patch'
  ./configure --enable-ft2232_libftdi
#install mkimage if you don't have it
  make
#compile the kernel (based on info at [http://www.skpang.co.uk/catalog/images/olimex/Atmel_SAM/SAM9_L9260_quickstart_guide.txt skpang.co.uk]
  make ins
#* we used gnueabi version if arm-linux for eabi compatibility (needs more info!)
next: follow http://code.google.com/p/rockboxplayer/wiki/EclipseWithJTAGDebugSetup
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi sam9_l9260_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi uImage
== Misc Notes ==
Note:Atmel has some good examples of launch-able firmware for testing the SAM9260, but they compile for Nand flash (the atmel demo board) not nor flash (the olimex board).
NOTE: we use minicom to connect to the board.
NOTE: linux on SAM9-L9260 is '''Linux sam9-l9260 2.6.31-rc3-olimex #1 PREEMPT Thu Jul 16 17:00:14 EEST 2009 armx'''
NOTE:
sam9-l9260:/mnt/NEATHACKER# /sys/devices/platform/                             
at91_mci/      at91_udc/     atmel_usart.1/ leds-gpio/                        
at91_ohci/     atmel_nand/   atmel_usart.2/ macb/                            
at91_rtt.0/    atmel_usart.0/ atmel_usart.3/
NOTE:
* gpio system stuff is at '/sys/class/gpio/' based on ports
NOTE:
[http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO accessing GPIO loines via Linux Kernel]
NOTE: we are using an Analog Devices DAC AD5764R
NOTE:
"fdisk -l"

Latest revision as of 20:00, 20 January 2010

A couple of SAM9 Boards are around the space (see http://www.olimex.com/dev/sam9-L9260.html for spec's). Here is how to setup for them.

Setup dev machine (Linux)

We have attempted setup on OSX and on Windows. In both cases, it was hard to get the project working. So instead we are working with Linux (Ubuntu 9.04) for our development.

  • Install Ubuntu

Bootloader (SAM)

1) The first thing to check is your bootloader, to make sure you can load code onto the board. 2) Download the bootloader (called SAM-BA) from the Atmel website, as part of the sam-ba_cdc_2.9.linux_cdc CD. That CD contains the linux tools for general Atmel ARM development. 3) Download some pre-built projects to test. You can download a CD image with a bunch of prebuilt projects from Atmel called at91sam9260-ek That disk will contain a directory 'packages' which is full of pre-built example projects, including the completed binaries. 4) Connect to the board Connecting to the board via SAM-BA is annoyingly complicated, and a bit wonky. It's bad bad design, and took a bit to figure out. To make a long process short, you have to munge the 'usbserial' kernel module. 4a) setup the machine That means you need to unload it if it's loaded, reload it with some custom settings, and then check it connected ok. Details on the computer side of that process are at http://www.at91.com/linux4sam/bin/view/Linux4SAM/SoftwareTools. ( TODO: add link to /serial_magic_for_sam9-l9260.sh) 4b) Setup the board For the board itself (the Olimex SAM9-L9260) you will also have to pull a couple of jumpers to get the programmer to connect properly. Unplug the board from the computer, and from the wall, and pull off jumper DF_E and jumper NAND_E. AFAIK (check this) that prevents the board from booting from flash or NAND flash, and it will default to a reprorgamming mode. (insert photo) 4c) Run SAM-BA While those jumpers are removed, plug power into the board. The reconenct the jumpers and connect the USB cable from your computer to the SAM9-L9260 board. The check at the command line if '/dev/ttyUSB?' exists. If that is there, If you then run SAM-BA (having done 1 - 4) you should see the /dev/ttyUSB? listed as connection, and you should be able to select the board 'at91sam9260-ek' in the 'select your board' menu. Click connect to connect to the board. 5) Load a program: TODO

SAM9-L9260

The SAM9-L9260 does not seem to run the prebuilt binaries from the Atmel CD. The atmel data comes as binaries SDRam NORFlash. We tried loading them into DFlash, NANDFlash, and other sections of the chip, and it didn't work. Assuming that is because the Olimex board is different from the official Atmel board.

  • DF_E is linked to SAM-BA memory system Dataflash SPI0 CS1
  • NANDF_E is linked to SAM-BA memory system NandFlash (no chip select for it)

USB connection

Document here how to get a USB -> serial dongle working, using the magic of modeprobe and rmmod, etc. We have a script for it. Base it on http://blog.mypapit.net/2008/05/how-to-use-usb-serial-port-converter-in-ubuntu.html

Boot Order Details

The 9260 tries to boot in the following order

  • DataFlash CS0
  • DataFlash CS1
  • NandFlash
  • Samba Monitor (USB or DBGU) until connection or reboot.

Compile Examples from Atmel for Olimex board

How to compile code to run off of a flash card or USB drive plugged into a Olimex SAM9-L9260 dev board running linux, based on Debian Lenny EnDebian is a site dedicated to getting Debian running on embedded devices, they have info on cross compilers and more. Cross tool chain binaries are at http://www.emdebian.org/tools/crosstools.html

Setup the Toolchain (Debian based system)

  1. Follow the instructions at this emdebian page.
  2. TODO list wiki and/or static setup page
  3. From the command line, run 'arm-linux-gnueabi-gcc-4.3 -v' to make sure you have it installed and working.
  4. Find the example 'hello world' program at the end of SAM9-L9260.pdf document from olimex. Save it to a file.
  5. run 'arm-linux-gnueabi-gcc-4.3 -o hello hello.c' to compile the program
  6. copy program to a flash drive
  7. log into the board using minicom (on linux)
  8. run 'mkdir /mnt/DRIVENAME' to make a mount point for the flashdirve.
  9. run 'mount /dev/disk/by-label/NEATHACKER /mnt/NEATHACKER -t auto'

Building the Linux Kernel

Some tools (SPI for example) are not in the example OS sent by Olimex on the board. Because SPI is wicked keen we needed to enable that

  1. get the linux2.6 image from the disk
  2. apply patches to linux 2.6 as described here under 'extract and patch'
  3. install mkimage if you don't have it
  4. compile the kernel (based on info at skpang.co.uk
    • we used gnueabi version if arm-linux for eabi compatibility (needs more info!)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi sam9_l9260_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi uImage

Misc Notes

Note:Atmel has some good examples of launch-able firmware for testing the SAM9260, but they compile for Nand flash (the atmel demo board) not nor flash (the olimex board). NOTE: we use minicom to connect to the board. NOTE: linux on SAM9-L9260 is Linux sam9-l9260 2.6.31-rc3-olimex #1 PREEMPT Thu Jul 16 17:00:14 EEST 2009 armx NOTE: sam9-l9260:/mnt/NEATHACKER# /sys/devices/platform/ at91_mci/ at91_udc/ atmel_usart.1/ leds-gpio/ at91_ohci/ atmel_nand/ atmel_usart.2/ macb/ at91_rtt.0/ atmel_usart.0/ atmel_usart.3/ NOTE:

  • gpio system stuff is at '/sys/class/gpio/' based on ports

NOTE: accessing GPIO loines via Linux Kernel NOTE: we are using an Analog Devices DAC AD5764R NOTE: "fdisk -l"