Difference between revisions of "BootLoader"

From ArmadeusWiki
Jump to: navigation, search
(Customize the flash memory organization)
(Customizing)
 
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
  
This page describe the U-Boot installation/usage in the Armadeus context.
+
This page describe the U-Boot usage/installation in the Armadeus context.
  
==Build U-Boot==
+
==Some (informational) commands==
Build process is now part of the Armadeus package.
+
<pre class="apf">
The process is automated in the global build process (see Install Armadeus software).
+
BIOS> printenv
Compiled binaries files are in the buildroot subdirectory.
+
</pre>
  
* '''u-boot.bin''' is a binary image file and can be downloaded with the u-boot loadb command (or tftpboot, nfs,...)
+
<pre class="apf">
* '''u-boot-brec''' is a boostrap record file compatible with the freescale bootloader. Use the kermit transmit command.
+
BIOS> bdinfo
 +
arch_number = 0x000006A2
 +
env_t      = 0x00000000
 +
boot_params = 0xA0000100
 +
DRAM bank  = 0x00000000
 +
-> start    = 0xA0000000
 +
-> size    = 0x04000000
 +
DRAM bank  = 0x00000001
 +
-> start    = 0xB0000000
 +
-> size    = 0x04000000
 +
ethaddr    = 00:1E:AC:00:10:54
 +
ip_addr    = 192.168.1.10
 +
baudrate    = 115200 bps
 +
</pre>
  
The following information is only usefull for a manual build process.
+
<pre class="apf">
 +
BIOS> nand info
  
* Download Das U-Boot source code archive from: http://sourceforge.net/project/showfiles.php?group_id=65938
+
Device 0: NAND 256MiB 1,8V 16-bit, sector size 128 KiB
* Uncompress it:
+
</pre>
    tar jxvf u-boot-1.1.3.tar.bz2
+
* Download Armadeus patches corresponding to your u-boot & gcc version from: http://fr.groups.yahoo.com/group/armadeus/files/Patches/ and copy it to the u-boot directory.
+
* Go inside the u-boot directory and apply the patches (here for u-boot1.1.3):
+
    patch -p1 < u-boot1.1.3-apm9328-2.1.patch
+
    patch -p1 < u-boot1.1-gcc3.4.patch (if necessary)
+
  
If you have a 8 or 16MB apm9328 board, edit the include/configs/apm9328.h.
+
==Modify your environment variables==
look for a #define SDRAM_xxxMBIT
+
* There is a set of variables you can customize to your needs. The command '''printenv''' show you most of them and their current state. Use the command '''setenv''' to change one of these variable. For instance:
change it to a:
+
<pre class="apf">
 +
BIOS> setenv ipaddr 192.168.0.10
 +
</pre>
 +
* Use the command '''saveenv''' to save the state of your environment variables in flash memory.
 +
* In order to use network features with U-Boot you have to set the network environment variables:
 +
<pre class="apf">
 +
setenv netmask 255.255.255.0                (default value should be fine in most situations)
 +
setenv ipaddr 192.168.0.10
 +
setenv serverip 192.168.0.2                (the IP address of your TFTP Host server to download image files)
 +
setenv rootpath "/tftpboot/apfXX-root"    (to boot Linux over NFS)
 +
setenv consoledev ttymxc0
 +
</pre>
 +
* You can use the '''dhcp''' command to configure these variable from your DHCP server. Probably you will have to adjust the '''serverip''' variable manually.
 +
<pre class="apf">
 +
BIOS> dhcp
 +
dm9000 i/o: 0x15c00000, id: 0x90000a46
 +
MAC: 00:0e:32:00:00:01
 +
operating at 100M full duplex mode
 +
BOOTP broadcast 1
 +
DHCP client bound to address 192.168.0.10
 +
BIOS>setenv serverip 192.168.0.2
 +
BIOS>saveenv
 +
</pre>
 +
* Do not forget to save your changes in flash with '''saveenv''' to have them available at power up !
  
    * #define SDRAM_64MBIT /* for 8MB */
+
==Build U-Boot==
    * #define SDRAM_128MBIT /* for 16MB */
+
Build process is now part of the Armadeus automated build (see [[Toolchain | Install Armadeus software]]). To only build U-Boot you can launch:
    * #define SDRAM_256MBIT /* for 32MB */
+
<pre class="host">
 +
$ make uboot-rebuild
 +
</pre>
  
Then build u-boot:
+
===Binaries===
    make apm9328_config
+
Compiled binary files will be put in the ''buildroot/output/images/'' subdirectory:
    make
+
* '''apf9328-u-boot.bin''' is a binary image file for the apf9328that can be downloaded and flashed from U-Boot itself (see below)
 +
