Nuclei-Software / nuclei-linux-sdk

Nuclei RISC-V Linux Software Development Kit
Apache License 2.0
38 stars 9 forks source link

AMP Demo about Linux + FreeRTOS #18

Open fanghuaqi opened 7 months ago

fanghuaqi commented 7 months ago

Let us take Nuclei U900FD(rv32imafdc) 2 SMP Core as example, CPU 0 run Linux Kernel 5.10, and CPU 1 run FreeRTOS demo.

Similar changes could be maded on UX900FD Core and 6.1 Linux Kernel.

Both Linux and FreeRTOS runs on DDR memory:

  1. Let us clone source code and switch to dev_nuclei_5.10_v2 branch, following steps #10

  2. Modify conf/evalsoc/build.mk and conf/evalsoc/freeloader.mk as below:

diff --git a/conf/evalsoc/build.mk b/conf/evalsoc/build.mk
index c18315c..220ec62 100644
--- a/conf/evalsoc/build.mk
+++ b/conf/evalsoc/build.mk
@@ -4,7 +4,7 @@ QEMU_MACHINE_OPTS := -M nuclei_evalsoc,download=flashxip -smp 8 -m 2G
 # initramfs pre command before generate initrd ramfs
 INITRAMFS_PRECMD := bash $(confdir)/preramfs.sh $(confdir) $(buildroot_initramfs_sysroot) copyfiles.txt
 # eg. $(confdir)/amp/cx.bin
-CORE1_APP_BIN :=
+CORE1_APP_BIN := $(confdir)/amp/amp_c1.bin
 CORE2_APP_BIN :=
 CORE3_APP_BIN :=
 CORE4_APP_BIN :=
diff --git a/conf/evalsoc/freeloader.mk b/conf/evalsoc/freeloader.mk
index 31e3d3b..7ac9644 100644
--- a/conf/evalsoc/freeloader.mk
+++ b/conf/evalsoc/freeloader.mk
@@ -12,4 +12,4 @@ ENABLE_SMP ?= 1
 ENABLE_L2 ?= 1
 AMPFW_START_OFFSET ?= 0x7E000000
 AMPFW_SIZE ?= 0x400000
-AMP_START_CORE ?= 8
+AMP_START_CORE ?= 1
  1. Clone Nuclei SDK 0.5.0 master branch from https://github.com/Nuclei-Software/nuclei-sdk

  2. Following steps in https://doc.nucleisys.com/nuclei_sdk/quickstart.html to setup Nuclei SDK build environment

  3. Download prepared ampdemo.zip and unzip it to /path/to/nuclei-sdk/application/freertos/

Now in Nuclei SDK folder

cd /path/to/nuclei-sdk/application/freertos/ampdemo
# make sure Makefile is in this ampdemo folder
# build this application for U900FD, and generate binary
make CORE=u900fd clean
make CORE=u900fd bin
# sample binary as below
$ ll -h freertos_demo.bin
-rwxr-xr-x 1 hqfang hqfang 130K Nov 16 18:03 freertos_demo.bin
# copy this binary to Nuclei Linux SDK's folder as  conf/evalsoc/amp/amp_c1.bin
mkdir -p /path/to/nuclei-linux-sdk/conf/evalsoc/amp/
cp -f freertos_demo.bin /path/to/nuclei-linux-sdk/conf/evalsoc/amp/amp_c1.bin
  1. Build Linux SDK for U900FD

Now in Nuclei Linux SDK folder, make sure you are using a clean and up to date dev_nuclei_5.10_v2 branch

cd /path/to/nuclei-linux-sdk
# build and generate freeloader and boot images for sdcard
# make sure step 1 changes have been made, and step 5 freertos binary has been copied
make CORE=u900fd freeloader bootimages

Get a 2 Core U900FD FPGA bitstream from Nuclei AE and evaluate it on hardware, this is not possible to run on Nuclei QEMU.

Following steps in https://github.com/Nuclei-Software/nuclei-linux-sdk/tree/dev_nuclei_5.10_v2#upload-freeloader-to-fpga-evaluation-board to upload freeloader and place boot images into SDCard.

Here is sample output, you can see freertos and linux both output in the same uart:

linux_5.10_freertos_ampdemo.log

Our prebuilt images could be found here: