Home ·
  • SAM-BA qspiflash applet
  • SAM-BA qspiflash applet

    The qspiflash applet drives any QSPIx controller to program an external QSPI NOR flash memory embedded on the board and connected to the SAM MPU device.

    Supported QSPI NOR flash memories

    The list of all QSPI NOR flash memories supported by the qspiflash applet is available here.

    Applet initialization

    The list of parameters to initialize the qspiflash applet can be displayed with the following command:

    sam-ba -p <port> -d <device> -a qspiflash:help
    
    $ sam-ba -p serial -d sama5d2 -a qspiflash:help
    Syntax: qspiflash:[<instance>]:[<ioset>]:[<frequency>]
    Parameters:
        instance   QSPI controller instance
        ioset      QSPI I/O set
        frequency  QSPI clock frequency in MHz
    Examples:
        qspiflash         use default board settings
        qspiflash:0:3:66  use fully custom settings (QSPI0, IOSET3, 66MHz)
        qspiflash:::20    use default board settings but force frequency to 20MHz

    Instance and I/O set

    An instance parameter x tells the qspiflash applet to use the QSPIx controller. The ioset parameter is an index that represents a group of I/O pins muxed to the QSPIx controller. The {Instance, I/O set} pairs are device specific; please refer to the qspiflash section of the device configuration:

    Frequency

    The frequency parameter expresses the SPI bus clock frequency in MHz.

    Supported commands

    The list of commands supported by the qspiflash applet can be displayed with the following commands:

    sam-ba -p <port> -d <device> -a qspiflash -c help
    
    $ sam-ba -p serial -d sama5d2 -a qspiflash -c help

    The erase command

    The erase command resets to 0xFF a range of erase blocks. The size of those erase blocks depends on the manufacturer and memory part. Typical erase block sizes are 8KiB, 32KiB, 64KiB, 128KiB or 256KiB of data.

    $ sam-ba -p serial -b sam9x60-ek -a qspiflash -c erase:help
    * erase - erase all or part of the memory
    Syntax:
        erase:[<addr>]:[<length>]
    Examples:
        erase                 erase all
        erase:4096            erase from 4096 to end
        erase:0x1000:0x10000  erase from 0x1000 to 0x11000
        erase::0x1000         erase from 0 to 0x1000

    The write and writeboot commands

    The write and writeboot commands program data from a binary file into the QSPI flash pages. The blocks containing the pages to be programmed should be erased first with the erase command. Padding bytes are added to align programmed data to the page boundary. Typical page sizes are 256 or 512 bytes. Prior to what both commands do, the writeboot command also modifies the relevant unused ARM exception vector to store the size of the bootstrap binary, as required by the ROM code during the boot process.

    $ sam-ba -p serial -b sam9x60-ek -a qspiflash -c write:help
    * write - write to memory from a file
    Syntax:
        write:<filename>:[<addr>]
    Examples:
        write:bootstrap.bin         write bootstrap.bin to start of memory
        write:u-boot.bin:0x10000    write u-boot.bin at offset 0x10000
    
    $ sam-ba -p serial -b sam9x60-ek -a qspiflash -c writeboot:help
    Syntax:
        writeboot:<filename>
    Example:
        writeboot:bootstrap.bin     write bootstrap.bin as boot program at start of memory

    The read command

    The read command loads data from the QSPI flash into a binary file.

    $ sam-ba -p serial -b sam9x60-ek -a qspiflash -c read:help
    * read - read from memory to a file
    Syntax:
        read:<filename>:[<addr>]:[<length>]
    Examples:
        read:firmware.bin              read all to firmware.bin
        read:firmware.bin:0x1000       read from 0x1000 to end into firmware.bin
        read:firmware.bin:0x1000:1024  read 1024 bytes from 0x1000 into firmware.bin
        read:firmware.bin::1024        read 1024 bytes from start of memory into firmware.bin

    The verify and verifyboot commands

    The verify and verifyboot compare the data programmed in the QSPI flash with the content of a given binary file. Unlike the verify command, the verifyboot command ignores the actual value of the relevant unused ARM exception vector in the binary file and does as if the value were the size of the binary file.

    $ sam-ba -p serial -b sam9x60-ek -a qspiflash -c verify:help
    * verify - verify memory from a file
    Syntax:
        verify:<filename>:[<addr>]
    Examples:
        verify:firmware.bin         verify that start of memory matches firmware.bin
        verify:firmware.bin:0x1000  verify that memory at offset 0x1000 matches firmware.bin
    
    $ sam-ba -p serial -b sam9x60-ek -a qspiflash -c verifyboot:help
    * verifyboot - verify boot program from a file
    Syntax:
        verifyboot:<filename>
    Example:
        verifyboot:bootstrap.bin    verify that start of memory matches boot program bootstrap.bin


    Copyright © 2018 Microchip Technology
    SAM-BA Documentation