SAMA5D29-Curiosity – Read and Write Boot Configuration Word Using SAM-BA® In System Programmer (ISP)

Last modified by Microchip on 2024/02/16 11:22

Introduction

In this training topic, you will learn how to read and write the Boot Configuration Word from the Secure Fuse Controller (SFC) and Backup Registers (BUREGn) using the SAM-BA® In System Programmer (ISP) on the SAMA5D29-Curiosity Development Board (P/N: EV07R15A)

The SAMA5D29-Curiosity has been designed with peripheral connections that require a custom Boot Configuration Word to configure the input/output settings (IOSET). The peripherals are: 

  • Quad Serial Peripheral Interface 1 (QSPI1) peripheral – connected to a 64 Mb Serial Quad I/O (SQI) Flash (U9). 
  • Universal Asynchronous Receiver Transmitter (UART) Console – configured to UART0 and is connected to the Serial Debug Port 6-pin connector (J28). 
  • JTAG interface – connected to JTAG 20-pin connector (J27). 

At manufacture, the SAMA5D29-Curiosity has been pre-programmed with a custom Boot Configuration Word located in the SFC to configure these peripherals. This training topic will show you how to read and explain its settings. 

A Boot Configuration Word written to SFC cannot be changed. However, for prototyping and development purposes, a custom Boot Configuration Word can be written into one of four Backup Registers (BUREGn) to override the SFC setting. This gives the developer a method to test different configurations, including Secure Boot mode, and finalize the Boot Configuration Word for their product. We show you how to enable the boot sequence to read from a Backup Register. 

Back to Top

Prerequisites

This training topic was developed with SAM-BA ISP v3.7 

Back to Top

Hardware

For this training, you will use the SAMA5D29-Curiosity Development Board (P/N: EV07R15A) and a USB Type-C cable. 

SAMA5D29-Curiosity Development Board

Set up the SAMA5D29-Curiosity as detailed in this tutorial to the host computer running the SAM-BA Host Application. 

Jumpers

SD Memory Cards

  • Ensure no SD Memory Cards are plugged into SD Memory Card slots (J6 or J7). 

USB-A Port (J1)

  • Connect a USB Type-C cable to the USB-A port (J1) and the host computer running the SAM-BA Host Application.  
  • This will be the serial communications path for the SAM-BA Host to communicate with the SAM-BA Monitor on the SAMA5D29-Curiosity (otherwise known as the target).  

Power

  • The SAMA5D29-Curiosity will power on when a USB Type-C cable is plugged into the USB-A port (J1) and the host computer. 

Console Serial Communications

  • Connect a USB-to-Serial 3.3 or 5.0 VDC TTL Level adapter with a 6-pin single-in-line 0.1” pitch connector to a Serial Debug connector (J28) and establish serial communications with the host computer running a terminal emulation program. 
  • This connection will allow you to observe that the SAMA5D29 is in monitor mode waiting for commands from the SAM-BA Host Application. 

For more information on establishing serial communications with the target console, see the "SAMA5D29-Curiosity – Console Serial Communications" page.

Back to Top

First-Stage Bootloader

Microprocessor Units (MPUs) contain an internal ROM (also known as Boot ROM) that contains the first-stage bootloader. It is the program that begins executing when the MPU is reset.  

The boot process steps are: 

  1. Initialize processor and master clocks. 
  2. Read the Boot Configuration Word. 
  3. If (valid code found) in external NVM, then: 
    • Load second-stage bootloader at91bootstrap into internal SRAM. 
    • Remap internal SRAM to address 0x0. 
    • Reset the PC to 0x0 and jump. 
  4. Else if (no valid code found) start the SAM-BA Monitor. 

For a complete description, see the "SAMA5D2 Series Boot Process" page.

Our focus in this training topic is on the Boot Configuration Word. You will use the SAM-BA ISP Applet bootconfig to read, write, and customize the Boot Configuration Word.  

For more information, see the "Read and Write Boot Configuration bootconfig" section of the "SAM-BA In-System Programmer - Applets" page.

Boot Process Flow

The boot process flow for reading the Boot Configuration Word on the SAMA5D2 Series is shown in the accompanying figure. The first step is to read the Boot Configuration Word from the Secure Fuse Controller (SFC). 

SAMA5D2 Series - First-Stage Bootloader

Read the Boot Configuration Word from the Secure Fuse Controller (SFC)

The SAM-BA Host Application command to read the Boot Configuration Word from the SFC is: 

$ sam-ba -p serial -d sama5d29 -a bootconfig -c readcfg:fuse 

For more information, see the "Read and Write Boot Configuration bootconfig" section of the "SAM-BA In-System Programmer - Applets" page.

Command Prompt: readcfg:fuse

Observe the Boot Configuration Word setting in SFC is 0x00061004.  

SAMA5D2 Series - Boot Configuration Word

The individual bit settings are explained in the following section. Note that a bit = 0 is the default setting (reset). 

Bits 1:0 – QSPI_0[0b00] = QSPI0_IOSET1 

  • Default setting. The QSPI0 peripheral is not used on the SAMA5D29-Curiosity. 

Bits 3:2 – QSPI_1[0b01] = QSPI1_IOSET2 

  • The QSPI1 peripheral is connected to a 64 Mb Serial Quad I/O (SQI) Flash with EUI-48 and EUI-64 memory (U9). 

Bits 5:4 – SPI_0[0b00] = SPI0_IOSET1 

  • Default setting. The SPI0 peripheral is not used on the SAMA5D29-Curiosity. 

Bits 7:6 – SPI_1[0b00] = SPI1_IOSET1 

  • Default setting. The SPI1 peripheral is connected to mikroBUS-1, mikroBUS-2, 10/100 RMII Ethernet, and LCD Interface. 

Bits 9:8 – NFC[0b00] = NFC_IOSET1 

  • Default setting. The NAND Flash Interface is available on the 20-pin Multifunction Connector (J26). 

Bit 10 – SDMMC_0[0b0] = Boots on SDMMC_0 using SDMMC_0 PIO Set 1. 

  • Default setting. The SDMMC0 peripheral is connected to a micro Secure Digital (SD) Memory Card (J6) slot (mounted on the bottom side of the development board). 

Bit 11 – SDMMC_1[0b0] = Boots on SDMMC_1 using SDMMC_1 PIO Set 1. 

Bits 15:12 – UART_CONSOLE[0b0001] = UART0_IOSET1 

  • The UART0 peripheral is connected to the Serial Debug Port (J28). This is the serial communications for the Console. 

Bits 17:16 – JTAG_IO_SET[0b10] = JTAG_IOSET3 

  • The JTAG port is connected to the JTAG connector (J27). 

JTAG port access is disabled during the execution of the first-stage bootloader. It is enabled when: 

  • If valid code is found in external NVM, code loaded, SRAM remap, PC to 0x0 and jump 
  • Else if no valid code is found, starts SAM-BA Monitor and locks access to the internal ROM 

For production, it is highly recommended that the JTAG port be DISABLED. 

