This is a cache of https://www.96boards.org/blog/hikey970-rt/. It is a snapshot of the page at 2024-11-25T04:12:51.054+0000.
96boards: Real time and ROS2 | Hikey970 RT Setup - 96Boards

96boards: Real time and ROS2 | Hikey970 RT Setup

Servando German Serrano
|

Real Time enablement on 96boards

The following is the first on a series of blogs targeting the enablement of real time capabilities on a range of 96boards.

We’ll kick off with the Hikey970, which features the HiSilicon Kirin 970 SoC with HiAI Architecture and a dedicated NPU. In addition of 6GB LPDDR4X 1866MHz memory, 64GB UFS 2.1 storage, Bluetooth ® wireless technology, WIFI, GPS among many other features.

The post is organized as follows:


Bootloader update

The bootloader needs to be updated to enable PCIE power on the board.

download the updated bootloader (fip.bin, l-loader.bin, sec_usb_xloader.img and sec_usb_xloader2.img) and the convenience script hisi-idt.py from http://people.linaro.org/~manivannan.sadhasivam/hikey970_images/.

Set the board to Recovery Mode and follow the steps to flash the updated bootloader, e.g. (assuming the board appears as ttyUSB0):

$ sudo python hisi-idt.py -d /dev/ttyUSB0 --img1 ./sec_usb_xloader.img --img2 ./sec_usb_xloader2.img --img3 ./l-loader.bin
$ sudo fastboot flash fastboot l-loader.bin
$ sudo fastboot flash fip fip.bin

Following the board jumper pins need to be set to fastboot mode as explained in https://www.96boards.org/documentation/consumer/hikey/hikey970/installation/linux-fastboot.md.html.

Kernel upgrade and flash

As mentioned at the beginning of this blog, our aim is to enable real time capabilities on the Hikey970 for further development.

The PREEMPT_RT patch changes the Linux kernel into being fully preemptible which enables real time capabilities on the patched kernel.

The preempt_rt patches are released for different kernel versions. Linux kernel v4.9.78 is the supported one for the Hikey970. Since there is no preempt_rt patch for this kernel version, a number of patches have been backported to v4.14.78 following Mani’s blog posts. The modified kernel can be found in https://github.com/sgermanserrano/96b-k/tree/hi970_4.14.78.

In order to build and flash the preempt_rt enabled kernel on the Hikey970:

  • Get kernel v4.14.78 from https://github.com/sgermanserrano/96b-k/tree/hi970_4.14.78
    $ git clone https://github.com/sgermanserrano/96b-k.git -b hi970_4.14.78 linux-4.14.78
    
  • download the appropriate preempt_rt patch:
    $ wget https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patch-4.14.78-rt47.patch.xz
    
  • Change directory to the kernel source and apply the patch:
    $ cd linux-4.14.78
    $ xzcat ../patch-4.14.78-rt47.patch.xz | patch -p1
    
  • download the kernel config:
    $ wget -O .config people.linaro.org/~servando.german.serrano/hikey970/config_hikey970
    
  • Build the kernel:
    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- dtbs modules Image
    
  • The modules can be installed into a local folder and should be copied on to the board before flashing the new kernel:
    $ mkdir hikey970_modules
    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=./hikey970_modules
    
  • Copy the modules to the board in /lib/modules/
  • Move up one level and download the ramdisk from http://people.linaro.org/~manivannan.sadhasivam/hikey970_images/ and convenience script from http://people.linaro.org/~servando.german.serrano/hikey970/:
    $ cd ..
    $ wget http://people.linaro.org/~manivannan.sadhasivam/hikey970_images/ramdisk.img
    $ wget http://people.linaro.org/~servando.german.serrano/hikey970/build_hi970_rt.sh
    
  • With the Hikey970 in fastboot mode, run the script to flash the compiled kernel:
    $ chmod +x build_hi970_rt.sh
    $ ./build_hi970_rt.sh
    
  • After flashing the kernel reboot the board and log into it, e.g. via the serial port. Now, if everything went well doing uname -v should show ... SMP PREEMPT RT ... so we can confirm that the running kernel has been successfully patched.

Note

It is possible that the Wifi does not connect automatically after flashing the rt enabled kernel. To enable it back again you need to log into the board via the serial interface, check that the wlan0 interface is available doing ifconfig -a and then:

$ sudo systemctl stop NetworkManager
$ sudo systemctl start NetworkManager

for it to restart.


Conclusion

Next week, we’ll make use of our new board setup to install ROS2 and test the pendulum demo which requires real time capabilities on the target hardware. In addition we’ll run a simple performance comparison between FastRTPS and Eclipse Cyclone DDS implementations.

This article is Part 1 in a 4-Part Series.

comments powered by Disqus