1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

Fix C builds (#8795)

Missing stdbool.h for 'bool' in features .h, at least one user is arduinoWebSockets
Adds minimal headers sanity-check script to verify that C builds work as expected

Also noticed and removed default argument from crc32() in internal .h that may be used in .c
(not sure how extern C & default worked simultaniously, but at least in our .cpp Gcc somehow figured out it is a no overload solution)
This commit is contained in:
Max Prokhorov 2023-01-11 03:48:30 +03:00 committed by GitHub
parent 7e2da8b25b
commit 840ef78237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 9 deletions

View File

@ -11,6 +11,22 @@ permissions:
jobs: jobs:
# Examples are built in parallel to avoid CI total job time limitation # 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: build-linux:
name: Linux - LwIP ${{ matrix.lwip }} (${{ matrix.chunk }}) name: Linux - LwIP ${{ matrix.lwip }} (${{ matrix.chunk }})

View File

@ -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 uint32_t firstPart = (uintptr_t)&__crc_len - 0x40200000; // How many bytes to check before the 1st CRC val
// Start the checksum // 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 // Pretend the 2 words of crc/len are zero to be idempotent
crc = crc32(z, 8, crc); crc = crc32(z, 8, crc);
// Finish the CRC calculation over the rest of flash // Finish the CRC calculation over the rest of flash

View File

@ -20,11 +20,9 @@
*/ */
#ifndef CORE_ESP8266_FEATURES_H #ifndef CORE_ESP8266_FEATURES_H
#define CORE_ESP8266_FEATURES_H #define CORE_ESP8266_FEATURES_H
#define CORE_HAS_LIBB64 #define CORE_HAS_LIBB64
#define CORE_HAS_BASE64_CLASS #define CORE_HAS_BASE64_CLASS
#define CORE_HAS_CXA_GUARD #define CORE_HAS_CXA_GUARD
@ -33,9 +31,10 @@
#define WIFI_HAS_EVENT_CALLBACK #define WIFI_HAS_EVENT_CALLBACK
#define WIFI_IS_OFF_AT_BOOT #define WIFI_IS_OFF_AT_BOOT
#include <stdlib.h> // malloc() #include <stdbool.h> // bool
#include <stddef.h> // size_t #include <stddef.h> // size_t
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> // malloc()
#ifndef __STRINGIFY #ifndef __STRINGIFY
#define __STRINGIFY(a) #a #define __STRINGIFY(a) #a
@ -118,6 +117,7 @@ int esp_get_cpu_freq_mhz()
#else #else
inline int esp_get_cpu_freq_mhz() inline int esp_get_cpu_freq_mhz()
{ {
uint8_t system_get_cpu_freq(void);
return system_get_cpu_freq(); return system_get_cpu_freq();
} }
#endif #endif
@ -129,7 +129,7 @@ void enablePhaseLockedWaveform(void);
// Determine when the sketch runs on ESP8285 // Determine when the sketch runs on ESP8285
#if !defined(CORE_MOCK) #if !defined(CORE_MOCK)
bool __attribute__((const, nothrow)) esp_is_8285(); bool esp_is_8285() __attribute__((const, nothrow));
#else #else
inline bool esp_is_8285() inline bool esp_is_8285()
{ {

View File

@ -20,18 +20,20 @@ void esp_delay(unsigned long ms);
void esp_schedule(); void esp_schedule();
void esp_yield(); void esp_yield();
void tune_timeshift64 (uint64_t now_us); 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 disable_extra4k_at_link_time (void) __attribute__((noinline));
void enable_wifi_enterprise_patch(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 __disableWiFiAtBootTime (void) __attribute__((noinline));
void __real_system_restart_local() __attribute__((noreturn)); void __real_system_restart_local() __attribute__((noreturn));
uint32_t sqrt32 (uint32_t n); uint32_t sqrt32(uint32_t n);
uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff);
#ifdef __cplusplus #ifdef __cplusplus
} }
uint32_t crc32(const void* data, size_t length, uint32_t crc = 0xffffffff);
#include <functional> #include <functional>
using BoolCB = std::function<void(bool)>; using BoolCB = std::function<void(bool)>;

View File

@ -23,7 +23,7 @@
#include "pgmspace.h" #include "pgmspace.h"
// moved from core_esp8266_eboot_command.cpp // 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; const uint8_t* ldata = (const uint8_t*)data;
while (length--) while (length--)

44
tests/sanity_check.sh Executable file
View File

@ -0,0 +1,44 @@
#!/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 <Arduino.h>
EOF
$gcc -c arduino.c
cat << EOF > coredecls.c
#include <coredecls.h>
EOF
$gcc -c coredecls.c
cat << EOF > features.c
#include <core_esp8266_features.h>
EOF
$gcc -c features.c
cat << EOF > sdk.c
#include <version.h>
EOF
$gcc -c sdk.c