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

risc-v/qemu-rv: Add LED Driver for QEMU RISC-V 32-bit and 64-bit #12762

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

rushabhvg
Copy link
Contributor

@rushabhvg rushabhvg commented Jul 24, 2024

Summary

  • This PR adds the LED Driver for QEMU RISC-V 32-bit and 64-bit (User LEDs and Auto LEDs)
  • QEMU RISC-V LED Driver will be used by the Rust Blinky App for Google Summer of Code
  • Blinking the LED is probably the most common Embedded Demo, and now it's supported by QEMU RISC-V
  • We added NuttX Configs rv-virt:leds and rv-virt:leds64 to support User LEDs for 32-bit and 64-bit RISC-V
  • Turning on/off a Simulated User LED will print a log message: "LED 1 set to 1"
  • The code is derived from NuttX PinePhone LED Driver

Modified Files in boards:

  • Kconfig: Added ARCH_HAVE_LEDS for QEMU RISC-V

Modified Files in boards/risc-v/qemu-rv/rv-virt:

  • include/board.h: Added LED Definitions
  • src/qemu_rv_appinit.c: Init User LEDs at startup
  • src/Makefile: Added source files for User LEDs and Auto LEDs
  • src/CMakeLists.txt: Added source files for User LEDs and Auto LEDs

New Files in boards/risc-v/qemu-rv/rv-virt:

  • src/qemu_rv_autoleds.c: QEMU RISC-V driver for Auto LEDs
  • src/qemu_rv_userleds.c: QEMU RISC-V driver for User LEDs
  • configs/leds/defconfig: NuttX Config for 32-bit RISC-V with User LEDs (rv-virt:leds)
  • configs/leds64/defconfig: NuttX Config for 64-bit RISC-V with User LEDs (rv-virt:leds64)

Updated Documentation:

  • platforms/risc-v/qemu-rv/boards/rv-virt/index.rst: Added rv-virt:leds and rv-virt:leds64

Impact

  • With this PR, NuttX for QEMU RISC-V (32-bit and 64-bit) will be able to control the Simulated User LEDs (for rv-virt:leds and rv-virt:leds64 only)
  • Auto LED Driver will be called by all QEMU RISC-V Boards at Startup, even when CONFIG_USERLED is disabled. We provided Empty Stub Functions for the Auto LED Driver, to minimise the impact on all QEMU RISC-V Boards.

Testing

We tested Rust Blinky App and the leds Example App on rv-virt:leds and rv-virt:leds64:

$ tools/configure.sh rv-virt:leds / leds64
...
nsh> uname -a
NuttX 0.0.0 e0ad35542b0 Jul 24 2024 08:27:18 risc-v rv-virt

nsh> hello_rust
Hello, Rust!!
Opening /dev/userleds
Set LED 1 to 1
board_userled: LED 1 set to 1
board_userled: LED 2 set to 0
board_userled: LED 3 set to 0
Sleeping...
Set LED 1 to 0
board_userled: LED 1 set to 0
board_userled: LED 2 set to 0
board_userled: LED 3 set to 0

nsh> leds
board_userled: LED 1 set to 1
board_userled: LED 2 set to 0
board_userled: LED 3 set to 0
...
nsh> ostest
ostest_main: Exiting with status 0

Regression Testing

For Regression Testing, we tested QEMU RISC-V Flat Build and Kernel Build, 32-bit and 64-bit:

$ tools/configure.sh rv-virt:nsh / nsh64 / knsh32 / knsh64
...
nsh> uname -a
NuttX 0.0.0 e0ad35542b0 Jul 24 2024 08:27:18 risc-v rv-virt
nsh> ostest
ostest_main: Exiting with status 0

@lupyuen lupyuen marked this pull request as ready for review July 24, 2024 15:15
Copy link
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again Rushabh for your awesome contribution to NuttX Kernel in Google Summer of Code! :-)

@lupyuen
Copy link
Member

lupyuen commented Jul 25, 2024

@rushabhvg Could you please Rebase To The Latest Master? It should fix the "imx9-sdimage.img" Issue for NuttX Continuous Integration thanks!

@rushabhvg
Copy link
Contributor Author

@lupyuen Yes, I have rebased to latest master and re-pushed the code. Thanks!

@lupyuen
Copy link
Member

lupyuen commented Jul 25, 2024

@rushabhvg Oops sorry we have a problem with the 2 defconfig files, it's missing the newline at the end of the files. Could you fix the newlines, then run tools/refresh.sh to verify? Remember to squash the commits thanks!

$ ./tools/refresh.sh --silent rv-virt:leds64
  Normalize rv-virt:leds64
75c75
< CONFIG_USERLED_LOWER=y
\ No newline at end of file
---
> CONFIG_USERLED_LOWER=y
Saving the new configuration file

$ ./tools/refresh.sh --silent rv-virt:leds
  Normalize rv-virt:leds
71c71
< CONFIG_USERLED_LOWER=y
\ No newline at end of file
---
> CONFIG_USERLED_LOWER=y
Saving the new configuration file

UPDATE: Sorry the rv-virt/smp and rv-virt/smp64 builds are also failing. I'll update you when I figure out what's wrong thanks!

@lupyuen lupyuen marked this pull request as draft July 25, 2024 15:42
- This PR adds the LED Driver for QEMU RISC-V 32-bit and 64-bit (User LEDs and Auto LEDs)
- QEMU RISC-V LED Driver will be used by the Rust Blinky App for Google Summer of Code
- Blinking the LED is probably the most common Embedded Demo, and now it's supported by QEMU RISC-V
- We added NuttX Configs `rv-virt:leds` and `rv-virt:leds64` to support User LEDs for 32-bit and 64-bit RISC-V
- Turning on/off a Simulated User LED will print a log message: "LED 1 set to 1"
- The code is derived from NuttX PinePhone LED Driver
@lupyuen lupyuen marked this pull request as ready for review July 25, 2024 18:10
@lupyuen
Copy link
Member

lupyuen commented Jul 25, 2024

The defconfig newlines are fixed and CMakeLists.txt has been updated. The build is now OK for rv-virt:smp and smp64. Thanks!

@rushabhvg
Copy link
Contributor Author

Thank you @lupyuen for the last minute fixes!

@acassis acassis merged commit 76bf628 into apache:master Jul 25, 2024
26 checks passed
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.

5 participants