* (Armadeus 5.0) image filenames are respectively for each board '''apf27-u-boot-nand.bin''' '''apf51-u-boot-nand.bin''' '''apf28-u-boot.sb'''
  
this produce u-boot.bin and u-boot.brec files described hereabove.
+
===Customizing===
 +
* U-Boot build is done by the following Makefiles:
 +
** ''buildroot/target/u-boot/Makefile.in''                  (generic part)
 +
** ''buildroot/target/device/armadeus/u-boot/u-boot.mk''    (target specific part)
  
==Install or restore from scratch==
+
* Configuration file (target specific) used to customize the build is:
 +
** ''buildroot/target/device/armadeus/apfxx/apfxx-u-boot-<version>.h''
  
If your Armadeus board doesn't boot anymore (flash content erased or dammaged), you will have to use the bootstrap mode of the i.MX. <br>
+
==== Autoboot keyed ====
The uboot_recover python script is used to flash an uboot version.<br>
+
This tool is located in the armadeus/software/uboot_recover folder of the armadeus project tree.<br>
+
Take a look a the INSTALL file the first time you want to use the recover tool.<br>
+
Remark: the serial port must support a baud rate of 57600 bps per second.<br>
+
  
==Modify your environment variables==
+
To stop autoboot with special keys or special word, add following lines in the apfxx-u-boot-<version>.h file :
 +
* after :
 +
<source lang="C">
 +
#define CONFIG_BOOTDELAY        2
 +
#define CONFIG_ZERO_BOOTDELAY_CHECK
 +
</source>
 +
* add :
 +
<source lang="C">
 +
#define CONFIG_AUTOBOOT_KEYED
 +
#define CONFIG_AUTOBOOT_PROMPT          "autoboot in %d seconds\n",bootdelay
 +
#define CONFIG_AUTOBOOT_STOP_STR        "v"
 +
</source>
  
There is a set of variables you can customize to your needs.
+
The autoboot delay will be stopped if «password» given by CONFIG_AUTOBOOT_STOP_STR be entered.
The commande '''printenv''' show you most of them and their current state.
+
Use the command '''setenv''' to change one of these variable.
+
For instance:
+
setenv ipaddr 192.168.0.3
+
Use the command '''saveenv''' to save the state of your environment variables in flash memory.
+
  
In order to use network features with u-boot you have to set the network environment variables:
+
==Install or restore from scratch (board bricked)==
setenv netmask 255.255.255.0 (default value should be fine in most situations)
+
setenv ipaddr 192.168.0.3
+
setenv serverip 192.168.0.5 (the IP adresse of your tftp host server to download update files )
+
setenv rootpath "/tftpboot/root" (to boot linux over nfs)
+
  
You can use the '''dhcp''' command to configure these variable from your dhcp server. Probably you will have to adjust the '''serverip''' variable manually.
+
If your Armadeus board doesn't boot anymore (flash content erased or dammaged), you will have to use the [[BootStrap | bootstrap mode]] of the i.MX. <br>
 
+
In that case the ''uboot_recover'' python script is used to flash a new U-Boot version; this tool is located in the ''armadeus/software/uboot_recover/'' folder of the Armadeus project tree.<br>
BIOS> dhcp
+
Take a look a the ''INSTALL'' file the first time you want to use the recover tool.<br>
dm9000 i/o: 0x15c00000, id: 0x90000a46
+
Remark: the serial port must support a baud rate of 57600 bps per second.
MAC: 00:0e:32:00:00:01
+
operating at 100M full duplex mode
+
BOOTP broadcast 1
+
DHCP client bound to address 192.168.0.3
+
BIOS>setenv serverip 192.168.0.5
+
BIOS>saveenv
+
 
+
Do not forget to save your changes in flash with '''saveenv''' to have them available at power up.
+
  
 
==Update U-Boot==
 
==Update U-Boot==
  
There are two steps to update u-boot:
+
There are 2 steps to update U-Boot:
*1] Load the new u-boot code in RAM
+
*1] Load the new U-Boot code in RAM (You can use the following commands to download U-boot):
You can use the following commands to download U-boot.
+
**With ethernet and a [[Connection_with_U-Boot_on_Linux#TFTP_server |TFTP server]]: <pre class="apf">BIOS>run download_uboot</pre>
With ethernet and a tftpboot server:
+
**With ethernet and a [[Network_Configuration | NFS server]]: <pre class="apf">BIOS> nfs ${loadaddr} ${serverip}:/tftpboot/apfxx-u-boot.bin</pre>
    tftpboot 08000000 /tftpboot_path_to_buildroot/u-boot.bin
+
**With the kermit and a serial line:
With ethernet and a nfs server:
+
<pre class="apf">
    nfs 08000000 host_ip_addr:/nfs_path_to_buildroot/u-boot.bin
+
BIOS> loadb ${loadaddr}
With the kermit and a serial line
+
     <CTRL> <ALT GR> \ then c
    loadb
+
     send /path_to_tftpboot/apfxx-u-boot.bin
     <CTRL><ALT GR>\
+
    ...>>> LOADING IN PROGRESS <<<...
    c
+
     send path_to_buildroot/u_boot.bin
+
 
     c
 
     c
 +
</pre>
  
*2] Transfer code from RAM to Flash memory
+
*2] Transfer code from RAM to FLASH memory (there is a simple U-Boot command/script to do that):
There is a simple u-boot command/script to do that:
+
<pre class="apf">
    run flash_uboot
