CM-X300: U-Boot: Firmware Development

From Compulab Mediawiki
Revision as of 16:01, 19 October 2010 by Mike (talk | contribs) (Reverted edits by Bettytaylor23 (Talk); changed back to last version by Grinberg)
Jump to: navigation, search

Overview

Compulab CM-X300 is shipped with built-in firmware, which deals with initial module power-up and initialization procedures. The firmware also provides a command line interface for Operating System or user program installation and loading.

This article describes the CM-X300 firmware structure, firmware assembly process and provides recommendations for testing U-Boot customization.

Admolition note.png The target audience of this article are developers, who need to alter the CM-X300 U-Boot behavior

CM-X300 firmware structure

CM-X300 firmware consists of three main parts:

In the default CM-X300 firmware image, all three binaries are built, assembled and tested at CompuLab. Latest versions of ready to run CM-X300 firmware images are available at Developer Resources for CM-X300 & SB-X300 web page.

Marvell Non Trusted Image Module (NTIM)

NTIM is a packed structure (table), which describes the images involved in the PXA3XX boot process. NTIM must be created each time cm-x300-firmware is built.
In order to build the NTIM binary image it is necessary to have the OBM and U-Boot binaries and a Key file with NTIM description. Building of the NTIM binary image is done by the ntbb (non-trusted boot builder) utility.
The default command line for ntbb utility is:

$ ./ntbb -v -m 1 -r <Key file name>

Both ntbb utility and Key file can be obtained from CompuLab.

Marvell Non Trusted OEM Boot Module (OBM)

OBM is the first boot loader software that runs on the PXA3XX cpu after power on and the internal PXA3XX Boot ROM initializations. It performs low level hardware initialization and copies U-Boot from NAND flash to CM-X300 RAM.
OBM is a proprietary software and can be distributed in binary form only.

U-Boot for CM-X300 module

U-Boot for CM-X300 is the last part of the CM-X300 firmware and it is the only part of CM-X300 firmware that could be altered by a user. Upon its start, U-Boot assumes that it is already in the system's RAM and does not relocate itself. U-Boot initializes CM-X300 peripheral devices, such as PMIC, serial port, network and USB.
U-Boot source code used for building CM-X300 firmware can be obtained from CompuLab on request.

CM-X300 firmware assembly

All three binary images described above are assembled into one file (cm-x300-firmware), to avoid errors during firmware update process. The following command sequence is used:

  • Prepare the NTIM table:
$ ./ntbb -v -m 1 -r CM-X300L-image.txt
  • Create empty cm-x300-firmware file and fill it with 0xff:
$ cat > ff.pl <<EOF
> open(OUT, ">", "cm-x300-firmware");
> \$data = 0xff;
> binmode(OUT);
> for (\$i = 0; \$i < 0x80000; \$i++) {
>         print OUT pack('c', \$data);
> }
> EOF
$ perl ff.pl
  • Copy all the binary images with offsets defined in CM-X300L-image.txt:
$ dd if=NTIM_X300L.bin of=cm-x300-firmware conv=notrunc
$ dd if=MHL_wince_NTOBM.bin of=cm-x300-firmware conv=notrunc bs=128k seek=1
$ dd if=u-boot.bin of=cm-x300-firmware conv=notrunc bs=128k seek=2

After completion of the above process cm-x300-firmware file contains ready CM-X300 firmware image, that can be flashed into NAND as described in Firmware Update article.
The above sequence is available in a sample script.

Testing U-Boot customizations

During normal operation U-Boot is stored in the CM-X300 NAND flash as a part of the CM-X300 firmware. U-Boot development and testing requires frequent updates of the U-Boot bootloader and therefore of the entire CM-X300 firmware. This approach has two significant drawbacks:

  • Multiple erases significantly shorten lifetime of vital blocks in the CM-X300 NAND flash.
  • Buggy U-Boot build or badly formed firmware can result in disabled CM-X300 module.

Recommended testing solution

The recommended way to test U-Boot customizations is to load U-Boot into CM-X300 RAM and test it thoroughly before overwriting the working version.
Use the following steps:

  • In the file /path/to/u-boot/board/cmx300/config.mk change the value of TEXT_BASE variable to 0x80200000. This is the new memory location of your U-Boot under test.
  • Compile U-Boot and put the u-boot.bin file to TFTP root directory or USB thumb drive.
  • Power up CM-X300 and wait until the working U-Boot version has started.
  • For network tftp download:
> setenv ipaddr <ip address for CM-X300>
> setenv serverip <TFTP server ip address>
> tftp 0x80200000 u-boot.bin
  • Or for USB thumb drive:
> usb start
> fatload usb 0 0x80200000 u-boot.bin
  • Start the test U-Boot version:
> go 0x80200000
  • If U-Boot has started normally, continue with the testing, else fix the problem and start over.
Admolition warning.png After finishing all the tests, and before assembling the CM-X300 firmware, switch back the TEXT_BASE value to its default: 0x83900000, otherwise firmware update will result in disabled CM-X300 module.

Known issues

Cross-Compiler issues

U-Boot compilation process is very sensitive and highly dependent on cross-compiler. It is possible that certain cross-compilers fail to generate bootable code out of U-Boot sources.
CompuLab recommended cross-compiler and build tool chain is Sourcery G++ Lite 2008q1-126 for ARM GNU/Linux.

See Also