Search by Tags

Linux (Colibri PXA) Flashing

 

Compare with Revision




Subscribe for this article updates

This article describes how to bring Linux onto a Colibri PXA.

For Colibri PXA modules Android/Linux BSPs are provided as-is. Support is currently limited and Toradex is not actively developing or maintaining them at present.
On newer module versions U-Boot and/or the Linux kernel may either fail or not support certain module features due to incompatible HW changes.

The files will be transferred to the Colibri with a USB Memory Stick.

Note: To return to WinCE you will need a JTAG adapter. http://developer.toradex.com/knowledge-base/colibri-loader

Note: Backup the config block with the update tool in WinCE before starting the update to Linux. The config block contains among other things manufacturing data like the ethernet MAC address. If you want to go back to WinCE you might want to restore the config block.

Note: If the update to the bootloader fails, you will need a JTAG adapter to revive the Colibri Module.

Updating a PXA 3xx

Get the Files PXA 3xx

http://developer.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Images/PXA-as-is/toradex-bsp-2011.02/
Replace XX, YY with what's applicable for your Module, in the rest of the document we use a Colibri PXA320 V2.0

get tools/wince2linux3XXvYY.zip                       unzip into a FAT formated USB Memorystick 
get bin/u-boot-nand-2010.09-colibri_pxa3XXvYY.bin and copy onto USB Memorystick
get bin/uImage-2.6.35.9-toradex and copy onto USB Memorystick
get bin/rootfs-toradex-bsp-2011.02-r1-ubifs.img and copy onto USB Memorystick

The folder AutoRun and the u-boot file in wince2linuxXXXX.zip must be in the rootfolder of the memory stick.

HW Setup PXA 3xx

Insert the module in one of the baseboards Connect the FFUART port to a terminal application, 115200,8,n,1

Flash an initial u-boot from within WinCE PXA 3xx

Power the board, WinCE starts. The entry in the AutoRun folder will start the Update Tool and overwrites the eboot bootloader with an initial u-boot bootloader.

Update U-Boot to final version PXA 3xx

Restart the board, press a key to enter the u-boot menu and use the u-boot commandline to update u-boot and delete the current u-boot environment.

U-Boot 2010.09-toradex (Sep 09 2011 - 13:04:20)

DRAM:  128 MiB
NAND:  1024 MiB
Bad block table not found for chip 0
Bad block table not found for chip 0
Bad block table written to 0x00003ffe0000, version 0x01
Bad block table written to 0x00003ffc0000, version 0x01
*** Warning - bad CRC or NAND, using default environment

In:    serial
Out:   serial
Err:   serial
Erasing Nand...
Erasing at 0xe0000 -- 100% complete.
Writing to Nand... done
Net:   ax88796c
Hit any key to stop autoboot:  0

$ usb start
(Re)start USB...
USB:   scanning bus for devices... 6 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
$ fatload usb 0:1 0x81000000 u-boot-nand-2010.09-colibri_pxa320v20.bin
reading u-boot-nand-2010.09-colibri_pxa320v20.bin

322612 bytes read
$ nupdate 0x81000000 $filesize
Successfully verified 0x0004ec34 bytes
$ nand erase 0x80000 0x80000

NAND erase: device 0 offset 0x80000, size 0x80000
Erasing at 0xe0000 -- 100% complete.
OK
$ reset
resetting ...

or as a one liner

usb start;fatload usb 0:1 0x81000000 u-boot-nand-2010.09-colibri_pxa320v20.bin;nupdate 0x81000000 $filesize;nand erase 0x80000 0x80000

Update the kernel PXA 3xx

U-Boot 2010.09-toradex (Sep 09 2011 - 12:56:00)

DRAM:  128 MiB
NAND:  1024 MiB
*** Warning - bad CRC or NAND, using default environment

In:    serial
Out:   serial
Err:   serial
Erasing Nand...
Erasing at 0xe0000 -- 100% complete.
Writing to Nand... done
Net:   ax88796c
Hit any key to stop autoboot:  0
$ usb start
(Re)start USB...
USB:   scanning bus for devices... 6 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
$ fatload usb 0:1 0x81000000 uImage-2.6.35.9-toradex
reading uImage-2.6.35.9-toradex

2056700 bytes read
$ mtdparts

device nand0 , # parts = 9
 #: name                size            offset          mask_flags
 0: u-boot-1-part       0x00020000      0x00000000      1
 1: u-boot-2-part       0x00020000      0x00020000      1
 2: configuration-block 0x00020000      0x00040000      1
 3: u-boot-3-part       0x00020000      0x00060000      1
 4: u-boot-env          0x00080000      0x00080000      1
 5: kernel-ubi          0x00300000      0x00100000      0
 6: rootfs-ubi          0x07c00000      0x00400000      0
 7: mass-storage        0x36000000      0x08000000      0
 8: replacement-blocks  0x02000000      0x3e000000      1

