Write on QuadSPI memory with SAM-BA

SAM-BA® is a programming tool for the Microchip MPUs/MCUs. This article illustrates how to use it to transfer the at91bootstrap bootloader on the QuadSPI memory mounted on the RoadRunner SOM

SAM-BA is freely downloadable in two versions:

  • A graphicaly version called SAM-BA 2.18
  • A pure command line version called SAM-BA 3.2.1

In this article we refer to the command line version that is the only version compatible with the QuadSPI memory used on the RoadRunner module. We will illustrate the use of the Linux version but probably the Windows version will work in the same way.

Installing SAM-BA 3.2.1 for Linux

Open the SAM-BA web site and download the package: SAM-BA 3.2.1 for Linux.

Uncompress the tar.gz file:

tar xvf sam-ba_3.2.1-linux_x86_64.tar

Download and save, inside the directory just created by tar, this file:

This is a script file written in QML that gives the istructions to SAM-BA on how and what tranfer inside the QuadSPI memory and much more.

More info about the QML function are available in: doc/index.html.

SAM-BA can be used only when on the MCU is running RomBOOT. When the CPU is running other codes like at91bootstrap, uboot or linux it is not usable because it talk only with RomBOOT.

RomBOOT is the first piece of code running by the MCU at startup. It is burned directly by Microchip factory inside the ROM MPU.At startup RomBOOT looks for a bootable code from any external memory memories available,if nothing is available, it waits for any serial commands incoming from the USB device port or from the serial debug port this is the way used by SAM-BA to talk with RomBOOT.

The RoadRunner with QuadSPI on board (Model Q16/Q64/Q256) are already programmed to boot from QuadSPI. The default code put on it is at91bootstrap.

In case you want to reflash it just press the push-button BOOTOFF on the Berta D2 board and the press the RESET botton to restart the MPU.

In this situation a new USB device is announced on the USB port of your PC:

$ lsusb
...
Bus 002 Device 004: ID <b>03eb:6124 Atmel Corp. at91sam SAMBA bootloader</b>
...

and a new serial device is available with the name /dev/ttyACM0:

$ dmesg
...
[ 4676.045662] cdc_acm 2-2.1:1.0: ttyACM0: USB ACM device
[ 4676.046800] usbcore: registered new interface driver cdc_acm
[ 4676.046803] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
...

$ ls -al /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Aug  2 12:53 /dev/ttyACM0

The device name /dev/ttyACM0 is used inside roadrunner.qml script.

Save the at91bootstrap.bin file inside the SAM-BA directory and launch SAM-BA with this command:

sudo ./sam-ba -x roadrunner.qml

Debug messages

Messages send by the Appletson the debug port writing the QuadSPI memory.

QuadSPI 16MB

Applet 'QSPI Flash' from softpack 2.10 (v2.10).
Initializing QSPI0 IOSet3 at 66000000Hz
Found Device n25q128ax3
Size: 16777216 bytes
Page Size: 256 bytes
Buffer Address: 0x00229b40
Buffer Size: 91136 bytes
QSPI applet initialized successfully

QuadSPI 64MB

Applet 'QSPI Flash' from softpack 2.10 (v2.10).
Initializing QSPI0 IOSet3 at 66000000Hz
Found Device n25q512ax3
Size: 67108864 bytes
Page Size: 256 bytes
Buffer Address: 0x00229b40
Buffer Size: 91136 bytes
QSPI applet initialized successfully

QuadSPI 256MB

Applet 'QSPI Flash' from softpack 2.12 (v2.12-dirty).
Initializing QSPI0 IOSet3 at 122000000Hz
Found Device mt25q02G
Size: 268435456 bytes
Page Size: 256 bytes
Buffer Address: 0x00229cc0
Buffer Size: 90880 bytes
QSPI applet initialized successfully.

How to generate test pattern

dd bs=1K count=64  < /dev/urandom > test64KB.bin
dd bs=1M count=16  < /dev/urandom > test16MB.bin
dd bs=1M count=64  < /dev/urandom > test64MB.bin
dd bs=1M count=256 < /dev/urandom > test256MB.bin

Links

Author: Sergio Tanzilli - tanzilli@acmesystems.it
System designer and CEO of Acme Systems srl
Web master of: https://www.acmesystems.it and http://www.tanzolab.it
Software developer on: https://github.com/tanzilli and https://github.com/acmesystemsss