Skip to content

Conversation

@alexandruradovici
Copy link
Contributor

@alexandruradovici alexandruradovici commented Nov 25, 2020

Pull Request Overview

This pull request fixes the stack size requirement for STM32F4 boards. Due to the new board instantiation #2188, the required stack size has to be doubled as @hudson-ayers suggested in #2188 (comment).

Testing Strategy

This pull request was tested using an STM32f412GDiscovery board.

TODO or Help Wanted

@krady21, @cosmindanielradu19, @teonaseverin please test using the STM32F3Discovery and Nucleo. Running the blink app is just enough.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

@krady21
Copy link
Contributor

krady21 commented Nov 25, 2020

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "--eh-frame-hdr" "-L" "/home/boco/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabi/lib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.12dwwfal2pk3xl9v.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.13gd6zpqlgsdcgb2.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.16xab2gadwd4x8v4.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.19jsfh0qdbiys8gp.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.1bqltkjzvzk2wh5g.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.1eqle9onac89688n.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.1t6a6yspesw3rox.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.1ygrwkderj23eqew.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.1ywblity7eptng7c.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.205ew61rbrn3lbdt.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.20cabhx8mclilud7.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.20d5yqonti8qsaxb.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.20drn350q0fz3f61.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.27s5p8bzgott9pp8.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.2besyqgm6jaibzjn.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.2bj7i85vtgeaaqoq.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.2depl18v2xy7l1yq.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.2peadg4ptxu13do5.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.2t5b7c9ewh5yyzs1.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.2ypyxshw3uwxz8ea.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.32oo67pxlv96y89m.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.33tqln3xjaq04ocn.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3byesfzut6g8romo.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3e1jqwbsot8kes1l.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3g7foi7kzrp1j6el.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3gtiz1lmniqzm0a8.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3gyxtc2i6e9ui5fu.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3imqfsqo1q4zzfpk.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3qiiw4sx3pjo6l5u.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3uxuz568rjdeif5w.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.3w49k0aicst04v8u.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.41keumdxvi1o1c7i.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.42t9z3mmn70qnbxv.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.435p1mnoknfi5ddo.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.47o87zxq0mw4tp33.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.48ymd19lt9nq1qg5.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4996p1ntye9vb609.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.49y1i9khupoa0qc0.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4hxtwwst55f8cgfl.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4kbcv82c246gbwtc.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4mipegrx5w5o8hrf.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4n7me65a9n94zkwm.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4nyvawmp8ss280qq.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4sk45npmajc4lnma.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.4tzmtp06cbe1evnc.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.50ctq1vg2yeftpqv.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.51fhfp4cipfq9csi.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.51wbpyalle7g8xfj.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.576pbcsquhm1lbib.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.57msu2uh3ep6l1nq.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.58txcighal9v4uym.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.59omotxqnfedh1q8.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.6eb9buzkszr7uep.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.9brf803j9iquacw.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.eyftsx60tvqzxap.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.i9ybrb7hz2ezpej.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.qo518nsaznuhmun.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.r1558i5kgcl8hu.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.w1wmelc9dj88yha.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.yiiz1lr3ks22i3.rcgu.o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc.yplp597qk324upm.rcgu.o" "-o" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/stm32f3discovery-8f4d9aebe9958cbc" "--gc-sections" "-L" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps" "-L" "/home/boco/upbiot/tock/target/debug/deps" "-L" "/home/boco/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabi/lib" "-Bstatic" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libstm32f303xc-b6405e54f36db0e8.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libtock_rt0-e74584d51947d188.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libcortexm4-f208e78f902a7048.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libcortexm-2415c161fe17acff.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libcomponents-80f083b8406ca8bc.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libcapsules-ba0842f859ac1b90.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libenum_primitive-59e405e8133c4deb.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libkernel-e04ebaf71cfb4bdd.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libtock_cells-356207d3adb49c10.rlib" "/home/boco/upbiot/tock/target/thumbv7em-none-eabi/debug/deps/libtock_registers-1e93443db3ab8848.rlib" "/home/boco/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabi/lib/librustc_std_workspace_core-494cca75eda583aa.rlib" "/home/boco/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabi/lib/libcore-93821ffd855ef33c.rlib" "/home/boco/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabi/lib/libcompiler_builtins-cf9e85ce112823b1.rlib" "-L/home/boco/upbiot/tock/boards/stm32f3discovery" "-Tlayout.ld" "-zmax-page-size=4096" "-icf=all" "-Bdynamic"
  = note: rust-lld: error: section '.ARM.exidx' will not fit in region 'rom': overflowed by 3292 bytes
          rust-lld: error: section '.storage' will not fit in region 'rom': overflowed by 3292 bytes
          rust-lld: error: section '.storage' will not fit in region 'rom': overflowed by 4096 bytes
          rust-lld: error: section '.storage' will not fit in region 'rom': overflowed by 4096 bytes
          rust-lld: error: 
          Text plus relocations exceeds the available ROM space.

@krady21
Copy link
Contributor

krady21 commented Nov 25, 2020

I tried changing memory space allocated to nonvolatile_storage in main.rs, but that didn't solve it. I managed to get it to compile only if i excluded nonvolatile_storage from main.rs. Sadly, the blink app even in that case didn't work. (so it must be something else besides the stack size)

@teonaseverin
Copy link
Contributor

It works normally on Nucleo-F429ZI.

@hudson-ayers
Copy link
Contributor

Thanks for testing and submitting this. I think the issue on stm32f3 is just a flash size issue that is separate from this. I'm going to look into that next week.

As an aside, the new peripheral instantiation approach requiring so much stack because it initializes all peripherals at once is a flaw. I'm going to try to rewrite the initialization code so only one peripheral is on the stack at a time, but that will also not be for a few days.

hudson-ayers
hudson-ayers previously approved these changes Nov 25, 2020
@krady21 krady21 mentioned this pull request Nov 26, 2020
2 tasks
@alexandruradovici alexandruradovici changed the title Stack size update for STM boards Stack size update for STM32F4 boards Nov 26, 2020
@alexandruradovici
Copy link
Contributor Author

Merging this as a quick fix would be helpful as no STM boards work right now.

Copy link
Contributor

@hudson-ayers hudson-ayers left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 27, 2020

@bors bors bot merged commit 9550f3b into tock:master Nov 27, 2020
bors bot added a commit that referenced this pull request Feb 9, 2021
2400: Double stack buffer for i.MX RT-based boards, prune panic! allocations r=bradjc a=mciantyre

### Pull Request Overview

This pull request doubles the stack buffer for boards that use i.MX RT chips. #2311 added board-based peripheral initialization for i.MX RT boards. We use more stack space (at least ~2KiB, most memory for GPIO pins) to initialize the static peripherals, which might exceed the stack buffer once the kernel starts running. Doubling the stack size seems to suffice for running the kernel and two applications on a Teensy 4.0. This approach is similar to #2223, which noted the issue in STM32 boards.

I first bisected the issue down to a commit in #2334. After that compiler update, I couldn't run the Tock kernel on the Teensy 4.0. But it turns out that, after #2311 and before the updated compiler, a `panic!()` would overflow the stack. So this seems to be a latent issue that manifested with a compiler update. The boards' panic handlers were allocating large GPIO ports structures just to access a single LED. This PR fixes that by exposing a constructor for individual GPIO pins, and using that constructor in the panic handler.

### Testing Strategy

This pull request was tested by rebasing onto trunk, compiling the kernel for a Teensy 4.0, and using the kernel to run two `libtock-c` example apps. Then, I added a `panic!()` just before the main kernel loop, and showed that the panic handler worked as expected.


### TODO or Help Wanted

There may be other boards that allocate large objects (GPIO ports and pins) in the panic handler. See the [stm32f3discovery board](https://github.com/tock/tock/blob/86079650ae9d2e5b7287571a2219050c76aa3f1c/boards/stm32f3discovery/src/io.rs#L72) and the [stm32f412gdiscovery board](https://github.com/tock/tock/blob/86079650ae9d2e5b7287571a2219050c76aa3f1c/boards/stm32f412gdiscovery/src/io.rs#L74) for two examples. Are we aware of this behaviors in these boards, or in other boards?

### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Ian McIntyre <[email protected]>
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.

4 participants