active partition: nand0,0 - (u-boot-1-part) 0x00020000 @ 0x00000000

defaults:
mtdids  : nand0=pxa3xx-nand
mtdparts: mtdparts=pxa3xx-nand:128k(u-boot-1-part)ro,128k(u-boot-2-part)ro,128k@256k(configuration-block)ro,128k(u-boot-3-part)ro,512k(u-boot-env)ro,3m(kernel-ubi),124m(rootfs-ubi),864m(mass-storage),-(replacement-blocks)ro
$ nand erase 0x100000 0x300000

NAND erase: device 0 offset 0x100000, size 0x300000
Erasing at 0x3e0000 -- 100% complete.
OK
$ ubi part kernel-ubi
Creating 1 MTD partitions on "nand0":
0x000000100000-0x000000400000 : "mtd=5"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    126976 bytes
UBI: smallest flash I/O unit:    2048
UBI: VID header offset:          2048 (aligned 2048)
UBI: data offset:                4096
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=5"
UBI: MTD device size:            3 MiB
UBI: number of good PEBs:        24
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             18
UBI: total number of reserved PEBs: 6
UBI: number of PEBs reserved for bad PEB handling: 2
UBI: max/mean erase counter: 1/0
$ ubi createvol kernel
Creating dynamic volume kernel of size 2285568
$ ubi write 0x81000000 kernel $filesize
Volume "kernel" found at volume id 0

or as a one liner

usb start;fatload usb 0:1 0x81000000 uImage-2.6.35.9-toradex;mtdparts;nand erase 0x100000 0x300000;ubi part kernel-ubi;ubi createvol kernel;ubi write 0x81000000 kernel $filesize

Update root file system PXA 3xx

Please note: Due to the Colibri PXA300 (XT) only featuring 64 MB of available RAM one has to be careful as to where/how much can actually be loaded. As the UBI file system image is more than 32 MB in size one has to load it to 0x80000000 rather than 0x81000000.

$ fatload usb 0:1 0x81000000 rootfs-toradex-bsp-2011.02-r1-ubifs.img
reading rootfs-toradex-bsp-2011.02-r1-ubifs.img

33648640 bytes read
$ nand erase 0x400000 0x8000000

NAND erase: device 0 offset 0x400000, size 0x8000000
Skipping bad block at  0x01480000
Skipping bad block at  0x014a0000
    ...
Skipping bad block at  0x01c80000
Skipping bad block at  0x01ca0000
Erasing at 0x83e0000 -- 100% complete.
OK
$ ubi part rootfs-ubi
UBI: mtd1 is detached from ubi0
Creating 1 MTD partitions on "nand0":
0x000000400000-0x000008000000 : "mtd=6"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    126976 bytes
UBI: smallest flash I/O unit:    2048
UBI: VID header offset:          2048 (aligned 2048)
UBI: data offset:                4096
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "mtd=6"
UBI: MTD device size:            124 MiB
UBI: number of good PEBs:        926
UBI: number of bad PEBs:         66
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     0
UBI: available PEBs:             913
UBI: total number of reserved PEBs: 13
UBI: number of PEBs reserved for bad PEB handling: 9
UBI: max/mean erase counter: 1/0
$ ubi createvol rootfs
Creating dynamic volume rootfs of size 115929088
$ ubi write 0x81000000 rootfs $filesize
Volume "rootfs" found at volume id 0

or as a one liner

fatload usb 0:1 0x81000000 rootfs-toradex-bsp-2011.02-r1-ubifs.img;nand erase 0x400000 0x8000000;ubi part rootfs-ubi;ubi createvol rootfs;ubi write 0x81000000 rootfs $filesize

Updating a PXA 270

The Colibri PXA 270 NOR Flash has a storage capacity of 32MByte. Thus the size of the rootfs is limited if it is stored on the modules flash.
The procedure shows how to store the rootfs either on the internal flash or on an SD card.

The JFFS2 file system code is not compiled into the binary kernel image provided, but is needed if you store the rootfs in NOR Flash. So you will need to compile the kernel yourself.

You need a Linux PC to prepare the rootfs from the provided compressed images and for kernel recompilation.

Get the Files PXA 270

http://developer.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Images/PXA-as-is/toradex-bsp-2011.02/

