Difference between revisions of "CM-X300: U-Boot: Firmware Development"

From Compulab Mediawiki
Jump to: navigation, search
m (Reverted edits by Bettytaylor23 (Talk); changed back to last version by Grinberg)
(U-Boot for CM-X300 module)
 
(One intermediate revision by the same user not shown)
Line 13: Line 13:
 
* [[CM-X300: U-Boot: Firmware Development#U-Boot_for_CM-X300_module|U-Boot for CM-X300 module]]
 
* [[CM-X300: U-Boot: Firmware Development#U-Boot_for_CM-X300_module|U-Boot for CM-X300 module]]
 
In the default CM-X300 firmware image, all three binaries are built, assembled and tested at CompuLab.
 
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 [http://www.compulab.co.il/x300/html/x300-developer.py Developer Resources for CM-X300 & SB-X300] web page.
+
Latest versions of ready to run CM-X300 firmware images are available at [http://compulab.co.il/products/computer-on-modules/cm-x300/#devres Developer Resources for CM-X300 & SB-X300] web page.
  
 
=== Marvell Non Trusted Image Module (NTIM) ===
 
=== Marvell Non Trusted Image Module (NTIM) ===
 
NTIM is a packed structure (table), which describes the images involved in the PXA3XX boot process.
 
NTIM is a packed structure (table), which describes the images involved in the PXA3XX boot process.
 
NTIM must be created each time {{filename|cm-x300-firmware}} is built.<br>
 
NTIM must be created each time {{filename|cm-x300-firmware}} is built.<br>
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.
+
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 {{cmd|ntbb}} (non-trusted boot builder) utility.<br>
 
Building of the NTIM binary image is done by the {{cmd|ntbb}} (non-trusted boot builder) utility.<br>
 
The default command line for {{cmd|ntbb}} utility is:
 
The default command line for {{cmd|ntbb}} utility is:
Line 34: Line 34:
 
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.
 
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.<br>
 
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.<br>
U-Boot source code used for building CM-X300 firmware can be obtained from CompuLab on request.
 
  
 
== CM-X300 firmware assembly ==
 
== CM-X300 firmware assembly ==
Line 64: Line 63:
 
</pre>
 
</pre>
  
After completion of the above process {{filename|cm-x300-firmware}} file contains ready CM-X300 firmware image, that can be flashed into NAND as described in [[CM-X300: U-Boot: Firmware Update|Firmware Update]] article.<br>
+
After completion of the above process the {{filename|cm-x300-firmware}} file will contain a ready to use CM-X300 firmware image, which can be flashed into NAND as described in [[CM-X300: U-Boot: Firmware Update|Firmware Update]] article.<br>
 
The above sequence is available in a sample [[media:build-firmware-sample.sh|script]].
 
The above sequence is available in a sample [[media:build-firmware-sample.sh|script]].
  
Line 77: Line 76:
 
Use the following steps:
 
Use the following steps:
 
* In the file {{filename|/path/to/u-boot/board/cmx300/config.mk}} change the value of {{parameter|TEXT_BASE}} variable to {{parameter|0x80200000}}. This is the new memory location of your U-Boot under test.
 
* In the file {{filename|/path/to/u-boot/board/cmx300/config.mk}} change the value of {{parameter|TEXT_BASE}} variable to {{parameter|0x80200000}}. This is the new memory location of your U-Boot under test.
* Compile U-Boot and put the {{filename|u-boot.bin}} file to TFTP root directory or USB thumb drive.
+
* Compile U-Boot and put the {{filename|u-boot.bin}} file to TFTP root directory, MMC/SD card or USB thumb drive.
 
* Power up CM-X300 and wait until the working U-Boot version has started.
 
* Power up CM-X300 and wait until the working U-Boot version has started.
 
* For network {{cmd|tftp}} download:
 
* For network {{cmd|tftp}} download:
Line 84: Line 83:
 
> setenv serverip <TFTP server ip address>
 
> setenv serverip <TFTP server ip address>
 
> tftp 0x80200000 u-boot.bin
 
> tftp 0x80200000 u-boot.bin
 +
</pre>
 +
* For MMC/SD card:
 +
<pre>
 +
> mmc init
 +
> fatload mmc 1 0x80200000 u-boot.bin
 
</pre>
 
</pre>
 
* Or for USB thumb drive:
 
* Or for USB thumb drive:

Latest revision as of 10:12, 4 April 2013

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.

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 the cm-x300-firmware file will contain a ready to use CM-X300 firmware image, which 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, MMC/SD card 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
  • For MMC/SD card:
> mmc init
> fatload mmc 1 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