+
BIOS> run flash_uboot
 +
</pre>
  
==Advanced Linux Boot==
+
==Advanced Linux boot==
  
The command "boot" is the common way to run linux from flash memory.
+
The command "boot" is the common way to run Linux from flash memory.
 
This command is equivalent to the macro:
 
This command is equivalent to the macro:
    run jffsboot
+
- on the APF9328 board
This is the default command stored the u-boot variable: bootcmd.
+
<pre class="apf">
    bootcmd=run jffsboot
+
BIOS> run jffsboot
U-boot also supports the commands to boot from a network or a sd/mmc card.
+
</pre>
 +
- on the other APF board
 +
<pre class="apf">
 +
BIOS> run ubifsboot
 +
</pre>
  
* nfs boot
+
This is the default command stored in the U-Boot variable: ''bootcmd''.
    run nfsboot
+
<pre class="apf">
This command boots linux rootfs from an nfs server. Change the u-boot variables serverip and rootpath to fit with your host pc.
+
BIOS> printenv bootcmd
 +
bootcmd=run jffsboot
 +
or
 +
bootcmd=run ubifsboot
 +
</pre>
 +
U-Boot also supports the commands to boot from the network or a SD/MMC card.
 +
 
 +
* NFS boot
 +
<pre class="apf">
 +
BIOS> run nfsboot
 +
</pre>
 +
This command boots Linux rootfs from a NFS server. Change the U-Boot variables ''serverip'' and ''rootpath'' to fit with your host PC.
 
     serverip=192.168.0.2
 
     serverip=192.168.0.2
     rootpath="/tftpboot/root"
+
     rootpath="/tftpboot/apfXX-root"
 +
 
 +
* MMC/SD boot
 +
