DESK-RZ-L/Deployment/Boot options flash programmer

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2024/12/16 DESK-RZ-L-1.x.x release


Flash programmer over SCI mode[edit | edit source]

The Flash Programmer tool is required when you want to program the NOR flash without first booting from other peripherals and then programming it from a higher software level.

It is a bare-metal tool that runs on the CR52 core, and its main purposes are:

  • Initialize the minimum set of peripherals required for the following operations
  • Initialize the DDR
  • Use xSPI0 to program the connected NOR flash

Boot from SCI Mode[edit | edit source]

See Boot options for how to set the bootstrap pins to boot in SCI mode.

Detect SCI mode running correctly[edit | edit source]

To verify that the system has correctly booted in this mode, check that the following message appears:

SCI Download mode (Normal SCI boot)

If this message appears on the debug console, the system is running in the correct mode.

Send binary[edit | edit source]

There are two ways to send the Flash Programmer binary over the debug serial port:

  • From Windows using the Tera Term tool
  • From Linux

In any case, the sequence to follow is the follows:

  • Power on the board in SCI download mode
  • Send the Flash Programmer header
  • Send the Flash Programmer
  • After the transfer, a prompt will appear
  • Program BL2 into the NOR:
    • Run the command XSPIW 0 0 0
    • Send the BL2 srec file over the serial port
  • Program U-Boot:
    • Run the command XSPIW 0 0x60000 0
    • Send the FIP srec file over the serial port

Attention: sending the binaries is slow; the process takes several minutes.

The files can be found either on the MVM or on the DESK-RZ-L-1.0.0 mirror and downloaded from there.

Note that the MVM may contain older versions; it is recommended to download the latest version from here.

From Windows[edit | edit source]

  • Open the serial port using the Tera Term tool
  • Open, with Windows Explorer, the directory where the downloaded binaries are located. The required binaries are:
    • HDR NM: Flash Programmer header
    • Flash_Programmer_SCIF_CR52_RZT2H_EVK.mot: Flash Programmer
    • bl2_bp_xspi0-desk-t2h-usd-devel.srec: TF-A BL2
    • fip-desk-t2h-usd-devel.srec: U-Boot
  • Send the Flash Programmer header HDR NM (drag the HDR NM file from the Explorer window and drop it into the Tera Term terminal)
    • A dialog will appear; make sure Send File (Paste content of file) is selected and click OK
  • If the header is sent correctly, the message -- Load Program to RAM --------------- will appear
    • In the same way, send the file Flash_Programmer_SCIF_CR52_RZT2H_EVK.mot (this may take some time)
  • A string similar to Flash Programmer V1.03 (RZT2H)(CR52_0) (built: Sep 10 2025, 13:34:42) will appear, followed by the prompt >
  • The Flash Programmer tool has now been loaded; proceed with programming the NOR flash with BL2 and FIP
    • Run the command xspiw 0 0 0
    • As before, send the file bl2_bp_xspi0-desk-t2h-usd-devel.srec
    • When finished, run the command xspiw 0 0x60000 0
    • As before, send the binary fip-desk-t2h-usd-devel.srec (this may take several minutes)

Example:

SCI Download mode (Normal SCI boot)
-- Load Program to RAM  ---------------
-- Start Boot Program on RAM ---------

Flash Programmer V1.03 (RZT2H)(CR52_0) (built: Sep 10 2025, 13:34:42)
> xspiw 0 0 0
send file
Erased
Written
> 
> xspiw 0 0x60000 0
send file
Erased
Written
> 

From Linux[edit | edit source]

For example, when using the DVDK Virtual Machine, just connect the debug serial port to the MVM and use the picocom tool to verify that the serial connection is working correctly:

dvdk@vagrant:~/desk-rz-l/bin$ picocom -b 115200 /dev/ttyUSB0
picocom v3.1

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready
SCI Download mode (Normal SCI boot)

On the MVM, the directory /home/dvdk/desk-rz-l/bin/ contains the following binaries:

  • bl2_bp_xspi0-desk-t2h-usd-devel.srec: TF-A BL2
  • fip-desk-t2h-usd-devel.srec: U-Boot
  • Flash_Programmer_SCIF_CR52_RZT2H_EVK.mot: Flash Programmer
  • HDR NM: Flash Programmer header

Using cat or echo redirected to the debug serial port, it is possible to send the binaries. Below is an example script that programs U-Boot.

The script assumes that the board has just been powered on and that no data has been sent on the serial port before running it.

In parallel, it is possible to keep a separate terminal open to cat the serial port in order to monitor the progress and diagnose any issues.

#!/bin/bash
# send_serial.sh
# Script to send files over serial with intermediate progress messages
# Usage: ./send_serial.sh <serial_port> <HDR_NM> <Flash_Programmer.mot> <bl2.srec> <fip.srec>

if [ "$#" -ne 5 ]; then
    echo "Usage: $0 <serial_port> <HDR_NM> <Flash_Programmer.mot> <bl2.srec> <fip.srec>"
    exit 1
fi

SERIAL="$1"
HDR_FILE="$2"
FLASH_FILE="$3"
BL2_FILE="$4"
FIP_FILE="$5"
BAUD=115200

# Configure serial port
echo "Configuring serial port $SERIAL at $BAUD 8N1, flow control disabled..."
stty -F "$SERIAL" "$BAUD" cs8 -parenb -cstopb -ixon -ixoff -crtscts raw -echo
sleep 1

echo "---- Sending HDR ----"
cat "$HDR_FILE" > "$SERIAL"
echo "HDR sent"

echo "---- Sending Flash Programmer ----"
cat "$FLASH_FILE" > "$SERIAL"
echo "Flash Programmer sent"

sleep 5

echo "---- Sending command: xspiw 0 0 0 ----"
echo "xspiw 0 0 0" > "$SERIAL"
echo "Command sent"

sleep 1

echo "---- Sending BL2 SREC ----"
cat "$BL2_FILE" > "$SERIAL"
echo "BL2 sent, waiting 10 seconds..."
sleep 10

echo "---- Sending command: xspiw 0 0x60000 0 ----"
echo "xspiw 0 0x60000 0" > "$SERIAL"
echo "Command sent"

sleep 1

echo "---- Sending FIP SREC ----"
cat "$FIP_FILE" > "$SERIAL"
echo "FIP sent, waiting 30 seconds..."
sleep 30

echo "---- Flash OK ----"
echo "Flashing completed successfully"

Example:

dvdk@vagrant:~/desk-rz-l/bin$ ./send_serial.sh /dev/ttyUSB0 HDR%20NM Flash_Programmer_SCIF_CR52_RZT2H_EVK.mot bl2_bp_xspi0-desk-t2h-usd-devel.srec fip-desk-t2h-usd-devel.srec 
Configuring serial port /dev/ttyUSB0 at 115200 8N1, flow control disabled...
---- Sending HDR ----
HDR sent
---- Sending Flash Programmer ----
Flash Programmer sent
---- Sending command: xspiw 0 0 0 ----
Command sent
---- Sending BL2 SREC ----
BL2 sent, waiting 10 seconds...
---- Sending command: xspiw 0 0x60000 0 ----
Command sent
---- Sending FIP SREC ----
FIP sent, waiting 30 seconds...
---- Flash OK ----
Flashing completed successfully