SAM-BA In-System Programmer Monitor
Introduction
The SAM-BA® Monitor program performs basic internal memory read, write, and execute commands. It is embedded in the ROM boot code of the target device (Microchip Technology Arm®-based MPU or MCU). The SAM-BA Monitor is controlled by and communicates with the SAM-BA host over a serial communications link. For additional information, refer to the SAM-BA Host to Monitor Serial Communications topic.
Boot Process
The boot process for an MPU device begins with a Processor Reset followed by the execution of the ROM boot code, also known as the Stage One Bootloader. The ROM boot code will:
- Configure external memories
- Configure the Universal Asynchronous Receiver Transmitter (UART) port used as a terminal console
- Initialize master clock
- If external memory is available and valid code is detected, read contents to SRAM
If external memory is not available, or no valid code is detected, and the SAM-BA Monitor has not been disabled, the ROM Boot Code will begin the execution of the SAM-BA Monitor.
The first step of the SAM-BA Monitor is to detect if there is an external 12 MHz clock signal or if there is an external quartz crystal resonator connected to the 12 MHz Crystal Oscillator.
- If there is, then the SAM-BA Monitor will configure the Clock Generator to supply the Main Clock signal from this source.
- If there is not, then the SAM-BA Monitor will configure the Clock Generator to supply the Main Clock signal from the internal 12 MHz RC Oscillator.
Next, the SAM-BA Monitor will initialize the UART pins specified in the Boot Configuration Word (UART_CONSOLE) and, if the source of the Main Clock signal is from an external 12 MHz clock signal or the 12 MHz Crystal Oscillator, it will initialize the USB High-Speed Device Port (UDPHS).
SAM-BA Monitor will print RomBOOT to the Target Console.
The SAM-BA Monitor will check if the USB Device Port has been enumerated, indicating there are serial communications available, and wait for a command.
If the USB Device Port has not been enumerated, it will check if characters are received on the Target Console. If characters are received, the SAM-BA Monitor will continue communicating through the UART and wait for further commands.
Monitor Commands
The SAM-BA Monitor program, controlled by the SAM-BA Host Application Program, performs basic internal memory read, write, and execute commands. It is embedded in the ROM boot code of the target device (Microchip Technology Arm-based MPU or MCU). The SAM-BA Monitor communicates with the SAM-BA host over a serial communications link.
Executing Monitor Commands
SAM-BA Monitor commands can be executed from the SAM-BA host using the -m, --monitor option.
Monitor -m, --monitor commands depend on the selected Port -p, --port option. The sam-ba -p <port> -m help command will display all supported monitor commands for a given <port> connection:
* read8 - read a byte
Syntax:
read8:<addr>
Example:
read8:0x200000 read a byte at address 0x200000
* read16 - read a half-word (16-bit)
Syntax:
read16:<addr>
Example:
read16:0x200000 read a half-word at address 0x200000
* read32 - read a word (32-bit)
Syntax:
read32:<addr>
Example:
read32:0x200000 read a word at address 0x200000
* read - read data into a file
Syntax:
read:<filename>:<addr>:<length>
Example:
read:test.bin:0x200000:512 read 512 bytes from address 0x200000 into file test.bin
* write8 - write a byte
Syntax:
write8:<addr>:<value>
Example:
write8:0x200000:0x12 write byte 0x12 at address 0x200000
* write16 - write a half-word (16-bit)
Syntax:
write16:<addr>:<value>
Example:
write16:0x200000:0x1234 write half-word 0x1234 at address 0x200000
* write32 - write a word (32-bit)
Syntax:
write32:<addr>:<value>
Example:
write32:0x200000:0x12345678 write word 0x12345678 at address 0x200000
* write - write data from a file
Syntax:
write:<filename>:<addr>
Example:
write:test.bin:0x200000 write data from file test.bin to address 0x200000
* execute - execute code
Syntax:
execute:<addr>
Example:
execute:0x200000 execute code at 0x200000