-
Notifications
You must be signed in to change notification settings - Fork 13.3k
PoC for handling Erase WiFi Setting after OTA #6965
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
Draft
mhightower83
wants to merge
64
commits into
esp8266:master
Choose a base branch
from
mhightower83:pr-erase-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
6fde10f
Proof of concept for post OTA 1st boot erase config.
mhightower83 93fb3d3
Added a 2nd method
mhightower83 c66ae2e
Merge branch 'master' into pr-erase-config
mhightower83 6d882e4
Added two_shots init to noextra4k
mhightower83 500b7cc
Removed cleaned up debug crud and added test example.
mhightower83 afd603b
Merge branch 'master' into pr-erase-config
mhightower83 bfb21b1
A proof of concept for handling Erase WiFi Setting after OTA
mhightower83 e51ab08
Addressed Tavis CI style issues.
mhightower83 a284b0a
Take two
mhightower83 3258d63
Merge branch 'master' into pr-erase-config
mhightower83 9d6e059
Merge branch 'master' into pr-erase-config
mhightower83 95eefed
Update example. Removed some debug crud. Added a Flash Info hotkey op…
mhightower83 815f1dc
Merge branch 'master' into pr-erase-config
mhightower83 660d19c
Merge branch 'master' into pr-erase-config
mhightower83 4554a7c
style fix
mhightower83 1ce4c60
Merge branch 'master' into pr-erase-config
mhightower83 7130877
Merge branch 'master' into pr-erase-config
mhightower83 73f16dc
Merge branch 'master' into pr-erase-config
mhightower83 9c4e44b
Added print messages to show progress.
mhightower83 546f0cb
Merge branch 'master' into pr-erase-config
mhightower83 560ddc5
Set default Method to 2, to side step travis issue of using preinit().
mhightower83 049d91b
Added a Third method.
mhightower83 4e2493a
Resolve merge conflict.
mhightower83 39160c8
one more :(
mhightower83 c0394fb
Merge branch 'master' into pr-erase-config
mhightower83 f1acb40
Access bin image header through ICACHE reduces IRAM usage by 16.
mhightower83 604b40a
Merge branch 'master' into pr-erase-config
mhightower83 4553009
Made function name longer to avoid possible name conflicts in the fut…
mhightower83 372998c
Merge branch 'master' into pr-erase-config
mhightower83 39b9508
CI issues
mhightower83 4954dcd
Merge branch 'master' into pr-erase-config
mhightower83 828a47d
Merge branch 'master' into pr-erase-config
mhightower83 b2d35ea
Merge branch 'master' into pr-erase-config
mhightower83 74129c5
Merge branch 'master' into pr-erase-config
mhightower83 14fede0
Merge branch 'master' into pr-erase-config
mhightower83 be5fe6d
Merge branch 'master' into pr-erase-config
mhightower83 cfd54df
Merge branch 'master' into pr-erase-config
mhightower83 6f91be0
Merge branch 'master' into pr-erase-config
mhightower83 6b1cdb8
Merge branch 'master' into pr-erase-config
mhightower83 fcb8b21
Merge branch 'master' into pr-erase-config
mhightower83 c40a873
Merge branch 'master' into pr-erase-config
mhightower83 2b2def2
Corrected new errors after upgrade to GCC 10.1 toolchain.
mhightower83 48ed5e9
Merge branch 'master' into pr-erase-config
devyte b211727
Merge branch 'master' into pr-erase-config
mhightower83 ab9b6b2
Corrected manual merge error, with init order of class.
mhightower83 e5539fe
Merge branch 'master' into pr-erase-config
mhightower83 502d8bc
Merge branch 'master' into pr-erase-config
mhightower83 f50b3a6
Merge branch 'master' into pr-erase-config
mhightower83 94365e1
Fixed merge errors and code rot.
mhightower83 5234f3f
Updated wifi_health_t and WiFiDisconnectLog_t to take
mhightower83 025bb2f
Merge branch 'master' into pr-erase-config
mhightower83 edade1c
Merge branch 'master' into pr-erase-config
mhightower83 24a117c
Merge branch 'master' into pr-erase-config
d-a-v 4e31c91
Merge branch 'master' into pr-erase-config
mhightower83 0b01518
Replaced ROM_uart_div_modify and associated logic, with the current
mhightower83 f9a3f95
Merge branch 'master' into pr-erase-config
devyte 217b2d2
Cleanup merge conflict. Now use IRAM_ATTR and _NOINLINE_STATIC w/o ch…
mhightower83 0b7fced
Merge branch 'master' into pr-erase-config
mhightower83 9f0e220
Merge branch 'master' into pr-erase-config
mhightower83 e44e752
Merge branch 'master' into pr-erase-config
mhightower83 c44a3f9
Changed to comply with strict-aliasing rules. Changes based on discus…
mhightower83 63a2048
Merge branch 'pr-erase-config' of github.com:mhightower83/Arduino int…
mhightower83 21b0154
Merge branch 'master' into pr-erase-config
mhightower83 fb05f15
Merge branch 'master' into pr-erase-config
mhightower83 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
Next
Next commit
Proof of concept for post OTA 1st boot erase config.
- Loading branch information
commit 6fde10f0bbfc3af62418aac38d0feb0a09e7d219
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <Arduino.h> | ||
#include <flash_utils.h> | ||
#include <eboot_command.h> | ||
#include <spi_flash.h> | ||
|
||
#ifdef ERASE_CONFIG_H | ||
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. Always true #if 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. okay |
||
|
||
extern "C" { | ||
#include "user_interface.h" | ||
|
||
bool erase_config(const uint32_t flash_erase_mask) { | ||
// This is really the active configured size | ||
uint32_t flash_size = flashchip->chip_size; | ||
uint32_t erase_mask = (flash_erase_mask & (uint32_t)ERASE_CONFIG_ALL_DATA); | ||
uint32_t sector = flash_size/SPI_FLASH_SEC_SIZE - 1U; | ||
|
||
for (; !!erase_mask; erase_mask >>= 1U, sector--) { | ||
if ((erase_mask & 1U)) { | ||
if (0 != spi_flash_erase_sector(sector)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool check_and_erase_config(void) { | ||
// This should work since each element of the structure is a word. | ||
eboot_command volatile * ebcmd = (eboot_command volatile *)RTC_MEM; | ||
|
||
// We want to run after an OTA has completed and the bin has been moved to its | ||
// final resting place in flash. We want to catch the moment of the 1st boot | ||
// of this new sketch. Then verify we have a valid erase option. | ||
if (0U == ebcmd->magic && | ||
0U == ebcmd->crc32 && | ||
ACTION_COPY_RAW == ebcmd->action && | ||
ebcmd->args[4] == ebcmd->args[6] && | ||
ebcmd->args[5] == ebcmd->args[7] && | ||
ebcmd->args[4] == ~ebcmd->args[5] && | ||
0U == (ebcmd->args[4] & ~ERASE_CONFIG_ALL_DATA)) { | ||
|
||
uint32_t erase_flash_option = ebcmd->args[4]; | ||
|
||
// Make sure we don't repeat | ||
for (size_t i=4; i<=7; i++) | ||
ebcmd->args[i] = 0U; | ||
|
||
if (erase_flash_option) { | ||
erase_config(erase_flash_option); | ||
system_restart(); | ||
while(true){} | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
}; | ||
|
||
#endif // ERASE_CONFIG_H |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef ERASE_CONFIG_H | ||
#define ERASE_CONFIG_H | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef enum ERASE_CONFIG { | ||
// Note, The Arduino ESP8266 flash memory map differs from Espressif's. | ||
// Espressive has separate sectors for PHY init data and RF_CAL. In Arduino | ||
// ESP8266 RF_CAL and PHY INIT share the same sector. Between two RF init user | ||
// calls the PHY init data is overlayed. Thus avoiding the waste of a 4K sector | ||
// to store only 128 bytes. | ||
// | ||
// Mapping of Sectors at end of Flash, adapted for the Arduino ESP8266. | ||
// Defaults to using the IDE configured flash size for placement | ||
//_______________________________________________________________________________________ | ||
//_Bit_number_for_Mask______|_____4_____|_____3_____|_____2_____|_____1_____|_____0_____| | ||
// | | RF_CAL | SDK Parameter Area | | ||
// Overlay at RF init | | PHY INIT | | | | | ||
// Persistant data | | | | SSID/PW | | | ||
// User storage | EEPROM | | | | | | ||
// Often shown downloaded | | BLANK.BIN | | BLANK.BIN | | | ||
//__________________________|___________|___________|___________|___________|___________| | ||
ERASE_CONFIG_NONE = 0, //| | | | | | | ||
ERASE_CONFIG_EEPROM = ( BIT(4) ), | ||
ERASE_CONFIG_RF_CAL = ( BIT(3) ), | ||
ERASE_CONFIG_PERSISTANT = ( BIT(1) ), | ||
ERASE_CONFIG_BLANK_BIN = ( BIT(3) | BIT(1) ), | ||
ERASE_CONFIG_SDK_DATA = ( BIT(3) | BIT(2) | BIT(1) | BIT(0) ), | ||
ERASE_CONFIG_ALL_DATA = ( BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0) ) | ||
//__________________________|___________|___________|___________|___________|___________| | ||
} ERASE_CONFIG_MASK_t; // Use one of these with eraseConfig | ||
|
||
bool check_and_erase_config(void); | ||
bool erase_config(const uint32_t flash_erase_mask); | ||
|
||
#ifdef __cplusplus | ||
}; | ||
#endif | ||
|
||
#endif |
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.
Same #if comment
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.
okay