Skip to content

__nocache section conflicts with __ramfunc on stm32h750 #88047

@xhpohanka

Description

@xhpohanka

Describe the bug

While playing with uart dma on my custom stm32h750 board (#87795) I have found a strange issue.
When I have both __ramfunc and __nocache then any call to function in ram ends with MPU FAULT.
If no __nocache memory is used functions in ram can be called normally, and vice versa.

There is probably some MPU misconfiguration, but I cannot find the exact issue, sections seem to be correctly placed and sized.

nocache         0x0000000024000000       0x20
                0x0000000024000000                . = ALIGN (_region_min_align)
                0x0000000024000000                . = ALIGN ((0x1 << LOG2CEIL (_nocache_ram_size)))
                0x0000000024000000                _nocache_ram_start = .
 *(SORT_BY_ALIGNMENT(.nocache))
 *(SORT_BY_ALIGNMENT(.nocache.*))
 .nocache."WEST_TOPDIR/test_mpu/src/main.c".0
                0x0000000024000000       0x20 app/libapp.a(main.c.obj)
                0x0000000024000020                . = ALIGN (_region_min_align)
                0x0000000024000020                . = ALIGN ((0x1 << LOG2CEIL (_nocache_ram_size)))
                0x0000000024000020                _nocache_ram_end = .
                0x0000000000000020                _nocache_ram_size = (_nocache_ram_end - _nocache_ram_start)

.ramfunc        0x0000000024000020       0xe0 load address 0x000000009003ce0c
                0x0000000024000020                . = ALIGN (_region_min_align)
                0x0000000024000080                . = ALIGN ((0x1 << LOG2CEIL (__ramfunc_size)))
 *fill*         0x0000000024000020       0x60 
                0x0000000024000080                __ramfunc_start = .
 *(SORT_BY_ALIGNMENT(.ramfunc))
 .ramfunc       0x0000000024000080       0x30 app/libapp.a(main.c.obj)
 .ramfunc.__stub
                0x00000000240000b0        0x8 linker stubs
 *(SORT_BY_ALIGNMENT(.ramfunc.*))
                0x00000000240000c0                . = ALIGN (_region_min_align)
 *fill*         0x00000000240000b8        0x8 
                0x0000000024000100                . = ALIGN ((0x1 << LOG2CEIL (__ramfunc_size)))
 *fill*         0x00000000240000c0       0x40 
                0x0000000024000100                __ramfunc_end = .
                0x0000000000000080                __ramfunc_size = (__ramfunc_end - __ramfunc_start)
                0x000000009003ce0c                __ramfunc_load_start = LOADADDR (.ramfunc)

I have prepared minimal example where the issue can be easily seen
test_mpu.zip

Note: I run my code from external qspi flash

To Reproduce
Steps to reproduce the behavior:

  1. use my minimal example on similar hw
  2. see the error

Logs and console output

*** Booting Zephyr OS build v3.7.1-78-gf000b8a131f3 ***
[00:00:00.074,000] <inf> net_config: Initializing network
[00:00:00.082,000] <inf> net_config: Waiting interface 1 (0x24001418) to be up...
[00:00:04.259,000] <inf> net_config: Interface 1 (0x24001418) coming up
[00:00:04.270,000] <inf> net_config: Running dhcpv4 client...
[00:00:04.281,000] <inf> test_mpu: main loop
[00:00:05.288,000] <inf> test_mpu: main loop
[00:00:06.296,000] <inf> test_mpu: main loop
[00:00:07.274,000] <inf> net_dhcpv4: Received: 10.42.0.175
[00:00:07.284,000] <inf> net_config: IPv4 address: 10.42.0.175
[00:00:07.293,000] <inf> net_config: Lease time: 3600 seconds
[00:00:07.301,000] <inf> net_config: Subnet: 255.255.255.0
[00:00:07.309,000] <inf> net_config: Router: 10.42.0.1
[00:00:07.319,000] <inf> test_mpu: main loop
[00:00:08.326,000] <inf> test_mpu: main loop
[00:00:09.333,000] <inf> test_mpu: main loop
[00:00:10.341,000] <inf> test_mpu: main loop
[00:00:10.474,000] <inf> phy_mii: PHY (0) Link speed 100 Mb, full duplex
[00:00:11.348,000] <inf> test_mpu: main loop
[00:00:12.356,000] <inf> test_mpu: main loop
[00:00:13.364,000] <inf> test_mpu: main loop
[00:00:14.281,000] <inf> test_mpu: work timeout
[00:00:14.289,000] <err> os: ***** MPU FAULT *****
[00:00:14.297,000] <err> os:   Instruction Access Violation
[00:00:14.305,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x000024d0  r2/a3:  0x24002ec0
[00:00:14.316,000] <err> os: r3/a4:  0x00000002 r12/ip:  0x00000000 r14/lr:  0x90024191
[00:00:14.327,000] <err> os:  xpsr:  0x61000000
[00:00:14.334,000] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x24002ec0  s[ 3]:  0x24000081
[00:00:14.347,000] <err> os: s[ 4]:  0x240014d8  s[ 5]:  0x90024191  s[ 6]:  0xffffffff  s[ 7]:  0xffffffff
[00:00:14.359,000] <err> os: s[ 8]:  0x00000000  s[ 9]:  0xaaaaaaaa  s[10]:  0xaaaaaaaa  s[11]:  0x2400a7f0
[00:00:14.372,000] <err> os: s[12]:  0x9002408d  s[13]:  0x24002ec0  s[14]:  0x00000000  s[15]:  0x00000000
[00:00:14.384,000] <err> os: fpscr:  0x00000008
[00:00:14.392,000] <err> os: Faulting instruction address (r15/pc): 0x24000100
[00:00:14.402,000] <err> os: >>> ZEPHYR FATAL ERROR 20: Unknown error on CPU 0
[00:00:14.412,000] <err> os: Current thread: 0x24002ec0 (sysworkq)
[00:00:14.421,000] <err> os: Halting system

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK
  • v3.7.1

Metadata

Metadata

Assignees

Labels

bugThe issue is a bug, or the PR is fixing a bugplatform: STM32ST Micro STM32priority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions