Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuttX RV32 (QEMU) - Example #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

kassane
Copy link
Contributor

@kassane kassane commented Oct 12, 2024

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

@rauhul
Copy link
Collaborator

rauhul commented Oct 24, 2024

Heads up im extremely oversubscribed until early November, I did see this PR but won't be able to give you a good review until then. I do really want to include a sample using Nuttx if possible :)

@rauhul
Copy link
Collaborator

rauhul commented Nov 11, 2024

I think the example makes sense to add. However Im trying to get CI setup for this repo before adding additional examples, so avoid hosting broken code!

@kassane
Copy link
Contributor Author

kassane commented Nov 11, 2024

I think the example makes sense to add. However Im trying to get CI setup for this repo before adding additional examples, so avoid hosting broken code!

I believe that putting all the required dependencies in is not a problem.
Sadly, NuttX cmake support is not fully featured like make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants