diff --git a/.gitmodules b/.gitmodules index 419e437ac5cb82d32798f0661eec52b7dfa695d9..0cc7d000a62429846821c9bd4c73deb9803bcafc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -114,3 +114,6 @@ ignore = all path = boards/ppc64/powernv/bsp url = https://gitee.com/tinylab/qemu-ppc64-powernv +[submodule "boards/riscv64/licheepi4a/bsp"] + path = boards/riscv64/licheepi4a/bsp + url = https://gitee.com/tinylab/sipeed-riscv64-licheepi4a.git diff --git a/boards/riscv64/licheepi4a/Makefile b/boards/riscv64/licheepi4a/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..481da02a8358c7ee634f61d7afbcbed8d13af76a --- /dev/null +++ b/boards/riscv64/licheepi4a/Makefile @@ -0,0 +1,30 @@ +# Copyright (C) 2020 Wu Zhangjin +# _BASE: 1, virt; 2, real; 3: virt+real +_BASE := 2 +ARCH := riscv +XARCH := riscv64 +CPU ?= th1520 +SMP ?= 4 +MEM ?= 8G +LINUX ?= v6.5 + +BUILDROOT?= 2023.02.2 +SERIAL ?= ttyS0 + +ROOTDEV_LIST := /dev/mmcblk0 +ROOTDEV ?= /dev/mmcblk0 +FSTYPE ?= ext4 +ROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.cpio.gz + +ORIIMG ?= arch/$(ARCH)/boot/Image +DIMAGE ?= light_lpi4a.dtb +ORIDTB ?= arch/$(ARCH)/boot/dts/thead/th1520-beaglev-ahead.dtb +KIMAGE ?= $(BSP_KERNEL)/$(LINUX)/Image +KRELEASE?= $(BSP_KERNEL)/$(LINUX)/kernel.release +DTB ?= $(BSP_KERNEL)/$(LINUX)/$(DIMAGE) + +# fw_dynamic.bin is built from https://github.com/xhackerustc/thead-opensbi +BIOS ?= $(BSP_BIOS)/opensbi/generic/fw_dynamic.bin + +# u-boot-with-spl.bin is built from https://github.com/revyos/thead-u-boot +BIMAGE ?= $(BSP_UBOOT)/u-boot-with-spl.bin diff --git a/boards/riscv64/licheepi4a/README.md b/boards/riscv64/licheepi4a/README.md new file mode 100644 index 0000000000000000000000000000000000000000..457e5002c17e6a452bf856b605799f1ea49a46aa --- /dev/null +++ b/boards/riscv64/licheepi4a/README.md @@ -0,0 +1,78 @@ + +# LicheePi 4A Usage + +## Basic Usage + +Use the following command to compile kernel and dts: + + $ make kernel + +Some work can be done automatically: + +1. Build the cross compiler +2. Switch to the selected kernel version +3. Patch the kernel with patches in bsp/patch/linux/ +4. Use config in bsp/configs/ as kernel config +5. Compile the kernel +6. Compile the dts + +## Burn + +The process of burning images onto the board can be referenced in bsp/burn_tools/README.md. + +## DTB + +Notice for burning: + +The compiled dtb shoule be renamed as light_lpi4a.dtb because U-Boot use this filename as the default dtb. + +Or you can modify the default config of /extlinux/extlinux.conf in boot.ext4. + +## BIOS + +Riscv64 requires a proxy kernel to do some prepare before running the real linux kernel. + +And the proxy kernel currently is replaced by the OpenSBI project. + +The OpenSBI used here is specially made for T-Head SoCs. + +More detailed instruction is in bsp/bios/opensbi/README.md. + +## U-Boot + +The U-Boot used here is specially made for T-Head SoCs. + +More detailed instruction is in bsp/uboot/README.md. + +## Latency testing + +After successfully booting the Linux on the board, real-time testing can be performed. + +Stress-ng can be used for generating system loads. + +I have tested real-time latency with the following stress-ng options: + +* stress-ng --cpu 4 +* stress-ng --vm 8 --vm-bytes 2G +* stress-ng --hdd 4 + +Cyclictest and Ftrace can be used for latency testing and tracing. + +Script for reference: + + $ mount -t tracefs none /sys/kernel/tracing + $ cd /sys/kernel/tracing + $ echo wakeup_rt > current_tracer + $ echo 1 > tracing_on + $ echo 0 > tracing_max_latency + $ stress-ng --cpu 4 & + $ cyclictest --mlockall --smp --priority=99 --distance=0 --duration=30m + $ echo 0 > tracing_on + $ cat trace + +## References + +* [Sipeed LicheePi 4A Documentation](https://wiki.sipeed.com/hardware/zh/lichee/th1520/lpi4a/1_intro.html) +* [T-Head OpenSBI](https://github.com/xhackerustc/thead-opensbi) +* [T-Head U-Boot](https://github.com/revyos/thead-u-boot) +* [Latency debugging with tracing](https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/cyclictest/tracing) diff --git a/boards/riscv64/licheepi4a/bsp b/boards/riscv64/licheepi4a/bsp new file mode 160000 index 0000000000000000000000000000000000000000..3234357d133328c7286531b9c56876f847222e8e --- /dev/null +++ b/boards/riscv64/licheepi4a/bsp @@ -0,0 +1 @@ +Subproject commit 3234357d133328c7286531b9c56876f847222e8e