rushabhvg opened a new pull request, #2462:
URL: https://github.com/apache/nuttx-apps/pull/2462

   ## Summary
   - This PR adds `examples/leds_rust` to call NuttX POSIX APIs like `open()` 
and `ioctl()`, so that it blinks an LED
   - The `leds_rust` app is also used for testing the GPIO and LED Drivers for 
Ox64 BL808 SBC and QEMU RISC-V Emulator in Google Summer of Code
   - `leds_rust` be executed locally on Linux / macOS / Windows, by commenting 
out the first 2 lines of code
   - The code is based on `examples/leds` in C, and `examples/hello_rust` in 
Rust
   
   ### New Files in `examples/leds_rust`
   - `Kconfig`: Configuration file for `leds_rust` that defines 
`EXAMPLES_LEDS_RUST`
   - `Make.defs`: Build the app if `EXAMPLES_LEDS_RUST` is enabled
   - `Makefile`: Makefile for `leds_rust`
   - `leds_rust_main.rs`: Call NuttX POSIX APIs and LED driver to blink the LED
   - `nuttx.rs`: NuttX Module for Rust to access the NuttX POSIX APIs in a 
safer way
   
   ## Impact
   - With this PR, NuttX for Ox64 and QEMU will be able to test and verify the 
operation of LED in Rust.
   - No impact on existing code, since we are adding a Rust App in `examples` 
directory.
   
   ## Testing
   
   We tested on QEMU RISC-V Emulator with `rv-virt:leds` (32-bit) and 
`rv-virt:leds64` (64-bit):
   
   ```text
   $ tools/configure.sh rv-virt:leds / leds64
   $ kconfig-tweak --enable CONFIG_EXAMPLES_LEDS_RUST
   $ make olddefconfig
   ...
   NuttShell (NSH) NuttX-12.4.0
   nsh> uname -a
   NuttX 12.4.0 fe45d8aace2 Aug  1 2024 14:03:19 risc-v rv-virt
   
   nsh> leds_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> 
   ```
   
   - [Test Log for leds_rust on rv-virt:leds (QEMU RISC-V 
32-bit)](https://gist.github.com/lupyuen/397984f53ce066ce1c17b32e48b19bf5#file-leds-rust-leds-log-L219-L239)
   - [Build Script for leds_rust on rv-virt:leds (QEMU RISC-V 
32-bit)](https://gist.github.com/lupyuen/fe881428017b3df85f93fd0ebdce3983)
   - [Test Log for leds_rust on rv-virt:leds64 (QEMU RISC-V 
64-bit)](https://gist.github.com/lupyuen/a7df2500fc9041ed06f88016c9b05982#file-leds-rust-leds64-log-L494-L514)
   - [Build Script for leds_rust on rv-virt:leds64 (QEMU RISC-V 
64-bit)](https://gist.github.com/lupyuen/3df729463de95d0c998b347a4fc8346f)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to