swift-embedded-examples icon indicating copy to clipboard operation
swift-embedded-examples copied to clipboard

NuttX RV32 (QEMU) - Example

Open kassane opened this issue 1 year ago • 0 comments

cc: @rauhul

The cmakelists was adapted to download, extract and build the automated NuttX to make it easier for experimental Swift-embedded use. The NuttX version used is the most recent with Swift 6 support.

Requirements

How to build

# list all supported boards
cmake -B build -DLIST_ALL_BOARDS=ON | less
# build configuration
cmake -B build -GNinja -DBOARD_CONFIG=rv-virt:leds_swift -DENABLE_NUTTX_TRACE=[ON|OFF]
# build
cmake --build build
# clean
cmake --build build -t distclean
# export NuttX as library
cmake --build build -t nuttx-libs
build-output
$ cmake -B build -GNinja -DBOARD_CONFIG=rv-virt:leds_swift
-- The Swift compiler identification is Apple 6.1
-- Check for working Swift compiler: /home/kassane/.local/bin/swiftc
-- Check for working Swift compiler: /home/kassane/.local/bin/swiftc - works
Cloning into 'apps'...
HEAD is now at ac11e3cba Adapt the new header file path of va_format.
Cloning into 'nuttx'...
HEAD is now at 10e44f8915 riscv_fork.c: Fix race condition when handling parent integer registers
-- BOARD_CONFIG: rv-virt:leds_swift
  Copy files
  Select CONFIG_HOST_LINUX=y
  Refreshing...
CP: arch/dummy/Kconfig to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/arch/dummy/dummy_kconfig
CP: boards/dummy/Kconfig to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/boards/dummy/dummy_kconfig
LN: platform/board to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/platform/dummy
LN: include/arch to arch/risc-v/include
LN: include/arch/board to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/boards/risc-v/qemu-rv/rv-virt/include
LN: drivers/platform to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/drivers/dummy
LN: include/arch/chip to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/arch/risc-v/include/qemu-rv
LN: arch/risc-v/src/chip to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/arch/risc-v/src/qemu-rv
LN: arch/risc-v/src/board to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/boards/risc-v/qemu-rv/rv-virt/src
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/audioutils
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/benchmarks
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/boot
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/canutils
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/crypto
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/database
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/examples/mcuboot
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/examples
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/fsutils
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/games
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/graphics
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/industry
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/inertial
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/interpreters/luamodules
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/interpreters
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/logging
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/lte
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/math
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/mlearning
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/netutils
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/sdr
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/system
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/testing
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/videoutils
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/wireless/bluetooth
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/wireless/ieee802154
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/wireless
mkkconfig in /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps
Loaded configuration '.config'
Configuration saved to '.config'
-- Configuring done (133.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build

$ cmake --build build
[2/3] Building NuttX
Create version.h
LN: platform/board to /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/apps/platform/dummy
Register: leds
Register: nsh
Register: sh
Register: ostest
Register: getprime
Register: leds_swift
Archive:  fdt/dtc.zip
039a99414e778332d8f9c04cbd3072e1dcc62798
# [...] Creating and inflating files

Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
CPP:  /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/boards/risc-v/qemu-rv/rv-virt/scripts/ld.script-> /home/kassane/swift-embedded-exLD: nuttx
riscv-none-elf-ld: warning: /home/kassane/swift-embedded-examples/nuttx-riscv-blink/build/nuttx/nuttx has a LOAD segment with RWX permissions
[3/3] Running utility command for build_nuttx
Output
qemu-system-riscv32 \
    -semihosting \
    -M virt,aclint=on \
    -cpu rv32 -smp 8 \
    -bios none \
    -kernel build/nuttx.elf \
    -nographic
NuttShell (NSH) NuttX-12.7.0
nsh> leds_swift
leds_main: led_daemon started

led_daemon (pid# 4): Running
led_daemon: Opening /dev/userleds
led_daemon: Supported LEDs 0x7
led_daemon: LED set 0x1
board_userled: LED 1 set to 1
board_userled: LED 2 set to 0
board_userled: LED 3 set to 0
nsh> led_daemon: LED set 0x0
board_userled: LED 1 set to 0
board_userled: LED 2 set to 0
board_userled: LED 3 set to 0
led_daemon: LED set 0x1
board_userled: LED 1 set to 1
board_userled: LED 2 set to 0
board_userled: LED 3 set to 0
led_daemon: LED set 0x0
# [...] see output in QEMU

Quit from QEMU: Ctrl-a x

References

kassane avatar Oct 12 '24 18:10 kassane