SAM-BA In-System Programmer Monitor

Last modified by Microchip on 2023/11/10 10:58

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.

Note: The SAM-BA Host to Monitor Serial Communications link is a dedicated serial port separate from the Target Console serial communications.

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.

Note: For more information see: 

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).

Note: The UART will be initialized for 115,200 baud, eight bits of data, no parity, and one stop bit.

Note: The USB Device Port will communicate using the Communication Device Class (CDC).

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.

Back to Top

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.

Note: The SAM-BA Host to Monitor Serial Communications link is a dedicated serial port separate from the Target Console serial communications.

Executing Monitor Commands

SAM-BA Monitor commands can be executed from the SAM-BA host using the -m, --monitor option.

Alert: DO NOT use the Monitor -m, --monitor option on the same command line with the Applet -a, --applet or Execute -e, --execute options. However, many -m, --monitor options can be passed on the same command line.

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:

$ sam-ba -p serial -m help

* 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

What's Next?

Back to Top