RZ-A/Boards/GR-PEACH-mainline
Contents
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.
u-boot
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.
Last available version of custom u-boot version is 'u-boot-2017.05'
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- grpeach_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- all
Flash u-boot version in QSPI at address 0x18000000
$JLinkExe -speed 15000 -if JTAG -jtagconf -1,-1 -device R7S721001 J-Link>connect J-Link> loadbin /tmp/u-boot.bin,0x18000000 J-Link> g
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.
Linux
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.
https://github.com/renesas-rz/rza_linux-4.9/commit/089a4d18a91debfcd68fc55f5ac561f1f7d5d653 https://github.com/renesas-rz/rza_linux-4.9/commit/089a4d18a91debfcd68fc55f5ac561f1f7d5d653.patch
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.
CONFIG_XIP_KERNEL=y CONFIG_XIP_PHYS_ADDR=0x18100000 CONFIG_PHYS_OFFSET=0x20000000
Linux Kernel
As of Linux v4.13 support for GR-Peach is currently not fully merged, and some out of tree patches are required to have Linux boot properly on the platform.
Most of the out-of-tree patches will land in Linux v4.14, while some other (cfr. XIP kernel Kconfig option support for multiarch platforms) are still under discussion.
A custom branch, with required patches to boot XIP Linux v4.13 on GR-Peach is available at
git://jmondi.org/linux/ v4.13/gr-peach
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
CONFIG_MTD=y CONFIG_MTD_OF_PARTS=y CONFIG_MTD_ROM=y
A sample defconfig is provided here for reference
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 arch/arm/boot/xipImage /tmp/xipImage.bin cp arch/arm/boot/dts/r7s72100-grpeach.dtb /tmp/r7s72100-grpeach.dtb.bin
And load on target using J-Link to write to QSPI directly
$ JLinkExe -speed 15000 -if JTAG -jtagconf -1,-1 -device R7S721001 J-Link> connect J-Link> loadbin /tmp/r7s72100-grpeach.dtb.bin,0x180C0000 J-Link> loadbin /tmp/xipImage.bin,0x18100000 J-Link> g
Linux will boot and mount the partition on MTD as rootfs
U-Boot 2017.05-g3853f3a (Oct 09 2017 - 10:18:26 +0200) CPU: Renesas Electronics CPU rev 0.0 Board: GRPEACH DRAM: 10 MiB SF: Detected mx25l6405d with page size 256 Bytes, erase size 64 KiB, total 8 MiB In: serial_sh Out: serial_sh Err: serial_sh 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 Net: sh_eth Hit any key to stop autoboot: 0 SF: Detected mx25l6405d with page size 256 Bytes, erase size 64 KiB, total 8 MiB device 0 offset 0xc0000, size 0x10000 SF: 65536 bytes @ 0xc0000 Read: OK Current Mode: Read Mode (3-byte Addr) (RZ/A1 reset value) SF: Detected mx25l6405d with page size 256 Bytes, erase size 64 KiB, total 8 MiB New Mode: Quad I/O Read Mode (3-byte Addr) Booting Linux... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.13.0-00010-g3feef85 (jmondi@w540) (gcc version 4.9.3 (Ubuntu/Linaro 4.9.3-13ubuntu2)) #873 Mon Oct 9 12:33:51 CEST 2017
Rootfs on MTD partition
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
INITRD=path_to_your_initrd 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
CONFIG_SQUASHFS=y CONFIG_SQUASHFS_XATTR=y CONFIG_SQUASHFS_ZLIB=y CONFIG_SQUASHFS_LZ4=y CONFIG_SQUASHFS_LZO=y CONFIG_SQUASHFS_XZ=y
Flash rootfs image on MTD partition
JLinkExe -speed 15000 -if JTAG -jtagconf -1,-1 -device R7S721001 J-Link> connect J-Link> loadbin /tmp/initrd-squash.bin,0x18600000 J-Linx> g
NFS mount
Change bootargs to point rootfs to NFS share location (change IP addresses and root path according to your setup
--- a/arch/arm/boot/dts/r7s72100-gr-peach.dts +++ b/arch/arm/boot/dts/r7s72100-gr-peach.dts @@ -23,7 +23,7 @@ }; chosen { - bootargs = "ignore_loglevel rw root=/dev/mtdblock0"; + bootargs = "ignore_loglevel rw root=/dev/nfs ip=192.168.100.10 nfsroot=192.168.100.1:/srv/nfs/peach/ nfsrootdebug"; stdout-path = "serial0:115200n8"; };
Make sure config include the following symbols to mount rootfs on NFS share
CONFIG_FILE_LOCKING=y CONFIG_MANDATORY_FILE_LOCKING=y CONFIG_NFS_FS=y CONFIG_NFS_V2=y CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y CONFIG_LOCKD=y CONFIG_LOCKD_V4=y CONFIG_NFS_COMMON=y
Flash helper script
Use the following script to help with flashing bootloader, dts, linux or initrd to GR-Peach's QSPI flash (or SRAM)
Debug with GDB and hard breakpoints
J-Link provides a gdb server through which is possible to debug GR-Peach with hard breakpoints. Use the following script to help create a .gdbinit file and launch gdbserver to which connect a gdb instance to.
Happy debug!