Skip to content

Commit 8d34181

Browse files
mcsprhasenradball
authored andcommitted
Fix C builds (esp8266#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)
1 parent c2a1fc3 commit 8d34181

File tree

6 files changed

+71
-9
lines changed

6 files changed

+71
-9
lines changed

.github/workflows/build-ide.yml

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ permissions:
1111
jobs:
1212

1313
# Examples are built in parallel to avoid CI total job time limitation
14+
sanity-check:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
shell: bash
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
submodules: false
23+
- uses: actions/cache@v3
24+
with:
25+
path: ./tools/dist
26+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }}
27+
- name: Toolchain sanity checks
28+
run: |
29+
bash ./tests/sanity_check.sh
1430
1531
build-linux:
1632
name: Linux - LwIP ${{ matrix.lwip }} (${{ matrix.chunk }})

cores/esp8266/Esp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ bool EspClass::checkFlashCRC() {
471471
uint32_t firstPart = (uintptr_t)&__crc_len - 0x40200000; // How many bytes to check before the 1st CRC val
472472

473473
// Start the checksum
474-
uint32_t crc = crc32((const void*)0x40200000, firstPart, 0xffffffff);
474+
uint32_t crc = crc32((const void*)0x40200000, firstPart);
475475
// Pretend the 2 words of crc/len are zero to be idempotent
476476
crc = crc32(z, 8, crc);
477477
// Finish the CRC calculation over the rest of flash

cores/esp8266/core_esp8266_features.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
2121
*/
2222

23-
2423
#ifndef CORE_ESP8266_FEATURES_H
2524
#define CORE_ESP8266_FEATURES_H
2625

27-
2826
#define CORE_HAS_LIBB64
2927
#define CORE_HAS_BASE64_CLASS
3028
#define CORE_HAS_CXA_GUARD
@@ -33,9 +31,10 @@
3331
#define WIFI_HAS_EVENT_CALLBACK
3432
#define WIFI_IS_OFF_AT_BOOT
3533

36-
#include <stdlib.h> // malloc()
34+
#include <stdbool.h> // bool
3735
#include <stddef.h> // size_t
3836
#include <stdint.h>
37+
#include <stdlib.h> // malloc()
3938

4039
#ifndef __STRINGIFY
4140
#define __STRINGIFY(a) #a
@@ -118,6 +117,7 @@ int esp_get_cpu_freq_mhz()
118117
#else
119118
inline int esp_get_cpu_freq_mhz()
120119
{
120+
uint8_t system_get_cpu_freq(void);
121121
return system_get_cpu_freq();
122122
}
123123
#endif
@@ -129,7 +129,7 @@ void enablePhaseLockedWaveform(void);
129129

130130
// Determine when the sketch runs on ESP8285
131131
#if !defined(CORE_MOCK)
132-
bool __attribute__((const, nothrow)) esp_is_8285();
132+
bool esp_is_8285() __attribute__((const, nothrow));
133133
#else
134134
inline bool esp_is_8285()
135135
{

cores/esp8266/coredecls.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ void esp_delay(unsigned long ms);
2020
void esp_schedule();
2121
void esp_yield();
2222
void tune_timeshift64 (uint64_t now_us);
23+
bool sntp_set_timezone_in_seconds(int32_t timezone);
24+
2325
void disable_extra4k_at_link_time (void) __attribute__((noinline));
2426
void enable_wifi_enterprise_patch(void) __attribute__((noinline));
25-
bool sntp_set_timezone_in_seconds(int32_t timezone);
2627
void __disableWiFiAtBootTime (void) __attribute__((noinline));
2728
void __real_system_restart_local() __attribute__((noreturn));
2829

29-
uint32_t sqrt32 (uint32_t n);
30-
uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff);
30+
uint32_t sqrt32(uint32_t n);
3131

3232
#ifdef __cplusplus
3333
}
3434

35+
uint32_t crc32(const void* data, size_t length, uint32_t crc = 0xffffffff);
36+
3537
#include <functional>
3638

3739
using BoolCB = std::function<void(bool)>;

cores/esp8266/crc32.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "pgmspace.h"
2424

2525
// moved from core_esp8266_eboot_command.cpp
26-
uint32_t crc32 (const void* data, size_t length, uint32_t crc /*= 0xffffffff*/)
26+
uint32_t crc32 (const void* data, size_t length, uint32_t crc)
2727
{
2828
const uint8_t* ldata = (const uint8_t*)data;
2929
while (length--)

tests/sanity_check.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
root=$(git rev-parse --show-toplevel)
4+
source "$root/tests/common.sh"
5+
6+
pushd "$root"/tools
7+
python3 get.py -q
8+
9+
popd
10+
pushd "$cache_dir"
11+
12+
gcc="$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc"\
13+
" -I$root/cores/esp8266"\
14+
" -I$root/tools/sdk/include"\
15+
" -I$root/variants/generic"\
16+
" -I$root/tools/sdk/libc/xtensa-lx106-elf"
17+
18+
$gcc --verbose
19+
20+
set -v -x
21+
22+
cat << EOF > arduino.c
23+
#include <Arduino.h>
24+
EOF
25+
26+
$gcc -c arduino.c
27+
28+
cat << EOF > coredecls.c
29+
#include <coredecls.h>
30+
EOF
31+
32+
$gcc -c coredecls.c
33+
34+
cat << EOF > features.c
35+
#include <core_esp8266_features.h>
36+
EOF
37+
38+
$gcc -c features.c
39+
40+
cat << EOF > sdk.c
41+
#include <version.h>
42+
EOF
43+
44+
$gcc -c sdk.c

0 commit comments

Comments
 (0)