Skip to content

Changed HAL_MspInit to mbed_main #6023

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

Closed
wants to merge 1 commit into from

Conversation

bqam-ublox
Copy link
Contributor

Description

Bug fix for C030 battery charger. There is a wait function being called in the boot process (inside HAL_MspInit) and at that stage, the kernel has not been initialised. A fix for this would be to use mbed_main() instead of HAL_MspInit() in user file as mbed_main() is being called at a later stage in the boot process.

@RobMeades is already following up this issue, please refer to #5995

@mbed-ci
Copy link

mbed-ci commented Feb 6, 2018

User not whitelisted, CI not run.

* in user defined file as described in documentation
*/

void HAL_MspInit(void)
void mbed_main(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is mbed_main: User's code to be executed before main(). . Should not be defined in the targets

What problem is here? Why a target code needs kernel to be initialized ?

Copy link
Contributor

Choose a reason for hiding this comment

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

See #5995: our C030 board requires configuration of a voltage level in its battery charger chip if it is to work reliably. This battery charger chip is only configurable over I2C. The [standard ST] I2C drivers make calls to wait_us(), which is an RTOS function. So our target code needs to do this configuration call after the RTOS has been initialised and before entry to main(). Is there such a hook, other than mbed_main()?

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 such a hook, other than mbed_main()?

No, there is not.

target code should use what it has, target code, in this case us ticker functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I guess it is a rule that target code should not use RTOS calls. Is that written down somewhere, just so that I can have the discussion with ST (whose code it is)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Grepping around a little, there are calls to wait_ms() and wait_us() all over the place in the target code so I don't see how it can be a rule that target code should not use RTOS calls. The other option would be to introduce a hook for target configuration to occur after the RTOS has been initialised, since I can see that being generally useful. I will raise a separate issue for this.

@bqam-ublox
Copy link
Contributor Author

This change is not required. Instead please refer to #6034.

@bqam-ublox bqam-ublox closed this Feb 9, 2018
@sg- sg- removed the needs: work label Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants