TNY-A9G20-LPW Software

From CALAO Systems Wiki
Jump to: navigation, search

How to use buildroot

How to build the binaries for the TNY-A9G20-LPW from buildroot

  • Download the lastest buildroot release available here
  • Untar and uncompress the buildroot-2012.0x.tar.bz2 package on your host (tar -xvjf buildroot-2012.0x.tar.bz2)
  • Issue cd buildroot-2012.0x
  • Issue make calao_tny_a9g20_lpw_defconfig or make calao_tny_a9g20_lpw_dt_defconfig if you want to use DT
  • Issue make 2>&1 | tee build.log to build the binaries for the TNY-A9G20-LPW
Note: By default we use the toolchain provided by buildroot. If you want to use an external toolchain you can issue
make menuconfig and go to the Toolchain Menu in order to configure the path and prefix of your toolchain.

How to modify the barebox default config from buildroot

You can modify the default barebox settings by issuing the following command:
  • make barebox-menuconfig
From the menu you can add/remove features and then rebuild barebox by issuing the following command:
  • make
If you want to save your config file your can save by issuing the following command:
  • make savedefconfig

How to modify the linux kernel default config from buildroot

You can modify the default linux kernel settings by issuing the following command:
  • make linux-menuconfig
From the menu you can add/remove features and then re-build the linux kernel by issuing the following command:
  • make
If you want to save your config file you can save by issuing the following command:
  • make savedefconfig

How to install SAM-BA from buildroot

How to add your software application in buildroot

  • More info available at here

How to flash the TNY-A9G20-LPW with the SAM-BA utility

  • Download the custom calao sam-ba utility available here
  • Untar and uncompress the sam-ba package on your host.
  • Setup your hardware
    1. Plug a USB cable in the micro USB connector of the TNY-A9G20-LPW
    2. Plug the USB cable in your host.

  • Issue sam-ba from the command line to start SAM-BA.
Note: Depending on your linux distro you should have to issue the following command in order to create a symlink to
/dev/ttyACM0: ln -s /dev/ttyACM0 /dev/ttyUSB0 
  • From the window below choose the tny9g20-lpw board and click on the Connect button.
  • Once sam-ba is loaded you should see the following window
  • Click on the Script File menu and click on Execute
  • Choose the tny-a9g20-lpw.tcl script in the calao directory.
  • When the tny-a9g20-lpw.tcl is interpreted, SAM-BA will ask you to browse your home directory in order to find the at91 bootstrap loader binary.
  • Browse your home directory in order to load the nandflash_tny_a9g20_lpw.bin file.
Note: By default the tny-a9g20-lpw.tcl script will load the binaries from ~/buildroot/output/images/
- Nand Flash Mapping Table
NAND Offset Size Reserved for
0x00000 128KB at91bootstrap loader (nandflash_tny_a9g20_lpw.bin)
0x20000 256KB bootloader (barebox.bin)
0xA0000 128KB Device tree blob (tny_a9g20_lpw.dtb)
0xC0000 4MB Linux kernel image (default:zImage)
0x4A0000 120MB UBI rootfs (default:rootfs.ubifs)
  • After a while your board is re-flash
NOTE: If you plan to use DT you should use the DT script. Indeed this script will install the DT blob at 0xA0000

How to use barebox

Introduction

Barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel: The size and look-and-feel of u-boot, with driver model and lots of design concepts from the kernel.

Start with barebox

Once your TNY-A9G20-LPW is re-flashed, you can plug in a TTL<>RS232 converter on the 4 pin connector located on the bottom side as shown below:

Then start a terminal program on your host (minicom for instance), setup your serial link with the following parameters: 115200,n,8,1.

In your terminal window you should see something similar to the information displayed below:

If you don't stop the auto countdown, you can notice barebox tries to boot from the network.

  • Issue a ctrl-c from your terminal to stop the network boot stage as it is not probably well configured.

How to install a UBI rootfs from barebox

Prepare the Flash before UBI rootfs install

The /dev/nand0.root partition can be attached to ubi using

  • ubiattach /dev/nand0.rootfs
NOTE: Before attaching the rootfs partition to ubi please erase it with erase /dev/nand0.rootfs

Create a volume on the UBI device

  • ubimkvol /dev/ubi0 root 0

Load a file from a tftp server

Setup a tftp server on your host and copy the UBI rootfs from ~/buildroot/output/images/ to your tftp directory.

Setup your network from barebox:

If you have a dhcp server available on your network you can see the network parameters by issuing the following command:

  • devinfo eth0

If you want to modify for example the serverip variable you have to issue the following command:

  • eth0.serverip=192.168.1.10

Now your network setup is ok, you can load a file from barebox with the command below:

  • tftp zImage zImage

Issue ls and you should see your file in the / directory

Note: As the TNY-A9G20-LPW is not equipped with an ethernet interface, you will have use the MOB-TNY-MD2 development board.
  • For more information about the MOB-TNY-MD2 see here

Flash the UBI rootfs from barebox

The UBI volume can then be flashed with the command below:

  • tftp rootfs.ubifs /dev/ubi0.root

Save your network settings

From the barebox command line you can save your network settings by editing the config file in /env directory:

  • edit env/config
 env/config                <ctrl-d>: Save and quit <ctrl-c>: quit 
#!/bin/sh

# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
ip=dhcp-barebox
dhcp_vendor_id=barebox-tny-a9g20

