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

Blink test #13

Open
cmcavity opened this issue Jul 18, 2018 · 4 comments
Open

Blink test #13

cmcavity opened this issue Jul 18, 2018 · 4 comments

Comments

@cmcavity
Copy link
Contributor

After the update to the Tock submodule, the blink test now fails to compile.

// Set this function to run whatever test you desire. Test functions are named XXX_test by convention.
pub fn test() {
spi::spi_test();
}
// Set this to true to make the kernel run the test instead of main.
pub const TEST: bool = false;

When this code is changed to run blink::blink_test(), we get the output: "error: linking with arm-none-eabi-gcc failed: exit code: 1".

This is the blink test:

pub fn blink_test() {
loop {
led_toggle();
delay();
}
}

If we change the test to use for _ in 1..1000_000 {} instead of loop {}, it compiles and passes, but it is unclear why the use of loop {} causes a compile error.

@alevy
Copy link
Member

alevy commented Jul 18, 2018

I'm not able to reproduce this. It compiles fine for me with the blink_test replacing the spi_test. Are you certain you're using the right version of Rust? Maybe a make clean first?

@cmcavity
Copy link
Contributor Author

Did you also change line 26 to pub const TEST: bool = true; ?

@alevy
Copy link
Member

alevy commented Jul 18, 2018

OK, got it now. It's not exactly a compilation error, it's a link time error, and it could be useful to include the linker error:

  = note: /var/local/alevy/hack/helena/tock-teensy/boards/teensy/target/thumbv7em-none-eabi/release/deps/teensy-2fd7a6e3494a6943.teensy0.rcgu.o: In function `mk66::hard_fault_handler':
          teensy0-e3f15d6091c6d8ba2affd3b5a05ecb68.rs:(.text._ZN4mk6618hard_fault_handler17h661e85eb5618eaeaE+0x384): undefined reference to `SYSCALL_FIRED'
          teensy0-e3f15d6091c6d8ba2affd3b5a05ecb68.rs:(.text._ZN4mk6618hard_fault_handler17h661e85eb5618eaeaE+0x388): undefined reference to `APP_FAULT'
          /var/local/alevy/hack/helena/tock-teensy/boards/teensy/target/thumbv7em-none-eabi/release/deps/teensy-2fd7a6e3494a6943.teensy0.rcgu.o: In function `to_kernel':
          teensy0-e3f15d6091c6d8ba2affd3b5a05ecb68.rs:(.text._ZN8cortexm411svc_handler17h3f9d44e363dd8ae7E+0x34): undefined reference to `SYSCALL_FIRED'
          collect2: error: ld returned 1 exit status

What's happening is it's not finding the symbols SYSCALL_FIRED and APP_FAULT, which are declared in the kernel::process.

The reason loop vs for _ 0..1000 makes a difference is that in the second case, the test terminates, while in the first it doesn't. If it doesn't terminate, because it's called before the kernel's main loop, the compiler will decide that there is no way to reach code that uses that symbol in the kernel crate, and elide the symbol from the object file.

The fix for this is to mark each of those symbols as #[used] in process.rs (tested and confirmed), but meanwhile, is there a reason for the blink test to never terminate? Why not adapt the blink example from the course that uses a timer and is asynchronous?

@cmcavity
Copy link
Contributor Author

Could you point me to that blink example?

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

No branches or pull requests

2 participants