-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support download SafeBoot image from URL
- Loading branch information
1 parent
9d9f1d1
commit cba2de3
Showing
11 changed files
with
120 additions
and
6 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
/.pio | ||
/.vscode | ||
/logs |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SafeBoot Example | ||
|
||
Please refer to the SafeBoot tool documentation |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x5000, | ||
otadata, data, ota, 0xE000, 0x2000, | ||
safeboot, app, factory, 0x10000, 0xA0000, | ||
app, app, ota_0, 0xB0000, 0x330000, | ||
fs, data, spiffs, 0x3E0000, 0x10000, | ||
coredump, data, coredump, 0x3F0000, 0x10000, |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x5000, | ||
otadata, data, ota, 0xE000, 0x2000, | ||
safeboot, app, factory, 0x10000, 0xA0000, | ||
app, app, ota_0, 0xB0000, 0x730000, | ||
fs, data, spiffs, 0x7E0000, 0x10000, | ||
coredump, data, coredump, 0x7F0000, 0x10000, |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[platformio] | ||
name = MyAwesomeApp | ||
|
||
[env] | ||
platform = espressif32 | ||
framework = arduino | ||
monitor_filters = esp32_exception_decoder, log2file | ||
monitor_speed = 115200 | ||
upload_protocol = esptool | ||
lib_compat_mode = strict | ||
lib_ldf_mode = chain | ||
lib_deps = | ||
mathieucarbou/AsyncTCP @ 3.2.4 | ||
mathieucarbou/ESPAsyncWebServer @ 3.1.3 | ||
mathieucarbou/MycilaSystem @ 2.0.7 | ||
|
||
extra_scripts = post:../tools/factory.py | ||
board_build.partitions = partitions-4MB-safeboot.csv | ||
custom_safeboot_dir = .. | ||
|
||
; -------------------------------------------------------------------- | ||
; ENVIRONMENTs | ||
; -------------------------------------------------------------------- | ||
|
||
[env:esp32dev] | ||
board = esp32dev |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: MIT | ||
/* | ||
* Copyright (C) 2023-2024 Mathieu Carbou | ||
*/ | ||
#include <ESPAsyncWebServer.h> | ||
#include <MycilaSystem.h> | ||
#include <WiFi.h> | ||
|
||
AsyncWebServer webServer(80); | ||
|
||
String getEspID() { | ||
uint32_t chipId = 0; | ||
for (int i = 0; i < 17; i += 8) { | ||
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i; | ||
} | ||
String espId = String(chipId, HEX); | ||
espId.toUpperCase(); | ||
return espId; | ||
} | ||
|
||
void setup() { | ||
WiFi.mode(WIFI_AP); | ||
WiFi.softAP(String("MyAwesomeApp-") + getEspID()); | ||
|
||
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { | ||
request->send(200, "text/html", "<form method='POST' action='/safeboot' enctype='multipart/form-data'><input type='submit' value='Restart in SafeBoot mode'></form>"); | ||
}); | ||
|
||
webServer.on("/safeboot", HTTP_POST, [](AsyncWebServerRequest* request) { | ||
request->send(200, "text/plain", "Restarting in SafeBoot mode... Look for an Access Point named: SafeBoot-" + getEspID()); | ||
Mycila::System.restartFactory("safeboot"); | ||
}); | ||
|
||
webServer.begin(); | ||
} | ||
|
||
void loop() { | ||
delay(100); | ||
} |
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