-
Notifications
You must be signed in to change notification settings - Fork 3k
Initialization steps in toolchains #2160
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
Complete test report on all STM32 platforms, all TCs |
In the uARM fix, static int mbed_sdk_inited = 0;
if (!mbed_sdk_inited) {
mbed_sdk_inited = !mbed_sdk_inited;
mbed_sdk_init();
} |
@svastm Thanks for proposal indeed ... |
884d3d4
to
fecc8e3
Compare
I took into account svastm proposal and I rebased to solve conflicts with latest master |
@mbed-bot: TEST HOST_OSES=windows |
|
||
extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) { | ||
#if defined(__MICROLIB) && (__ARMCC_VERSION>5030000) | ||
// Before version 5.03, we were using a patched version of microlib with proper names | ||
// This is the workaround that the microlib author suggested us | ||
static int n = 0; | ||
static int mbed_sdk_inited = 0; | ||
if (!mbed_sdk_inited) { | ||
mbed_sdk_inited = 1;; |
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.
nit ;;
double
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.
thx - will correct now
@c1728p9 Any comments to this changeset? |
[Build 660] |
Test results look good |
@@ -648,6 +649,7 @@ __asm void __rt_entry (void) { | |||
LDR R4,=armcc_heap_top | |||
STR R0,[R3] | |||
STR R2,[R4] | |||
BL _platform_post_stackheap_init |
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.
Does this need to be called before the RTOS has been initialized? If not you might want to move this to pre_main.
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.
@c1728p9 I actually have tried the pre_main hook as this was a good candidate. The call needs to be placed before the C++ objects are initialized, which is done I think in __rt_lib_init calling to _cpp_initializaze__aeabi. When RTOS gets initialized, this is too late unfortunately ...
@0xc0170 : rebased and updated according to comment |
I confirm that all tests are OK on STM32 boards |
@0xc0170 just rebased as there were conflicts |
static int mbed_sdk_inited = 0; | ||
if (!mbed_sdk_inited) { | ||
mbed_sdk_inited = 1; | ||
mbed_sdk_init(); |
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.
Why is mbed_sdk_init only being called on _open for microlib? Also, here mbed_sdk_inited is checked, but it is not checked below so this might get called twice.
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.
@c1728p9: it just happen that _open "seems" to be called on every init and that we are looking for a path that is called after RAM init and before C++ object initialization. If you happen to know another alternative, that would be welcome.
Here is what I wrote in commit message :
In uARM, the library's hook _platform_post_stackheap_init does not seem to
exist and I couldnot find a documentation describing the initialisation
flow. All we know is that _open is called after RAM init and before the
C++ init, so this is a working placeholder.
This is maybe not acceptable so a uARM lib expert may propose a better
hook to fullfil the requirement.
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.
@c1728p9 About being called twice, I think that various calls are under different #defines - the one in _open is only for uARM toolchain, the other calls are in case of GCC or ARM toolchain. But I may be wrong, which line to you suspect to be the 2nd call ?
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.
Ah I see. I didn't notice the define wrapping it before.
Various toolchains supported in MBED don't follow the same initialization steps. This can have impacts on platform behavior. For STM32, it is needed to call the HAL_Init() _after_ the RAM has been initialized (sdata from flash / zero initialized data) and _before_ the C++ objects are being created, especially if those objects require support of tickers for instance. In GCC, this is easily done because SystemInit is called after the ram initialisation, so HAL_Init does not need to called from mbed_sdk_init. this is covered by the changes in mbed_overrides.c files. This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object ARMmbed#2115
Various toolchains supported in MBED don't followthe same initialization steps. This can have impacts on platform behavior. For STM32, it is needed to call the HAL_Init() _after_ the RAM has been initialized (sdata from flash / zero initialized data) and _before_ the C++ objects are being created, especially if those objects require support of tickers for instance. In GCC and IAR, this was done in previous commit to avoid HAL_Init() to be called twice. In ARM this there is no hook defined in MBED yet to place the call. The proposal is to take benefit of the library's _platform_post_stackheap_init function that is going to be called before __rt_lib_init where the C++ object init is done (__cpp_initialize__aeabi_) This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object ARMmbed#2115
In uARM, the library's hook _platform_post_stackheap_init does not seem to exist and I couldnot find a documentation describing the initialisation flow. All we know is that _open is called after RAM init and before the C++ init, so this is a working placeholder. This is maybe not acceptable so a uARM lib expert may propose a better hook to fullfil the requirement. At least this is a workign setup. This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object ARMmbed#2115
Supported toolchains initialization steps have been modified to make sure that mbed_sdk_initi is called _after_ RAM initialization and _before_ C++ objects creation. since this was done, there is no need to redundant SystemCoreClockUpdates in the drivers
rebased to solve conflicts with master ... |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 738 Test Prep failed! |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 739 Test Prep failed! |
Looks like there was bug introduced with the latest version of setuptools, oh joy! I've deployed a workaround that should fix the test prep issue for now until they patch setuptools. /morph test |
Result: ABORTEDYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 743 Build Cleanup failed! |
@bridadan so what's next ? Is there something broken with my PR or with the test tool ? |
@LMESTM sorry for the delay on this. The above issue was caused by a faulty version of pip package that was released. I will rerun the CI now. /morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 760 Build failed! |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 761 All builds and test passed! |
mbed OS 5 tests look good! Thanks for your patience! |
|
The point is that this behavior is not consistent over all toolchains (since the beginning also I guess ...)
Which toolchain are you referring to in this comment ?
All of this happens before RTOS init as far as I've seen. |
That may have changed over time so we need to fix it.
No, the reason for this hook was a IO API not providing the necessary initializer option
Quite the opposite https://github.com/ARMmbed/mbed-os/blob/master/hal/common/retarget.cpp#L523 IAR was the only one that specifically hooked pre ctor. 3062999 We'll take the action to add proper hooks and document the bootstrap process |
when do you think this would this be done ? We have other ongoing developments that would be impacted if we can't solve this. Most of my colleagues are using this series in advance to not hit the init related issues. There are actually 5 commits for 5 cases proposed in this PR: |
Can we move forward with this and just fix what C027 does to make it safe (add init calls)?
|
…..4a19dc4 4a19dc4 Import new thread files f6a021d Removed test files b9e842a Merge branch 'release_internal' into release_external 7d5d869 Merge pull request ARMmbed#2167 from ARMmbed/release_internal_merge 26e2d43 Merge branch 'master' into release_internal f43620f Add support for India band (ARMmbed#2166) 122f158 Merge pull request ARMmbed#2165 from ARMmbed/release_internal_merge 0e65ee5 Added disabling of NA for Thread BR PPP backbone 4c50e52 Added disabling of NA for Wi-SUN BR PPP backbone d2ea325 Moved DAD enabled check to Ipv6 SLAAC handler 49994fc Added PPP interface to nanostack 3383e91 Merge pull request ARMmbed#2163 from ARMmbed/IOTTHD-3558 81f7511 MAC: print RF configs 397240a MAC: Implemented CCA threshold and TX power setting 5907042 Added check for allocation failures in EAPOL 9ed97c9 ETX update: b489415 Add own certificate handling APIS (ARMmbed#2149) 888a0fb fhss_ws: check if 0 used as divider 586f2f2 Merge pull request ARMmbed#2160 from hugueskamba/hk-iotcore-1299-remove-fp-usage-ns_monitor f1d03b1 Remove floating-point usage in Nanostack heap monitor ef88f64 Removed rank comprae and also probe 5 best on the list. a2887d6 Clean PAN id compare trace print. f37dcf2 Wi-SUN NS NUD & Probe send update f7133f8 Merge pull request ARMmbed#2158 from ARMmbed/remove_temp_debug_traces 2dc1a8e fhss_ws: removed temporary debug traces 96f962a Reduce wi-sun NS Probe 0a1beb2 GTK update trigger fix a1d172e Limit Pan config sol timeout after 5 solication. 9d7414b Limit PAE supplikant GTK re-use for authentication from 2->1. 662df08 Fixed Key request address set issue if GTK mismatch is detected. a56b908 Merge pull request ARMmbed#2153 from ARMmbed/IOTTHD-3650 9b33e98 Fixed mac_pd_sap CCA_PREPARE active ACK handler. 035af9a Enhanced ACK GEN and TX update b1beb5d fhss_ws: typecast drift to int32_t f786fc9 Merge pull request ARMmbed#2152 from ARMmbed/fhss_coverity_fix 6efff35 fhss_ws: Coverity fixes d743e91 WS LLC brodacst shedule fix 6a6fb0c Removed old configuration options from Border router API a051865 Merge pull request ARMmbed#2135 from ARMmbed/IOTTHD-3232 ff771b1 Added empty interface function for network name set e94da3c Merge pull request ARMmbed#2146 from ARMmbed/IOTTHD-3571_2 234e649 added network name change function to public API 1770465 fhss_ws: Added temporary debug traces (IOTTHD-3571) d400859 Fix Thread 1.1 unitests (ARMmbed#2145) 38978f3 wi-sun ETX update: 4a71b04 Adjust Thread functions defined for Thread 1.2 (ARMmbed#2139) 4d8dc0d remove border router from pan size calculation fb3363e Merge pull request ARMmbed#2141 from ARMmbed/IOTTHD-3571 f01c5f2 fhss_ws: conversion macros/functions to support int64 a7b0027 Suprress dio sending whenRPL is not yet ready f8c9d54 Adjust tracing (ARMmbed#2138) 678eaf8 Moved Thread 1.2 code to to correct place f39d07e Merge pull request ARMmbed#2136 from ARMmbed/IOTTHD-3571 ab23116 FHSS: temporary debug traces (IOTTHD-3571) 09d4b06 MAC: Implemented PHY statistics git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 4a19dc4
This PR is a follow-up of "Fix issue #2124: IAR no rtos #2129" for other tooochains.
jamike analysis explained that mbed_sdk_init needs to be called once at the right time (after ram initialization and before C++ object creation) - this PR aims to fulfill this same requirement for the supported toolchains (gcc / arm / µarm) and also in case of ARM + rtos configuration.
Once this series is applied, few workarounds' can be removed from STM32 drivers.