Skip to content

examples/hello_rust: Add feature to blink the LED - #1

Draft
rushabhvg wants to merge 1 commit into
masterfrom
nuttx-rust-build
Draft

rushabhvg wants to merge 1 commit into
masterfrom
nuttx-rust-build

Conversation

@rushabhvg

@rushabhvg rushabhvg commented Jul 3, 2024 •

Copy link
Copy Markdown
Owner

Summary

  • The existing Rust Demo App hello_rust only prints a message, it might be simplistic for a NuttX App. This PR extends hello_rust to call NuttX POSIX APIs like open() and ioctl(), so that it blinks an LED.
  • If the LED Driver is not available, the app terminates gracefully.
  • The updated hello_rust app is also used for testing the GPIO and LED Drivers for Ox64 BL808 SBC in Google Summer of Code.
  • The code is based on examples/leds in C.

Modified file examples/hello_rust:

  • hello_rust_main.rs: Call LED and GPIO drivers to turn the LED on and off

Impact

Testing

We tested the updated hello_rust app on Ox64 Emulator. The app blinks the Simulated LED correctly:

rushabhvg@rushabhvg-laptop:~/Desktop/nuttx$ ./temu nuttx.cfg
TinyEMU Emulator for Ox64 BL808 RISC-V SBC

NuttShell (NSH)
nsh> nx_start: CPU0: Beginning Idle Loop

nsh> uname -a
nxposix_spawn_exec: ERROR: exec failed: 2
NuttX 0.0.0 b8c1ce45e6 Jul  8 2024 13:30:17 risc-v ox64

nsh> hello_rust
nxtask_activate: hello_rust pid=4,TCB=0x5040b290
nxsig_tcbdispatch: TCB=0x5040b290 pid=4 signo=0 code=0 value=0 masked=NO
Hello, Rust!!
Opening /dev/userleds
Set LED 1 to 1
{"nuttxemu":{"gpio29":1}}
Sleeping...
Set LED 1 to 0
{"nuttxemu":{"gpio29":0}}
nxsig_tcbdispatch: TCB=0x5040af80 pid=3 signo=17 code=5 value=0 masked=NO
nxtask_exit: hello_rust pid=4,TCB=0x5040b290
nxsig_tcbdispatch: TCB=0x5040af80 pid=3 signo=17 code=5 value=0 masked=NO

@rushabhvg rushabhvg self-assigned this Jul 3, 2024

@lupyuen lupyuen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please retest Rust Blinky on Ox64 Emulator thanks :-)

Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
Comment thread examples/hello_rust/hello_rust_main.rs Outdated
@lupyuen lupyuen changed the title Update hello_rust_main.rs examples/hello_rust: Add the blinking of LED Jul 4, 2024
@lupyuen lupyuen changed the title examples/hello_rust: Add the blinking of LED examples/hello_rust: Add feature to blink the LED Jul 5, 2024
@rushabhvg
rushabhvg force-pushed the nuttx-rust-build branch 3 times, most recently from 0fa88f2 to 3951fd3 Compare July 8, 2024 09:31
- The existing Rust Demo App hello_rust only prints a message, it might be too simplistic for a NuttX App. This PR extends hello_rust to call NuttX POSIX APIs like open() and ioctl(), so that it blinks an LED.
- If the LED Driver is not available, the app terminates gracefully.
- The updated hello_rust app is also used for testing the GPIO and LED Drivers for Ox64 BL808 SBC in Google Summer of Code.
- The code is based on examples/leds in C.
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