Flasher#

This page will tell you how to flash a board with firmware.

You can see all connected boards using command: lsusb, it will list each device’s information:

  • Bus number

  • Device index

  • vendor id

  • product id

for example there is a device : Bus 002 Device 003: ID 04b4:5bc2 Cypress Semiconductor Corp. , then this device has a bus number of 2, a device index of 3, a vendor id of 0x04b4 and a product id of 0x5bc2.

Note every time you unplug and plug in, the devices information may be changed.

examples#

Please replace the filename in example to the real firmware to run them.

  • flash empty board

from samna.flasher import *

# assume there is only one empty device to flash
d = get_empty_devices()[0]
# after done, the product id of the device will change to some other value from 0x00F3.
program_empty_fx3_ram(d, 'newdynapcnnDevkit.img')

# don't unplug, we need to flash fx3 before unpluging. as device has changed, we should get device info again.
d = get_programmable_devices()[0]
# after done, if the file written into flash is different from the file written into ram, you need reboot to take effect, i.e. unplug and plug in again to let the FX3 boot from flash.
program_fx3_flash(d, 'newdynapcnnDevkit.img')
  • flash fx3 firmware to flash

from samna.flasher import *

d = get_programmable_devices()[0]
program_fx3_flash(d, 'newdynapcnnDevkit.img')
  • flash fpga firmware to flash then boot it from flash

from samna.flasher import *

d = get_programmable_devices()[0]
program_fpga_flash(d, 'newDynapcnnFPGA.bin')  # you don't need to unplug the board
  • print firmware header

from samna.flasher import *

# print fx3 firmware file header info
print_firmware_header_from_file('newdynapcnnDevkit.img', FileType.fx3Firmware)

# print fpga firmware file header info
print_firmware_header_from_file('newDynapcnnFPGA.bin', FileType.fpgaFirmware)

# the second input enumerator can be neglected
print_firmware_header_from_file('newdynapcnnDevkit.img')
print_firmware_header_from_file('newDynapcnnFPGA.bin')
  • write firmware header

If there is no header in the target file, a header will be added. Or a new header will overwrite the old header.

from samna.flasher import *

# write fx3 firmware header
write_firmware_header('newdynapcnnDevkit.img', FileType.fx3Firmware, 0x5bc2, 0, [3,6,9], "")

# write fpga firmware header
write_firmware_header('newDynapcnnFPGA.bin', FileType.fpgaFirmware, 0x5bc2, 5, [3,6,9], "")
  • print device info

from samna.flasher import *

d = get_programmable_devices()[0]
print_firmware_info_from_device(d)
  • make board empty

If you want to erase all images (fx3 image and fpga image), you can use the following commands:

from samna.flasher import *

d = get_programmable_devices()[0]
samna.flasher.make_board_empty(d)
  • read daughter board info

Every daughter board has an unique daughter board info stores in the EEPROM, it can be read by the following commands:

from samna.flasher import *

d = get_programmable_devices()[0]
# where the second parameter is the index of the daughter board, which is usually 0
info = samna.flasher.read_daughter_board_info(d, 0)

print(info)
  • read board info

Every mother board or dev kit main board has an unique board info stores in the flash, it can be read by the following commands:

from samna.flasher import *

d = get_programmable_devices()[0]
info = samna.flasher.read_board_info(d)

print(info)

firmware header format#

main header:

Content: [SYN][TYPE][md5]
Bytes:   [ 3 ][ 1  ][32 ]

sub-header of fx3:

Content: [PID][version]
Bytes:   [ 2 ][   3   ]

sub-header of fpga:

Content: [PID][CID][version]
Bytes:   [ 2 ][ 1 ][   3   ]

configuration id#

Here we list configuration id for all firmware files:

  1. fx3 firmware: 0

  2. fpga firmware for dev kit: 0

  3. fpga firmware for test board:
    • speck2b test board: 8

    • speck2bmini test board: 11

    • speck2cmini test board: 12

    • xylo test board: 5

    • xylo audio test board: 10

    • speck2 test board: 4

    • dvs128 test board: 7

api reference#

Flasher api samna.flasher