Your SD should contain a rootfs and a kernel Linux in the /boot directory. see [[MultiMediaCard#Put_your_rootfs_and_Linux_kernel_on_the_MMC.2FSD| Put your rootfs and Linux kernel on the MMC/SD]] for more information.
 +
 
 +
<pre class="apf">
 +
BIOS> run mmcboot
 +
</pre>
  
* mmc boot
+
== Installing Target software from U-Boot ==
    run mmcboot
+
This command boots linux rootfs from an sd/mmc memory card. Adapt the variables: mmcroot and mmcrootfstype to your extension card boot partition.
+
    mmcroot=/dev/mmcblk0p1
+
    mmcrootfstype=ext2
+
  
==Customize the flash memory organization==
+
[[Target Software Installation]]
TBD
+
  
 
==Booting Linux==
 
==Booting Linux==
Line 139: Line 185:
 
==Links==
 
==Links==
 
* http://www.denx.de/wiki/DULG/Manual
 
* http://www.denx.de/wiki/DULG/Manual
 +
* http://git.denx.de/?p=u-boot.git;a=blob_plain;f=tools/scripts/dot.kermrc

Latest revision as of 15:30, 13 May 2015

Introduction

This page describe the U-Boot usage/installation in the Armadeus context.

Some (informational) commands

BIOS> printenv
BIOS> bdinfo
arch_number = 0x000006A2
env_t       = 0x00000000
boot_params = 0xA0000100
DRAM bank   = 0x00000000
-> start    = 0xA0000000
-> size     = 0x04000000
DRAM bank   = 0x00000001
-> start    = 0xB0000000
-> size     = 0x04000000
ethaddr     = 00:1E:AC:00:10:54
ip_addr     = 192.168.1.10
baudrate    = 115200 bps
BIOS> nand info

Device 0: NAND 256MiB 1,8V 16-bit, sector size 128 KiB

Modify your environment variables

  • There is a set of variables you can customize to your needs. The command printenv show you most of them and their current state. Use the command setenv to change one of these variable. For instance:
 BIOS> setenv ipaddr 192.168.0.10
  • Use the command saveenv to save the state of your environment variables in flash memory.
  • In order to use network features with U-Boot you have to set the network environment variables:
 setenv netmask 255.255.255.0                (default value should be fine in most situations)
 setenv ipaddr 192.168.0.10
 setenv serverip 192.168.0.2                 (the IP address of your TFTP Host server to download image files)
 setenv rootpath "/tftpboot/apfXX-root"    (to boot Linux over NFS)
 setenv consoledev ttymxc0
  • You can use the dhcp command to configure these variable from your DHCP server. Probably you will have to adjust the serverip variable manually.
 BIOS> dhcp
 dm9000 i/o: 0x15c00000, id: 0x90000a46
 MAC: 00:0e:32:00:00:01
 operating at 100M full duplex mode
 BOOTP broadcast 1
 DHCP client bound to address 192.168.0.10
 BIOS>setenv serverip 192.168.0.2
 BIOS>saveenv
  • Do not forget to save your changes in flash with saveenv to have them available at power up !

Build U-Boot

Build process is now part of the Armadeus automated build (see Install Armadeus software). To only build U-Boot you can launch:

 $ make uboot-rebuild

Binaries

Compiled binary files will be put in the buildroot/output/images/ subdirectory:

  • apf9328-u-boot.bin is a binary image file for the apf9328that can be downloaded and flashed from U-Boot itself (see below)
  • (Armadeus 5.0) image filenames are respectively for each board apf27-u-boot-nand.bin apf51-u-boot-nand.bin apf28-u-boot.sb

Customizing

  • U-Boot build is done by the following Makefiles:
    • buildroot/target/u-boot/Makefile.in (generic part)
    • buildroot/target/device/armadeus/u-boot/u-boot.mk (target specific part)
  • Configuration file (target specific) used to customize the build is:
    • buildroot/target/device/armadeus/apfxx/apfxx-u-boot-<version>.h

Autoboot keyed

To stop autoboot with special keys or special word, add following lines in the apfxx-u-boot-<version>.h file :

  • after :
#define CONFIG_BOOTDELAY        2
#define CONFIG_ZERO_BOOTDELAY_CHECK
  • add :
#define CONFIG_AUTOBOOT_KEYED
#define CONFIG_AUTOBOOT_PROMPT          "autoboot in %d seconds\n",bootdelay
#define CONFIG_AUTOBOOT_STOP_STR        "v"

The autoboot delay will be stopped if «password» given by CONFIG_AUTOBOOT_STOP_STR be entered.

Install or restore from scratch (board bricked)

If your Armadeus board doesn't boot anymore (flash content erased or dammaged), you will have to use the bootstrap mode of the i.MX.
In that case the uboot_recover python script is used to flash a new U-Boot version; this tool is located in the armadeus/software/uboot_recover/ folder of the Armadeus project tree.
Take a look a the INSTALL file the first time you want to use the recover tool.
Remark: the serial port must support a baud rate of 57600 bps per second.

Update U-Boot

There are 2 steps to update U-Boot:

  • 1] Load the new U-Boot code in RAM (You can use the following commands to download U-boot):
    • With ethernet and a TFTP server:
      BIOS>run download_uboot
    • With ethernet and a NFS server:
      BIOS> nfs ${loadaddr} ${serverip}:/tftpboot/apfxx-u-boot.bin
    • With the kermit and a serial line:
BIOS> loadb ${loadaddr}
    <CTRL> <ALT GR> \ then c
    send /path_to_tftpboot/apfxx-u-boot.bin
    ...>>> LOADING IN PROGRESS <<<...
    c
  • 2] Transfer code from RAM to FLASH memory (there is a simple U-Boot command/script to do that):
 BIOS> run flash_uboot

Advanced Linux boot

The command "boot" is the common way to run Linux from flash memory. This command is equivalent to the macro: - on the APF9328 board

BIOS> run jffsboot

- on the other APF board

BIOS> run ubifsboot

This is the default command stored in the U-Boot variable: bootcmd.

BIOS> printenv bootcmd
bootcmd=run jffsboot
or
bootcmd=run ubifsboot 

U-Boot also supports the commands to boot from the network or a SD/MMC card.

  • NFS boot
BIOS> run nfsboot

This command boots Linux rootfs from a NFS server. Change the U-Boot variables serverip and rootpath to fit with your host PC.

   serverip=192.168.0.2
   rootpath="/tftpboot/apfXX-root"
  • MMC/SD boot

Your SD should contain a rootfs and a kernel Linux in the /boot directory. see Put your rootfs and Linux kernel on the MMC/SD for more information.

BIOS> run mmcboot

Installing Target software from U-Boot

Target Software Installation

Booting Linux

The Install Armadeus software on target provide some information to install linux on Armadeus board

Customize Linux boot mode

Typical Kermit (.kermrc) config file

set line /dev/ttyS0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5
set transmit linefeed on

Links