From 235b96d97a8adb2dd9ddf7d3a26e019ac65c1e4e Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 9 Jan 2023 18:39:08 +0300 Subject: [PATCH 1/6] fix --- cores/esp8266/core_esp8266_eboot_command.cpp | 2 +- cores/esp8266/core_esp8266_features.h | 3 ++- cores/esp8266/coredecls.h | 7 ++++--- cores/esp8266/crc32.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cores/esp8266/core_esp8266_eboot_command.cpp b/cores/esp8266/core_esp8266_eboot_command.cpp index 2ddc65933e..b3497474ae 100644 --- a/cores/esp8266/core_esp8266_eboot_command.cpp +++ b/cores/esp8266/core_esp8266_eboot_command.cpp @@ -29,7 +29,7 @@ extern "C" { static uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd) { - return crc32((const uint8_t*) cmd, offsetof(struct eboot_command, crc32)); + return crc32((const uint8_t*) cmd, offsetof(struct eboot_command, crc32), 0xffffffff); } int eboot_command_read(struct eboot_command* cmd) diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index 43ba31674e..a0b0ad80ad 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -33,9 +33,10 @@ #define WIFI_HAS_EVENT_CALLBACK #define WIFI_IS_OFF_AT_BOOT -#include // malloc() +#include // bool #include // size_t #include +#include // malloc() #ifndef __STRINGIFY #define __STRINGIFY(a) #a diff --git a/cores/esp8266/coredecls.h b/cores/esp8266/coredecls.h index 1e2776d71b..afca22f8d9 100644 --- a/cores/esp8266/coredecls.h +++ b/cores/esp8266/coredecls.h @@ -20,14 +20,15 @@ void esp_delay(unsigned long ms); void esp_schedule(); void esp_yield(); void tune_timeshift64 (uint64_t now_us); +bool sntp_set_timezone_in_seconds(int32_t timezone); + void disable_extra4k_at_link_time (void) __attribute__((noinline)); void enable_wifi_enterprise_patch(void) __attribute__((noinline)); -bool sntp_set_timezone_in_seconds(int32_t timezone); void __disableWiFiAtBootTime (void) __attribute__((noinline)); void __real_system_restart_local() __attribute__((noreturn)); -uint32_t sqrt32 (uint32_t n); -uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff); +uint32_t sqrt32(uint32_t n); +uint32_t crc32(const void* data, size_t length, uint32_t crc); #ifdef __cplusplus } diff --git a/cores/esp8266/crc32.cpp b/cores/esp8266/crc32.cpp index c2fdf928e7..42de0c1b91 100644 --- a/cores/esp8266/crc32.cpp +++ b/cores/esp8266/crc32.cpp @@ -23,7 +23,7 @@ #include "pgmspace.h" // moved from core_esp8266_eboot_command.cpp -uint32_t crc32 (const void* data, size_t length, uint32_t crc /*= 0xffffffff*/) +uint32_t crc32 (const void* data, size_t length, uint32_t crc) { const uint8_t* ldata = (const uint8_t*)data; while (length--) From f463bd758261b6db3ccfce8fcb059026fdf57353 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 9 Jan 2023 19:25:15 +0300 Subject: [PATCH 2/6] re-add default under cplusplus instead --- cores/esp8266/Esp.cpp | 2 +- cores/esp8266/core_esp8266_eboot_command.cpp | 2 +- cores/esp8266/coredecls.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index 0109bbe943..20da390008 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -471,7 +471,7 @@ bool EspClass::checkFlashCRC() { uint32_t firstPart = (uintptr_t)&__crc_len - 0x40200000; // How many bytes to check before the 1st CRC val // Start the checksum - uint32_t crc = crc32((const void*)0x40200000, firstPart, 0xffffffff); + uint32_t crc = crc32((const void*)0x40200000, firstPart); // Pretend the 2 words of crc/len are zero to be idempotent crc = crc32(z, 8, crc); // Finish the CRC calculation over the rest of flash diff --git a/cores/esp8266/core_esp8266_eboot_command.cpp b/cores/esp8266/core_esp8266_eboot_command.cpp index b3497474ae..2ddc65933e 100644 --- a/cores/esp8266/core_esp8266_eboot_command.cpp +++ b/cores/esp8266/core_esp8266_eboot_command.cpp @@ -29,7 +29,7 @@ extern "C" { static uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd) { - return crc32((const uint8_t*) cmd, offsetof(struct eboot_command, crc32), 0xffffffff); + return crc32((const uint8_t*) cmd, offsetof(struct eboot_command, crc32)); } int eboot_command_read(struct eboot_command* cmd) diff --git a/cores/esp8266/coredecls.h b/cores/esp8266/coredecls.h index afca22f8d9..368aaf135c 100644 --- a/cores/esp8266/coredecls.h +++ b/cores/esp8266/coredecls.h @@ -28,11 +28,12 @@ void __disableWiFiAtBootTime (void) __attribute__((noinline)); void __real_system_restart_local() __attribute__((noreturn)); uint32_t sqrt32(uint32_t n); -uint32_t crc32(const void* data, size_t length, uint32_t crc); #ifdef __cplusplus } +uint32_t crc32(const void* data, size_t length, uint32_t crc = 0xffffffff); + #include using BoolCB = std::function; From f294a614c0040b751e800098eb4e10e4d6d87e25 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 9 Jan 2023 21:14:39 +0300 Subject: [PATCH 3/6] attr placement --- cores/esp8266/core_esp8266_features.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index a0b0ad80ad..8cc20c6b6e 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -20,11 +20,9 @@ */ - #ifndef CORE_ESP8266_FEATURES_H #define CORE_ESP8266_FEATURES_H - #define CORE_HAS_LIBB64 #define CORE_HAS_BASE64_CLASS #define CORE_HAS_CXA_GUARD @@ -130,7 +128,7 @@ void enablePhaseLockedWaveform(void); // Determine when the sketch runs on ESP8285 #if !defined(CORE_MOCK) -bool __attribute__((const, nothrow)) esp_is_8285(); +bool esp_is_8285() __attribute__((const, nothrow)); #else inline bool esp_is_8285() { From 6fb4e557bf76af1a029fa40b7b1b5b042eea1430 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 10 Jan 2023 21:41:56 +0300 Subject: [PATCH 4/6] sanity check --- .github/workflows/build-ide.yml | 16 +++++++++++ cores/esp8266/core_esp8266_features.h | 3 ++- tests/sanity_check.sh | 38 +++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 tests/sanity_check.sh diff --git a/.github/workflows/build-ide.yml b/.github/workflows/build-ide.yml index a2801a60cb..75e0e0583e 100644 --- a/.github/workflows/build-ide.yml +++ b/.github/workflows/build-ide.yml @@ -11,6 +11,22 @@ permissions: jobs: # Examples are built in parallel to avoid CI total job time limitation + sanity-check: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v3 + with: + submodules: false + - uses: actions/cache@v3 + with: + path: ./tools/dist + key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }} + - name: Toolchain sanity checks + run: | + bash ./tests/sanity_check.sh build-linux: name: Linux - LwIP ${{ matrix.lwip }} (${{ matrix.chunk }}) diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index 8cc20c6b6e..33531ce6e2 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -31,7 +31,7 @@ #define WIFI_HAS_EVENT_CALLBACK #define WIFI_IS_OFF_AT_BOOT -#include // bool +//#include // bool #include // size_t #include #include // malloc() @@ -117,6 +117,7 @@ int esp_get_cpu_freq_mhz() #else inline int esp_get_cpu_freq_mhz() { + uint8_t system_get_cpu_freq(void); return system_get_cpu_freq(); } #endif diff --git a/tests/sanity_check.sh b/tests/sanity_check.sh new file mode 100755 index 0000000000..ef4d080f50 --- /dev/null +++ b/tests/sanity_check.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +root=$(git rev-parse --show-toplevel) +source "$root/tests/common.sh" + +pushd "$root"/tools +python3 get.py -q + +popd +pushd "$cache_dir" + +gcc="$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc"\ +" -I$root/cores/esp8266"\ +" -I$root/tools/sdk/include"\ +" -I$root/variants/generic"\ +" -I$root/tools/sdk/libc/xtensa-lx106-elf" + +$gcc --verbose + +set -v -x + +cat << EOF > arduino.c +#include +EOF + +$gcc -c arduino.c + +cat << EOF > coredecls.c +#include +EOF + +$gcc -c coredecls.c + +cat << EOF > features.c +#include +EOF + +$gcc -c features.c From 525ec896fe5388337e02aaa3d3905312bef5a977 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 10 Jan 2023 21:42:18 +0300 Subject: [PATCH 5/6] re-apply fix --- cores/esp8266/core_esp8266_features.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index 33531ce6e2..9c574f20c7 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -31,7 +31,7 @@ #define WIFI_HAS_EVENT_CALLBACK #define WIFI_IS_OFF_AT_BOOT -//#include // bool +#include // bool #include // size_t #include #include // malloc() From 1adf6e8e87e6aaf73af4895228710469d3f431a9 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 10 Jan 2023 21:54:40 +0300 Subject: [PATCH 6/6] fixup --- tests/sanity_check.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/sanity_check.sh b/tests/sanity_check.sh index ef4d080f50..a4754a0ed4 100755 --- a/tests/sanity_check.sh +++ b/tests/sanity_check.sh @@ -36,3 +36,9 @@ cat << EOF > features.c EOF $gcc -c features.c + +cat << EOF > sdk.c +#include +EOF + +$gcc -c sdk.c