Skip to content

Conversation

jdharuman
Copy link
Contributor

@jdharuman jdharuman commented Feb 23, 2025

Overview

Why do we need this change?
The FreeRTOS Rust Linux machine setup instructions in the README were outdated or unclear. Updating them ensures accurate and up-to-date guidance for setting up and running the project.

What has changed?

  • Updated the README with revised FreeRTOS Rust Linux machine setup instructions.
  • Included additional details and clarifications where necessary.
  • Changed the signature of set_on_assert() from taking a mutable reference (&mut self) to an immutable reference (&self)
11 |     unsafe {
   |     ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default

error[E0596]: cannot borrow immutable static item `FREERTOS_HOOKS` as mutable
  --> freertos-rust-examples/examples/linux/main.rs:12:9
   |
12 |         FREERTOS_HOOKS.set_on_assert(|| { println!("Assert hook called") });
   |         ^^^^^^^^^^^^^^ cannot borrow as mutable

For more information about this error, try `rustc --explain E0596`.
warning: `freertos-rust-examples` (example "linux") generated 1 warning

image

  • Ensured that the callback functionality remains intact, with the hook being callable through the do_on_assert() method when an assertion occurs.

Testing

  • Linux
    Linux console output:
~/git/FreeRTOS-rust user/jdharum..p-doc-update !1 > cargo run --example linux                                                         py platform

warning: freertos-rust-examples@0.1.1: /home/jayachandran/git/FreeRTOS-rust/freertos-rust/src/freertos/shim.c: In function 'freertos_rs_isr_yield':
warning: freertos-rust-examples@0.1.1: /home/jayachandran/git/FreeRTOS-rust/freertos-rust/src/freertos/shim.c:282:9: warning: implicit declaration of function 'portYIELD_FROM_ISR' [-Wimplicit-function-declaration]
warning: freertos-rust-examples@0.1.1:   282 |         portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
warning: freertos-rust-examples@0.1.1:       |         ^~~~~~~~~~~~~~~~~~
   Compiling freertos-rust-examples v0.1.1 (/home/jayachandran/git/FreeRTOS-rust/freertos-rust-examples)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/examples/linux`
Boxed int '15' (allocator test)
Starting FreeRTOS app ...
Task registered
Starting scheduler
Timer Resolution for Run TimeStats is 100 ticks per second.
Hello from Task! 0
Hello from Task! 1
Hello from Task! 2
Hello from Task! 3
Hello from Task! 4
Hello from Task! 5
Hello from Task! 6
^C

@jdharuman
Copy link
Contributor Author

@niondir @apullin @CaseySanchez @reitermarkus Could you please review the PR?

}

fn do_on_assert(&self) {
pub fn do_on_assert(&self) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need to be pub? I think the idea was that do_on_assert should only be called here by the assert handler so it shouldn't need to be pub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for clarification and reverted the changes

@schteve
Copy link
Collaborator

schteve commented Mar 24, 2025

Hi, thanks for the PR. Left one comment but otherwise LGTM

@schteve
Copy link
Collaborator

schteve commented May 8, 2025

Thanks again and apologies for the long delay

@schteve schteve merged commit 5337d61 into lobaro:master May 8, 2025
3 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.

2 participants