All of lore.kernel.org
 help / color / mirror / Atom feed
* R-Car Gen3 Network Based Flash Programming Tool for SCIF D/L Mode
@ 2021-09-19  5:15 Magnus Damm
  0 siblings, 0 replies; only message in thread
From: Magnus Damm @ 2021-09-19  5:15 UTC (permalink / raw)
  To: Linux-Renesas

Hi everyone,

Embedded systems traditionally have several options when it comes to
flash programming such as external JTAG devices, boot loader and/or
operating system functionality. In case the flash is empty, on R-Car
Gen3 there are two choices for flash programming: JTAG or using MD
pins to select on-chip ROM boot instead of external storage. Out of
several different boot modes available the SCIF D/L mode allows for
software upload via an UART interface.

Traditionally binary images provided by Renesas have been used
together with the SCIF D/L mode. For such binaries the user was often
requested to perform various board specific operations such as
adjusting DIP switches and input addresses via the UART interface.
Source code and documentation for "flash_writer" has been released at
https://github.com/renesas-rcar/flash_writer/

Once the on-board storage has been initially programmed other software
may be used for additional flash programming. Not utilizing SCIF D/L
mode but also making use of flash_writer functionality is the abloader
tool. Two software copies are stored in flash and may be switched
between. It is available at https://github.com/marex/abloader

The subject of this email "R-Car Gen3 Network Based Flash Programming
Tool for SCIF D/L Mode" describes what in practice is just a
chain-loaded U-Boot with networking support. But to get there several
components are made use of:

- Failsafe ROM-based SCIF D/L mode
- Chain loading by U-Boot SPL
- Hardware setup using ATF BL2 with RCAR_RPC_HYPERFLASH_LOCKED=0
- Networked flash programming via U-Boot DFU TFTP functionality

The target platform in this case happens to be R-Car H3 ES2
Salvator-XS but the instructions should be generic enough as long as
U-Boot support exists for the target and SCIF D/L mode can be enabled.

- - -

Step 1: Compiling the Flash Programming Tool

Required software components are ATF and U-Boot.


Step 1A: ATF

For ATF the following git repository and commit have been used:
https://github.com/ARM-software/arm-trusted-firmware/commit/8078b5c5a

The ATF source code needs to be patched for SCIF D/L chain loading to work:
https://github.com/marex/arm-trusted-firmware/commit/ced85c01d886cc39f51cc9dd3bae72e7061886a7

Generic build instructions for R-Car Gen3 ATF are available at:
https://elinux.org/R-Car/Boards/ATF-Gen3
This includes information about how to setup MBEDTLS_DIR.

For SCIF D/L chain loading some customization is needed:
- Let U-Boot access the RPC HF via RCAR_RPC_HYPERFLASH_LOCKED=0
- No need for OPTEE so set SPD=none

The exact commands used to build the ATF source code are:
$ CROSS_COMPILE=_ make PLAT=rcar LSI=H3 MACHINE=salvator-x
DCAR_DRAM_SPLIT=1 RCAR_DRAM_LPDDR4_MEMCONF=0 SPD=none
RCAR_RPC_HYPERFLASH_LOCKED=0 MBEDTLS_DIR bl2
$ cp build/rcar/release/bl2.bin bl2-scif.bin


Step 1B: U-Boot

For U-Boot the v2021.10-rc4 was selected since it is the latest release:
https://source.denx.de/u-boot/u-boot/-/tags/v2021.10-rc4

For flash programming to work on this particular target platform the
DTS source for the board needs to be modified. For this board the
following rpc node needs to be enabled:
arch/arm/dts/r8a77950--salvator-x-u-boot.dts

Instructions related to U-Boot on R-Car Gen3 (see "U-Boot recovery
SPL") are available at: https://elinux.org/R-Car/Boards/U-Boot-Gen3

For SCIF D/L case build the source code and compress the binary using:
$ make CROSS_COMPILE=_ rcar3_salvator-x_defconfig
$ make CROSS_COMPILE=_
$ cp spl/u-boot-spl.scif .
$ cp u-boot.bin u-boot-scif.bin
$ cat u-boot-scif.bin | gzip -9 - > u-boot-scif.bin.gz

Create chain loading images using:
$ ./tools/mkimage -A arm -O arm-trusted-firmware -T firmware -C none
-a 0xe6304000 -e 0xe6304000 -n "BL2" -d bl2-scif.bin bl2-scif.uimage
$ ./tools/mkimage -A arm -O u-boot -T firmware -C gzip -a 0x50000000
-e 0x50000000 -n "U-Boot" -d u-boot-scif.bin.gz u-boot-scif.gz.img

The following files are needed for next step:
u-boot-spl.scif
bl2-scif.uimage
u-boot-scif.gz.img


- - -

Step 2: Using the Flash Programming Tool

Network transfer of software images for flash programming allows for
fast operation however the SCIF D/L boot with 3-step chain loading
takes some time and effort to get right.


Step 2A: Booting U-Boot from SCIF D/L mode

Adjust the MD pins to enable SCIF D/L mode and configure your terminal
program to 115200n81. Verify that a message is printed on the serial
port after power on. Once the "please send !" message appears start
ASCII upload of "u-boot-spl.scif". After a short while "U-Boot SPL,
Trying to boot from UART" will appear. Then it is time to upload
"bl2-scif.uimage" using ZMODEM/YMODEM/XMODEM protocol. After a while
plenty of BL2 messages appear followed by yet another "U-Boot SPL,
Trying to boot from UART". At such time proceed with upload of
"u-boot-scif.gz.img". Once finished the regular U-Boot user interface
will be available for console I/O.


Step 2B: U-Boot Flash Programming Example

Once the U-Boot user interface is presented a wide range of commands
are available. To update the flash with a multi-component fitImage the
following commands may be used:
=> setenv loadaddr 0x60000000
=> setenv bootfile update.itb
=> bootp
=> dfu tftp 0x60000000

The above 4 steps may be used to quickly update all components of the
on-board software stack. It however assumes that the file update.itb
is formatted as expected and the network environment is correctly
setup with services such as BOOTP/DHCP and TFTP.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-19  5:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-19  5:15 R-Car Gen3 Network Based Flash Programming Tool for SCIF D/L Mode Magnus Damm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.