Bit 18 – EXT_MEM_BOOT_ENABLE[0b1

  • Booting from external non-volatile memory (NVM) is enabled. 

Bit 21 – QSPI_XIP_MODE[0b0

  • Default setting. The QSPI peripherals are configured to read from external serial memory and copy data to internal SRAM. 

Bit 22 – DISABLE_BSCR[0b0

  • Default setting. Allows reading the Boot Configuration Word from a Backup Register (BUREGn) if the Backup Register Valid (BUREG_VALID) bit is set in the Boot Sequence Controller Configuration Register (BSC_CR). 

For production, it is highly recommended to set DISABLE_BSCR = 0b1 to prevent an alternate Boot Configuration. 

Bit 24 – DISABLE_MONITOR[0b0

  • Default setting. If no valid code is found, start the SAM-BA Monitor. 

For production, it is highly recommended to set DISABLE_MONITOR = 0b1 to prevent access to the monitor.  

Bit 29 – SECURE_MODE[0b0

  • Default setting. Boot using the standard boot sequence. 

The SAMA5D2 Series of Arm® Cortex®-A5 processor-based MPUs can load signed and encrypted programs during the boot process. This allows only authorized code to load and execute on the processor. 

Enabling the ROM Boot Code for Secure Boot mode requires a Non-Disclosure Agreement (NDA) from Microchip Technology. Contact your nearest Microchip Sales office for instructions on how to attain confidential application note AN2435, SAMA5D2 series Secure Boot Strategy (Lit. No. DS00002435). 

Read the Boot Sequence Controller Configuration Register (BSC_CR)

Once the Boot Configuration Word has been read, the second step is to check the Disable Boot Sequence Controller Configuration Register (DISABLE_BSCR) bit 22.  

  • If bit = 0, read the Boot Sequence Controller Configuration Register (BSC_CR) 
  • If bit = 1, use the Boot Configuration Word from the SFC 

SAMA5D2 Series - First-Stage Bootloader

When the Boot Configuration Word was read from SFC above, we observed bit 22 = 0. Thus, the third step in the boot process will be to read the BSC_CR.  

The SAM-BA Host Application command to read the BSC_CR is: 

$ sam-ba -p serial -d sama5d29 -a bootconfig -c readcfg:bscr 

Command Window: readcfg:bscr

Observe BSC_CR = 0x0, as would be expected from a power-on reset. 

The fourth step is to check the Backup Register Valid (BUREG_VALID) bit 2. 

  • If bit = 0, no backup register will be read, therefore use the Boot Configuration Word from SFC 
  • If bit = 1, read the Backup Register Index (BUREG_INDEX) bits 1:0 and read the Boot Configuration Word from BUREGn. 

SAMA5D2 Series - First-Stage Bootloader

Since BUREG_VALID = 0, no backup register will be read and the Boot Configuration Word from SFC will be used in the boot process. The result is the SAMA5D29-Curiosity will boot with the pre-programmed Boot Configuration Word and configure the IOSETs for the peripherals as designed on the development board. 

Back to Top

Customize the Boot Configuration Word

Let’s say you want to boot with your own version of the Boot Configuration Word for prototyping and development. In this case, you will need to write to the Boot Sequence Controller Configuration Register (BSC_CR) and set the BUREG_VALID bit = 1, and choose one of the four Backup Registers (BUREGn) and set the appropriate value in the Backup Register Index (BUREG_INDEX) register. 

Write to Boot Sequence Controller Configuration Register (BSC_CR)

The SAM-BA Host Application command to write to the BSC_CR register and set BUREG_VALID is: 

$ sam-ba -p serial -d sama5d29 -a bootconfig -c writecfg:bscr:bureg0,valid 

Note that the command has shortened BSC_CR to bscr. 

Command Prompt: writecfg:bscr

You can read the BSC_CR (bscr) register to verify the value was written. 

Note that BUREG_INDEX = 0b00 is the default if no token is given. For each of the BUREG_INDEX values, the BSC_CR (bscr) tokens are: 

  • bureg0 (default) 
  • bureg 1 
  • bureg 2 
  • bureg 3 

Write to Backup Register n (BUREGn)

The SAM-BA Host Application command to write to the BUREG0 register and set UART 1 to IOSET 1 and JTAG to IOSET 1: 

$ sam-ba -p serial -d sama5d29 -a bootconfig -c writecfg:bureg0:UART1_IOSET1,JTAG_IOSET1 

Command Prompt: writecfg:bureg0

Read Backup Register n (BUREGn)

The SAM-BA Host Application command to read the BUREG0 register: 

$ sam-ba -p serial -d sama5d29 -a bootconfig -c readcfg:bureg0 

Backup Registers 1, 2, and 3 can be read using the appropriate token in the command. 

Back to Top

Backup Power VDDBU

When the SAMA5D29-Curiosity is powered off, the supercapacitor (C13) maintains the Backup Power, VDDBU provided jumper J3 is closed (the default). With VDDBU voltage applied, the MPU maintains the contents of the Backup Registers (BUREG). 

To erase the contents of the BUREGs, open jumper J3 and power off the SAMA5D29-Curiosity.  

Back to Top

Summary

In this training, you read and wrote values to registers associated with the Boot Configuration Word and learned how to boot using a customized version from the Backup Registers (BUREGn) using the SAM-BA ISP on the SAMA5D29-Curiosity Development Board (P/N: EV07R15A). 

Back to Top

Learn More

Back to Top