mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
risc-v/k230: kernel build for CanMV-K230 board
Changes: - Documentation/platforms/risc-v/k230 revised for both modes - arch/risc-v/include/k230/irq.h add S-mode IRQs - under arch/risc-v/src/k230 folder: - Make.defs drop use of k230_exception_m.S - hardware/k230_clint.h add S-mode defs, revised freq - k230_head.S unified flat/kernel mode support - k230_irq.c add S-mode support with debug dump - k230_mm_init.c revised for K230 S-mode - k230_start.c revised for flat/s-mode, - arch/risc-v/src/k230/k230_timerisr.c unified flat/s-mode support. - under boards/risc-v/k230/canmv230 folder: - configs/nsh/defconfig fix RAM size - include/board_memorymap.h cleanup for S-mode - src/.gitignore ignore romfs_boot.c - src/Makefile add romfs support Renames: - under boards/risc-v/k230/canmv230/src/ folder: - canmv_init.c from k230_appinit.c making room for more k230 devices Dropped: - under arch/risc-v/src/k230/ - k230_exception_m.S as hybrid mode not ready yet. New files in boards/riscv/k230/canmv230: - configs/knsh/defconfig S-mode config - scripts/ld-kernel.script S-mode linker script - src/romfs.h User space ROMFS defs needed in S-mode - src/romfs_stub.c Stub ROMFS image Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
@@ -10,27 +10,25 @@ The `K230 SDK <https://github.com/kendryte/k230_sdk>`_ contains source code, lib
|
||||
|
||||
K230 boots from CPU0 and loads U-Boot into DRAM first, then U-Boot kicks off OpenSBI wrapped Linux/RTT OS images on respective CPU cores accordingly.
|
||||
|
||||
The K230 U-Boot operates in machine mode, thus provides an ideal environment for NuttX. allowing one to run flat or kernel builds in theory.
|
||||
|
||||
The K230 U-Boot runs in machine mode, thus it can run flat or kernel NuttX builds. The kernel build shall run with or without SBI layer.
|
||||
|
||||
Preparations
|
||||
============
|
||||
|
||||
Please follow the K230 SDK to prepare a booting SD card for the board, or use prebuilt boot image from `here <https://kendryte-download.canaan-creative.com/developer/k230/k230_canmv_sdcard_v1.2_nncase_v2.5.1.img.gz>`_.
|
||||
Take the prebuilt CanMV-k230 boot image from `here <https://gitee.com/yf1972/filexfers/tree/canmv230-tools-for-nuttx-v1.2>` as the v1.2 K230 SDK doesn't provide RiscV standard PTE format support needed by NuttX. This package also contains extract of OpenSBI from K230 SDK v1.2 release, which is needed to wrap kernel build NuttX binary.
|
||||
|
||||
Make sure that before trying NuttX:
|
||||
|
||||
- The board can boot default SDK image normally.
|
||||
- U-Boot console can be accessed from host(e.g. `minicom -D /dev/ttyACM0`).
|
||||
- U-Boot has access to a TFTP service is available.
|
||||
- You can drop files to the TFTP service folder.
|
||||
- The board can boot K230 SDK image normally.
|
||||
- Device console access available (e.g. `minicom -D /dev/ttyACM0`).
|
||||
- U-Boot connectivity to TFTP service available.
|
||||
|
||||
Note for below NuttX tests, the SD image is only used to enter U-Boot console.
|
||||
For NuttX tests, the microSD card is only used to enter U-Boot console, NuttX isn't using any persistent storage on the target now.
|
||||
|
||||
RISC-V Toolchain
|
||||
================
|
||||
Toolchains
|
||||
==========
|
||||
|
||||
Before building NuttX for Star64, download the **RISC-V Toolchain riscv64-unknown-elf** from `XPack <https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack>`_ or use "gcc-riscv64-unknown-elf" on Ubuntu.
|
||||
Before building NuttX, download the **RISC-V Toolchain riscv64-unknown-elf** from `XPack <https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack>`_ or use the stock "gcc-riscv64-unknown-elf" on Ubuntu.
|
||||
|
||||
|
||||
Building
|
||||
@@ -46,18 +44,50 @@ Configure the NuttX project and build the project:
|
||||
$ tools/configure.sh canmv230:nsh
|
||||
$ make -j4
|
||||
|
||||
There should have `nuttx.bin` generated.
|
||||
This should have `nuttx.bin` generated, it can be used without OpenSBI wrapping on the board.
|
||||
|
||||
The kernel build requires two build passes: first pass to build kernel and apps, second pass to build the kernel with a ROMFS image that includes some built apps.
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ cd nuttx
|
||||
$ tools/configure.sh canmv230:knsh
|
||||
$ make -j4 # first pass for apps build preparations
|
||||
$ (make export; cd ../apps; tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.gz; make import)
|
||||
$ (cd ../apps/; tools/mkromfsimg.sh ../nuttx/boards/risc-v/k230/canmv230/src/romfs_boot.c)
|
||||
$ make -j4 # second pass to pick up ROMFS
|
||||
|
||||
The built `nuttx.bin` can be then wrapped with K230 OpenSBI like below:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ cd $HOME
|
||||
$ tar xvf canmv230-opensbi-dtb.tar.xz
|
||||
$ export OSBI=$HOME/opensbi
|
||||
$ cd /tmp/aaa # use a temporary work folder
|
||||
$ make -C $OSBI O=$(pwd) PLATFORM=generic\
|
||||
CROSS_COMPILE=riscv64-unknown-elf- FW_PIC=n K230_LIITLE_CORE=1\
|
||||
FW_FDT_PATH=$OSBI/k230.dtb FW_PAYLOAD_PATH=nuttx.bin -j4
|
||||
$ cp platform/generic/firmware/fw_payload.bin tftp-server-path/nuttx.bin
|
||||
|
||||
Note to use actual paths of SBI source tree, device dtb, TFTP folder etc when using above commands.
|
||||
|
||||
Booting
|
||||
=======
|
||||
|
||||
Copy the `nuttx.bin` to the TFTP service folder and work with the U-Boot console:
|
||||
Within U-boot console, load `nuttx.bin` from TFTP service and run it:
|
||||
|
||||
.. code:: console
|
||||
|
||||
k230# usb start
|
||||
k230# ping $serverip
|
||||
k230# tftp 8000000 nuttx.bin
|
||||
k230# boot_barememtal 0 8000000 $filesize
|
||||
k230# go 8000000
|
||||
|
||||
Then the `nsh> ` console should appear, type `help` to see available commands.
|
||||
|
||||
Issues
|
||||
======
|
||||
|
||||
- The `ostest` app only works with flat build.
|
||||
|
||||
Then the `nsh> `console should appear, type `help` to see available commands.
|
||||
|
||||
Reference in New Issue
Block a user