APF9328 APF27 APF51 OPOS6UL SP FPGA configuration

From ArmadeusWiki


Test bitstream

  • The FPGA bitstreams 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.


Configuring from Linux

Directly

Please use the FPGA loader linux driver.

Warning Warning: For APF51, please use binary format .bin, bitstream format .bit doesn't work.


Flashing the FPGA firmware partition

The FPGA firmware partition (mainly used from U-Boot) can be updated by means of U-Boot (see here) or directly from Linux as described herewith.

Under Linux:

  • At first, download your FPGA firmware:
 # tftp -g -r my_firmware.bit 192.168.0.2
  • Then, determine which partition in the flash is the firmware partition:
  # cat /proc/mtd 
  dev:    size   erasesize  name
  mtd0: 00100000 00020000 "u-boot"
  mtd1: 00080000 00020000 "env"
  mtd2: 00080000 00020000 "env2"
  mtd3: 00100000 00020000 "firmware"
  mtd4: 00080000 00020000 "dtb"
  mtd5: 00080000 00020000 "splash"
  mtd6: 00800000 00020000 "kernel"
  mtd7: 1f400000 00020000 "rootfs"

The example above is taken from an APF51 running Armadeus version 5.2 and we can see that mtd3 is the firmware partition. If yours is different, then replace mtd3 by what you found out to be the right one in the following commands.

  • Once done, the firmware partition has to be erased:
 # flash_erase /dev/mtd3 0 0
  • Then your FPGA .bit file can be written:
 # nandwrite -p /dev/mtd3 my_firmware.bit

Configuring from uBoot

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 


  • Step 1: 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  --->
    • 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 
  • Step 2: 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

  • Step 3: 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}

Using U-Boot scripts

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.

Download and test your firmware image with:

 BIOS> run download_firmware
 BIOS> run load_firmware

Autoloading

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