Skip to content

Endless loop at startup for not optimized application started by bootloaderΒ #69789

@GeorgeCGV

Description

@GeorgeCGV

Describe the bug
The application freezes in an endless loop when the bootloader starts it.

The Zephyr calls z_arm_init_arch_hw_at_boot after the bootloader jumps to the application. It detects the enabled D-Cache and tries to disable it. That performs a call to SCB_DisableDCache that stucks in an endless loop.

The issue is related to ARM-software/CMSIS_5#620. I confirm that applying ARM-software/CMSIS_5#1426 to https://github.com/zephyrproject-rtos/cmsis fixes the problem.

The patch requires an addition:

#ifdef CONFIG_NO_OPTIMIZATIONS
#undef __OPTIMIZE__
#endif

Currently, Zephyr uses CMSISv5. The upstream fixes the issue in the develop branch that is not released (v5.9.0 won't fix the problem), and in CMSISv6 (not used).

It would be great to mention the issue in the docs.

To Reproduce

1 Build and flash bootloader with enabled D-Cache and I-Cache (CONFIG_CACHE_MANAGEMENT=y).
2. Build and flash application with enabled D-Cache and I-Cache (CONFIG_CACHE_MANAGEMENT=y) and

CONFIG_DEBUG=y
CONFIG_NO_OPTIMIZATIONS=y

Expected behavior
An application shall start.

Impact
It might be a showstopper. Developers must be aware of the issue. Otherwise, they risk bricking their devices after an application update.

Environment (please complete the following information):

  • Toolchain: zephyr-sdk-0.16.5 (arm-zephyr-eabi)
  • Commit SHA: 650a594

Metadata

Metadata

Assignees

Labels

Stalearea: ARMARM (32-bit) Architecturearea: CMSIS-CorebugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions