Skip to content

Commit 83a32f1

Browse files
Add compilation to CI (earlephilhower#155)
Stolen from ESP8266, modified to run basic sanity compiles on the core. Fix warnings identified by the new checks.
1 parent 10a44c8 commit 83a32f1

30 files changed

+939
-34
lines changed

.github/workflows/pull-request.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,39 @@ jobs:
2424
with:
2525
skip: ./pico-extras,./ArduinoCore-API,./libraries/SdFat,./libraries/Adafruit_TinyUSB_Arduino,./libraries/LittleFS/lib,./tools/pyserial,./pico-sdk,./.github,./docs/i2s.rst
2626
ignore_words_list: ser,DOUT
27+
28+
29+
build-linux:
30+
name: Build ${{ matrix.chunk }}
31+
runs-on: ubuntu-latest
32+
strategy:
33+
matrix:
34+
chunk: [0, 1, 2, 3, 4, 5, 6, 7]
35+
steps:
36+
- uses: actions/checkout@v2
37+
with:
38+
submodules: true
39+
- uses: actions/setup-python@v2
40+
with:
41+
python-version: '3.x'
42+
- name: Cache Linux toolchain
43+
id: cache-linux
44+
uses: actions/cache@v2
45+
with:
46+
path: ./tools/dist
47+
key: ${{ runner.os }}-${{ hashFiles('package/package_pico_index.template.json', 'tests/common.sh') }}
48+
- name: Build Sketches
49+
env:
50+
TRAVIS_BUILD_DIR: ${{ github.workspace }}
51+
TRAVIS_TAG: ${{ github.ref }}
52+
BUILD_PARITY: custom
53+
mod: 8
54+
rem: ${{ matrix.chunk }}
55+
run: |
56+
cd pico-sdk
57+
git submodule update --init
58+
cd ../pico-extras
59+
git submodule update --init
60+
cd ..
61+
bash ./tests/build.sh
62+

cores/rp2040/RP2040USB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ uint8_t const * tud_hid_descriptor_report_cb(void)
161161

162162
const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
163163
(void)index;
164-
int len = 0;
165164
static uint8_t *usbd_desc_cfg;
166165

167166
if (!usbd_desc_cfg) {
@@ -217,6 +216,7 @@ const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
217216
}
218217

219218
const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
219+
(void) langid;
220220
#define DESC_STR_MAX (20)
221221
static uint16_t desc_str[DESC_STR_MAX];
222222

cores/rp2040/SerialUSB.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ size_t SerialUSB::write(const uint8_t *buf, size_t length) {
125125
static uint64_t last_avail_time;
126126
int i = 0;
127127
if (tud_cdc_connected()) {
128-
for (int i = 0; i < length;) {
128+
for (size_t i = 0; i < length;) {
129129
int n = length - i;
130130
int avail = tud_cdc_write_available();
131131
if (n > avail) n = avail;
@@ -173,12 +173,14 @@ static void CheckSerialReset() {
173173
}
174174

175175
extern "C" void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
176+
(void) itf;
176177
_dtr = dtr ? true : false;
177178
_rts = rts ? true : false;
178179
CheckSerialReset();
179180
}
180181

181182
extern "C" void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding) {
183+
(void) itf;
182184
_bps = p_line_coding->bit_rate;
183185
CheckSerialReset();
184186
}

cores/rp2040/SerialUSB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SerialUSB : public HardwareSerial {
2929
public:
3030
SerialUSB() { }
3131
void begin(unsigned long baud = 115200) override;
32-
void begin(unsigned long baud, uint16_t config) override { begin(baud); };
32+
void begin(unsigned long baud, uint16_t config) override { (void) config; begin(baud); };
3333
void end() override;
3434

3535
virtual int peek() override;

cores/rp2040/Tone.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static PIOProgram _tonePgm(&tone_program);
3939
static std::map<pin_size_t, Tone *> _toneMap;
4040

4141
void tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
42-
if ((pin < 0) || (pin > 29)) {
42+
if (pin > 29) {
4343
DEBUGCORE("ERROR: Illegal pin in tone (%d)\n", pin);
4444
return;
4545
}
@@ -87,7 +87,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
8787
void noTone(uint8_t pin) {
8888
CoreMutex m(&_toneMutex);
8989

90-
if ((pin < 0) || (pin > 29) || !m) {
90+
if ((pin > 29) || !m) {
9191
DEBUGCORE("ERROR: Illegal pin in tone (%d)\n", pin);
9292
return;
9393
}

cores/rp2040/posix.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,34 @@ extern "C" int errno;
3535

3636
extern "C" ssize_t _write(int fd, const void *buf, size_t count) {
3737
#if defined DEBUG_RP2040_PORT
38+
(void) fd;
3839
return DEBUG_RP2040_PORT.write((const char *)buf, count);
3940
#else
41+
(void) fd;
42+
(void) buf;
43+
(void) count;
4044
return 0;
4145
#endif
4246
}
4347

4448
extern "C" int _chown (const char *path, uid_t owner, gid_t group) {
49+
(void) path;
50+
(void) owner;
51+
(void) group;
4552
errno = ENOSYS;
4653
return -1;
4754
}
4855

49-
extern "C" int _close (int fildes) {
56+
extern "C" int _close (int fd) {
57+
(void) fd;
5058
errno = ENOSYS;
5159
return -1;
5260
}
5361

5462
extern "C" int _execve (char *name, char **argv, char **env) {
63+
(void) name;
64+
(void) argv;
65+
(void) env;
5566
errno = ENOSYS;
5667
return -1;
5768
}
@@ -61,7 +72,9 @@ extern "C" int _fork (void) {
6172
return -1;
6273
}
6374

64-
extern "C" int _fstat (int fildes, struct stat *st) {
75+
extern "C" int _fstat (int fd, struct stat *st) {
76+
(void) fd;
77+
(void) st;
6578
errno = ENOSYS;
6679
return -1;
6780
}
@@ -74,6 +87,7 @@ extern "C" int _getpid (void) {
7487
static int64_t __timedelta_us = 0.0;
7588

7689
extern "C" int _gettimeofday (struct timeval *tv, void *tz) {
90+
(void) tz;
7791
uint64_t now_us = to_us_since_boot(get_absolute_time()) + __timedelta_us;
7892
if (tv) {
7993
tv->tv_sec = now_us / 1000000L;
@@ -83,6 +97,7 @@ extern "C" int _gettimeofday (struct timeval *tv, void *tz) {
8397
}
8498

8599
extern "C" int settimeofday (const struct timeval *tv, const struct timezone *tz) {
100+
(void) tz;
86101
uint64_t now_us = to_us_since_boot(get_absolute_time());
87102
if (tv) {
88103
uint64_t newnow_us;
@@ -94,62 +109,86 @@ extern "C" int settimeofday (const struct timeval *tv, const struct timezone *tz
94109
}
95110

96111
extern "C" int _isatty (int file) {
112+
(void) file;
97113
errno = ENOSYS;
98114
return 0;
99115
}
100116

101117
extern "C" int _kill (int pid, int sig) {
118+
(void) pid;
119+
(void) sig;
102120
errno = ENOSYS;
103121
return -1;
104122
}
105123

106124
extern "C" int _link (char *existing, char *newlink) {
125+
(void) existing;
126+
(void) newlink;
107127
errno = ENOSYS;
108128
return -1;
109129
}
110130

111131
extern "C" int _lseek (int file, int ptr, int dir) {
132+
(void) file;
133+
(void) ptr;
134+
(void) dir;
112135
errno = ENOSYS;
113136
return -1;
114137
}
115138

116139
extern "C" int _open (char *file, int flags, int mode) {
140+
(void) file;
141+
(void) flags;
142+
(void) mode;
117143
errno = ENOSYS;
118144
return -1;
119145
}
120146

121147
extern "C" int _read (int file, char *ptr, int len)
122148
{
149+
(void) file;
150+
(void) ptr;
151+
(void) len;
123152
// return Serial.read(ptr, len);
124153
return -1;
125154
}
126155

127156
extern "C" int _readlink (const char *path, char *buf, size_t bufsize) {
157+
(void) path;
158+
(void) buf;
159+
(void) bufsize;
128160
errno = ENOSYS;
129161
return -1;
130162
}
131163

132164
extern "C" int _stat (const char *file, struct stat *st) {
165+
(void) file;
166+
(void) st;
133167
errno = ENOSYS;
134168
return -1;
135169
}
136170

137171
extern "C" int _symlink (const char *path1, const char *path2) {
172+
(void) path1;
173+
(void) path2;
138174
errno = ENOSYS;
139175
return -1;
140176
}
141177

142178
extern "C" clock_t _times (struct tms *buf) {
179+
(void) buf;
143180
errno = ENOSYS;
144181
return -1;
145182
}
146183

147184
extern "C" int _unlink (char *name) {
185+
(void) name;
148186
errno = ENOSYS;
149187
return -1;
150188
}
151189

152190
extern "C" int _wait (int *status) {
191+
(void) status;
153192
errno = ENOSYS;
154193
return -1;
155194
}

cores/rp2040/wiring_analog.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
#include <hardware/pll.h>
2727
#include <hardware/adc.h>
2828

29-
static int32_t analogScale = 255;
30-
static uint32_t analogMap = 0;
29+
static uint32_t analogScale = 255;
3130
static uint16_t analogFreq = 1000;
3231
static bool pwmInitted = false;
3332
static bool adcInitted = false;
@@ -73,7 +72,7 @@ extern "C" void analogWriteResolution(int res) {
7372
extern "C" void analogWrite(pin_size_t pin, int val) {
7473
CoreMutex m(&_dacMutex);
7574

76-
if ((pin < 0) || (pin > 29) || !m) {
75+
if ((pin > 29) || !m) {
7776
DEBUGCORE("ERROR: Illegal analogWrite pin (%d)\n", pin);
7877
return;
7978
}
@@ -89,7 +88,7 @@ extern "C" void analogWrite(pin_size_t pin, int val) {
8988

9089
if (val < 0) {
9190
val = 0;
92-
} else if (val > analogScale) {
91+
} else if ((uint32_t)val > analogScale) {
9392
val = analogScale;
9493
}
9594

cores/rp2040/wiring_digital.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ extern "C" void pinMode( pin_size_t ulPin, PinMode ulMode ) {
5151
return;
5252
}
5353

54-
if ((ulPin < 0) || (ulPin > 29)) {
54+
if (ulPin > 29) {
5555
DEBUGCORE("ERROR: Illegal pin in pinMode (%d)\n", ulPin);
5656
return;
5757
}
5858
_pm[ulPin] = ulMode;
5959
}
6060

6161
extern "C" void digitalWrite( pin_size_t ulPin, PinStatus ulVal ) {
62-
if ((ulPin < 0) || (ulPin > 29)) {
62+
if (ulPin > 29) {
6363
DEBUGCORE("ERROR: Illegal pin in pinMode (%d)\n", ulPin);
6464
return;
6565
}
@@ -81,10 +81,9 @@ extern "C" void digitalWrite( pin_size_t ulPin, PinStatus ulVal ) {
8181
}
8282

8383
extern "C" PinStatus digitalRead( pin_size_t ulPin ) {
84-
if ((ulPin < 0) || (ulPin > 29)) {
84+
if (ulPin > 29) {
8585
DEBUGCORE("ERROR: Illegal pin in digitalRead (%d)\n", ulPin);
8686
return LOW;
8787
}
8888
return gpio_get(ulPin) ? HIGH : LOW;
8989
}
90-

cores/rp2040/wiring_private.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ auto_init_mutex(_irqMutex);
4848
static std::map<pin_size_t, voidFuncPtr> _map;
4949

5050
void _gpioInterruptDispatcher(uint gpio, uint32_t events) {
51+
(void) events;
5152
// Only need to lock around the std::map check, not the whole IRQ callback
5253
voidFuncPtr cb = nullptr;
5354
{

cores/rp2040/wiring_pulse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeo
2727
uint64_t start = time_us_64();
2828
uint64_t abort = start + timeout;
2929

30-
if ((pin < 0) || (pin > 29)) {
30+
if (pin > 29) {
3131
DEBUGCORE("ERROR: Illegal pin in pulseIn (%d)\n", pin);
3232
return 0;
3333
}

cores/rp2040/wiring_shift.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,42 @@
2424
extern "C" uint8_t shiftIn(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder) {
2525
uint8_t value = 0;
2626
uint8_t i;
27-
if ((dataPin < 0) || (dataPin > 29)) {
27+
if (dataPin > 29) {
2828
DEBUGCORE("ERROR: Illegal dataPin in shiftIn (%d)\n", dataPin);
2929
return 0;
3030
}
31-
if ((clockPin < 0) || (clockPin > 29)) {
31+
if (clockPin > 29) {
3232
DEBUGCORE("ERROR: Illegal clockPin in shiftIn (%d)\n", clockPin);
3333
return 0;
3434
}
3535
for (i = 0; i < 8; ++i) {
3636
digitalWrite(clockPin, HIGH);
37-
if (bitOrder == LSBFIRST)
37+
if (bitOrder == LSBFIRST) {
3838
value |= digitalRead(dataPin) << i;
39-
else
39+
} else {
4040
value |= digitalRead(dataPin) << (7 - i);
41-
digitalWrite(clockPin, LOW);
41+
}
42+
digitalWrite(clockPin, LOW);
4243
}
4344
return value;
4445
}
4546

4647
extern "C" void shiftOut(pin_size_t dataPin, pin_size_t clockPin, BitOrder bitOrder, uint8_t val) {
4748
uint8_t i;
48-
if ((dataPin < 0) || (dataPin > 29)) {
49+
if (dataPin > 29) {
4950
DEBUGCORE("ERROR: Illegal dataPin in shiftOut (%d)\n", dataPin);
5051
return;
5152
}
52-
if ((clockPin < 0) || (clockPin > 29)) {
53+
if (clockPin > 29) {
5354
DEBUGCORE("ERROR: Illegal clockPin in shiftOut (%d)\n", clockPin);
5455
return;
5556
}
5657
for (i = 0; i < 8; i++) {
57-
if (bitOrder == LSBFIRST)
58+
if (bitOrder == LSBFIRST) {
5859
digitalWrite(dataPin, !!(val & (1 << i)));
59-
else
60+
} else {
6061
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
62+
}
6163

6264
digitalWrite(clockPin, HIGH);
6365
digitalWrite(clockPin, LOW);

0 commit comments

Comments
 (0)