Difference between revisions of "Target Software Installation"

From ArmadeusWiki
Jump to: navigation, search
m (Linux RootFS installation)
(Update U-Boot, kernel and rootfs images all at once)
 
(152 intermediate revisions by 15 users not shown)
Line 1: Line 1:
===Flash memory partitions (APF9328)===
+
On this page you will learn how to update (from U-Boot) the Flash's partitions of your APF module storing the Linux, rootfs and U-Boot software images.
{| border="1" cellpadding="5" cellspacing="0" summary="Signal connections"
+
|- style="background:#efefef;"
+
! width="66%" | Address range (index from FLASH physical @ 0x10000000) !! Type
+
|- align="center"
+
|0x000000 - 0x03FFFF ( 256KB )
+
| U-Boot
+
|- align="center"
+
|0x040000 - 0x5FFFF ( 128KB )
+
| U-Boot environment variables
+
|- align="center"
+
|0x060000 - 0x9FFFF ( 256KB )
+
| FPGA bitfile
+
|- align="center"
+
|0x0A0000 - 0x21FFFF ( 1.5MB )
+
| Linux kernel image
+
|- align="center"
+
|0x220000 - End of FLASH ( ~6 MB or ~14MB  )
+
| Root filesystem
+
|}
+
  
 
==Configure U-Boot==
 
==Configure U-Boot==
Line 25: Line 6:
 
U-Boot can be customized in a flexible way with the use of "environment variables/scripts".
 
U-Boot can be customized in a flexible way with the use of "environment variables/scripts".
 
The command '''printenv''' shows you most of them and their current value:
 
The command '''printenv''' shows you most of them and their current value:
 +
<pre class="apf">
 
  BIOS> printenv
 
  BIOS> printenv
 
  bootcmd=run jffsboot
 
  bootcmd=run jffsboot
 
  bootdelay=20
 
  bootdelay=20
 
  baudrate=115200
 
  baudrate=115200
  ethaddr=00:0E:32:00:00:01
+
  ethaddr=
 
  autoload=no
 
  autoload=no
 
  ...
 
  ...
 
