Skip to content

Commit

Permalink
Merge branch 'master' into add-redirect2
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v authored Nov 7, 2023
2 parents ebf6235 + 31c1592 commit 2874a98
Show file tree
Hide file tree
Showing 34 changed files with 817 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- run: |
Expand All @@ -32,7 +32,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-ide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- uses: actions/cache@v3
Expand All @@ -39,7 +39,7 @@ jobs:
lwip: ["default", "IPv6"]
chunk: [0, 1, 2, 3, 4, 5, 6, 7]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
Expand All @@ -63,7 +63,7 @@ jobs:
name: Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- uses: actions/setup-python@v4
Expand All @@ -88,7 +88,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check-autogenerated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- run: |
Expand All @@ -29,7 +29,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- uses: actions/setup-python@v4
Expand All @@ -51,7 +51,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-to-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
name: Update master JSON file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/style-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
name: codespell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
- name: Run codespell
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-to-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down
43 changes: 37 additions & 6 deletions bootloaders/eboot/eboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,39 @@

#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);

extern void ets_wdt_enable(void);
extern void ets_wdt_disable(void);
/*
After Power Enable Pin, EXT_RST, or HWDT event, at "main()" in eboot, WDT is
disabled. Key WDT hardware registers are zero.
After "ESP.restart()" and other soft restarts, at "main()" in eboot, WDT is enabled.
References for the under-documented ets_wdt_* API
https://mongoose-os.com/blog/esp8266-watchdog-timer/
http://cholla.mmto.org/esp8266/bootrom/boot.txt
After looking at esp8266-watchdog-timer some more, `ets_wdt_enable(4, 12, 12)`
is good for eboot's needs. From a ".map" the NON-OS SDK does not use the
ets_wdt_* APIs, so our choices are not too critical.
The SDK will set up the WDT as it wants it.
A rationale for keeping the "ets_wdt_enable()" line, if the system is not
stable during a "soft restart," the HWDT would provide a recovery reboot.
*/
extern void ets_wdt_enable(uint32_t mode, uint32_t arg1, uint32_t arg2);
/*
"ets_wdt_disable"
Diables WDT, then feeds the dog.
For current modes other than 1 or 2, returns the current mode.
For current mode 1, calls ets_timer_disarm, then return the current mode.
For current mode 2, calls ets_isr_mask, then return the current mode.
I always see a return value of 0xFFFFFFFF.
The return value would normally be used with ets_wdt_restore; however, that is
not an option since a valid prior call to ets_wdt_enable() may not have been done.
*/
extern uint32_t ets_wdt_disable(void);

int print_version(const uint32_t flash_addr)
{
Expand Down Expand Up @@ -241,12 +272,12 @@ int main()

ets_wdt_disable();
res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2], false);
ets_wdt_enable();
ets_wdt_enable(4, 12, 12); // WDT about 13 secs.

ets_printf("%d\n", res);
#if 0
//devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the
//beginning of the image in the empty area, see #7458. Disabling for now.
//devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the
//beginning of the image in the empty area, see #7458. Disabling for now.
//TODO: replace the below verify with hash type, crc, or similar.
// Verify the copy
ets_printf("cmp:");
Expand All @@ -257,7 +288,7 @@ int main()
}

ets_printf("%d\n", res);
#endif
#endif
if (res == 0) {
cmd.action = ACTION_LOAD_APP;
cmd.args[0] = cmd.args[1];
Expand Down
Binary file modified bootloaders/eboot/eboot.elf
Binary file not shown.
14 changes: 13 additions & 1 deletion cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "umm_malloc/umm_malloc.h"
#include <pgmspace.h>
#include "reboot_uart_dwnld.h"
#include "hardware_reset.h"

extern "C" {
#include "user_interface.h"
Expand Down Expand Up @@ -519,7 +520,7 @@ struct rst_info * EspClass::getResetInfoPtr(void) {
}

bool EspClass::eraseConfig(void) {
const size_t cfgSize = 0x4000;
const size_t cfgSize = 0x4000; // Sectors: RF_CAL + SYSTEMPARAM[3]
size_t cfgAddr = ESP.getFlashChipSize() - cfgSize;

for (size_t offset = 0; offset < cfgSize; offset += SPI_FLASH_SEC_SIZE) {
Expand All @@ -531,6 +532,17 @@ bool EspClass::eraseConfig(void) {
return true;
}

bool EspClass::eraseConfigAndReset(void) {
// Before calling, ensure the WiFi state is equivalent to
// "WiFi.mode(WIFI_OFF)." This will reduce the likelihood of the SDK
// performing WiFi data writes to Flash between erasing and resetting.
bool reset = eraseConfig();
if (reset) {
hardware_reset();
}
return reset;
}

uint8_t *EspClass::random(uint8_t *resultArray, const size_t outputSizeBytes)
{
/**
Expand Down
16 changes: 16 additions & 0 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ class EspClass {

static bool eraseConfig();

/**
* @brief Erases 4 sectors at the end of flash, 1 - RF_CAL and 3 - SYSTEMPARM.
* These are the same additional sectors that are erase when you select
* Erase Flash: "Sketch + WiFi Settings" from the Arduino IDE Tools menu.
*
* This operation erases the running SDK's flash configuration space.
* As a precaution before calling, first call "WiFi.mode(WIFI_OFF)."
*
* If you need to erase "WiFi Settings" and reboot consider using
* "ArduinoOTA.eraseConfigAndReset()" it handles shutting down WiFi
* before the erase.
* @return bool result of operation. Always False on return.
* Function does not return on success.
*/
static bool eraseConfigAndReset();

static uint8_t *random(uint8_t *resultArray, const size_t outputSizeBytes);
static uint32_t random();

Expand Down
26 changes: 26 additions & 0 deletions cores/esp8266/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,32 @@ String Stream::readStringUntil(char terminator) {
return ret;
}

String Stream::readStringUntil(const char* terminator, uint32_t untilTotalNumberOfOccurrences) {
String ret;
int c;
uint32_t occurrences = 0;
size_t termLen = strlen(terminator);
size_t termIndex = 0;
size_t index = 0;

while ((c = timedRead()) > 0) {
ret += (char) c;
index++;

if (terminator[termIndex] == c) {
if (++termIndex == termLen && ++occurrences == untilTotalNumberOfOccurrences) {
// don't include terminator in returned string
ret.remove(index - termIndex, termLen);
break;
}
} else {
termIndex = 0;
}
}

return ret;
}

// read what can be read, immediate exit on unavailable data
// prototype similar to Arduino's `int Client::read(buf, len)`
int Stream::read (uint8_t* buffer, size_t maxLen)
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class Stream: public Print {
// Arduino String functions to be added here
virtual String readString();
String readStringUntil(char terminator);
String readStringUntil(const char* terminator, uint32_t untilTotalNumberOfOccurrences = 1);

virtual int read (uint8_t* buffer, size_t len);
int read (char* buffer, size_t len) { return read((uint8_t*)buffer, len); }
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/Udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class UDP: public Stream {
public:
virtual ~UDP() {};
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
virtual void stop() =0; // Finish with the UDP socket

// Sending UDP packets
Expand Down
Loading

0 comments on commit 2874a98

Please sign in to comment.