Sonoff NSPanel Pro 120: Building And Running Linux

Sonoff NSPanel Pro 120: Building And Running Linux

So, assuming we’ve already synced the RK3326 Linux SDK and are familiar with how Linux is booted, in this article, let’s compile a new Linux firmware and upload it to the device.

The Rockchip Linux SDK provides three rootfs options: Buildroot , Debian , and Yocto . I’ll choose Buildroot because its footprint is relatively small, it includes a display server (Wayland compositor), and theoretically, getting things to work on Buildroot will make it easier to adapt them for Debian and other systems.

From the .dts file extracted from the factory firmware, we know that the "px30-evb-ddr3-v10" configuration was used as a base. Let’s pick it up and compile the firmware.
Lets create a new configuration file in our SDK folder under device/rockchip/rk3326, and name it sonoff_nspanel_pro_120_defconfig with the folowing contents:

# RK_WIFIBT is not set
RK_WIFIBT_CHIP="RTL8723DS"
RK_KERNEL_DTS_NAME="px30-evb-ddr3-v10"

Just to clarify, we are disabling Wi-Fi/BT chip support as it generates a lot of debug messages while repeatedly retrying to establish a connection and eventually fails. We will investigate this issue later.

To compile, we need to start the build process and select our defconfig when prompted.

./build.sh

The scripts build all parts of the firmware and pack them into a single file, update.img, which can then be flashed all at once. Compiling the rootfs is the most time-consuming part, as it fetches all the necessary packages and creates the rootfs on the fly. Overall, it took me about 30 minutes.

At the end we have this files at the rockdev/ folder

  • uboot.img : Compiled by U-Boot.
  • misc.img : Used by the recovery system.
  • boot.img : Compiled by the kernel.
  • recovery.img : Compiled by the recovery system.
  • Backup partition : Reserved, temporarily unused.
  • rootfs.img : Compiled by Buildroot, Debian, or Yocto.
  • oem.img: Used by manufacturers to store their applications or data. Mounted in the /oem directory.
  • userdata.img: Used for applications to temporarily generate files or for end-user data. Mounted in the /userdata directory.
  • parameter.txt : Used to generate the GPT table header.
  • MiniLoader.bin : A special loader used to upload the firmware via the rockusb driver. It contains rkxx_miniloader_vx.xx.bin and rkxx_ddr_vx.xx.bin.
  • update.img: single update file that has all above partitions packed in one single file

These partitions are default, but they are subject to change. The major components, as we know, are MiniLoader.bin , uboot.img , boot.img , and rootfs.img .

Let’s upload the update.img to our Sonoff NSPanel 120 Pro and see if we can get Linux running. To do so, let’s put the panel into MaskRom mode as described here and execute the following from the SDK folder.

./rkflash.sh update

After a successful upload, I can see the boot log on UART, and after a few seconds, the following appears in lsusb:
Bus 001 Device 033: ID 2207:0006 Fuzhou Rockchip Electronics Company rk3xxx.
Surprisingly, it is an ADB device, and we can gain access to the root shell from there. Lets do it and check the linux and kernel version

Great we have Linux running with the 5.10 kernel!

That’s it for this article. In the next articles, we will try to gain control over all connected hardware, including the LCD panel, touchscreen, Wi-Fi/BT module, speaker, microphones, light sensor, and proximity sensor. Stay tuned!