get tools/wince2linux270.zip                              unzip into a FAT formated USB Memorystick 
get bin/uImage-2.6.35.9-toradex-pxa270v22b and copy onto USB Memorystick
get bin/rootfs-toradex-bsp-2011.02-r1.tar.bz2 will be used for rootfs on SD card

get bin/rootfs-small-toradex-bsp-2011.02-r1-ext2.img.gz will be used for rootfs on NOR Flash
get src/linux-2.6.35.9-toradex.tar.bz2 kernel sources get src/linux-2.6.35.9-toradex-pxa270v22b.patch kernel sources, patch get src/toradex_jffs2_config.patch kernel sources, patch

The folder AutoRun and the u-boot file in wince2linuxXXXX.zip must be in the rootfolder of the memory stick.

HW Setup PXA 270

Insert the module in one of the baseboards Connect the FFUART port to a terminal application, 115200,8,n,1

Flash u-boot from within WinCE PXA 270

Power the board, WinCE starts. The entry in the Autostart folder will start the Update Tool and overwrites the eboot bootloader with the u-boot bootloader.

Update U-Boot with a new version PXA 270

Omit this step if you did update from WinCE. Restart the board, press a key to enter the u-boot menu and use the u-boot commandline to update u-boot and delete the current u-boot environment.

U-Boot 2010.09-toradex (May 23 2012 - 13:24:37)

DRAM:  64 MiB
Flash: 32 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0
$ usb start
(Re)start USB...
USB:   scanning bus for devices... 6 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
$ fatload usb 0:1 0xa0000000 u-boot-2010.09-colibri_pxa270.bin
reading u-boot-2010.09-colibri_pxa270.bin

176220 bytes read
$ protect off 0x0 0x3ffff
.... done
Un-Protected 4 sectors
$ erase 0x0 0x3ffff

.... done
Erased 4 sectors
$ cp.b 0xa0000000 0x0 $filesize
Copy to Flash... done
$ reset
resetting ...

or as a one liner

usb start;fatload usb 0:1 0xa0000000 u-boot-2010.09-colibri_pxa270.bin;;protect off 0x0 0x3ffff;erase 0x0 0x3ffff;cp.b 0xa0000000 0x0 $filesize

Update the kernel PXA 270

U-Boot 2010.09-toradex (Feb 01 2011 - 15:18:04)

DRAM:  64 MiB
Flash: 32 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0
$ usb start
(Re)start USB...
USB:   scanning bus for devices... 6 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
$ fatload usb 0:1 0xa0000000 uimage-2.6.35.9-toradex-pxa270v22b
reading uimage-2.6.35.9-toradex-pxa270v22b

2056520 bytes read
$ protect off 0xc0000 0x47ffff
................ done
Un-Protected 16 sectors
$ erase 0xc0000 0x47ffff

................ done
Erased 16 sectors
$ cp.b 0xa0000000 0xc0000 $filesize
Copy to Flash... done

or as a one liner

usb start;fatload usb 0:1 0xa0000000 uimage-2.6.35.9-toradex-pxa270v22b;protect off 0xc0000 0x47ffff;erase 0xc0000 0x47ffff;cp.b 0xa0000000 0xc0000 $filesize

Use SD card for rootfs PXA 270

Prepare SD card

Use a linux computer to format the SD card to ext2.
Uncompress the provided rootfs into the SD card as root.

[root@trdx ~]# fdisk /dev/sdX

Command (m for help): o
Building a new DOS disklabel with disk identifier 0x9d89bee2.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3862527, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3862527, default 3862527): 
Using default value 3862527

Command (m for help): v
Remaining 2047 unallocated 512-byte sectors

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@trdx trdx]# mkfs.ext2 /dev/sdc1
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
120720 inodes, 482560 blocks
24128 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=494927872
15 block groups
32768 blocks per group, 32768 fragments per group
8048 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@trdx trdx]# mkdir /mnt/sdc1
[root@trdx trdx]# mount -t ext2 /dev/sdc1 /mnt/sdc1
[root@trdx trdx]# cd /mnt/sdc1
[root@trdx sdc1]# ls
lost+found
[root@trdx sdc1]# tar xjf /home/trdx/rootfs-toradex-bsp-2011.02-r1.tar.bz2 
[root@trdx sdc1]# ls
lost+found  rootfs-toradex-bsp-2011.02-r1
[root@trdx sdc1]# mv rootfs-toradex-bsp-2011.02-r1/* .
[root@trdx sdc1]# ls
bin  boot  data  dev  etc  home  lib  lost+found  media  mnt  proc  psplash_fifo  rootfs-toradex-bsp-2011.02-r1  sbin  sys  system  tmp  usr  var
[root@trdx sdc1]# rmdir rootfs-toradex-bsp-2011.02-r1/
[root@trdx sdc1]# cd ..
[root@trdx mnt]# umount /dev/sdc1
[root@trdx mnt]# rmdir sdc1

