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

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

Open
GeorgeCGV opened this issue Mar 5, 2024 · 7 comments
Assignees
Labels
area: ARM ARM (32-bit) Architecture area: CMSIS-Core bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@GeorgeCGV
Copy link
Collaborator

GeorgeCGV commented Mar 5, 2024

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
@GeorgeCGV GeorgeCGV added the bug The issue is a bug, or the PR is fixing a bug label Mar 5, 2024
@aescolar aescolar added the priority: medium Medium impact/importance bug label Mar 5, 2024
Copy link

github-actions bot commented May 5, 2024

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label May 5, 2024
@GeorgeCGV
Copy link
Collaborator Author

Reproduction steps change after #1922:

Approach 1

The CONFIG_BOOT_DISABLE_CACHES must be set to n, then follow the "To Reproduce" steps from above.

Approach 2

Build and run the bootloader with CONFIG_NO_OPTIMIZATIONS and CONFIG_DEBUG if CONFIG_BOOT_DISABLE_CACHES is enabled to trigger the issue in the bootloader.

@GeorgeCGV GeorgeCGV removed the Stale label May 7, 2024
@snalvc
Copy link

snalvc commented May 15, 2024

This also happens in my setup.
Board: sam_v71_xult (I detached onboard Xplained Pro board debugger and replaced it w/ picoprobe)
App: samples/hello_world
Toolchain: zephyr-sdk-0.16.5-1
Zephyr commit SHA: 0a8d03b95f
prj.conf:

CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
CONFIG_NO_OPTIMIZATIONS=y
CONFIG_CACHE_MANAGEMENT=y

Confirmed applying ARM-software/CMSIS_5#1426 to cachel1_armv7.h solves the problem

@nashif nashif added the area: ARM ARM (32-bit) Architecture label Jun 4, 2024
Copy link

github-actions bot commented Aug 4, 2024

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Aug 4, 2024
@GeorgeCGV GeorgeCGV removed the Stale label Aug 4, 2024
Copy link

github-actions bot commented Oct 4, 2024

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Oct 4, 2024
@GeorgeCGV GeorgeCGV removed the Stale label Oct 10, 2024
@ithinuel
Copy link
Collaborator

Unfortunately ARM-software/CMSIS_5#1426 is not in CMSIS 5.9.0.
However, it is in CMSIS_6, so migrating to it could help resolve this issue.

Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Jan 13, 2025
@kartben kartben assigned wearyzen and unassigned ithinuel Jan 14, 2025
@github-actions github-actions bot removed the Stale label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture area: CMSIS-Core bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

No branches or pull requests

8 participants