Tests:r-car-gen3-kexec

This document describes how to test the kexec functionality of R-Car Gen3 based boards.

= Environment =


 * Hardware:
 * Salvator-X/r8a7796 (Gen 3 R-Car H3 SoC)
 * Software:
 * Kernel: v4.8-rc2
 * kexec-tools: git://git.kernel.org/pub/scm/linux/kernel/git/geoff/kexec-tools.git for-merge-arm64-v5 (v2.0.13 + arm64 patches)

= Prepare Cross Compiler (Optional) =

For the work described here code was cross compiled compiled on an x86_64 system. The cross compiler used was installed as follows.

cd $SOMEWHERE wget http://releases.linaro.org/archive/14.11/components/toolchain/binaries/aarch64-linux-gnu/gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu.tar.xz tar -Jxf gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu.tar.xz export CROSS=aarch64-linux-gnu- export PATH=$PATH:$SOMEWHERE/gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu/bin

= Prepare kexec-tools =

The for-merge-arm64-v5 branch of git://git.kernel.org/pub/scm/linux/kernel/git/geoff/kexec-tools.git was used.

This corresponds to "[PATCH v5 0/3] arm64 kexec-tools patches", the latest version of the kexec-tools patchset by Geoff Levand at the time of writing.

LDFLAGS=-static is optional. It is used to build static binaries for inclusion in initrd without libraries.

$ ./bootstrap $ LDFLAGS=-static ./configure --host=aarch64-linux-gnu $ make

The resulting kexec binary is ./build/sbin/kexec

= Prepare 2nd Kernel Initrd =

Buildroot 2016.08 was used to create an initrd image.

$ https://buildroot.org/downloads/buildroot-2016.08.tar.gz $ tar -zxf buildroot-2016.08.tar.gz $ cd buildroot-2016.08

For reference a config is provided. To use it, copy it to .config in the working directory.

$ make oldconfig $ make

The resulting initrd will be present in output/images/rootfs.cpio

= Prepare 2nd Kernel =

The kernel was build using this config.

The CONFIG_INITRAMFS_SOURCE option should be updated to reflect the patth to the 2nd kernel initrd.

With the config present as .config in the kernel source directory the kernel may be built:

$ ARCH=arm64 make

= Prepare 1st Kernel Initrd =

The 1st kernel initrd is prepared by adding kexec, and the Image and DTB for the 2nd kernel to the 2nd kernel initrd.

$ mkdir root $ cp $KEXEC_TOOLS_SOURCE/ $ cp $KERNEL_SOURCE/arch/arm64/boot/Image root/ $ cp $KERNEL_SOURCE/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dtb root/ $ cp rootfs-2nd.cpio rootfs-1st.cpio $ find root | cpio -o --force-local --format=newc --append --file=rootfs-1st.cpio

The result may then be compressed (optional).

gzip --best rootfs-1st.cpio

= Prepare 1st Kernel =

= Prepare 2nd Kernel =

The kernel was build using this config.

The CONFIG_INITRAMFS_SOURCE option should be updated to reflect the path to the 1st kernel initrd.

With the config present as .config in the kernel source directory the kernel may be built:

$ ARCH=arm64 make

= Perform Kexec =

With the above preparation in place it should now be possible to use kexec to perform a soft-boot from the 1st to 2nd kernel.

1. Boot using the 1st kernel and its accompanying DTB.

2. Load 2nd kernel and DTB using kexec-tools: kexec -l --dtb=r8a7796-salvator-x.dtb Image

3. Execute kexec kexec -e

After a few moments the 2nd kernel should boot.