RZ-G/RZ-G2L Flash Programming: Difference between revisions

From Renesas.info
mNo edit summary
m (WIP.)
Line 1: Line 1:


RZ/G2L cannot boot from USB, so at the end-of-line there are two/three real viable options:  
RZ/G2L cannot boot from USB, so at the end-of-line there are a few real viable options:  


# Boot from SCIF
# Boot from SCIF
# Use JTAG
# Use JTAG
# It is worth to mention that, in general, if a QSPI FLASH is present on the custom board, it can also be bought preprogrammed
# It is worth to mention that, in general, if a QSPI FLASH is present on the custom board, it can also be bought preprogrammed
# Use a temporary QSPI flash card
# Booting from SD-card ('''TO BE CONFIRMED''', specs officially allow eSD only)


In any of the cases above the goal is to have U-Boot up and running, then there are plenty of options to program the rootfs: ethernet, USB as host, USB with Mass Storage gadget, fastboot or even boot Linux kernel + initramfs.
In any of the cases above the goal is to have U-Boot up and running, then there are plenty of options to program the rootfs: ethernet, USB as host, USB with Mass Storage gadget, fastboot or even boot Linux kernel + initramfs.


With option 1, you can download the flash writer and program the bootloaders, Arm Trusted Firmware (ATF) and U-Boot, into QSPI / eMMC boot partition, then reset and run U-Boot.
With option 1, you can download Flash Writer and program the bootloaders, Arm Trusted Firmware (ATF) and U-Boot, into QSPI / eMMC boot partition, then reset and run U-Boot.


With option 2, you can download ATF and U-Boot via JTAG and then run the boot loaders without having to initially program them. Once U-Boot runs, you can program both bootloaders and rootfs.
With option 2, you can download ATF and U-Boot via JTAG and then run the boot loaders without having to initially program them. Once U-Boot runs, you can program both bootloaders and rootfs.


With option 3, QSPI has already bootloaders pre-programmed, so U-Boot is already available.
With option 3, QSPI has already bootloaders pre-programmed, so U-Boot is already available.
With option 4, a QSPI flash card is somehow attached to the board that needs to be programmed. The QSPI flash contains ATF and U-Boot and potentially also the root file system to be programmed, depending on the size of both. More details are available [[RZ-G/RZ-G2 Update Trusted-firmware and U-boot Under Linux#Updating using Linux Running on the Board|here]].
'''TO BE CONFIRMED'''. Option 5 may be complicated. Assuming the final goal is to boot from eMMC, since RZ/G2L can only boot from SDHI0, the system should implement a HW mechanism to switch from SD to eMMC during runtime.


All the options above may not require any human intervention and can be to a certain extent automatized.
All the options above may not require any human intervention and can be to a certain extent automatized.

Revision as of 14:23, 4 March 2022

RZ/G2L cannot boot from USB, so at the end-of-line there are a few real viable options:

  1. Boot from SCIF
  2. Use JTAG
  3. It is worth to mention that, in general, if a QSPI FLASH is present on the custom board, it can also be bought preprogrammed
  4. Use a temporary QSPI flash card
  5. Booting from SD-card (TO BE CONFIRMED, specs officially allow eSD only)

In any of the cases above the goal is to have U-Boot up and running, then there are plenty of options to program the rootfs: ethernet, USB as host, USB with Mass Storage gadget, fastboot or even boot Linux kernel + initramfs.

With option 1, you can download Flash Writer and program the bootloaders, Arm Trusted Firmware (ATF) and U-Boot, into QSPI / eMMC boot partition, then reset and run U-Boot.

With option 2, you can download ATF and U-Boot via JTAG and then run the boot loaders without having to initially program them. Once U-Boot runs, you can program both bootloaders and rootfs.

With option 3, QSPI has already bootloaders pre-programmed, so U-Boot is already available.

With option 4, a QSPI flash card is somehow attached to the board that needs to be programmed. The QSPI flash contains ATF and U-Boot and potentially also the root file system to be programmed, depending on the size of both. More details are available here.

TO BE CONFIRMED. Option 5 may be complicated. Assuming the final goal is to boot from eMMC, since RZ/G2L can only boot from SDHI0, the system should implement a HW mechanism to switch from SD to eMMC during runtime.

All the options above may not require any human intervention and can be to a certain extent automatized.

Boot from SCIF

The main tool that can assist in performing external non-volatile memory (QSPI and eMMC) is Flash Writer. Depending on the host PC used, you can either use a script (link to be added) or a TeraTerm macro. In both cases what you would need are two files:

  • bl2_bp-smarc-rzg2l.bin
  • fip-smarc-rzg2l.bin

These are either the output of Yocto or generated by combining ATF and U-Boot binaries. Actually the first one is generated by ATF directly whereas the second is the generated by the Firmware Image Package (FIP) utility by combining BL3x binaries.

Linux script

A Linux bash script is available here. Please refer to the README for help on the usage.

Windows TeraTerm macro

Usually dealing with this type of devices a Linux host PC is normally available. However sometimes it might be convenient to have a quick way to program the bootloaders using Windows.

Instead of using an ad-hoc tool developed only for the RZ/G2L the idea is to use a generic terminal utility. Tera Term is an open source tool that has some nice scripting capabilities embedded: a Tera Term script is called MACRO. The developed macro "replaces" the user and provides inputs to Flash Writer, whose binary is also downloaded automatically. However the macro alone cannot work, it needs the Flash Writer binary and the files to be programmed (ATF BL2 and FIP).

Since Windows users are typically lazy, a PowerShell script (press ALT and then click on this link to download it) was developed to:

  • Check if Tera Term is installed and retrieve the installation path;
  • Download in a temporary folder the needed files;
  • Retrieve the PC COM ports and ask the user to confirm the one used to communicate with the RZ/G2L board;
  • Create a Windows shortcut to call the Tera Term macro executer using the right parameters;
  • Launch the macro to program the RZ/G2L boot loaders.

Once executed the first time the user can simply double click on the shortcut created by the macro script to relaunch the programming. The macro programs automatically the files present in the "Binaries" folder and it can handle both SREC and BIN. Binary is normally faster to be programmed since files are smaller. The file names should start with bl2 and fip respectively but the rest can be arbitrary. Users can replace the default files with custom files and launch the programming. There can be many files in the folder, the first in alphabetical order are used. You can also mix SREC and BIN files, i.e. program a BL2 SREC and a FIP BIN or vice versa.

It is worth noticing that the macro and the PowerShell script can be easily modified to remove any user intervention, something that may be useful for an unattended flash programming.

Flash Writer binary chip / board dependency

Even though RZ/G2L and RZ/V2L are brother chips (the only functional difference is the DRP-AI), there are some subtle changes that lead to have a different DDR register configuration. Flash Writer does initialize the DDR so, the binaries to be used are different for RZ/G2L and RZ/V2L. On top of that there are several slightly different variant of the SMARC SOM due to the different DDR chips / topology. Below a summary:

  • SMARC RZ/G2L WS1 (only discrete) DDR config is 2x1GB;
  • SMARC RZ/G2L WS2 discrete DDR config is 2x1GB but there are some HW changes between WS2 and WS1 hence different DDR init code;
  • SMARC RZ/V2L discrete DDR config is 2x2GB;
  • SMARC RZ/G2L WS2 - RZ/V2L PMIC DDR config is 1x2GB.

For the last variant, the only difference is the chip but as said the DDR init code is different so different binaries are needed.

Use JTAG

TBD