Skip to content

Add a function to transfer control to another app #3748

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 1 commit into from
Feb 21, 2017

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Feb 11, 2017

Add the function mbed_application_start() which allows a bootloader to transfer control to an application.

@c1728p9 c1728p9 force-pushed the application_transfer_support branch from 5bc7425 to ae5be6d Compare February 11, 2017 00:28
@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 11, 2017

CC: @LiyouZhou

@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 11, 2017

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1564

Build failed!

Copy link
Contributor

@sg- sg- left a comment

Choose a reason for hiding this comment

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

A few nits. Looks quite good but will need some strong worded docs about assumptions made when transferring control regarding systick, scb and nvic


#include<stdint.h>

#define MBED_APPLICATION_SUPPORT (defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_M7))
Copy link
Contributor

Choose a reason for hiding this comment

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

What will be different in M0 and can it be added now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the M0 the VTOR is optional. Devices that have a VTOR could be supported easily, but I'm not sure if there is a good way to tell that. Alternatively, for M0 the reset sequence could be to jump to the reset handler and leave it up to the application to remap interrupts as necessary.

#endif

/**
* Start the application at the given address. This function does
Copy link
Contributor

Choose a reason for hiding this comment

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

all documentation reads '... start application ...' but the function name is application_start. Just difficult to read. Should the func be mbed_start_application(addr);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll rename so it makes more sense to users. The function was named like this so the prefix matched the filename, similar to mbed_stats_heap_get.

BX R1
}

#elif defined (__GNUC__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the IAR and GNU implementation be unified? What about ARM compiler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ARMCC has its own syntax so it can't be unified. As is the GCC and IAR function can be unified, but I'm not sure if this is a good idea. I don't know how much of the syntax is different between these two assemblers.

@c1728p9 c1728p9 force-pushed the application_transfer_support branch from ae5be6d to 35ec0cd Compare February 13, 2017 23:56
@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 13, 2017

/morph test

void *pc;

// Interrupts are re-enabled in start_new_application
core_util_critical_section_enter();
Copy link
Contributor

Choose a reason for hiding this comment

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

is there anywhere exit called? I can see interrupts are enabled in the asm functions below. I am asking as critical sections can be nested (contain counters), thus this would lead that there's currently still one active critical section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no call to critical section exit, instead right before jumping to the next application, interrupts are re-enabled with "msr primask, r2" where r2=0.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but that is incorrect, every enter should have counterpart exit?

@bridadan
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1594

All builds and test passed!

@c1728p9 c1728p9 force-pushed the application_transfer_support branch from 35ec0cd to 7047d0f Compare February 14, 2017 23:30
@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 14, 2017

Updated PR to replace core_util_critical_section_enter with __disable_irq, add parameter and clobber list in start_new_application and combine GCC and IAR assembly.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 14, 2017

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1595

All builds and test passed!

Copy link
Contributor

@sg- sg- left a comment

Choose a reason for hiding this comment

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

One last nit, sorry :(


void mbed_start_application(uintptr_t address)
{

Copy link
Contributor

Choose a reason for hiding this comment

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

extra /n

@c1728p9 c1728p9 force-pushed the application_transfer_support branch from 7047d0f to 590fff4 Compare February 17, 2017 15:28
@sg-
Copy link
Contributor

sg- commented Feb 17, 2017

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1627

All builds and test passed!

Add the function mbed_start_application() which allows a bootloader to
transfer control to an application.
@c1728p9 c1728p9 force-pushed the application_transfer_support branch from 590fff4 to 36cbae6 Compare February 19, 2017 01:48
@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 19, 2017

rebased the PR in the hopes it will restart the Cam-CI

@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 19, 2017

/morph test

1 similar comment
@bridadan
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1651

All builds and test passed!

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.

6 participants