+
</pre>
Use the command '''setenv''' to change these variables. For example, to set the IP address:
+
The command '''setenv''' is used to change these variables. For example, to set the IP address (don't do it yet):
  BIOS> setenv ipaddr 192.168.0.3
+
<pre class="apf">
 
+
  BIOS> setenv ipaddr 192.168.0.10
Use the command '''saveenv''' to save the state of your environment variables in FLASH memory:
+
</pre>
 +
The command '''saveenv''' is used to save the state of your environment variables in FLASH memory; that way they will be available at next boot:
 +
<pre class="apf">
 
  BIOS> saveenv
 
  BIOS> saveenv
 
  Saving Environment to Flash...
 
  Saving Environment to Flash...
Line 47: Line 31:
 
  . done
 
  . done
 
  Protected 1 sectors
 
  Protected 1 sectors
 +
</pre>
  
 
===Network configuration===
 
===Network configuration===
In order to use the U-Boot's network features, you have to set the network environment variables:
+
{{Note| You have to install [[Communicate#TFTP_server_installation | tftpboot on your host development]] computer}}
BIOS> setenv netmask 255.255.255.0 (this default value should be fine in most situations)
+
BIOS> setenv ipaddr 192.168.0.3
+
BIOS> setenv serverip 192.168.0.5 (the IP address of your tftp server/PC hosting the files to download)
+
BIOS> setenv rootpath "/tftpboot/root" (to boot Linux over NFS)
+
  
 +
In order to use the U-Boot's network features, you have to set the network environment variables:
 +
<pre class="apf">
 +
BIOS> setenv netmask 255.255.255.0                (this default value should be fine in most situations)
 +
BIOS> setenv ipaddr 192.168.0.10
 +
BIOS> setenv serverip 192.168.0.2                (the IP address of your tftp server/PC hosting the files to download)
 +
BIOS> setenv rootpath "/tftpboot/apf9328-root"    (to boot Linux over NFS)
 +
BIOS> setenv consoledev ttymxc0
 +
</pre>
 
You can use the '''dhcp''' command to configure these variables from your DHCP server. You probably will have to adjust the '''serverip''' variable manually.
 
You can use the '''dhcp''' command to configure these variables from your DHCP server. You probably will have to adjust the '''serverip''' variable manually.
 
+
If you use VirtualBox or VMware make sure you have selected Bridge Mode for the network adaptor, otherwise the U-Boot cannot talk to your host.
 +
<pre class="apf">
 
  BIOS> dhcp
 
  BIOS> dhcp
 
  dm9000 i/o: 0x15c00000, id: 0x90000a46
 
  dm9000 i/o: 0x15c00000, id: 0x90000a46
Line 62: Line 52:
 
  operating at 100M full duplex mode
 
  operating at 100M full duplex mode
 
  BOOTP broadcast 1
 
  BOOTP broadcast 1
  DHCP client bound to address 192.168.0.3
+
  DHCP client bound to address 192.168.0.10
  BIOS> setenv serverip 192.168.0.5
+
  BIOS> setenv serverip 192.168.0.2
 
  BIOS> saveenv
 
  BIOS> saveenv
 
+
</pre>
 
Do not forget to save your changes in FLASH, to have them available at next power up:
 
Do not forget to save your changes in FLASH, to have them available at next power up:
 +
<pre class="apf">
 
  BIOS> saveenv
 
  BIOS> saveenv
 +
</pre>
 
In case of troubles you can use the following U-Boot script to reset the variables to the "factory"/default settings:
 
In case of troubles you can use the following U-Boot script to reset the variables to the "factory"/default settings:
 +
<pre class="apf">
 
  BIOS> run flash_reset_env
 
  BIOS> run flash_reset_env
 +
</pre>
 +
or
 +
<pre class="apf">
 +
BIOS> env default -f -a; saveenv
 +
</pre>
  
===Linux kernel building and installation===
+
==Linux kernel installation==
  
* configure your Linux kernel:
+
* Check that your Armadeus kernel image size is smaller than the U-Boot partition (see [[#Flash_memory_partitions|Flash Memory Partitions]] for size allowances):
[armadeus]$ make linux-menuconfig
+
<pre class="host">
 
+
  [armadeus]$ ls -al buildroot/output/images/
* save your configuration and then rebuild your kernel image:
+
</pre>
[armadeus]$ make
+
* If yes, copy it to your TFTP server directory (here ''/tftpboot/''):
 
+
<pre class="host">
* check that your Armadeus kernel image size is smaller than the U-Boot partition (1,5MB):
+
  [armadeus]$ cp buildroot/output/images/* /tftpboot/
  [armadeus]$ ls -al buildroot/binaries/armadeus/
+
</pre>
...
+
===Linux kernel update script===
  [armadeus]$ cp buildroot/binaries/armadeus/linux-kernel-2.6.xx-arm.bin /tftpboot/
+
* This is the recommended method and the easiest one. The automatic 'update_kernel' scripts downloads the image and flash it in the same go:
 +
<pre class="apf">
 +
BIOS> run update_kernel
 +
</pre>
 +
* To know what ''update_kernel'' script is doing you can display its content:
 +
<pre class="apf">
 +
BIOS> printenv update_kernel
 +
</pre>
 +
{{Warning|If the loaded kernel image is too large, the following operation can destroy data that are stored after the partition limits (e.g. RootFS) - Check that transferred size value is less than the ones specified here [[#Flash_memory_partitions|Flash Memory Partitions]]
 +
}}
  
 +
===Other Linux kernel update method===
 
* Load kernel image with U-Boot through network:
 
* Load kernel image with U-Boot through network:
    BIOS> tftpboot 08000000 pathtoyourhostedbuildrootdir/linux-kernel-2.6.xx-arm.bin
+
<pre class="apf">
 +
BIOS> run download_kernel
 +
</pre>
 
or with the serial line:
 
or with the serial line:
    BIOS> loadb 08000000
+
<pre class="apf">
    Ctrl+Altgr+\+c to access kermit command line then...
+
BIOS> loadb ${loadaddr}
    send pathtoyourhostedbuildrootdir/linux-kernel-2.6.xx-arm.bin
+
    ''Ctrl+Altgr+\+c to access kermit command line then:''
    the you can type the c command to reconnect to the terminal
+
(/home/.../) C-Kermit>send /tftpboot/XX-linux.bin
 +
    ''After download is completed, you can type the c command to reconnect to the terminal:''
 +
(/home/.../) C-Kermit>c
 +
Connecting to /dev/ttyUSB0, speed 115200
 +
  Escape character: Ctrl-\ (ASCII 28, FS): enabled
 +
Type the escape character followed by C to get back,
 +
or followed by ? to see other options.
 +
----------------------------------------------------
 +
## Total Size      = 0x<size of XX-linux.bin> = .... Bytes
 +
## Start Addr      = 0x08000000
 +
BIOS> setenv filesize <size of XX-linux.bin>
 +
</pre>
 +
 
 
----
 
----
<span style="color:red">
+
Check that transferred size value is less than the ones specified here [[#Flash_memory_partitions|Flash Memory Partitions]]
'''!!! WARNING !! If the loaded kernel image is too large, the following operation can destroy data that are stored after the partition limits (e.g. RootFS) !!!'''
+
<pre class="apf">
</span><br>
+
  Bytes transferred = 1313216 (1409c0 hex)
Check that transfered size value is less than 1572864 (0x180000 hex)
+
</pre>
  Bytes transferred = 1313216 (1409c0 hex)  
+
 
----
 
----
  
* You can test your new kernel image without flashing it with:
+
* You can test your new kernel image without flashing it with; if so you will have to reload it again after test:
    BIOS> bootm 08000000
+
** '''Please note''': The ''bootm'' command is not supported by [[APF51]] boards yet; directly flash the kernel with the below commands instead
 +
<pre class="apf">
 +
BIOS> bootm
 +
</pre>
 +
* a U-Boot script exists to ease kernel image loading through Ethernet:
 +
<pre class="apf">
 +
BIOS> run download_kernel
 +
</pre>
 +
* After kernel image has been downloaded into RAM memory, you can flash it with:
 +
<pre class="apf">
 +
BIOS> run flash_kernel
 +
</pre>
 +
* If you only want to try a new kernel without flashing the kernel image you can launch it directly from RAM (U-Boot 2011.12):
 +
<pre class="apf">
 +
BIOS> setenv bootargs console=${consoledev},${baudrate} ${mtdparts};run addubifsargs addipargs; bootm
 +
(the kernel image you want to try must have been loaded at ${loadaddr})
 +
</pre>
 +
* '''Please note''': The ''bootm'' command is not supported by [[APF51]] boards yet; directly flash the kernel with the below commands
  
----
+
==rootfs installation==
  
* Flash kernel image with:
+
* Check that your Armadeus rootfs image size is smaller than the rootfs partition (see [[#Flash_memory_partitions|Flash Memory Partitions]] for size allowances):
    BIOS> run flash_kernel
+
<pre class="host">
 +
$ ls -al buildroot/output/images/
 +
...
 +
$ cp buildroot/output/images/* /tftpboot/
 +
</pre>
 +
* Load rootfs image with U-Boot through network:
 +
<pre class="apf">
 +
BIOS> run update_rootfs
 +
</pre>
  
* To make it easier next time, you can write a small U-Boot script:
+
* or serial line:
BIOS> setenv kernel_img linux-kernel-2.6.23.1-arm.bin
+
<pre class="apf">
BIOS> setenv update_kernel_tftp if tftp 08000000 \${kernel_img}\; then run flash_kernel\; fi
+
BIOS> loadb ${loadaddr}
* So next time you will only launch:
+
    ''Ctrl+Altgr+\+c to access kermit command line then...''
BIOS> run update_kernel_tftp
+
(/home/.../) C-Kermit>send path_to_your_host_buildroot_dir/XX-rootfs.ubi
 +
    ''After download is completed, you can type the c command to reconnect to the terminal:''
 +
(/home/.../) C-Kermit>c
 +
Connecting to /dev/ttyUSB0, speed 115200
 +
Escape character: Ctrl-\ (ASCII 28, FS): enabled
 +
Type the escape character followed by C to get back,
 +
or followed by ? to see other options.
 +
----------------------------------------------------
 +
## Total Size      = 0x<size of rootfs>
 +
## Start Addr      = 0x........
 +
BIOS> setenv filesize <size of rootfs>
 +
BIOS> run flash_rootfs
 +
</pre>
  
* If you only want to try a new kernel without flashing the kernel image you can launch it directly from RAM:
+
* Now you should be ready to test Linux:
  BIOS> setenv bootargs ${console} ${mtdparts}; run addjffsargs addipargs; bootm
+
<pre class="apf">
(the kernel image you want to try must have been loaded at 0x08000000)
+
BIOS> boot
 +
</pre>
 +
 
 +
* For large rootfs (bigger than the available RAM on your system) please use the method which suit your board:
 +
** [[APF9328]]: none :-(
 +
** [[APF27]]/[[APF28]]/[[APF51]]:
 +
<pre class="apf">
 +
BIOS> nand erase.part rootfs
 +
  BIOS> tftpboot ${rootfs_addr} ${board_name}-rootfs.ubi nand
 +
</pre>
 +
** [[APF6]]: [[U-Boot UMS on APF6|U-Boot UMS]]
 +
 
 +
==FPGA firmware test==
 +
 
 +
* The FPGA firmwares are all located in the ''firmware/'' directory of your Armadeus BSP sources:
 +
<pre class="host">
 +
$ ls firmware/
 +
apf_pkg  BRAMTest  bus_led  led  PS2  PS2_Opencore  servo  sram_test  wishbone_example  Xtools
 +
</pre>
 +
* You can make some trials with the ''firmware/leds/blinking_led/bin/'' files.
 +
<br>
 +
 
 +
{{Warning| for the APF9328, please check that your bitfile size is smaller than the firmware partition size (256KB) before trying the following commands or you may corrupt your Linux kernel FLASH partition !!!}}
 +
 
 +
{{Note | For the APF51 and U-Boot versions earlier than 2013.04, only binary file format ('''.bin''') can be used; do not try '''.bit''' file. <br> For the APF51 and U-Boot versions 2013.04 or later you can also use .bit files with the U-Boot command: <pre class="apf"> BIOS> fpga loadb </pre>}}
 +
 
 +
* Load FPGA firmware image file with U-Boot through:<br>
 +
Ethernet:
 +
<pre class="apf">
 +
BIOS> tftpboot ${loadaddr} fpgafirmware.bin
 +
</pre>
 +
''fpgafirmware.bin'' is of course the name of your bitfile stored in your TFTP shared directory (''/tftpboot/'')
  
===Linux RootFS installation===
 
* Load RootFS image with U-Boot through network:
 
    BIOS> tftp 08000000 pathtoyourhostedbuildrootdir/rootfs.arm.jffs2
 
or serial line:
 
    BIOS> loadb 08000000
 
    Ctrl+Altgr+\+c to access kermit command line then...
 
    send pathtoyourhostedbuildrootdir/rootfs.arm.jffs2
 
 
then you can type the c command to reconnect to the terminal
 
then you can type the c command to reconnect to the terminal
  
* Flash RootFS image with:
+
* Test your new FPGA firmware's downloading:
    BIOS> run flash_rootfs
+
** for .bin binary files  <pre class="apf">BIOS> fpga load 0 ${loadaddr} ${filesize}</pre>
 +
** for .bit binary files <pre class="apf">BIOS> fpga loadb 0 ${loadaddr} ${filesize}</pre>
 +
* For your convenience a set of U-Boot script to facilitate firmware management with the APF boards:
 +
** ''download_firmware'': assuming your firmware is in /tftpboot and name apfXX-firmware.bin (where apfXX is the name of your board apf27, apf51, apf9328..) will download the firmware in RAM with the command: run download_firmware
 +
** ''flash_firmware'': save the previously downloaded firmware from RAM into the flash.
 +
** ''update_firmware'': will execute the previous 2 scripts in sequence.
 +
** ''load_firmware'': read a firmware from the flash (there is dedication partition named firmware for this purpose) and load it into the FPGA.
  
* Now you should be ready to test Linux:
+
==FPGA firmware installation==
    BIOS> boot
+
=== APF9328, APF27 and APF51 ===
 +
* instal/copy your firmware to /tftpboot
 +
** manually: <pre class="host"> $ cp myfirmware.bin /tftpboot/apfXX-firmware.bin (where apfXX is the name of your board: apf27, apf51 or apf9328)</pre>
 +
** using the armadeus BSP:
 +
:<pre class="host"> $ make menuconfig</pre>
 +
:<pre class="config">Package Selection for the target  --->  Armadeus specific tools/utilities  ---></pre>
  
To make it easier next time, you can write a small U-Boot script:
+
:you can specify the path to the FPGA firmware:
  BIOS> setenv rootfs_img rootfs.arm.jffs2
+
<pre class="config">
  BIOS> setenv update_rootfs_tftp if tftp 08000000 \${rootfs_img}\; then run flash_rootfs\; fi
+
[*] FPGA Firmware
 +
      Firmware to install (Install a custom FPGA firmware) --->
 +
($(TOPDIR)/../firmware/leds/blinking_led/bin/blinking_led_apf27_200k.bit) FPGA binary file path
 +
[*]  Export this file to Buildroot images folder
 +
</pre>
 +
:<pre class="host"> $ cp buildroot/output/images/* /tftpboot </pre>
 +
* Download and test your firmware image with:
 +
<pre class="apf">
 +
BIOS> run download_firmware
 +
BIOS> run load_firmware
 +
</pre>
 +
* When you are satisfied with your firmware, you can write it in flash make it "autoloaded" at power up:
 +
{{Warning| '''Before''' setting the firmware_autoload variable, be sure that your FPGA binary file is correct. If not, your board will '''hang up''' at U-Boot start and you will need to cancel the fpga download to take control of the board. see note below}}
 +
<pre class="apf">
 +
  BIOS> run update_firmware
 +
  BIOS> setenv firmware_autoload 1
 
  BIOS> saveenv
 
  BIOS> saveenv
 +
</pre>
  
* So next time you will only launch:  
+
{{Note | (U-Boot 2012.04) you can manually cancel the firmware autoload using the following procedure: keeping <CTRL-C> pressed on the console and power up the board will start the board without downloading the FPGA firmware - This procedure can be helpfull if you have programmed a broken firmware  }}
BIOS> run update_rootfs_tftp
+
  
===FPGA firmware installation===
+
=== APF6_SP ===
  
The FPGA firmwares are all located in the ''firmware/'' directory of your Armadeus view:
+
Firmware installation was simplified in APF6_SP.
[armadeus]$ ls firmware/
+
BRAMTest  led  PS2  PS2_Opencore  sram_test
+
You can make some trials with the ''firmware/PS2/ps2_top.bit'' file.<br>
+
<br>
+
----
+
'''!!! Check that your bitfile size is smaller than the firmware partition size (256KB) before trying the following commands or you may corrupt your Linux kernel FLASH partition !!!'''
+
----
+
<br>
+
  
* Load FPGA firmware image file with U-Boot through:<br>
+
* To «autoload» your firmware while U-Boot is starting, simply add your bitstream to your rootfs, for example :
Ethernet:
+
<pre class="apf">
    BIOS> tftpboot 08000000 fpgafirmware.bit
+
/lib/firmware/fpga/firmware.periph.rbf
fpgafirmware.bit is of course the name of your bitfile stored in your TFTP shared directory (/tftpboot/)
+
</pre>
  
or serial line:
+
{{Note| By default, directory /lib/firmware/fpga doesn't exists, then simply create it with <pre class="apf"># mkdir /lib/firmware/fpga</pre>}}
    BIOS> loadb 08000000
+
    Ctrl+Altgr+\+c to access kermit command line then...
+
    C-Kermit> send path_to_your_tftp/fpgafirmware.bit
+
then you can type the c command to reconnect to the terminal
+
  
* Flash your firmware image with:
+
* Then reboot under U-Boot and configure your environment variables '''firmware_autoload''' and '''firmware_path''' :
    BIOS> run flash_firmware
+
<pre class="apf">
 +
BIOS> setenv firmware_path /lib/firmware/fpga/firmware.periph.rbf
 +
BIOS> setenv firmware_autoload 1
 +
</pre>
  
* Test your new FPGA firmware:
+
* Do not forget to save your environment variables:
    BIOS> fpga load 0 ${firmware_addr} ${firmware_len}
+
<pre class="apf">
 +
BIOS> saveenv
 +
</pre>
  
* When your are satisfied with your firmware you can make it "autoloaded" at power up:
+
* That's all, now your bitstream will be loaded with U-Boot at boot:
    BIOS> setenv firmware_autoload 1
+
<pre class="apf">
    BIOS> saveenv
+
U-Boot SPL 2014.07 (Apr 23 2015 - 16:16:45)
 +
 
 +
U-Boot 2014.07 (Apr 23 2015 - 16:16:45)
 +
 
 +
[...]
 +
 
 +
39688 bytes read in 260 ms (148.4 KiB/s)
 +
Hit any key to stop autoboot:  0
 +
</pre>
  
 
==Update U-Boot==
 
==Update U-Boot==
 +
* Check that your Armadeus U-Boot image size is smaller than the u-boot partition (see [[#Flash_memory_partitions|Flash Memory Partitions]] for size allowances) and copy all the binary images to your TFTP server directory:
 +
<pre class="host">
 +
[armadeus]$ ls -al buildroot/output/images/
 +
...
 +
[armadeus]$ cp buildroot/output/images/* /tftpboot/
 +
</pre>
  
There are two steps to update U-Boot:
+
===U-Boot update script===
*1] Load the new U-Boot code in RAM
+
* This is the recommended method and the easiest one. The automatic 'update_uboot' scripts downloads the image and flash it in the same go:
You can use the following commands to download U-boot:<br>
+
<pre class="apf">
With Ethernet and a TFTP server:
+
BIOS> run update_uboot
  BIOS> tftpboot 08000000 /tftpboot_path_to_buildroot/u-boot.bin
+
</pre>
With Ethernet and a NFS server:
+
 
  BIOS> nfs 08000000 host_ip_addr:/nfs_path_to_buildroot/u-boot.bin
+
* Reset your board and check if you need to update your environment variables:
With the kermit and a serial line
+
<pre class="apf">
  BIOS> loadb 08000000
+
BIOS> reset
 +
U-Boot 2011.12 ..
 +
...
 +
*** Warning - Environment version change suggests: run flash_reset_env; reset
 +
BIOS> run flash_reset_env; reset
 +
</pre>
 +
In such a case you may have to update your network environment variables (see [[#Configure_U-Boot|Configure U-Boot]])
 +
===Other U-Boot update method===
 +
You can use the following commands to download U-boot in RAM:<br>
 +
*With Ethernet and a TFTP server:
 +
<pre class="apf">
 +
  BIOS> run download_uboot
 +
</pre>
 +
*With Ethernet and a NFS server:
 +
<pre class="apf">
 +
  BIOS> nfs ${loadaddr} host_ip_addr:/nfs_path_to_buildroot/apfXX-u-boot{.bin|-nand.bin|.sb}
 +
</pre>
 +
*With kermit and the serial/RS232 line
 +
<pre class="apf">
 +
  BIOS> loadb ${loadaddr}
 
     <CTRL><ALT GR>\
 
     <CTRL><ALT GR>\
 
     c
 
     c
     send path_to_buildroot/u_boot.bin
+
     send path_to_buildroot/apfXX-u-boot{.bin|-nand.bin|.sb}
     c
+
     c<ENTER>
 +
Connecting to /dev/ttyUSB0, speed 115200
 +
  Escape character: Ctrl-\ (ASCII 28, FS): enabled
 +
Type the escape character followed by C to get back,
 +
or followed by ? to see other options.
 +
----------------------------------------------------
 +
## Total Size      = 0x<size of U-Boot> = .... Bytes
 +
## Start Addr      = 0x08000000
 +
BIOS> setenv filesize <size of U-Boot>
 +
</pre>
  
*2] Transfer code from RAM to Flash memory
+
Then you can use the U-Boot command/script 'flash_uboot' to tranfert the new U-Boot from RAM to Flash memory:
There is a simple U-Boot command/script to do that:
+
<pre class="apf">
    BIOS> run flash_uboot
+
BIOS> run flash_uboot
 +
</pre>
  
 
Advanced informations can be found at the [[BootLoader]] wiki page.
 
Advanced informations can be found at the [[BootLoader]] wiki page.
 +
 +
{{Note | '''APF51'''
 +
 +
When updating your board from a legacy version of Armadeus BSP you should set the `fdt_addr_r` environment var to boot correctly:
 +
<pre class="apf">
 +
BIOS> setenv fdt_addr_r 91000000
 +
</pre>
 +
 +
See [[How_to_use_vanilla_kernel_on_APF51]] for more informations.
 +
}}
 +
 +
 +
==Update U-Boot, kernel and rootfs images all at once==
 +
* Copy all the binary images to your TFTP server directory:
 +
<pre class="host">
 +
[armadeus]$ cp buildroot/output/images/* /tftpboot/
 +
</pre>
 +
 +
* The automatic 'update_all' scripts downloads each image and flash it in the same go:
 +
<pre class="apf">
 +
BIOS> run update_all
 +
</pre>
 +
 +
* Reset your board to check that wour board is correctly updated.
 +
 +
{{Note |When updating your board from a legacy version of Armadeus BSP you should update U-Boot first to update the environment variables before any other partition update ( see [[#Update_U-Boot|Update U-Boot]]) }}
 +
 +
==Flash memory partitions==
 +
* Old Flash partitionning (pre armadeus-5.0) is kept [[Talk:Target_Software_Installation|here]].
 +
 +
===APF9328 / U-Boot 2011.12 and newer release - Flash memory partitions===
 +
{| border="1" cellpadding="5" cellspacing="0" summary="APF9328 Flash memory partitions"
 +
|- style="background:#efefef;" align="center"
 +
! width="60%" |Address range (index from FLASH physical @ 0x10000000) !!Type
 +
|- align="center"
 +
|0x000000 - 0x03FFFF ( 256KB )
 +
|U-Boot image
 +
|- align="center"
 +
|0x040000 - 0x5FFFF ( 128KB )
 +
|U-Boot environment variables (primary partition: env)
 +
|- align="center"
 +
|0x060000 - 0x7FFFF ( 128KB )
 +
|U-Boot environment variables (redundant partition: env2)
 +
|- align="center"
 +
|0x080000 - 0xBFFFF ( 256KB )
 +
|FPGA bitfile (firmware)
 +
|- align="center"
 +
|0x0C0000 - 0x2BFFFF ( 2MB )
 +
|Linux kernel image (kernel)
 +
|- align="center"
 +
|0x2C0000 - End of FLASH ( ~5.5 MB or ~13.5 MB  )
 +
|Root filesystem (rootfs)
 +
|}
 +
<br>
 +
 +
===APF27  / U-Boot 2011.12 and newer release - Flash memory partitions===
 +
* It's safer to not touch sectors marked as red ;-)
 +
 +
{| border="1" cellpadding="5" cellspacing="0" summary="APF27 Flash memory partitions"
 +
|- style="background:#efefef;" align="center"
 +
! width="60%" |NAND flash address range !!Type
 +
|- style="background:#ffcccc;" align="center"
 +
|0x00000000 - 0x000FFFFF (1MiB, including NAND SPL and spare memory for bad blocks)
 +
|U-Boot image
 +
|- align="center"
 +
|0x00100000 - 0x0017FFFF (512kB)
 +
|U-Boot environment variables (primary partition: env)
 +
|- align="center"
 +
|0x00180000 - 0x001FFFFF (512kB)
 +
|U-Boot environment variables (redundant partition: env2)
 +
|- align="center"
 +
|0x00200000 - 0x0027FFFF (512KB)
 +
|FPGA bitfile (firmware)
 +
|- align="center"
 +
|0x00280000 - 0x002FFFFF (512kB)
 +
|DeviceTree Block partition (dtb)
 +
|- align="center"
 +
|0x00300000 - 0x007FFFFF (5MB)
 +
|Linux kernel image (kernel)
 +
|- align="center"
 +
|0x00800000 - 0xff7ffff (>~248MB)
 +
|Root filesystem (rootfs)
 +
|- style="background:#ffcccc;" align="center"
 +
|0xff800000 - End of FLASH (512KB)
 +
|U-Boot NAND bad blocks table. Sectors mark as bad, don't touch !!
 +
|}
 +
<br>
 +
 +
===APF28 / U-Boot 2011.12 and newer release - Flash memory partitions===
 +
{| border="1" cellpadding="5" cellspacing="0" summary="APF28 Flash memory partitions"
 +
|- style="background:#efefef;" align="center"
 +
!  width="60%" |NAND flash address range !!Type
 +
|- align="center"
 +
|0x00000000 - 0x002FFFFF (3MB, including NAND SPL and spare memory for bad blocks)
 +
|U-Boot
 +
|- align="center"
 +
|0x00300000 - 0x0037FFFF (512kB)
 +
|U-Boot environment variables (primary partition: env)
 +
|- align="center"
 +
|0x00380000 - 0x003FFFFF (512kB)
 +
|U-Boot environment variables (redundant partition: env2)
 +
|- align="center"
 +
|0x00400000 - 0x0047FFFF (512kB)
 +
|DeviceTree Block partition (dtb)
 +
|- align="center"
 +
|0x00480000 - 0x004FFFFF (512kB)
 +
|Reserved for a futur splash screen (splash)
 +
|- align="center"
 +
|0x00500000 - 0x00CFFFFF (8MB)
 +
|Linux kernel image (kernel)
 +
|- align="center"
 +
|0x00D00000 - End of FLASH (>~243MB)
 +
|Root filesystem (rootfs)
 +
|}
 +
<br>
 +
 +
===APF51 / U-Boot 2011.12 and newer release - Flash memory partitions===
 +
{| border="1" cellpadding="5" cellspacing="0" summary="APF51 Flash memory partitions"
 +
|- style="background:#efefef;" align="center"
 +
!  width="60%" |NAND flash address range !!Type
 +
|- align="center"
 +
|0x00000000 - 0x000FFFFF (1MB, including NAND SPL and spare memory for bad blocks)
 +
| U-Boot image
 +
|- align="center"
 +
|0x00100000 - 0x0017FFFF (512kB)
 +
|U-Boot environment variables (primary partition: env)
 +
|- align="center"
 +
|0x00180000 - 0x001FFFFF (512kB)
 +
|U-Boot environment variables (redundant partition: env2)
 +
|- align="center"
 +
|0x00200000 - 0x002FFFFF (1MB)
 +
|FPGA bitfile
 +
|- align="center"
 +
|0x00300000 - 0x0037FFFF (512kB)
 +
|DeviceTree Block partition (dtb)
 +
|- align="center"
 +
|0x00380000 - 0x003FFFFF (512kB)
 +
|Reserved for a futur splash screen (splash)
 +
|- align="center"
 +
|0x00400000 - 0x00BFFFFF (8MB)
 +
|Linux kernel image (kernel)
 +
|- align="center"
 +
|0x00C00000 - End of FLASH (>~500MB)
 +
|Root filesystem (rootfs)
 +
|}
 +
 +
===APF6===
 +
[[APF6]] has an [[eMMC]].
 +
 +
===OPOS6UL===
 +
[[OPOS6UL]] has an [[EMMC OPOS6UL|eMMC]].
 +
 +
[[Category:System Update]]

Latest revision as of 08:46, 9 September 2021

On this page you will learn how to update (from U-Boot) the Flash's partitions of your APF module storing the Linux, rootfs and U-Boot software images.

Configure U-Boot

Environment variables

U-Boot can be customized in a flexible way with the use of "environment variables/scripts". The command printenv shows you most of them and their current value:

 BIOS> printenv
 bootcmd=run jffsboot
 bootdelay=20
 baudrate=115200
 ethaddr=
 autoload=no
 ...

The command setenv is used to change these variables. For example, to set the IP address (don't do it yet):

 BIOS> setenv ipaddr 192.168.0.10

The command saveenv is used to save the state of your environment variables in FLASH memory; that way they will be available at next boot:

 BIOS> saveenv
 Saving Environment to Flash...
 . done
 Un-Protected 1 sectors
 Erasing Flash...
 . done
 Erased 1 sectors
 Writing to Flash... done
 . done
 Protected 1 sectors

Network configuration

Note Note: You have to install tftpboot on your host development computer


In order to use the U-Boot's network features, you have to set the network environment variables:

 BIOS> setenv netmask 255.255.255.0                (this default value should be fine in most situations)
 BIOS> setenv ipaddr 192.168.0.10 
 BIOS> setenv serverip 192.168.0.2                 (the IP address of your tftp server/PC hosting the files to download)
 BIOS> setenv rootpath "/tftpboot/apf9328-root"    (to boot Linux over NFS)
 BIOS> setenv consoledev ttymxc0

You can use the dhcp command to configure these variables from your DHCP server. You probably will have to adjust the serverip variable manually. If you use VirtualBox or VMware make sure you have selected Bridge Mode for the network adaptor, otherwise the U-Boot cannot talk to your host.

 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, to have them available at next power up:

 BIOS> saveenv

In case of troubles you can use the following U-Boot script to reset the variables to the "factory"/default settings:

 BIOS> run flash_reset_env

or

 BIOS> env default -f -a; saveenv

Linux kernel installation

  • Check that your Armadeus kernel image size is smaller than the U-Boot partition (see Flash Memory Partitions for size allowances):
 [armadeus]$ ls -al buildroot/output/images/
  • If yes, copy it to your TFTP server directory (here /tftpboot/):
 [armadeus]$ cp buildroot/output/images/* /tftpboot/

Linux kernel update script

  • This is the recommended method and the easiest one. The automatic 'update_kernel' scripts downloads the image and flash it in the same go:
 BIOS> run update_kernel
  • To know what update_kernel script is doing you can display its content:
 BIOS> printenv update_kernel
Warning Warning: If the loaded kernel image is too large, the following operation can destroy data that are stored after the partition limits (e.g. RootFS) - Check that transferred size value is less than the ones specified here Flash Memory Partitions


Other Linux kernel update method

  • Load kernel image with U-Boot through network:
 BIOS> run download_kernel

or with the serial line:

 BIOS> loadb ${loadaddr}
     ''Ctrl+Altgr+\+c to access kermit command line then:''
 (/home/.../) C-Kermit>send /tftpboot/XX-linux.bin
     ''After download is completed, you can type the c command to reconnect to the terminal:''
 (/home/.../) C-Kermit>c
 Connecting to /dev/ttyUSB0, speed 115200
  Escape character: Ctrl-\ (ASCII 28, FS): enabled
 Type the escape character followed by C to get back,
 or followed by ? to see other options.
 ----------------------------------------------------
 ## Total Size      = 0x<size of XX-linux.bin> = .... Bytes
 ## Start Addr      = 0x08000000
 BIOS> setenv filesize <size of XX-linux.bin>

Check that transferred size value is less than the ones specified here Flash Memory Partitions

 Bytes transferred = 1313216 (1409c0 hex)

  • You can test your new kernel image without flashing it with; if so you will have to reload it again after test:
    • Please note: The bootm command is not supported by APF51 boards yet; directly flash the kernel with the below commands instead
 BIOS> bootm
  • a U-Boot script exists to ease kernel image loading through Ethernet:
 BIOS> run download_kernel
  • After kernel image has been downloaded into RAM memory, you can flash it with:
 BIOS> run flash_kernel
  • If you only want to try a new kernel without flashing the kernel image you can launch it directly from RAM (U-Boot 2011.12):
 BIOS> setenv bootargs console=${consoledev},${baudrate} ${mtdparts};run addubifsargs addipargs; bootm
(the kernel image you want to try must have been loaded at ${loadaddr})
  • Please note: The bootm command is not supported by APF51 boards yet; directly flash the kernel with the below commands

rootfs installation

  • Check that your Armadeus rootfs image size is smaller than the rootfs partition (see Flash Memory Partitions for size allowances):
 $ ls -al buildroot/output/images/
 ...
 $ cp buildroot/output/images/* /tftpboot/ 
  • Load rootfs image with U-Boot through network:
 BIOS> run update_rootfs
  • or serial line:
BIOS> loadb ${loadaddr}
    ''Ctrl+Altgr+\+c to access kermit command line then...''
(/home/.../) C-Kermit>send path_to_your_host_buildroot_dir/XX-rootfs.ubi
    ''After download is completed, you can type the c command to reconnect to the terminal:''
(/home/.../) C-Kermit>c
Connecting to /dev/ttyUSB0, speed 115200
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
## Total Size      = 0x<size of rootfs>
## Start Addr      = 0x........
BIOS> setenv filesize <size of rootfs>
BIOS> run flash_rootfs
  • Now you should be ready to test Linux:
 BIOS> boot
  • For large rootfs (bigger than the available RAM on your system) please use the method which suit your board:
 BIOS> nand erase.part rootfs
 BIOS> tftpboot ${rootfs_addr} ${board_name}-rootfs.ubi nand

FPGA firmware test

  • The FPGA firmwares are all located in the firmware/ directory of your Armadeus BSP sources:
 $ ls firmware/
 apf_pkg  BRAMTest  bus_led  led  PS2  PS2_Opencore  servo  sram_test  wishbone_example  Xtools
  • You can make some trials with the firmware/leds/blinking_led/bin/ files.


Warning Warning: for the APF9328, please check that your bitfile size is smaller than the firmware partition size (256KB) before trying the following commands or you may corrupt your Linux kernel FLASH partition !!!


Note Note: For the APF51 and U-Boot versions earlier than 2013.04, only binary file format (.bin) can be used; do not try .bit file.
For the APF51 and U-Boot versions 2013.04 or later you can also use .bit files with the U-Boot command:
 BIOS> fpga loadb 


  • Load FPGA firmware image file with U-Boot through:

Ethernet:

 BIOS> tftpboot ${loadaddr} fpgafirmware.bin

fpgafirmware.bin is of course the name of your bitfile stored in your TFTP shared directory (/tftpboot/)

then you can type the c command to reconnect to the terminal

  • Test your new FPGA firmware's downloading:
    • for .bin binary files
      BIOS> fpga load 0 ${loadaddr} ${filesize}
    • for .bit binary files
      BIOS> fpga loadb 0 ${loadaddr} ${filesize}
  • For your convenience a set of U-Boot script to facilitate firmware management with the APF boards:
    • download_firmware: assuming your firmware is in /tftpboot and name apfXX-firmware.bin (where apfXX is the name of your board apf27, apf51, apf9328..) will download the firmware in RAM with the command: run download_firmware
    • flash_firmware: save the previously downloaded firmware from RAM into the flash.
    • update_firmware: will execute the previous 2 scripts in sequence.
    • load_firmware: read a firmware from the flash (there is dedication partition named firmware for this purpose) and load it into the FPGA.

FPGA firmware installation

APF9328, APF27 and APF51

  • instal/copy your firmware to /tftpboot
    • manually:
       $ cp myfirmware.bin /tftpboot/apfXX-firmware.bin (where apfXX is the name of your board: apf27, apf51 or apf9328)
    • using the armadeus BSP:
 $ make menuconfig
Package Selection for the target  --->   Armadeus specific tools/utilities  --->
you can specify the path to the FPGA firmware:
[*] FPGA Firmware 
      Firmware to install (Install a custom FPGA firmware)  --->
 ($(TOPDIR)/../firmware/leds/blinking_led/bin/blinking_led_apf27_200k.bit) FPGA binary file path
[*]   Export this file to Buildroot images folder
 $ cp buildroot/output/images/* /tftpboot 
  • Download and test your firmware image with:
 BIOS> run download_firmware
 BIOS> run load_firmware
  • When you are satisfied with your firmware, you can write it in flash make it "autoloaded" at power up:
Warning Warning: Before setting the firmware_autoload variable, be sure that your FPGA binary file is correct. If not, your board will hang up at U-Boot start and you will need to cancel the fpga download to take control of the board. see note below
 BIOS> run update_firmware
 BIOS> setenv firmware_autoload 1
 BIOS> saveenv
Note Note: (U-Boot 2012.04) you can manually cancel the firmware autoload using the following procedure: keeping <CTRL-C> pressed on the console and power up the board will start the board without downloading the FPGA firmware - This procedure can be helpfull if you have programmed a broken firmware


APF6_SP

Firmware installation was simplified in APF6_SP.

  • To «autoload» your firmware while U-Boot is starting, simply add your bitstream to your rootfs, for example :
/lib/firmware/fpga/firmware.periph.rbf
Note Note: By default, directory /lib/firmware/fpga doesn't exists, then simply create it with
# mkdir /lib/firmware/fpga


  • Then reboot under U-Boot and configure your environment variables firmware_autoload and firmware_path :
BIOS> setenv firmware_path /lib/firmware/fpga/firmware.periph.rbf
BIOS> setenv firmware_autoload 1
  • Do not forget to save your environment variables:
BIOS> saveenv
  • That's all, now your bitstream will be loaded with U-Boot at boot:
U-Boot SPL 2014.07 (Apr 23 2015 - 16:16:45)

U-Boot 2014.07 (Apr 23 2015 - 16:16:45)

[...]

39688 bytes read in 260 ms (148.4 KiB/s)
Hit any key to stop autoboot:  0

Update U-Boot

  • Check that your Armadeus U-Boot image size is smaller than the u-boot partition (see Flash Memory Partitions for size allowances) and copy all the binary images to your TFTP server directory:
 [armadeus]$ ls -al buildroot/output/images/
 ...
 [armadeus]$ cp buildroot/output/images/* /tftpboot/ 

U-Boot update script

  • This is the recommended method and the easiest one. The automatic 'update_uboot' scripts downloads the image and flash it in the same go:
 BIOS> run update_uboot
  • Reset your board and check if you need to update your environment variables:
 BIOS> reset
 U-Boot 2011.12 ..
 ...
 *** Warning - Environment version change suggests: run flash_reset_env; reset
 BIOS> run flash_reset_env; reset

In such a case you may have to update your network environment variables (see Configure U-Boot)

Other U-Boot update method

You can use the following commands to download U-boot in RAM:

  • With Ethernet and a TFTP server:
 BIOS> run download_uboot
  • With Ethernet and a NFS server:
 BIOS> nfs ${loadaddr} host_ip_addr:/nfs_path_to_buildroot/apfXX-u-boot{.bin|-nand.bin|.sb}
  • With kermit and the serial/RS232 line
 BIOS> loadb ${loadaddr}
    <CTRL><ALT GR>\
    c
    send path_to_buildroot/apfXX-u-boot{.bin|-nand.bin|.sb}
    c<ENTER>
 Connecting to /dev/ttyUSB0, speed 115200
  Escape character: Ctrl-\ (ASCII 28, FS): enabled
 Type the escape character followed by C to get back,
 or followed by ? to see other options.
 ----------------------------------------------------
 ## Total Size      = 0x<size of U-Boot> = .... Bytes
 ## Start Addr      = 0x08000000
 BIOS> setenv filesize <size of U-Boot>

Then you can use the U-Boot command/script 'flash_uboot' to tranfert the new U-Boot from RAM to Flash memory:

 BIOS> run flash_uboot

Advanced informations can be found at the BootLoader wiki page.

Note Note: APF51

When updating your board from a legacy version of Armadeus BSP you should set the `fdt_addr_r` environment var to boot correctly:

BIOS> setenv fdt_addr_r 91000000

See How_to_use_vanilla_kernel_on_APF51 for more informations.


Update U-Boot, kernel and rootfs images all at once

  • Copy all the binary images to your TFTP server directory:
 [armadeus]$ cp buildroot/output/images/* /tftpboot/ 
  • The automatic 'update_all' scripts downloads each image and flash it in the same go:
 BIOS> run update_all
  • Reset your board to check that wour board is correctly updated.
Note Note: When updating your board from a legacy version of Armadeus BSP you should update U-Boot first to update the environment variables before any other partition update ( see Update U-Boot)


Flash memory partitions

  • Old Flash partitionning (pre armadeus-5.0) is kept here.

APF9328 / U-Boot 2011.12 and newer release - Flash memory partitions

Address range (index from FLASH physical @ 0x10000000) Type
0x000000 - 0x03FFFF ( 256KB ) U-Boot image
0x040000 - 0x5FFFF ( 128KB ) U-Boot environment variables (primary partition: env)
0x060000 - 0x7FFFF ( 128KB ) U-Boot environment variables (redundant partition: env2)
0x080000 - 0xBFFFF ( 256KB ) FPGA bitfile (firmware)
0x0C0000 - 0x2BFFFF ( 2MB ) Linux kernel image (kernel)
0x2C0000 - End of FLASH ( ~5.5 MB or ~13.5 MB ) Root filesystem (rootfs)


APF27 / U-Boot 2011.12 and newer release - Flash memory partitions

  • It's safer to not touch sectors marked as red ;-)
NAND flash address range Type
0x00000000 - 0x000FFFFF (1MiB, including NAND SPL and spare memory for bad blocks) U-Boot image
0x00100000 - 0x0017FFFF (512kB) U-Boot environment variables (primary partition: env)
0x00180000 - 0x001FFFFF (512kB) U-Boot environment variables (redundant partition: env2)
0x00200000 - 0x0027FFFF (512KB) FPGA bitfile (firmware)
0x00280000 - 0x002FFFFF (512kB) DeviceTree Block partition (dtb)
0x00300000 - 0x007FFFFF (5MB) Linux kernel image (kernel)
0x00800000 - 0xff7ffff (>~248MB) Root filesystem (rootfs)
0xff800000 - End of FLASH (512KB) U-Boot NAND bad blocks table. Sectors mark as bad, don't touch !!


APF28 / U-Boot 2011.12 and newer release - Flash memory partitions

NAND flash address range Type
0x00000000 - 0x002FFFFF (3MB, including NAND SPL and spare memory for bad blocks) U-Boot
0x00300000 - 0x0037FFFF (512kB) U-Boot environment variables (primary partition: env)
0x00380000 - 0x003FFFFF (512kB) U-Boot environment variables (redundant partition: env2)
0x00400000 - 0x0047FFFF (512kB) DeviceTree Block partition (dtb)
0x00480000 - 0x004FFFFF (512kB) Reserved for a futur splash screen (splash)
0x00500000 - 0x00CFFFFF (8MB) Linux kernel image (kernel)
0x00D00000 - End of FLASH (>~243MB) Root filesystem (rootfs)


APF51 / U-Boot 2011.12 and newer release - Flash memory partitions

NAND flash address range Type
0x00000000 - 0x000FFFFF (1MB, including NAND SPL and spare memory for bad blocks) U-Boot image
0x00100000 - 0x0017FFFF (512kB) U-Boot environment variables (primary partition: env)
0x00180000 - 0x001FFFFF (512kB) U-Boot environment variables (redundant partition: env2)
0x00200000 - 0x002FFFFF (1MB) FPGA bitfile
0x00300000 - 0x0037FFFF (512kB) DeviceTree Block partition (dtb)
0x00380000 - 0x003FFFFF (512kB) Reserved for a futur splash screen (splash)
0x00400000 - 0x00BFFFFF (8MB) Linux kernel image (kernel)
0x00C00000 - End of FLASH (>~500MB) Root filesystem (rootfs)

APF6

APF6 has an eMMC.

OPOS6UL

OPOS6UL has an eMMC.