From eLinux.org
< RZ-A
Revision as of 02:03, 23 May 2017 by Jmondi (talk | contribs) (XIP kernel)
Jump to: navigation, search

Hardware Setup

Please refer to RZ-A/Boards/GR-PEACH

Flash Storage Memory Map

GR-Peach comes with a 8Mb Flash Storage. The Flash chip is connected through a QSPI link and can run in single or dual mode and supports XIP. It is possible to increase storage size substituting the flash chip, which is easily accessible on the bottom of board.

For 8Mb Flash Storage we're going to use the following partitioning scheme

                     SPI Flash Memory Map
                        Start      Size     SPI
               u-boot:  0x00000000 0x080000 0
                  env:  0x00080000 0x040000 0
                   DT:  0x000C0000 0x040000 0
               Kernel:  0x00100000 0x050000 0
               Rootfs:  0x00600000 0x0A0000 0

The QSPI flash chip is memory mapped, and it's content is accessible at address 0x18000000 in the SPI multi I/O bus space.


As we are going to run a XIP kernel, a patched u-boot version is required. Renesas provides an u-boot version that supports XIP.

Please refer to u-boot instructions in RZ-A/Boards/GR-PEACH-bsp. Build and flash u-boot as instructed.

Overwrite some environment commands and variables as follows, once u-boot has successfully loaded

bootargs=console=ttySC2,115200 ignore_loglevel root=/dev/mtdblock0
bootcmd=sf probe 0; sf read 20500000 C0000 10000 ; qspi single ; bootx 18100000 20500000

As the previous commands show, we're going to load DTS file from Flash storage, save it in SRAM at address 0x20500000 and boot a XIP kernel from QSPI Flash at address 0x18100000. As rootfs we'll use a partition of the Flash storage, at address 0x18600000.


XIP kernel

As explained in Hardware Setup paragraph, the GR-Peach comes with only 10MB of on-chip SRAM. While it is possible to trim down kernel configuration to boot and execute from volatile memory, eXecution In Place allows the inclusion of much more features and drivers in the built kernel, and is thus the recommended choice.

Building a XIP kernel for multi-platforms devices is currently not allowed, and a small patch is required to allow selecting that option for our target platform.


Make sure you point the kernel physical address to the correct location with the XIP_PHYS_ADDR configuration option and set the correct offset where on-chip SRAM is mapped to.


Linux Kernel

Please use renesas-drivers kernel tree that as per v4.11 contains the required driver support for Renesas RZ/A1 devices. git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git master

As GR-Peach is currently not officially supported by mainline kernel, a device tree source file for it is required http://jmondi.org/git/linux/commit/f38567427d2db4a8d14001f8aba860a307b41186

Make sure to be enable MTD support, in particular MTD_OF_PARTS enabled in order to be able to mount the Flash storage as root during boot


Build XIP kernel and dts

make JOBS=32 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=./linux-build xipImage dtbs
#Add .bin extension to xipImage and dtb file to make Segger J-Link happy
cp linux-build/arch/arm/boot/xipImage linux-build/arch/arm/boot/xipImage.bin
cp linux-build/arch/arm/boot/dts/r7s72100-grpeach.dtb linux-build/arch/arm/boot/dts/r7s72100-grpeach.dtb.bin


A minimal initrd image (< 2 MB) can be loaded in flash storage, and mounted as rootfs. Create a squash archive from your initrd archive with the following

mksquashfs $INITRD initrd-squash.bin -b 1024k

Make sure memory offsets from flash memory mapping address matches both the device tree node describing the rootfs partition, and the address where it gets actually loaded.

rootfs@18600000 {
       label = "rootfs";
       reg = <0x00600000 0x00200000>; /* 2MB @ 0x18600000 */

Also, make sure your kernel configuration supports accessing squashfs archives


Flash procedure

We'll use Segger J-Link as it ships with the ability to write directly to QSPI flash chip while in dual mode (during u-boot execution, not after the kernel has loaded).

All the below commands write directly to QSPI flash. It is however possible to load each component in SRAM, and use u-boot to write QSPI. See [[1]]

For sake of simplicity, we assume dtb file, kernel xipImage and initrd-squash have all been copied to /tmp directory, with .bin extension appended

Connect your J-Link and enter its command line to write QSPI flash directly

$JLinkExe -speed 15000 -if JTAG -jtagconf -1,-1  -device R7S721001
J-Link>loadbin /tmp/r7s72100-grpeach.dtb.bin,0x180C0000
J-Link>loadbin /tmp/xipImage.bin,0x18100000
J-Link>loadbin /tmp/initrd-squash.bin,0x18600000

Now resume u-boot execution and run the above specified bootcmd command. Linux should load up to your very minimal boot environment and present you a login screen.

boot (Linux 4.11.0-00011-g51978fd-dirty, BusyBox v1.17.0.git, )