Skip to content

Commit 4debb1c

Browse files
committed
Merge branch 'master' into v4.3.0-DaynaPORT
2 parents 2bbbcbe + 7add625 commit 4debb1c

File tree

146 files changed

+7458
-4379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+7458
-4379
lines changed

.github/workflows/build-libpico.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Run whenever it is manually triggered, a pull request or a push is done that modifes the libpico configuration
2+
3+
name: libpico Builder
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- tools/libpico/**
9+
workflow_dispatch:
10+
push:
11+
paths:
12+
- tools/libpico/**
13+
jobs:
14+
build-libpico:
15+
name: Build libpico precompiled libraries
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: false
21+
- name: Get submodules for pico-sdk
22+
run: cd pico-sdk && git submodule update --init --recursive
23+
- name: Install dependencies
24+
run: |
25+
sudo apt update
26+
sudo apt install cmake make build-essential wget
27+
# Automatically get correct toolchain
28+
cd tools && python3 get.py && cd ..
29+
# add to PATH
30+
echo "$GITHUB_WORKSPACE/system/riscv32-unknown-elf/bin" >> "$GITHUB_PATH"
31+
echo "$GITHUB_WORKSPACE/system/arm-none-eabi/bin" >> "$GITHUB_PATH"
32+
- name: Build libpico
33+
run: |
34+
cd tools/libpico
35+
./make-libpico.sh
36+
- uses: actions/upload-artifact@v4
37+
with:
38+
name: libpico
39+
path: |
40+
tools/libpico/build-rp2040/*.a
41+
tools/libpico/build-rp2350/*.a
42+
tools/libpico/build-rp2350-riscv/*.a

.github/workflows/pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ jobs:
322322
python -m pip install --upgrade pip
323323
pip install --upgrade platformio
324324
pio pkg install --global --platform https://github.com/maxgerhardt/platform-raspberrypi.git
325+
pio pkg update --global --platform https://github.com/maxgerhardt/platform-raspberrypi.git
325326
pio pkg install --global --tool symlink://.
326327
cp -f /home/runner/work/arduino-pico/arduino-pico/tools/json/*.json /home/runner/.platformio/platforms/raspberrypi/boards/.
327328
- name: Build Every Variant

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
1616
* Raspberry Pi Pico
1717
* Raspberry Pi Pico W
1818
* Raspberry Pi Pico 2
19+
* Raspberry Pi Pico 2W
1920
* 0xCB Helios
2021
* Adafruit Feather RP2040
2122
* Adafruit Feather RP2040 SCORPIO
23+
* Adafruit Floppsy RP2040
2224
* Adafruit ItsyBitsy RP2040
2325
* Adafruit KB2040
2426
* Adafruit Macropad RP2040
@@ -30,6 +32,8 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
3032
* Amken Revelop
3133
* Amken Revelop Plus
3234
* Amken Revelop eS
35+
* Architeuthis Flux Jumperless
36+
* Architeuthis Flux Jumperless V5
3337
* Arduino Nano RP2040 Connect
3438
* ArtronShop RP2 Nano
3539
* Breadstick Raspberry
@@ -70,6 +74,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
7074
* nullbits Bit-C PRO
7175
* Pimoroni PGA2040
7276
* Pimoroni Pico Plus 2
77+
* Pimoroni Pico Plus 2W
7378
* Pimoroni Plasma2040
7479
* Pimoroni Tiny2040
7580
* Pimoroni Tiny2350
@@ -80,6 +85,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
8085
* Sea-Picro
8186
* Seeed Indicator RP2040
8287
* Seeed XIAO RP2040
88+
* Seeed XIAO RP2350
8389
* Silicognition RP2040-Shim
8490
* Solder Party RP2040 Stamp
8591
* Solder Party RP2350 Stamp
@@ -88,6 +94,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
8894
* SparkFun ProMicro RP2040
8995
* SparkFun ProMicro RP2350
9096
* SparkFun Thing Plus RP2040
97+
* SparkFun Thing Plus RP2350
9198
* uPesy RP2040 DevKit
9299
* VCC-GND YD-RP2040
93100
* Viyalab Mizu RP2040
@@ -99,7 +106,10 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
99106
* Waveshare RP2040 Matrix
100107
* Waveshare RP2040 PiZero
101108
* WIZnet W5100S-EVB-Pico
109+
* WIZnet W5100S-EVB-Pico2
102110
* WIZnet W5500-EVB-Pico
111+
* WIZnet W5500-EVB-Pico2
112+
* WIZnet W55RP20-EVB-Pico
103113
* WIZnet WizFi360-EVB-Pico
104114
* Generic RP2040 (configurable flash, I/O pins)
105115
* Generic RP2350 (configurable flash, I/O pins)
@@ -126,7 +136,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
126136
* Peripherals: SPI master/slave, Wire(I2C) master/slave, dual UART, emulated EEPROM, I2S audio input/output, Servo
127137
* printf (i.e. debug) output over USB serial
128138
* Transparent use of PSRAM globals and heap (RP2350 only)
129-
* ARM or RISC-V (Hazard3) support for The RP2350
139+
* ARM or RISC-V (Hazard3) support for the RP2350
130140

131141
The RP2040 PIO state machines (SMs) are used to generate jitter-free:
132142
* Servos

boards.txt

Lines changed: 3106 additions & 0 deletions
Large diffs are not rendered by default.

cores/rp2040/RP2040Support.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#ifdef PICO_RP2040
22+
2123
#include <Arduino.h>
2224
#include <hardware/structs/psm.h>
2325

@@ -31,3 +33,5 @@ void RP2040::enableDoubleResetBootloader() {
3133
boot_double_tap_check();
3234
}
3335
}
36+
37+
#endif

cores/rp2040/RP2040Support.h

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include <hardware/irq.h>
2323
#include <hardware/pio.h>
2424
#include <pico/unique_id.h>
25+
#ifdef PICO_RP2350
26+
#include <hardware/regs/powman.h>
27+
#else
28+
#include <hardware/regs/vreg_and_chip_reset.h>
29+
#endif
2530
#include <hardware/exception.h>
2631
#include <hardware/watchdog.h>
2732
#include <hardware/structs/rosc.h>
@@ -284,7 +289,11 @@ class RP2040 {
284289

285290
inline uint32_t getStackPointer() {
286291
uint32_t *sp;
292+
#if defined(__riscv)
293+
asm volatile("mv %0, sp" : "=r"(sp));
294+
#else
287295
asm volatile("mov %0, sp" : "=r"(sp));
296+
#endif
288297
return (uint32_t)sp;
289298
}
290299

@@ -342,7 +351,9 @@ class RP2040 {
342351
}
343352
}
344353

354+
#ifdef PICO_RP2040
345355
static void enableDoubleResetBootloader();
356+
#endif
346357

347358
void wdt_begin(uint32_t delay_ms) {
348359
watchdog_enable(delay_ms, 1);
@@ -352,6 +363,61 @@ class RP2040 {
352363
watchdog_update();
353364
}
354365

366+
enum resetReason_t {UNKNOWN_RESET, PWRON_RESET, RUN_PIN_RESET, SOFT_RESET, WDT_RESET, DEBUG_RESET, GLITCH_RESET, BROWNOUT_RESET};
367+
368+
resetReason_t getResetReason(void) {
369+
io_rw_32 *WD_reason_reg = (io_rw_32 *)(WATCHDOG_BASE + WATCHDOG_REASON_OFFSET);
370+
371+
if (watchdog_caused_reboot() && watchdog_enable_caused_reboot()) { // watchdog timer
372+
return WDT_RESET;
373+
}
374+
375+
if (*WD_reason_reg & WATCHDOG_REASON_TIMER_BITS) { // soft reset() or reboot()
376+
return SOFT_RESET;
377+
}
378+
379+
#ifdef PICO_RP2350
380+
// **** RP2350 is untested ****
381+
io_rw_32 *rrp = (io_rw_32 *)(POWMAN_BASE + POWMAN_CHIP_RESET_OFFSET);
382+
383+
if (*rrp & POWMAN_CHIP_RESET_HAD_POR_BITS) { // POR: power-on reset (brownout is separately detected on RP2350)
384+
return PWRON_RESET;
385+
}
386+
387+
if (*rrp & POWMAN_CHIP_RESET_HAD_RUN_LOW_BITS) { // RUN pin
388+
return RUN_PIN_RESET;
389+
}
390+
391+
if ((*rrp & POWMAN_CHIP_RESET_HAD_DP_RESET_REQ_BITS) || (*rrp & POWMAN_CHIP_RESET_HAD_RESCUE_BITS) || (*rrp & POWMAN_CHIP_RESET_HAD_HZD_SYS_RESET_REQ_BITS)) { // DEBUG port
392+
return DEBUG_RESET;
393+
}
394+
395+
if (*rrp & POWMAN_CHIP_RESET_HAD_GLITCH_DETECT_BITS) { // power supply glitch
396+
return GLITCH_RESET;
397+
}
398+
399+
if (*rrp & POWMAN_CHIP_RESET_HAD_BOR_BITS) { // power supply brownout reset
400+
return BROWNOUT_RESET;
401+
}
402+
403+
#else
404+
io_rw_32 *rrp = (io_rw_32 *)(VREG_AND_CHIP_RESET_BASE + VREG_AND_CHIP_RESET_CHIP_RESET_OFFSET);
405+
406+
if (*rrp & VREG_AND_CHIP_RESET_CHIP_RESET_HAD_POR_BITS) { // POR: power-on reset or brown-out detection
407+
return PWRON_RESET;
408+
}
409+
410+
if (*rrp & VREG_AND_CHIP_RESET_CHIP_RESET_HAD_RUN_BITS) { // RUN pin
411+
return RUN_PIN_RESET;
412+
}
413+
414+
if (*rrp & VREG_AND_CHIP_RESET_CHIP_RESET_HAD_PSM_RESTART_BITS) { // DEBUG port
415+
return DEBUG_RESET; // **** untested **** debug reset may just cause a rebootToBootloader()
416+
}
417+
#endif
418+
return UNKNOWN_RESET;
419+
}
420+
355421
const char *getChipID() {
356422
static char id[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1] = { 0 };
357423
if (!id[0]) {
@@ -399,7 +465,7 @@ class RP2040 {
399465
}
400466

401467
bool isPicoW() {
402-
#if !defined(ARDUINO_RASPBERRY_PI_PICO_W)
468+
#if !defined(PICO_CYW43_SUPPORTED)
403469
return false;
404470
#else
405471
extern bool __isPicoW;

cores/rp2040/RP2040Version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
22
#define ARDUINO_PICO_MAJOR 4
3-
#define ARDUINO_PICO_MINOR 1
4-
#define ARDUINO_PICO_REVISION 1
5-
#define ARDUINO_PICO_VERSION_STR "4.1.1"
3+
#define ARDUINO_PICO_MINOR 3
4+
#define ARDUINO_PICO_REVISION 0
5+
#define ARDUINO_PICO_VERSION_STR "4.3.0"

cores/rp2040/Tone.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
100100
}
101101
pio_sm_clear_fifos(newTone->pio, newTone->sm); // Remove any old updates that haven't yet taken effect
102102
pio_sm_put_blocking(newTone->pio, newTone->sm, RP2040::usToPIOCycles(us));
103+
pio_sm_exec(newTone->pio, newTone->sm, pio_encode_pull(false, false));
104+
pio_sm_exec(newTone->pio, newTone->sm, pio_encode_mov(pio_x, pio_osr));
103105
pio_sm_set_enabled(newTone->pio, newTone->sm, true);
104106

105107
_toneMap.insert({pin, newTone});

cores/rp2040/cyw43_wrappers.cpp

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
20+
#if defined(PICO_CYW43_SUPPORTED)
2121

2222
#include <lwip/netif.h>
2323
extern "C" {
2424
#include <cyw43.h>
2525
#include <cyw43_stats.h>
2626
}
2727
#include <pico/cyw43_arch.h>
28+
#include <pico/cyw43_driver.h>
29+
#include <pico/lwip_nosys.h>
30+
#include <hardware/resets.h>
31+
#include <hardware/gpio.h>
32+
#include <hardware/adc.h>
33+
#include <hardware/clocks.h>
2834
#include <Arduino.h>
2935

3036
// From cyw43_ctrl.c
@@ -101,4 +107,100 @@ extern "C" void __wrap_cyw43_cb_tcpip_deinit(cyw43_t *self, int itf) {
101107
(void) itf;
102108
}
103109

110+
#ifndef WIFICC
111+
#define WIFICC CYW43_COUNTRY_WORLDWIDE
112+
#endif
113+
114+
// Taken from https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
115+
// also discussion in https://github.com/earlephilhower/arduino-pico/issues/849
116+
static bool CheckPicoW() {
117+
#ifdef PICO_RP2040
118+
adc_init();
119+
auto dir = gpio_get_dir(29);
120+
auto fnc = gpio_get_function(29);
121+
adc_gpio_init(29);
122+
adc_select_input(3);
123+
auto adc29 = adc_read();
124+
gpio_set_function(29, fnc);
125+
gpio_set_dir(29, dir);
126+
127+
dir = gpio_get_dir(25);
128+
fnc = gpio_get_function(25);
129+
gpio_init(25);
130+
gpio_set_dir(25, GPIO_IN);
131+
auto gp25 = gpio_get(25);
132+
gpio_set_function(25, fnc);
133+
gpio_set_dir(25, dir);
134+
135+
if (gp25) {
136+
return true; // Can't tell, so assume yes
137+
} else if (adc29 < 200) {
138+
return true; // PicoW
139+
} else {
140+
return false;
141+
}
142+
#else
143+
return true;
144+
#endif
145+
}
146+
147+
bool __isPicoW = true;
148+
149+
extern "C" void init_cyw43_wifi() {
150+
__isPicoW = CheckPicoW();
151+
if (__isPicoW) {
152+
// Fix for overclocked CPU: SPI communication breaks down with default "div by 2" speed
153+
// So, divide clock by 4 for anything including and above 250MHz CPU frequency.
154+
if (clock_get_hz(clk_sys) >= 250000000) {
155+
cyw43_set_pio_clock_divisor(4, 0); // div by 4.0
156+
}
157+
cyw43_arch_init_with_country(WIFICC);
158+
}
159+
}
160+
161+
extern "C" void __lockBluetooth() {
162+
async_context_acquire_lock_blocking(cyw43_arch_async_context());
163+
}
164+
165+
extern "C" void __unlockBluetooth() {
166+
async_context_release_lock(cyw43_arch_async_context());
167+
}
168+
169+
extern "C" void __pinMode(pin_size_t pin, PinMode mode);
170+
extern "C" void __digitalWrite(pin_size_t pin, PinStatus val);
171+
extern "C" PinStatus __digitalRead(pin_size_t pin);
172+
173+
extern "C" void cyw43_pinMode(pin_size_t pin, PinMode mode) {
174+
if (!__isPicoW && (pin == PIN_LED)) {
175+
pin = 25; // Silently swap in the Pico's LED
176+
}
177+
if (pin < 64) {
178+
__pinMode(pin, mode);
179+
} else {
180+
// TBD - There is no GPIO direction control in the driver
181+
}
182+
}
183+
184+
extern "C" void cyw43_digitalWrite(pin_size_t pin, PinStatus val) {
185+
if (!__isPicoW && (pin == PIN_LED)) {
186+
pin = 25; // Silently swap in the Pico's LED
187+
}
188+
if (pin < 64) {
189+
__digitalWrite(pin, val);
190+
} else {
191+
cyw43_arch_gpio_put(pin - 64, val == HIGH ? 1 : 0);
192+
}
193+
}
194+
195+
extern "C" PinStatus cyw43_digitalRead(pin_size_t pin) {
196+
if (!__isPicoW && (pin == PIN_LED)) {
197+
pin = 25; // Silently swap in the Pico's LED
198+
}
199+
if (pin < 64) {
200+
return __digitalRead(pin);
201+
} else {
202+
return cyw43_arch_gpio_get(pin - 64) ? HIGH : LOW;
203+
}
204+
}
205+
104206
#endif

0 commit comments

Comments
 (0)