Difference between revisions of "RZ-A/Boards/GR-PEACH-mainline"

From eLinux.org
Jump to: navigation, search
(u-boot)
(Linux Kernel)
Line 66: Line 66:
 
==Linux Kernel==
 
==Linux Kernel==
  
Please use ''renesas-drivers'' kernel tree that as per v4.11 contains the required driver support for Renesas RZ/A1 devices.
+
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.
  
git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git master
+
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.
  
As GR-Peach is currently not officially supported by mainline kernel, a device tree source file for it is required
+
A custom branch, with required patches to boot Linux v4.13 on GR-Peach is available at
 
+
  git://jmondi.org/linux/ v4.13/gr-peach
  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
 
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
Line 79: Line 78:
 
  CONFIG_MTD_OF_PARTS=y
 
  CONFIG_MTD_OF_PARTS=y
 
  CONFIG_MTD_ROM=y
 
  CONFIG_MTD_ROM=y
 +
 +
A sample defconfig is provided here for reference
 +
##gr-peach-defconfig
  
 
Build XIP kernel and dts
 
Build XIP kernel and dts
Line 84: Line 86:
 
  make JOBS=32 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- O=./linux-build xipImage dtbs
 
  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
 
  #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 arch/arm/boot/xipImage /tmp/xipImage.bin
  cp linux-build/arch/arm/boot/dts/r7s72100-grpeach.dtb linux-build/arch/arm/boot/dts/r7s72100-grpeach.dtb.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> go
 +
 
 +
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
  
 
==Initrd==
 
==Initrd==

Revision as of 07:15, 9 October 2017

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> go

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 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

##gr-peach-defconfig

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> go

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

Initrd

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 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>connect
J-Link>loadbin /tmp/r7s72100-grpeach.dtb.bin,0x180C0000
J-Link>loadbin /tmp/xipImage.bin,0x18100000
J-Link>loadbin /tmp/initrd-squash.bin,0x18600000
J-Linx>g
J-Linx>exit

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, )
#