Skip to content

NanoPI from scratch

Introduction

The goal of this laboratory is to Configure Buildroot from scratch for the NanoPI Neo Plus2 and generate a workable image. Make sure to describe your actions and solutions, especially regarding the various questions asked.

Configure Buildroot

Configure Buildroot according to the instructions below:

  • Clone a new version of Buildroot in /workspace/buildroot2
  • Similarly to what you did in the previous lab, create a new “ses” branch based on Buildroot version 2022.08.3.
  • Make a copy of the NanoPI Neo Plus2 defconfig (friendlyarm_nanopi_neo_plus2_defconfig) into ses_defconfig
  • Create this directory for future patches: board/friendlyarm/nanopi-neo-plus2/patches
  • Configure Buildroot with ses_defconfig

In the Buildroot configuration (menuconfig), make sure you have the following settings:

Toolchain --->
  C library (glibc)
  Kernel Headers (Manually specified Linux version)
  (6.3.6) linux version
  Custom kernel headers series (5.17.x or later)

Build options --->
  (board/friendlyarm/nanopi-neo-plus2/patches) global patch directories
  Stack Smashing Protection (None)

Kernel --->
  (6.3.6) Kernel version

Target packages --->
  Debugging, profiling and benchmark ---> strace
  Networking applications ---> iptables and openssh
  Shell and utilities ---> file

Filesystem images --->
  (200M) exact size

Bootloaders --->
  (2020.10-rc5) U-Boot version
  BOARDNAME -> nanopi_neo_plus2

Host utilities --->
  [*] host u-boot tools`
  [*]   Flattened Image Tree (FIT) support`
  [*]   FIT signature verification support`
  [ ]   Environment image (NEW)`
  [*]   Generate a U-Boot boot script`
  (board/friendlyarm/nanopi-neo-plus2/boot.cmd) U-Boot boot script source

Save the configuration to configs/ses_defconfig

You can now start the build.

Question 1

After a while, you should get the following error:

make[1]: Entering directory '/workspace/buildroot2/output/build/host-uboot-tools-2021.07'
  UPD     include/generated/timestamp_autogenerated.h
  AR      tools/env/built-in.o
  HOSTCC  tools/env/crc32.o
  HOSTCC  tools/env/ctype.o
  HOSTCC  tools/env/env_attr.o
  HOSTCC  tools/env/env_flags.o
  HOSTCC  tools/env/fw_env.o
  HOSTCC  tools/env/linux_string.o
  AR      tools/env/lib.a
  HOSTCC  tools/env/fw_env_main.o
  HOSTLD  tools/env/fw_printenv
  STRIP   tools/env/fw_printenv
make[1]: Leaving directory '/workspace/buildroot2/output/build/host-uboot-tools-2021.07'
/workspace/buildroot2/output/build/host-uboot-tools-2021.07/tools/mkimage -C none -A arm64 -T script -d board/friendlyarm/nanopi-neo-plus2/boot.cmd /workspace/buildroot2/output/build/host-uboot-tools-2021.07/tools/boot.scr
/workspace/buildroot2/output/build/host-uboot-tools-2021.07/tools/mkimage: Can't stat board/friendlyarm/nanopi-neo-plus2/boot.cmd: No such file or directory
make: *** [package/pkg-generic.mk:293: /workspace/buildroot2/output/build/host-uboot-tools-2021.07/.stamp_built] Error 1

Explain the reason of this error and how to fix it. Once fixed, restart the build.

Question 2

After a little while, you should get another error:

Explain the source of this error and create a patch to fix it. Place your patch in the global patch directory, then restart the build process. Describe how you created the patch (with git) and give the patch’s content.

Question 3

Similarly to the previous lab, flash the SD card with the generated disk image, insert the SD card in your NanoPi and boot your target.

Observing the boot process, you should see these U-Boot messages (excerpt):

switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
144 bytes read in 2 ms (70.3 KiB/s)
1:  linux
Retrieving file: /Image
39475712 bytes read in 1887 ms (19.9 MiB/s)
append: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait
Retrieving file: /sun50i-h5-nanopi-neo-plus2.dtb
22509 bytes read in 4 ms (5.4 MiB/s)

However, what we would like to see is this:

switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
279 bytes read in 2 ms (135.7 KiB/s)
## Executing script at 4fc00000
39475712 bytes read in 1887 ms (19.9 MiB/s)
22509 bytes read in 4 ms (5.4 MiB/s)

As you can see, currently U-Boot reads /extlinux/extlinux.conf, but instead we want it to execute our boot.scr script.

Correct this issue and explain how you solved it.

Rebuild the disk image, reboot your target and make sure you see the expected logs as mentioned above:

...
Found U-Boot script /boot.scr
...