-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Reimplemented esp_init_data_default. #1526
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,49 @@ void TEXT_SECTION_ATTR user_start_trampoline (void) | |
rtctime_early_startup (); | ||
#endif | ||
|
||
/* Re-implementation of default init data deployment. The SDK does not | ||
* appear to be laying down its own version of init data anymore, so | ||
* we have to do it again. To see whether we need to, we read out | ||
* the flash size and do a test for esp_init_data based on that size. | ||
* If it's missing, we need to initialize it *right now* before the SDK | ||
* starts up and gets stuck at "rf_cal[0] !=0x05,is 0xFF". | ||
* If the size byte is wrong, then we'll end up fixing up the init data | ||
* again on the next boot, after we've corrected the size byte. | ||
* Only remaining issue is lack of spare code bytes in iram, so this | ||
* is deliberately quite terse and not as readable as one might like. | ||
*/ | ||
SPIFlashInfo sfi; | ||
SPIRead (0, (uint32_t *)(&sfi), sizeof (sfi)); // Cache read not enabled yet, safe to use | ||
if (sfi.size < 2) // Compensate for out-of-order 4mbit vs 2mbit values | ||
sfi.size ^= 1; | ||
uint32_t flash_end_addr = (256 * 1024) << sfi.size; | ||
uint32_t init_data_hdr = 0xffffffff; | ||
uint32_t init_data_addr = flash_end_addr - 4 * SPI_FLASH_SEC_SIZE; | ||
SPIRead (init_data_addr, &init_data_hdr, sizeof (init_data_hdr)); | ||
if (init_data_hdr == 0xffffffff) | ||
{ | ||
// Note: ideally we should generate the actual init data from the | ||
// SDK's bin/esp_init_data_default.bin during the build, and #include it | ||
// straight into this array. E.g.: | ||
// xxd -i esp_init_data_default | tail -n13 | head -n11 > eidd.h | ||
static uint8_t flash_init_data[128] __attribute__((aligned(4))) = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #1527 |
||
{ | ||
0x05, 0x00, 0x04, 0x02, 0x05, 0x05, 0x05, 0x02, 0x05, 0x00, 0x04, 0x05, | ||
0x05, 0x04, 0x05, 0x05, 0x04, 0xfe, 0xfd, 0xff, 0xf0, 0xf0, 0xf0, 0xe0, | ||
0xe0, 0xe0, 0xe1, 0x0a, 0xff, 0xff, 0xf8, 0x00, 0xf8, 0xf8, 0x52, 0x4e, | ||
0x4a, 0x44, 0x40, 0x38, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, | ||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0xe1, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x01, 0x93, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
}; | ||
SPIEraseSector (init_data_addr); | ||
SPIWrite (init_data_addr, (const uint32_t *)flash_init_data, sizeof (flash_init_data)); | ||
} | ||
|
||
call_user_start (); | ||
} | ||
|
||
|
@@ -87,9 +130,7 @@ void nodemcu_init(void) | |
// Fit hardware real flash size. | ||
flash_rom_set_size_byte(flash_safe_get_size_byte()); | ||
|
||
// Reboot to get SDK to use (or write) init data at new location | ||
system_restart (); | ||
|
||
// Don't post the start_lua task, we're about to reboot... | ||
return; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there a reason that you didn't do this?
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.
@pjsg Time.
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.
See #1527