Set u-boot environment

Insert SD card on Colibri PXA270 system. Restart u-boot und press a key to get to the u-boot prompt.

$ setenv bootcmd bootm 0xc0000
$ setenv bootargs 'console=tty0 console=ttyS0,115200 root=/dev/mmcblk0p1 ip=:::::eth0: rootfstype=ext2 rw rootdelay=2'
$ save
Saving Environment to Flash...
. done
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
. done
Protected 1 sectors
$ boot

Use NOR Flash for rootfs PXA 270

Compile the kernel for JFFS2

For a cross toolchain have a look here Linux (Colibri T20) - Source Code.
Set CROSS_COMPILE acording to your system.
The default configuration is called as follows:

toradex_defconfig


tar xjf linux-2.6.35.9-toradex.tar.bz2
cd linux-2.6.35.9-toradex
patch -p1 < ../linux-2.6.35.9-toradex-pxa270v22b.patch
export ARCH=arm
export CROSS_COMPILE=${HOME}/bin/arm/bin/arm-none-linux-gnueabi-
make toradex_defconfig
patch -p0 < ../toradex_jffs2_config.patch
make -j3 uImage 2>&1 | tee build.log

This kernel can be found in arch/arm/boot/uImage
Update the target with the new kernel as explained above.

Prepare rootfs

Use a linux computer to build a JFFS2 binary blob from the rootfs.
You need the program mkfs.jffs2. (look for the package mtd-utils)

[root@trdx tmp]# mkdir rootfs
[root@trdx tmp]# gzip -d rootfs-small-toradex-bsp-2011.02-r1-ext2.img.gz 
[root@trdx tmp]# mount -o loop rootfs-small-toradex-bsp-2011.02-r1-ext2.img rootfs
[root@trdx tmp]# ls rootfs
bin  boot  data  dev  etc  home  lib  lost+found  media  mnt  proc  psplash_fifo  sbin  sys  system  tmp  usr  var
[root@trdx tmp]# mkfs.jffs2 -r rootfs -o rootfs-small-toradex-bsp-2011.02-r1.jffs2 -e 0x40000 --pad=0x01b80000
[root@trdx tmp]# ls rootfs-small-toradex-bsp-2011.02-r1.jffs2 -l
-rw-r--r--. 1 root root 28835840 May 24 18:19 rootfs-small-toradex-bsp-2011.02-r1.jffs2
[root@trdx tmp]# umount rootfs
[root@trdx tmp]# rmdir rootfs

Update rootfs in Flash and set u-boot environment

Copy rootfs-small-toradex-bsp-2011.02-r1.jffs2 to your USB Memorystick Use u-boot to save the rootfs to the NOR Flash and update environment

$ usb start
(Re)start USB...
USB:   scanning bus for devices... 6 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
$ fatload usb 0:1 0xa2000000 rootfs-small-toradex-bsp-2011.02-r1.jffs2
$ protect off 0x480000 0x1ffffff
$ erase 0x480000 0x1ffffff
$ cp.b 0xa2000000 0x480000 $filesize
$ setenv bootcmd bootm 0xc0000
$ setenv bootargs 'console=ttyS0,115200 root=/dev/mtdblock4 rootfstype=jffs2 ip=:::::eth0:'
$ save
Saving Environment to Flash...
. done
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
. done
Protected 1 sectors
$ boot

or as a one liner

usb start;fatload usb 0:1 0xa2000000 rootfs-small-toradex-bsp-2011.02-r1.jffs2;erase 0x480000 0x1ffffff;cp.b 0xa2000000 0x480000 $filesize;setenv bootcmd bootm 0xc0000;setenv bootargs 'console=ttyS0,115200 root=/dev/mtdblock4 rootfstype=jffs2 ip=:::::eth0:';save

Alternative to USB Memorystick: Use a TFTP Server

u-boot can request files from a TFTP server and transfer them to RAM.

instead of

$ usb start

$ fatload usb 0:1 memory-addr filename


you could also load the file from a tftp server. (the last three bytes of our MAC address are set to the hex representation of the modules serial number)

$ setenv ethaddr 00:14:2d:xx:xx:xx
$ setenv serverip 192.168.10.1
$ setenv ipaddr 192.168.10.2

$ tftp memory-addr filename