Skip to content

Commit

Permalink
Clarify purpose of user_init and user_pre_init
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Mar 13, 2024
1 parent ceb5162 commit 2e50adc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sming/Arch/Esp8266/Components/esp8266/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern void init();
extern void cpp_core_initialize();

// Normal entry point for user application code from SDK
extern "C" void user_init(void)
{
// Initialise hardware timers
Expand All @@ -39,12 +40,20 @@ extern "C" void user_init(void)

gdb_init();

/*
* Load partition information.
* Normally this is done in user_pre_init() but if building without WiFi
* (via esp_no_wifi Component) then user_pre_init() is not called as none of the
* SDK-related partitions are required.
* Calling this a second time is a no-op.
*/
Storage::initialize();

init(); // User code init
}

extern "C" void ICACHE_FLASH_ATTR WEAK_ATTR user_pre_init(void)
// SDK 3+ calls this method to configure partitions
extern "C" void user_pre_init(void)
{
Storage::initialize();

Expand Down
6 changes: 6 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_no_wifi/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ The SDKnoWiFi implements the startup code and some system functions but contains
which is provided by the SDK and in other parts of the Sming framework. We need to provide
replacement functions to interoperate correctly with the remaining SDK code.

Advantages
----------

- Reduces code image size when networking/WiFi is not required
- Eliminates need for SDK-specific partitions (rf_cal, phy_init, sys_param)

Process
-------

Expand Down

0 comments on commit 2e50adc

Please sign in to comment.