Open aabadie opened 4 years ago
Second attempt at guessing at this solution:
https://github.com/RIOT-OS/RIOT/pull/14355#issuecomment-677558815
There is a difference between the cortex-m0+ and the cortex-m4(and higher) MPU. The cortex-m0+ minimum MPU region size is 256 bytes, whereas the cortex-m4 MPU minimum region size is 32 bytes.
What could be happening here is that on the cortex-m0+, the region is automatically increased to 256B, covering a larger area than initially expected.
A quick fix could be to disable mpu on stm32g0 but if it's possible to really fix it, then I would prefer that.
Also note that the cortex-m0+ doesn't have a separate mem_manage_handler
and triggers a hard fault when the MPU denies access.
Description
MPU doesn't work on cortex-m0+.
Initially it was enabled for stm32g0 and was resulting in the following problems:
Context switching is broken in master on stm32g0 CPUs (cortex-m0+). Every switch to the idle thread triggers an hard fault:
examples/hello_world
``` 2020-08-21 14:20:23,397 # main(): This is RIOT! (Version: 2020.10-devel-888-g0b639) 2020-08-21 14:20:23,398 # Hello World! 2020-08-21 14:20:23,402 # You are running RIOT on a(n) nucleo-g070rb board. 2020-08-21 14:20:23,405 # This board features a(n) stm32 MCU. 2020-08-21 14:20:23,406 # 2020-08-21 14:20:23,408 # Context before hardfault: ```examples/default
``` 2020-08-21 14:22:40,262 # main(): This is RIOT! (Version: 2020.10-devel-888-g0b639) 2020-08-21 14:22:40,263 # Welcome to RIOT! > 2020-08-21 14:22:40,263 # 2020-08-21 14:22:40,266 # Context before hardfault: ```tests/thread_flags
``` 2020-08-21 14:23:47,476 # Help: Press s to start test, r to print it is ready 2020-08-21 14:23:47,477 # 2020-08-21 14:23:47,479 # Context before hardfault: ```All these applications were working when the support was introduced in #14163.
Bisecting shows that the commit introducing the regression is 43d6c4147a8034a1a115a061a1b8ca0705c86222 from #14355. So it seems that it's rather an issue with MPU although the STM32G0 family provides that feature.
@bergzand @kaspar030, any idea what could be the problem ?
Steps to reproduce the issue
Just build and flash
examples/hello-world
and you'll get the following output:Expected results
Applications work
Actual results
All applications trigger an hard fault
Versions
make print-versions
``` Operating System Environment ---------------------------- Operating System: "Ubuntu" "20.04.1 LTS (Focal Fossa)" Kernel: Linux 5.4.0-42-generic x86_64 x86_64 System shell: /usr/bin/dash (probably dash) make's shell: /usr/bin/dash (probably dash) Installed compiler toolchains ----------------------------- native gcc: gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0 arm-none-eabi-gcc: arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599] avr-gcc: avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.2_1759) 5.4.0 mips-mti-elf-gcc: mips-mti-elf-gcc (Codescape GNU Tools 2016.05-03 for MIPS MTI Bare Metal) 4.9.2 msp430-elf-gcc: missing riscv-none-embed-gcc: riscv-none-embed-gcc (GNU MCU Eclipse RISC-V Embedded GCC, 64-bit) 8.2.0 xtensa-esp32-elf-gcc: missing xtensa-esp8266-elf-gcc: missing clang: clang version 10.0.0-4ubuntu1 Installed compiler libs ----------------------- arm-none-eabi-newlib: "3.1.0" mips-mti-elf-newlib: "2.1.0" msp430-elf-newlib: missing riscv-none-embed-newlib: "3.0.0" xtensa-esp32-elf-newlib: missing xtensa-esp8266-elf-newlib: missing avr-libc: "2.0.0" ("20150208") Installed development tools --------------------------- ccache: ccache version 3.7.7 cmake: cmake version 3.16.3 cppcheck: Cppcheck 1.90 doxygen: 1.8.17 git: git version 2.25.1 make: GNU Make 4.2.1 openocd: Open On-Chip Debugger 0.10.0+dev-01383-gd46f28c2e-dirty (2020-08-20-10:53) python: Python 3.8.2 python2: Python 2.7.18rc1 python3: Python 3.8.2 flake8: 3.7.9 (mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.8.2 on Linux coccinelle: missing ```