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

error: use __INITIAL_SP from cmsis instead of RTX one #14624

Merged
merged 2 commits into from
May 11, 2021

Conversation

0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented May 5, 2021

Summary of changes

We used to require INITIAL_SP as rtx target headers define it. This should not be required, as
cmsis already defines symbol __INITIAL_SP for all toolchains.

Fixes #14432

We have platform/tests/TESTS/mbed_platform/error_handling/main.cpp but that does not probably contain any config in our CI to run with these enabled:

"platform.error-all-threads-info": true,
"platform.stack-dump-enabled": true,

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[x] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


We used to require INITIAL_SP as rtx target headers define it. This should not be required, as
cmsis already defines symbol  __INITIAL_SP for all toolchains.

Fixes ARMmbed#14432
@ciarmcom
Copy link
Member

ciarmcom commented May 5, 2021

@0xc0170, thank you for your changes.
@ARMmbed/mbed-os-maintainers please review.

Patater
Patater previously approved these changes May 5, 2021
@mergify mergify bot added needs: CI and removed needs: review labels May 5, 2021
@rotu
Copy link
Contributor

rotu commented May 6, 2021

I'm not getting this to build under ARMC6. User error?

mbed compile -t arm --profile debug  
[mbed] Working path "/home/dan/Mbed Programs/ng-robot-firmware" (program)
Building project ng-robot-firmware (NUCLEO_H743ZI2, ARMC6)
Scan: ng-robot-firmware
Using ROM region application in this build.
  Region application: size 0x200000, offset 0x8000000
Using RAM region application_ram in this build.
  Region application_ram: size 0x80000, offset 0x24000000
Compile [ 41.7%]: mbed_printf_armlink_overrides.c
Compile [ 42.0%]: mbed_printf_implementation.c
Compile [ 42.3%]: mbed_stats.c
Compile [ 42.6%]: mbed_wait_api_no_rtos.c
Compile [ 42.9%]: mbed_sdk_boot.c
Compile [ 43.2%]: mbed_semihost_api.c
Compile [ 43.5%]: mbed_printf_wrapper.c
Compile [ 43.8%]: mbed_error.c
[Error] mbed_error.c@522,41: use of undeclared identifier 'Image$$ARM_LIB_STACK$$ZI$$Limit'
[Error] mbed_error.c@522,41: use of undeclared identifier 'Image$$ARM_LIB_STACK$$ZI$$Limit'
[ERROR] ./mbed-os/platform/source/mbed_error.c:522:41: error: use of undeclared identifier 'Image$$ARM_LIB_STACK$$ZI$$Limit'
        uint32_t msp_size = MAX(0, (int)__INITIAL_SP - (int)msp_sp);
                                        ^
./mbed-os/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/Include/cmsis_armclang.h:124:35: note: expanded from macro '__INITIAL_SP'
#define __INITIAL_SP              Image$$ARM_LIB_STACK$$ZI$$Limit
                                  ^
./mbed-os/platform/source/mbed_error.c:522:41: error: use of undeclared identifier 'Image$$ARM_LIB_STACK$$ZI$$Limit'
./mbed-os/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/Include/cmsis_armclang.h:124:35: note: expanded from macro '__INITIAL_SP'
#define __INITIAL_SP              Image$$ARM_LIB_STACK$$ZI$$Limit
                                  ^
2 errors generated.

[mbed] ERROR: "/home/dan/.config/Mbed Studio/mbed-studio-tools/python/bin/python" returned error.
       Code: 1
       Path: "/home/dan/Mbed Programs/ng-robot-firmware"
       Command: "/home/dan/.config/Mbed Studio/mbed-studio-tools/python/bin/python -u /home/dan/Mbed Programs/ng-robot-firmware/mbed-os/tools/make.py -t arm -m NUCLEO_H743ZI2 --profile debug --source . --build ./BUILD/NUCLEO_H743ZI2/ARM-DEBUG"
       Tip: You could retry the last command with "-v" flag for verbose output
---

@rotu
Copy link
Contributor

rotu commented May 6, 2021

Maybe should be #define __INITIAL_SP __builtin___get_unsafe_stack_top() for armclang?

doesn't work. No idea what it should be.

@0xc0170
Copy link
Contributor Author

0xc0170 commented May 7, 2021

We might have some targets that do not define the required symbols? I'll check NUCLEO_H743ZI2 first and then more targets.

@mergify mergify bot dismissed Patater’s stale review May 10, 2021 15:04

Pull request has been modified.

@0xc0170
Copy link
Contributor Author

0xc0170 commented May 10, 2021

I believe I fixed it. It was not marked as being extern symbol so compiler could not find it's definition but I've checked and the linker files should provide these.

I've tested both toolchains, no errors.

@0xc0170
Copy link
Contributor Author

0xc0170 commented May 10, 2021

I run CI to check more targets

@mbed-ci
Copy link

mbed-ci commented May 10, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@rotu
Copy link
Contributor

rotu commented May 10, 2021

It works!

@0xc0170
Copy link
Contributor Author

0xc0170 commented May 11, 2021

As it was already approved, I'll merge this

@0xc0170 0xc0170 merged commit 3bd40d3 into ARMmbed:master May 11, 2021
@mergify mergify bot removed the ready for merge label May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler error for any target when stack dump is enabled
6 participants