-
Notifications
You must be signed in to change notification settings - Fork 3k
Update Mbed 5 boot sequence #7794
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
Conversation
Docs for this change can be found here: |
Is this related? #7382 |
this is unrelated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize I'm not on the reviewers list but I was perusing some of the PRs and noticed a couple of comment oopsies in this one! Very cool change though!
rtos/TARGET_CORTEX/mbed_boot.h
Outdated
/** | ||
* SDK hook for running code before ctors or OS | ||
* | ||
* This is a weak function which can be overridden at by a target's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English nit:
This is a weak function which can be overridden at by a target's
should probably just be "by".
rtos/TARGET_CORTEX/mbed_boot.h
Outdated
/** | ||
* Application hook for running code before main | ||
* | ||
* This is a weak function which can be overridden at by an application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English nit:
This is a weak function which can be overridden at by an application
should probably just be "by".
Thanks for the review @bridadan. I update the PR to fix those typos. |
@@ -43,6 +43,10 @@ extern osMutexId_t singleton_mutex_id; | |||
inline static void singleton_lock(void) | |||
{ | |||
#ifdef MBED_CONF_RTOS_PRESENT | |||
if (!singleton_mutex_id) { | |||
// RTOS has not booted yet so no mutex is needed | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we throw an MBED_ERROR
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, this case is expected to be hit early in the boot sequence when when the RTOS has not yet started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem to be the case for STM boards...
|
||
/* Define stack sizes if they haven't been set already */ | ||
#if !defined(ISR_STACK_SIZE) | ||
#define ISR_STACK_SIZE ((uint32_t)1024) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define is used by ARM and GCC_ARM toolchain, can we move it to "mbed_boot.h" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks... this was much needed refactoring 👍
|
||
void mbed_toolchain_init() | ||
{ | ||
#if defined(MBED_CONF_RTOS_PRESENT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this checks, nothing in rtos/
folder will be compiled in if the RTOS is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,159 @@ | |||
/* mbed Microcontroller Library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are using doxy, but it's not going to be anchored nicely. Is it worth creating a group and turning all the comments (even the file global one) into doxy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* - The RTOS has been started by a call to mbed_rtos_start | ||
* - The toolchain has been initialized by a call to mbed_toolchain_init | ||
*/ | ||
void mbed_main(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing for compatibility reasons that need to stay, but from the conceptual point of view it doesn't have much sense as it's run from the same context than main. Would it make sense to add app entry point before RTOS and target entry point after RTOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be easy to add these hooks, although I would be hesitant to add them without having a use case in mind.
rtos/TARGET_CORTEX/mbed_rtos_rtx.c
Outdated
} | ||
|
||
osKernelStart(); | ||
while (1); // Code should never get here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually should we assert/error out here, rather than spin forever in case something goes wrong in RTX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I made the following changes:
|
I really like your goal and work you've done here. This is probably outside your desired scope, but would it take much effort to add an mbed config system entry to disable rtos aka: #7800 I regularly need to run mbed without the rtos on smaller targets that do not have enough ram/flash to support the os. Currently the only way I know of to do this is adding the rtos and events libraries to
Unfortunately, I just tested this with this PR and it no longer works.
It would be great if you could make a better supported method of disabling the rtos! |
In case it wasn't clear in my last message, This may not be a particularly supported use case, but it is a critical need for many applications. |
@andrewleech Thanks for the feedback. This is supported use case (this approach could be found in the issues/questions - its being used). From your error log, what does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine - nice cleanup!
From the changes, this only touches rtos, not certain how this affects non rtos build as reported above. Please review it
@0xc0170 It was a new project, fresh clone of mbed os with this branch checked out (0e7c3bfa) and the basic hello world main.cpp
I tried compiling (I think for NRF52_DK) with Just tried it again, |
@0xc0170 The problem is probably the inclusion of rtos related headers in the toolchain boot source files. These rtos headers won't be present if the rtos directory is being ignored. |
I tried non-rtos build with blinky and shared .mbedignore and noted issue exists on the master branch as well. Our network interfaces are dependent on rtos, agree we have not done great job in separating those and adding appropriate errors. You can add a separate issue to mbed-os to take care of this in future. For now non-rtos blinky works with below:
|
Thanks @deepikabhavnani . Please review and leave feedback here. We can start CI soon @andrewleech Please create an issue, we shall fix it ! |
I'm so sorry I forgot to check master build as well, @c1728p9 sorry for the distraction. I love what you've done here. |
Fixed ARM failures |
/morph build |
Build : SUCCESSBuild number : 2944 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2561 |
Test : FAILUREBuild number : 2693 |
There's one device that hard faults, please verify |
@c1728p9 Fyi ^^^ |
/morph build |
Crud. Only meant to retest... Oh well. |
Build : SUCCESSBuild number : 2955 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 2571 |
GnuArmEclipse had an error initializing storage... Huh. |
Reshuffling the Integration Test queue. Will restart shortly. |
Exporter Build : FAILUREBuild number : 2572 |
This is less than useful... /morph export-build |
Exporter Build : FAILUREBuild number : 2574 |
/morph export-build |
/morph test |
Exporter Build : SUCCESSBuild number : 2578 |
Test : SUCCESSBuild number : 2712 |
Description
Refactor the Mbed 5 boot process to make is simpler and more modular. This is done by breaking the boot sequence into 4 distinct steps - Target setup, Toolchain setup, RTOS setup and Mbed setup. This patch also move toolchain specific code into a per toolchain folder to make it more maintainable.
Pull request type