Skip to content

Support mbed_start_application for Cortex-M0+ #9791

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

Merged
merged 4 commits into from
Feb 25, 2019

Conversation

sarahmarshy
Copy link
Contributor

Description

Add support for mbed_start_application for Cortex M0+ targets. This will enable M0+ targets to support bootloader applications.

Pull request type

[X ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@c1728p9

Copy link
Contributor

@donatieng donatieng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -170,7 +177,11 @@ __asm static void start_new_application(void *sp, void *pc)
void start_new_application(void *sp, void *pc)
{
__asm volatile(
"movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with MOVW.
#if defined(__CORTEX_M0PLUS)
"mov r2, #0 \n" // No MOVW instruction on Cortex-M0+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting note that ARMC6 fails, does this compile for m0+ ?

Copy link
Contributor Author

@sarahmarshy sarahmarshy Feb 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have armc6 to test. This was a comment from @ccli8. I also thought it was interesting, because this is part of the code path for IAR and GCC, not Arm compiler, so I don't know the significance of the comment. I left it as is in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, @ccli8 should that comment be removed or ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarahmarshy ARMC6 (not ARM) toolchain doesn't define __CC_ARM, but define __GNUC__, so ARMC6 will compile this code path.

@0xc0170 I re-compile this code path with ARMC6 (6.10) and GCC_ARM (2018/Q2), mov r2, #0 compiles failed only on ARMC6/M23 combination. So if the comment is to be left, it can change to more accurate like Fail to compile "mov r2, #0" with ARMC6/M23. Replace with MOVW.

#elif defined (__GNUC__) || defined (__ICCARM__)

void start_new_application(void *sp, void *pc)
{
    __asm volatile(
        "movw   r2, #0      \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with MOVW.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ccli8 . The latest update took care of it

@ciarmcom ciarmcom requested review from c1728p9 and a team February 21, 2019 12:00
@ciarmcom
Copy link
Member

@sarahmarshy, thank you for your changes.
@c1728p9 @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested a review from a team February 21, 2019 12:00
for (i = 0; i < 8; i++) {
NVIC->IP[i] = 0x00000000;
}
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative to having this as a separate block could you set isr_groups_32 = 1 for m0+ and reuse the code below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit 👍

@cmonr
Copy link
Contributor

cmonr commented Feb 21, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Feb 21, 2019

Test run: FAILED

Summary: 4 of 8 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_mbed2-build-ARM
  • jenkins-ci/mbed-os-ci_mbed2-build-IAR
  • jenkins-ci/mbed-os-ci_build-IAR
  • jenkins-ci/mbed-os-ci_build-ARM

@cmonr
Copy link
Contributor

cmonr commented Feb 21, 2019

@sarahmarshy Please review the build failure.

Was this changeset tested in IAR and ARM compilers?

@sarahmarshy
Copy link
Contributor Author

@cmonr, no, but it has been now. Should be fixed by latest commit 👍

@@ -158,7 +161,11 @@ static void powerdown_scb(uint32_t vtor)

__asm static void start_new_application(void *sp, void *pc)
{
#if defined(__CORTEX_M0PLUS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to just use MOVS unconditionally here - it's a 16-bit instruction instead of 32-bit (which is why the M0+ supports it). So you'll save ROM on all Cortex-Ms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I've added this in my most recent commit.

@@ -170,7 +173,7 @@ __asm static void start_new_application(void *sp, void *pc)
void start_new_application(void *sp, void *pc)
{
__asm volatile(
"movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with MOVW.
"movs r2, #0 \n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad that worked. (It's so fiddly getting inline assembler to go smoothly across all toolchains - especially as GCC refuses to use unified syntax for Thumb-1 devices. Actually a bit surprised it is accepting MOVS...)

The MOVT comment is no longer relevant with the MOVW gone.

@NirSonnenschein
Copy link
Contributor

started CI

@mbed-ci
Copy link

mbed-ci commented Feb 24, 2019

Test run: SUCCESS

Summary: 12 of 12 test jobs passed
Build number : 2
Build artifacts

@NirSonnenschein
Copy link
Contributor

@0xc0170 does this need any other reviews before merge?

@0xc0170 0xc0170 merged commit 5f38878 into ARMmbed:master Feb 25, 2019
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.

10 participants