# or set your networking parameters here
#eth0.ipaddr=a.b.c.d
#eth0.netmask=a.b.c.d
#eth0.gateway=a.b.c.d
#eth0.serverip=a.b.c.d

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=nand
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=nand
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=none

Uncomment and setup your network parameters as below:

# or set your networking parameters here
eth0.ipaddr=192.168.1.100
eth0.netmask=255.255.255.0
eth0.gateway=192.168.1.10
eth0.serverip=192.168.1.10

Save your config file by issuing Ctrl-d

Now to save your config issue the following command :

  • saveenv

Modify the default boot sequence

By default barebox tries to boot from the network.Once you have flashed your kernel and your root filesystem in the Nand Flash memory you can boot from the NAND Flash.

Below the steps required to modify the default boot sequence (Boot from Nand Flash).

  • Stop the autoboot from your terminal

  • Edit the config file by issuing the following command edit env/config
 env/config                <ctrl-d>: Save and quit <ctrl-c>: quit 
#!/bin/sh
# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
# ip=dhcp-barebox
dhcp_vendor_id=barebox-tny-a9g20

# or set your networking parameters here
#eth0.ipaddr=a.b.c.d
#eth0.netmask=a.b.c.d
#eth0.gateway=a.b.c.d
#eth0.serverip=a.b.c.d

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=nfs
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=net
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=none

# can be either 'jffs2' or 'ubifs'
rootfs_type=ubifs
  • replace ip by none & modify the kernel_loc and rootfs_loc by nand as shown below:

# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
# ip=dhcp-barebox
ip=none
dhcp_vendor_id=barebox-tny-a9g20

# or set your networking parameters here
#eth0.ipaddr=a.b.c.d
#eth0.netmask=a.b.c.d
#eth0.gateway=a.b.c.d
#eth0.serverip=a.b.c.d

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=nand
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=nand
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=nand

# can be either 'jffs2' or 'ubifs'
rootfs_type=ubifs
rootfsimage=root.$rootfs_type

kernelimage=zImage
#kernelimage=uImage
#kernelimage=Image
#kernelimage=Image.lzo

Save your config file by issuing Ctrl-d

Note: If you built a linux kernel with DT, you should specify where your DT blob is located with oftree_loc

Now to save your config issue the following command :

  • saveenv

Issue reset in order to check your default boot sequence

  • reset

How to use the dfu

DFU for Device Firmware upgrade can be used to download and upload barebox, linux kernel and the rootfs to the TNY-A9G20-LPW connected over USB.

Let's assume that you want to upgrade your kernel image from barebox.

  • Plug a usb cable in the micro USB connector as shown below:
Note: As there's no user push button available on the TNY-A9G20-LPW, you will have to start the dfu
from the barebox command line by issuing the following command:dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
  • Now from your host you can start dfu-util
Note: dfu-util can be installed on your host from buildroot or by downloading the package.
dfu-util can be downloaded: here.
  • From your host open a terminal window and issue the following command:
  • $sudo dfu-util -l (if you have installed dfu-util from buildroot issue cd ~/buildroot/output/host/usr/bin/ and then sudo ./dfu-util -l)
  • You should see the upgradable partition list
barebox@Calao TNY-A9G20-LPW:/                                                                                                                
# dfu ${dfu_config} -P ${product_id} -V ${vendor_id}                                                                                     
dfu: register alt0(barebox) with device /dev/nand0.barebox.bb                                                                            
dfu: register alt1(kernel) with device /dev/nand0.kernel.bb                                                                              
dfu: register alt2(rootfs) with device /dev/nand0.rootfs.bb

Let's assume that you want to reflash your linux kernel

  • Issue the following command:

$sudo ./dfu-util -d 4321:1234 -a kernel -R -D ~/buildroot/output/images/zImage

$ sudo ./dfu-util -d 4321:1234 -a kernel -R -D ~/buildroot/output/images/zImage 
dfu-util 0.6

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY

Filter on vendor = 0x4321 product = 0x1234
Opening DFU capable USB device... ID 4321:1234
Run-time device DFU version 0100
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening DFU USB Device...
Found Runtime: [4321:1234] devnum=0, cfg=1, intf=0, alt=1, name="kernel"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0100
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=42475
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode

Let's assume that you want to reflash your rootfs

  • Issue the following command:

$sudo ./dfu-util -d 4321:1234 -a rootfs -R -D ~/buildroot/output/images/rootfs.ubi

sudo ./dfu-util -d 4321:1234 -a rootfs -R -D ~/buildroot/output/images/rootfs.ubi
dfu-util 0.6

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY

Filter on vendor = 0x4321 product = 0x1234
Opening DFU capable USB device... ID 4321:1234
Run-time device DFU version 0100
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening DFU USB Device...
Found Runtime: [4321:1234] devnum=0, cfg=1, intf=0, alt=2, name="rootfs"
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0100
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=62914
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
 Note: The rootfs.ubi is an image of the UBI rootfs and can be built from buildroot 

How to download a file from the serial port

If you want to download a file through the serial port you can issue the following command on your target:

  • loadb -f filename -c

From your host you can use for instance C-Kermit and issue the command below in order to send a file to your TNY-A9G20-LPW:

~$ kermit
?SET SPEED has no effect without prior SET LINE
C-Kermit 8.0.211, 10 Apr 2004, for Linux
 Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
Linux Kermit> send filename
Note: You should configure kermit by editing the kermrc file located in /etc/kermit/

Misc