Moves to just released GCC 14.3
Moves to full-fat printf/scanf because Newlib no longer supports all the
calls libstdc++ requires with the older, smaller, nano-formatted-io option.
Moves to latest SDK develop branch with important float acceleration fixes
for the RP2350, among other updates.
Moves to latest pioasm, picotool develop branches
* SDK was refactored, update the includes
* Rebuild PicoSDK and BearSSL libs
* Update certs in BSSL validation example
* Don't spell check the certs!
* Updated tools with full fat++ newlib printf/scanf
Prevents weird update errors stemming from an already installed platform
(cached), then updating some files in it manually and then pio pkg updating it.
When a link comes up, we were only sending a DHCP request if the existing
netif's ipaddress was 0. When a DHCP lease is acquired at first that IP
is changed to the given address, and if we do another ::begin we wouldn't
dhcp_start to send a new request and use the old one (until its lease
expired).
In the case of network changing (i.e. WiFiMulti on different nets or
moving an Ethernet cable to another router) that old address would not
be valid.
Track if an IP address has been manually set and use that to determine
if DHCP needs to be re-requested instead of looking at the old netif's
ipaddress.
Fixes#2974
Newlib has a stack protector fail handler which write(2)s a
message to STDERR which doesn't work here. Override with a
call to panic().
Tell GCC to protect all functions for stack protection instead of
ones that it heuristically decides need protection. Slower but
safer, and only when stack protection is enabled.
* Update pins_arduino.h
Changed PIN_LED to match USERLED on PCB. Removed unavailable pins from SPI0 connection.
* Update pins_arduino.h
Uncommented SPI0 pins and reassigned them over GPIO 2,3,4,5.
Fixes#2935
The PICO_2350A patch flipped the logic of the ADCInput bitmask calcs
causing the 2040 and 2350A to use bitmasks for the 2350B (i.e. wrong
GPIOs) and vice versa.
The SerialPIO(SoftwareSerial) receive path was convoluted and required
a lot of work on the host to get the actual data out. It also wasn't
always sampling on the proper edge leading to errors whenever clocks
or hold times shifted slightly.
Rewrite the SerialPIO RX path to explicitily wait for start bit,
pause 1/2 bit time, then idle for a full bit time for all bits.
Takes more PIO instruction memory but works flawlessly even with
mismatched clocks.
Tested with a loopback from HW UART to SW UART with a 5% clock
mismatch @ 19200 baud without reception errors, whereas the
original code would fail with less than a 0.5% variation.
Fixes#2928
````
SoftwareSerial s(15, -1);
void setup() {
Serial1.setTX(0);
Serial1.begin(19200 + 1920/2, SERIAL_8N1);
s.begin(19200, SERIAL_8N1);
}
void loop() {
Serial.println("---");
Serial1.write("Had we but world enough and time", 32);
uint32_t now = millis();
while (millis() - now < 500) {
while (s.available()) {
auto c = s.read();
Serial.printf("%02x '%c'\n", c, c);
}
}
}
````
Fixes#2914
There are 2 systick units, one per core. Set up and start core1's
systick unit and track each core's epoch separately.
Document a method of preserving 100% user-only code on core1
and add a core1_disable_systick boolean flag that works like the
separate stack one.
* Add PIO.h header verification to CI
Ensure all PIO .pio.h headers match the .pio sources in the tree
* Install all tools for Style check
* Clean up mismatched PIO headers
No functional changes, but the PDM pdm.pio file did not init a data pin
while the pdm.pio.h (the one actually used in the core) did. Correct to
match.
* No need for submodules in the style check
* Convert to SDK RP2350A/B determination
Fixes#2878
The SDK uses `defined(PICO_RP2350) && !PICO_RP2350A` to indicate an RP2350B
chip, not the define PICO_RP2350B.
Match the SDK's usage by converting from `defined(PICO_RP2350B)` to
`defined(PICO_RP2350) && !PICO_RP2350A` and update the chip variants
accordingly.
* Need to explicitly override PICO_RP2350A for all
The *SDK*'s board definition file hardcodes a PICO_RP2350A value for
all boards, but we use the same board file for both A and B variants.
Override the SDK board definition in the variant definition file.
* Generic RP2350 needs 2-stage PICO_RP2350A setting
Also ensure SDK board definition included before pins_arduino.h for
clearing up redefinition errors.
* Factor out undef PICO_RP2350A
* Update Arduino.h
Boards with selectable flash sizes only had a 1MB FS as the smallest
option on 2MB boards. For the normal Pico @ 2MB, though, we supported
filesystems down to 64KB. Add those same options to the 2MB SKUs
of configurable boards.
* Initial commit.
* Works with AK4619 in TDM128 I2S compatibility mode set to rising BCLK.
* Works with I2S compat mode with BCLK mode set to 0 on AK4619.
Windows Python doesn't seem to kill the worker Thread properly when the IDE
is exited, leading to a) multiple Python3 instances on a PC after many uses
and b) errors updating the core when it tries to re-install Python3 while
still having the older version's EXE loaded and in use.
When an exception happens on the input() call under Windows, it seems like it
can still leave a thread running. Add one more flag, caught in a global
exception handler.
Works around https://github.com/arduino/arduino-cli/issues/2867
Supercedes #2815
Move to pico-sdk official develop branch which includes a necessary
IRQ header fix.
200MHz is now default for the Pico, but 133 is still available from
the menus.
My application is designed to generate HSTX data on core0 in interrupts,
but also uses hardware SPI for SD card access.
It turns out that the amount of time spent in maskInterrupts/
unmaskInterrupts, even with an empty _usingIRQs, is too long.
Add a quick check and avoid touching the interrupt disable flag if
there's not actually any GPIO interrupt to (un)mask.
* Adjust the PSRAM clock when over/underclock F_SYS
Fixes#2818
* Need to increase PSRAM divider before sysclk increase
Per datasheet, when increasing sysclk speed we need to set the qmi
clocks first and do a dummy transfer to ensure no invalid speed
operations happen on the bus. Handle the logic for this while setting
up the overclock.
* Move to Arduino API 10501
Track upstream Arduino API headers
* IPAddress V4/V6 compatiblity restored
* Fix WiFiUDP includes
* String differences in example
* HardwareSerial using exported
* Add PIO-based SoftwareSPI enabling SPI on any pins
The Raspberry Pi team has a working PIO-based SPI interface. Wrap it
to work like a hardware SPI interface, allowing SPI on any pin
combination.
Tested reading and writing an SD card using unmodified SD library.
* Add W5500 example
Good for testing, shows non-contiguous pin outs.
* Added buffer read to `AudioBufferManager` and `I2S`. Example and documentation included.
* Update type of words to unsigned in example.
* Improve buffered loopback example.
* Remove const from read buffer.
* Don't set SDFAT_FILE_TYPE, default is OK
Fixes#2772
No need to set SDFAT_FILE_TYPE=3 as that is the defaulr value with upstream
SdFat. Remove it from platform.txt and platform.io build.
* Codespell got all techy
* Replace ESP8266SdFat w/SdFat 2.3.0, add SDIO and ExFAT support
Remove ESP8266SdFat fork and replaces with upstream SdFat to simplify
maintenance.
This 2.3.0 version adds SDIO support and enables exFAT support.
Also upgraded FAT filename support to 256 chars, identical to LittleFS.
* Add SDIO support to SD and SDFS, documentation, and examples
* Update SD examples to all support SPI0, SPI1, or SDIO
* Remove Pico-SDK C++ exception-override new/delete
We support exceptions on and off, but the cxx_options file in the
SDK implemented a single override to new/delete.
Remove it so we will use GCC's build-in operator new/delete
which will be correct for either option (2 different libstdc++
versions are shipped as part of the toolchain).
* Remove duplicated SDK files
The SDK will link in the same compilation unit in the LWIP builds.
Remove them to shrink the repo size by ~28MB.
When multiple inputs were active, the frequency was being scaled two
times resulting in incorrect sampling speed. Correct to only scale
the calculation and not the stored value (which is used in `begin`).
Fixes#2754
Pico-SDK changed the output extension of their compilation from "x.c.obj"
to "x.c.o" meaning the removed Newlib and STDIO SDK wrappers were still
being linked in certain situations. Update make-libpico Cmakefile to
remove the new names.
Fixes debug `printf` output.
The memcpy-version of the ABM::write updated the destination and count
but neglected to move the source forward. If a block write crossed a
frame boundary then the 2nd frame would repeat the data from the first
half of the buffer.
Fix by incrementing the source pointer by the same amount as was written.
Calculating the DMA clock divider for PWMAudio can take a very long time
because there are 65K floating point divisions required. But most audio
will be one of a dozen sample rates, so it is possible to precalculate
the rates on the host and use a small lookup table to avoid any math at
all. Removes occasional scratching in PWMAudio when the BackgroundAudio
library changes sample rates.
Optimize AudioRequestBuffer writing when large blocks are available (i.e.
I2S writes of full MP3 or AAC frames in BackgroundAudio). Update I2S to use
the new call. Reduces 1152 calls to arb::write() to a single call/return
and optimized memcpy in that case.
Leave that to the main app instead, so we don't reset peripherals twice.
* ota: fix copy error for riscv headers
* ota: initialize bootrom bit ops and add explanation
* my attempt at adding plasma_2040 support.. cant seem to get it working to test yet though?
* Tracked+replaced files, this now works it seems!
* correct serial count
* Update pins_arduino.h
* Rudimentary Pimoroni Plasma2350 support.
* include correct files + changes needed for proper support.
also!! fixes pin definitions for the i2c on Pimoroni Plasma 2350 (tested, working) and (presumably, untested) on the Plasma RP2040 too by swapping the i2c numbers. i2c now works!!
* use correct USB PID for Plasma 2350
The audio output objects all have the same general necessary configuration
calls. Abstract them out to a generic AudioOutputBase interface class that
they will inherit from. Simplifies letting applications use different
output channels.
Should be backwards compatible with existing code.
Semihosting is handy for debugging, so allow the core to use `SerialSemi` as the
::printf port. Add menu item to the IDE to allow selection.
Add RISC-V implementation of semihost call
* Add MDNS.addServiceTxt() to SimpleMDNS
Fixes#2678
A simple mapping allows for basic service text addition even when using
SimpleMDNS and ArduinoOTA.
* Protection against duplicate services addition
* added logic so that the build.mcu value is written to a board defintion in boards.txt. This is needed for Arduino libs that use precompiled/archive libs
* move the setting for the build.mcu as recommended - to manage the different archs available on the rp2340
Adds a menu item to enable onboard profiling. This requires significant
RAM and really only makes sense on devices with PSRAM to store the state.
When the menu item is selected, allocates RAM and tracks function calls and
periodically samples the PC to generate a histogram of application usage.
The onboard gmon.out file can be written over Semihosting or
some other way to transfer to a PC for analysis.
Adds a profiling example with command lines.
Enable ARM-only semihosting mode. This mode allows applications on the
Pico to write to the OpenOCD console and read and write files on the
host system (i.e. debugging dump information, etc.)
It is not very fast because of the way it uses breakpoints on the Pico
to communicate, but it is useful in cases when you want to get a single
file off of the Pico while debugging.
Note that this **requires** a connected OpenOCD and GDB or else the
semihosting will cause a system panic.
Using pico-sdk develop branch, add in support for CYW43-based
WiFi/BT/BLE boards on the RP2350 such as the
SparkFun Thing Plus RP2350 or the Pimoroni Pico Plus 2W.
Fixes#2608
Rolls in dynamic SPI divider #2600
* Support LED digitalWrite on RP2350+CYW
Also move "special GPIO" to 64 since the Pimoroni Pico 2W uses the
RP2350B with 48 GPIOs.
* Enable CYW43_PIN_WL_DYNAMIC in IDE and P.IO
Allows calling `cyw43_set_pins_wl(cyw43_pin_array);` to redefine the
CYW43 hookup in the variant initialization.
A flush() on a packet that's already been sent should be a no-op, not
send a 0-byte UDP packet. Track when an outgoing packet is dirty and
only endPacket()/transmit it when so.
Fixes#2617
* Add SparkFun Thing Plus RP2350
* Add Thing Plus RP2350 PSRAM definition
* Remove radio from Thing Plus RP2350
Will need to add back once full radio support is added, see #2605
The RP2350 boot ROM seems to randomize memory on a HW reset, including
both CPU stacks where we normally stuff the "reset to bootloader" flag.
Update the docs and source to remove rp2040.enableDoubleResetBootloader()
on RP2350-based boards.
Fixes#2606
* Enable LWIP IGMP, MDNS internal server
* Enable MDNS lookup from LWIP DNS
* Add SimpleMDNS responder, small code and no malloc
* Ensure we copy out lwipopts in make-libpico
Adds a small wrapper around the LWIP-provided MDNS responder application.
Drop-in replacement in many basic cases for LEAmDNS.
For FreeRTOS it is important to not allocate memory on an LWIP callback.
LEAmDNS needs to do this to create response objects, leading to crashes.
Increase LWIP timers by bumping the LWIP_ARP number (as done before).
Replace ArduinoOTA LEAmDNS with SimpleMDNS and update a
HTTPUpdateServer example.
Remove old pre-release BTStack files from sdkoverrides (were needed for
compound BLE devices, but the latest BTStack now incorporates these
changes).
Fixes#2547
* Workaround PSRAM cache invalid'n by reading flash
Fixes#2537
While waiting for a working direct cache flush routine, try and force the
cache to evict all PSRAM values by reading a bunch of flash addresses (which
share the XIP cache). This hurts performance when PSRAM is not used, but
is required for correctness until we have a working XIP flush.
* Invalidate after cleaning the cache line
gmx from the RPI forums came up with this hack and it seems to work!
https://forums.raspberrypi.com/viewtopic.php?p=2262371#p2262371
33% faster for 4K memcpy using DMAMemcyp example
With this assembly:
CPU: 4835 clock cycles for 4K
DMA: 2169 clock cycles for 4K
Using stock Newlib memcpy:
CPU: 7314 clock cycles for 4K
DMA: 2175 clock cycles for 4K
The flash ROM routines seem to overwrite the QMI configuration we set for
PSRAM, rendering it unreadable after any erase or write or ID command.
Wrap the 4 flash control functions to preserve the QMI state on the
RP2350. On the RP2040, simply pass through the call.
Fixes#2537
Released packages have a post-processing step to allow them to work with IDE
installed toolchains. This was not updated for the RISC-V compiler, so R5 compiles
fail under the release IDE package. Update to call proper compiler path.
Fixes#2510
* Adds RISC-V compilation option to the IDE and Platform.IO.
* Build RP2350-RISCV libpico, libbearssl
* Fix RP2350 BearSSL library (was copied from RP2040, now built for M33)
* New GCC 14.2 toolchain is required (12.4 RISC-V support is borked)
* Newlib locking fixed prototypes
* Manually force all runtime init code into RP2350 binaries
* Add RISC-V to CI
* Remove RP2350 BOOT2.S files, binaries (not used)
* Clean up minor GCC 14.x warnings
* Add RP2350-RISCV OTA build, link
* Add RISC-V FreeRTOS files (configuration still not running, but builds)
* Add basic documentation
Newlib built using `-Os` causes things like `memcpy` to be very slow on the
RP2350 because it uses byte-wise operations. On the RP2040 this doesn't
matter because there is a ROM routine we use instead of the library, but on
the Pico 2 it's almost 10x slower than the optimal method.
Update GCC to 12.4
Update Newlib to 4.4.0
Move to -O2 library compilation
New toolchain looks to add ~10K to RP2350 flash usage (less on the RP2040).
* Adds a menu item for selecting type of ESP wifi type.
* Updated pin definitions to work with ESP hosted.
* Fixed residual debug modification.
* Added ESPHost support library.
* Removed local cloning of ESPHost and added to excluded from CI
* Updated boards.txt
---------
Co-authored-by: Pontus Oldberg <pontus.oldberg@non.se.com>
Split the 1300+ char define-setting line into a multi-line value.
Makes it more maintainable and easier to see when changes needed.
No settings should have been modified.
The RP2350 has a different blob header requirement to identify a working
image. Ensure that header is present in the OTA loader.
Update the PicoOTA examples for the 2350
Several Arduino APIs realloc(NULL) which is legal and equivalent to
"malloc()", but the PSRAM logic was placing those malloc calls in PSRAM
and not RAM because "0" < RAM_START.
Ensure the realloc address is non-null and before RAM_START before
using PSRAM.
Pull in Raspberry Pi's custom RP2350 ARM and RISC-V ports for FreeRTOS.
Basic tests run, but stress mutex test is failing in unique and interesting
ways.
* Add simplified switching test catching task swap problem
* Freertosrp2350: use FreeRTOS macros in noInterrupts/interrupts when applicable. (#2456)
* Use FreeRTOS macros in noInterrupts/interrupts when applicable.
* Fixed calling taskEXIT_CRITICAL and taskENTER_CRITICAL
---------
Co-authored-by: fietser28 <fietser28@users.noreply.github.com>
* Add support for the extra 16 GPIO pins in the menus and core.
* Clean up Generic RP2350 PSRAM ("none" is valid) and flash (other than 16MB) options.
* Add extra GPIO<->peripheral connections
* Add Pimoroni PGA2350 RP2350B-based board
* Pins 32-47 can be used for PIOPrograms
* Avoid hang when PSRAM fails to initialize
* Move libpico to an RP2350B board for SDK (otherwise the SDK drops all GPIOHI support)
SWSerial wasn't even building due to a typo in the header, and SerialPIO
needs to set the OE-invert flag after PIO initialization for transmit.
Fixes#2419
Use real GPIO pad inversion to allow inverted RX, TX, and controls for
the hardware UART and software PIO-emulated serial ports.
Adds ``setInvertTX(bool)`` and ``setInvertRX(bool)`` calls to both ports,
with ``setInvertControl(bool)`` for the HW UARTS.
* Fix Pio MHZ for RP2350, fix RP2350 generic menus
* Clean up platform.txt IPV4 default
Was never used, but should at least exist for sanity's sake
Fixes#2365
* Migrate RP2040-specific bits to separate dirs
* Add chip to boards.txt, isolate RP2040-specifics
* Add RP2350 boot2, bearssl, and libraries
* Platform.IO adjust to new paths
* Add RPIPICO2 JSON for P.IO
* Add RP2350 to Platform.io
* Update Picotool and OpenOCD for all hosts
* Use picotool to generate UF2s
* Build separate libpico blobs serially
Thanks for the review, @aarturo182 !
* Add RP2350 to CI
* Allow Ethernet/WiFi building for RP2350
* Update Adafruit TinyUSB to latest
* Test skip fix
* Make RP2350 Picotool work. update USB ID
* Fix EEPROM/FS flash locations
RP2350 adds a 4K header sector to the UF2, meaning we have 4K less total
flash to work with. Adjust all constants appropriately on the RP2350.
* Adds ilabs board and PSRAM support. (#2342)
* Adds iLabs boards and basic PSRAM support.
* Make PSRAM come up as part of chip init
Uses SparkFun psram.cpp to set timings on clocks which are defined in the
variant file. Prefix things with RP2350_PSRAM_xxx for sanity.
Users don't need to call anything, PSRAM "just appears". Still need to
add in malloc-type allocation.
* Add board SparkFun ProMicro RP2350
Same pinout as the SparkFun ProMicro RP2040 with 8MB PSRAM and RP2350
* Add TLSF library for use w/PSRAM
Fork of upstream to include add'l C++ warning fixes.
* Add pmalloc/pcalloc to use PSRAM memory
free() and realloc() all look at the pointer passed in and jump to the
appropriate handler. Also takes care of stopping IRQs and taking the
malloc mutex to support multicore and FreeRTOS (when that workd)
* Fix BOOTSEL for RP2350
* Add simple rp2040.idleOtherCore test
* Add Generic RP2350 and clean up PSRAM menus
Commercial boards now only have 1 size PSRAM, no need to have menu for them.
* Add Solder Party RP2350 Stamp boards (#2352)
* Add PSRAM heap info helpers, mutex lock mallinfo
* Add RP2350 docs
* FreeRTOS and OTA unsupported warnings for RP2350
* Update to 2.0.0 SDK
* Board type needs to be set before earliest SDK setup
* Platform includes update
* Boot2 files
* Simple compilation issues
* Build and link
* PIO rebuild with version
* Newlib wrapper update
* Force inclusion of runtime_init_* fcns
The linker was dropping all references to the library's included
runtime_init_xxx functions and hence things like the IRQ vector
table and mutexes and alarms weren't properly set up leading to
instant crashes on start up..
Explicitly call out one function from the object file stored in
the .A to force the inclusion of all the functions. May be a better
way, heppy to hear any ideas.
* Fix SPI GPIO calls
* Fix Ethernet GPIO
* Remove SDK warnings
Remove the skipped error messages once the following PR merged:
https://github.com/raspberrypi/pico-sdk/pull/1786
* BTStack moved SBC encode/decode paths
* Platform.IO fixes
* BT No longer has special absolute mouse
* Rebuild and update OTA
* Rebuild BearSSL, too
* Update liker file to latest SDK
* Clean up libpicocmake
* Clean up LWIP/BT library names
* Add VFS to enable POSIX file I/O operations
Enables use of FILE * operations on internal and external storage. fopen,
fclose, fseek, fprintf, fscanf, etc. supported.
* Add FS/File::stat and support POSIX stat/fstat
Removed FS::info64, and updates FS::info with the 64-bit version since in
2024 it's almost impossible to get a SD card smaller than 4GB.
Most code can simply replace info64 with info and continue operation, if they
were updated to be 64-bit in the first place.
RP2040::memcpyDMA implements a DMA-controlled memory copy call identical in
function to standard memcpy, but using an onboard DMA engine. For large
memory transfers this can be significantly faster than using the CPU-based
memcpy. Only 4-byte aligned source, destination, and counts are allowed.
If any inputs are not 4-byte aligned, then standard memcpy will occur so
it will behave correctly for any inputs.
Underlying HID_Joystick now always using 16-bit format axes, need to update
BT and BLE descriptors sent to the BT master or it will misinterpret the
reports and the reported joystick state will be read as garbage.
Fixes bug introduced in #2276, oops!
Variant builds were taking longer than the actual individual CI jobs, so
split it up.
Combine the spelling and style checks, they ran very fast and spent more
time in checking out than in running.
Fixes#2275
Adds `Joystick.use10bit` and `Joystick.use16bit` methods. 10-bit is
unsigned from 0...1023 while 16-bit is signed -32767..32767.
Defines a new HID descriptor to support the increased resolution.
The repo and development use only '\n' (UNIX) EOLs. When a user runs
makeboards on a Windows system they end up changing every line in boards.txt
and the JSON files to Windows '\r\n' format.
Explicitly set the newline character when opening the output files to
avoid this.
* Add a build of all variants to CI using P.IO
* Split out into separate job, use BOOTSEL sketch
* Fix Breadstick variant
* Fix Bridgetech boards with illegal define names
Dash(-) to underscore(_) in define and variant for the -7 and -43.
* Bridgetech JSON updates
* Temporarily remove Bridgetech boards from CI
Needs an update to the P.IO external repo to work since the names
of the boards have changed.
FreeRTOS often seems to have interesting corner cases. Add two simple
tests that have been useful while debugging issues found from users or
from FreeRTOS updates.
An oversight in the order of updating the ASFLAGS with a copy of the CCFLAGS (see line 110) and then updating the CCFLAGS (without resyncing the ASFLAGS) leads to a fatal compilation error in the Adafruit PicoDVI library, in which `tmds_encode.S` fails to find the `pico/config.h` include file. This fix updates the ASFLAGS manually after changing the CCFLAGS so that they're equal again, and the library can be compiled.
Fixes#2251
The 2-phase send could get out of whack if transmission was attempted when
no device was connected. Clear things up so if things aren't connected,
then no data gets set as pending.
Instead of manually iterating over netifs to find the one a packet came
in over for NetBIOS name lookup, use a built-in LWIP macro that's
available for udp_recv callbacks. Shrinks and simplifies NetBIOS code.
Thanks to @me-no-dev's code. Lets Windows look up the PicoW by name
using NBNS and needs much less memory and code than mDNS.
AsyncUDP ported from the old ESP8266 version, only minimal changes. Will
probably only be valid in IPv4 environments and may not match current
ESP32 AsyncUDP interfaces.
The LittleFS folks changed the on-flash format in 2.6.0, making
it unmountable with earlier precompiled code.
Rebuild the OTA bootloader using the 2.9.3 LittleFS release,
matching the core version.
Fixes#2198
Adds BluetoothHIDMaster and HIDKeyStream which let the PicoW connect to
and use Bluetooth Classic HID devices like keyboards and mice.
An example that lets the PicoW use a BT keyboard as a piano is
included and shows the use of the new classes.
* fix: Changed folder name to match build.variant property
* Added GPIO definitions for Archi board
Co-authored-by: Christian Halter <christian.halter@newsan.com.ar>
Fixes#2188
We get a call to stop the audio channel from a timer/IRQ context, so can't
safely remove the IRQ handler for the AudioBufferManager. The SDK will panic.
Because the IRQ handler will be a noop if it's not uninstalled, we will
instead just leave our shared handler in place and let it do nothing.
Use a common BluetoothLock RAII in BluetoothAudio to clen up the code and
automatically lock BT for the AVRCP button methods.
Add a "-32K" option to all the IP stack options that doubles the PCB and memory
pools from default. For most use cases this is not necessary, but it could be
helpful in cases where large numbers of TCP clients are connected or high
bandwidth applications.
Fixes#2050
Adds a library to run classic Bluetooth A2DP source (output) audio from
the PicoW. Simple example showing operation and callbacks.
Factor out multiple BT lock/unlock and place in the PicoW variant files.
Use -O2 only on the LWIP checksum routine, resulting in a speedup of
around 13% (checksumming only, not entire LWIP stack) for 72 add'l bytes
of flash.
Fixes#1730
Uses DMA operations to avoid the need to bit-bang or busy wait for I2C operations
that might be very slow. Optional, adds new API calls to enable. Simple example
included.
Fixes#1192
Uses DMA operations to avoid the need to bit-bang or busy wait for SPI
operations that might be very slow. Optional, adds new API calls to enable.
Simple example included.
When a ping is sent from the Pico, a raw_recv callback is added which
sees all raw incoming packets to detect the response from the ping target.
If while waiting for the target response an external ping packet arrives
this incoming ping request packet will be processed by the
LwipIntfDev<>::_pingCB which will return "0" not processed and which
*should* not change the payload unless it handles the actual packet.
Unfortunately, the 20 byte header was unconditionally stripped off of
the packet before checking if this was our response, changing the
payload address and causing an assertion in LWIP.
Fix by using absolute offsets inside the raw packet for the ping
response checks.
Fixes#2156Fixes#2149
As seen in debug of #2149, if the LwipIntfDev is already _started,
return false for a ::begin() call.
Also, protect netif_add/_remove on the very small possibilty of being
called by LwipIntfDev devices while the CYW43 driver is doing work.
If a file called `.ci.defines` is present in a directory, apply those
while building the specified sketch.
* Add an lwip_ESPHost test, like the wired Ethernet ones
* Add WINC1500 test and CI hook
* Remove 1 minor warning in WINC build
* Add FatFS for onboard flash use/sharing of FAT
* Move all to "fatfs" namespace
The FatFS library defines commonly used names like WORD which could conflict
with user code otherwise.
* Restyle
* FTL-based, wear-leveling FatFS with USB export
Allow using FAT filesystem with onboard flash in a safer, wear-leveled
way and to export the onboard flash to the host as a USB drive for easy
data transfer.
* Update documentation
* Fix submodule reference
* Don't spellehcek ChaN FatFS files
* Disable FTL debugging
* More codespell skips
* Move to latest SPIFTL library
* Allow using raw flash instead of FTL
* Remove unneeded static FIL 4k allocation
* Expose FAT FS format configuration options
* Update documentation
* Remove USB partial flash rewrites
* Remove unneeded dups of FatFS sources
Leave the LICENSE.md and README.md to point to upstream.
* Clean up comments
The `Picoprobe` example showing how to upload to Ubuntu is invalid because Ubuntu does not create or assign users to a `users` group (for many major releases, now).
The reason the example worked is because the permissions were applied globally, rendering the `GROUP=users` assignment in the rule irrelevant. Hence, this assignment has been dropped.
The `pico-debug` example has been updated similarly, but it uses a proper group-level rule, and Ubuntu does still use group `plugdev`.
The reader thus has two good examples of creating `udev` rules.
WiFiMulti specifies a specific BSSID, in addition to the AP name and
password. In the WiFi core the BSSID is stored as the raw 6-byte MAC
address, but the ESPHostedFG firmware expects a formatted C-String
(i.e. "ab💿ef:01:02:03" instead of {0xab, 0xcd, 0xef, 1, 2, 3})
Convert the raw bytes to the string format expected in the ESP FW.
No polling needed and massively reduces latency by using the GPIO interrupt to
signal the Pico to read a received packet. Also drops CPU load when no packets
are incoming.
Fixes#1973
The periodic LWIP pump/Ethernet packet reader async_context stopped
firing occasionally under high packet loads, causing the LWIP stack
to become unresponsive to any incoming data.
Re-implement the 2-step process for polling (like the CYW43 driver
from the RPI folks does) and undoes #1864 change.
* Add native Apple ARM silicon M1/M2/M3 support
* Identify Mac ARM in download get.py script
Thanks to the ESP32 `get.py` sources!
* Rebuild M1 w/o using strip
The Arduino WiFi normalization ended up calling the underlying LWIP
::config after the AP was begin, resulting in a failure to set the
IP configuration of the AP. Move the _wifi.begin() call to after
the IP configuration is set.
Fixes#1989
* Adds definition for WIRE_INTERFACES_COUNT so those libraries which rely on it can detect and use...
Wire1. e.g. u8g2 will not use Wire1 unless this is (a) defined and (b) >1. This constant is defined
on other cores, e.g. for SAMD based boards.
Avoid issues with interrupts and priority inversions and other deadlocks
and use a SW based random generator for LWIP when under FreeRTOS.
This means removing any overrides for sleep_until and the two
get_rand_xx calls from the SDK, making things much saner.
Related to #1883, #1872, and other random FreeRTOS lockups.
If the BLE connection is severed, don't wait for the needToSend
flag to clear in the HID::send routine since it may never actually
clear unless the BLE connection is restored.
Partial #1817
* Aggregated several earlier patches in one to add RP2040-Eins board into the project.
- Moved RP2040-ProMini in alphabetical order position.
- Added board description files for RP2040-Eins.
- Added board header file for RP2040-Eins.
- Adjusted unused pins order of RP2040-ProMini to be the same as in RP2040-Eins.
- Added RP2040-Eins to README.md.
- Renamed board files to use underscores to better fit the existing file naming style.
* Updated README.md
With HW chip select enabled, transfer16's 2 individual byte transfers will
actualy deassert CS for a brief instant between bytes. Avoid this by doing
a single multi-byte (2) tranfer of 16b.
Fixes#1749
Defining a global true `bool core1_separate_stack = true` will separate
the two cores' stacks, with core 0 using the scratch RAM while core 1
will use 8K from the heap.
* Adapted all libraries to support multiprotocol HID over BT & BLE
* Added ATT DB depending on setup; still no success with working connection
* Added hids_device from BTStack develop branch as override
* Fixing the GATT handle patching, added working ATT DB
* ran astyle on example
* Updates in BLE implementation; WORKING! (but only if all are activated). Removed sdkoverride again, doesn't work.
* Moved ATT DB handles to correct places
* Finally functioning for Mouse+KBD+Joy, and each individual
* Cleaned up code & ran astyle
* Added sdkoverrides to pull develop functions from BTSTack
* Changed a few typos by BTStack to run codespell successfully
* Ran astyle on sdkoverride files
* Added some #if guards for including BTSTack file only if BT is enabled
* Fixed Feature Report value characteristics handle assignment; fixed too long HID report
* Ran astyle
_spiUnit is a reference, and when initialized with SPI, it cannot be changed in the constructor afterwards.
So initialize it in the constructor's declaration.
It would be possible for an IRQ-driven SPI user to fire
while the main app's SPI.beginTransaction was in process.
This would result in incorrect state for the main app since
the IRQ may overwrite some settings that the app already
set.
Disable all IRQs around the begin and end processes to avoid
the possibility.
Fixes#1147
When SPI.beginTransaction() is called, disable all GPIO IRQs that were
registered using SPI.usingInterrupt(). On SPI.endTransaction(), restore
all the IRQs to their prior state.
Enable use of wired Ethernet modules as first-class LWIP citizens. All
networking classes like MDNS, WebServer, HTTPClient, WiFiClient, and OTA
can use a wired Ethernet adapter just like built-in WiFi.
Two examples updated to show proper use.
Uses the Async Context support built into the Pico SDK. When running on the
Pico it will use the CYW43 async instance.
Uses modified wired Ethernet drivers, thanks Nicholas Humfrey!
Note, the classic, non-LWIP integrated `Ethernet` and related libraries
should still work fine (but not be able to use WebServer/HTTPS/etc.)
Fixes#775
Fixes#1696
Additional pin definitions for Pimoroni Tiny 2040, including using the Green LED element of the RGB LED as the default LED.
There are only 12 external header pins for GPIO, including 4 ADC pins, so there are less options for assigning pins than on a generic Pico RP2040. In particular, there can only be one SPI, and it can't have an SS pin but I've defined GPIO17, as on the pico, because the definition is used in generic / common.h.
BOOTSEL on the Pimoroni Tiny 2040 is connected to GPIO23. I don't know if that has any consequences for implementing reading from BOOTSEL for this board. That may need to be revisited, but it doesn't appear to involve any changes to pins_arduino.h.
For some reason `program ... reset" causes OpenOCD to leave the chip in a
state where the 2nd core does not come up properly, leading to problems in
FreeRTOS and others.
Use a separate reset sequence after programming to work around the issue.
Fixes#1687
Fixes#1619
Requiring the auto-discovery tool and serial monitor if they have not already been included by other boards (namely if AVR cores have been uninstalled in the IDE).
If another packet comes in between freeing `_rx_buf` and setting `_rx_buf` to 0, that new packet could get put into the same memory address and get concatenated to itself, which leads to an infinite loop.
New solution assigns a temp pointer, sets `rx_buf` to 0, then frees the memory, which guarantees `_rx_buf` always points to valid data.
The `_idedata` has been changed to `__idedata` in newer PlatformIO core versions per 158aabbdf2. This change has broken the logic to expand out the `-iprefix PATH @INCLUDEFILE` argument into its individual include paths, causing Intellisense breakages on some VSCode systems and other IDEs that didn't handle these arguments correctly or in which the path was corrupted.
* Enable proper reuse of PIO programs
Rewrite the PIOProgram helper class to properly re-use loaded programs
and to try to re-use loaded instructions before allocating a new PIO
program.
Supersedes #1524
* Less copy-pasta
The ABM had an off-by-one error in the DMA buffer swapover. Instead of
setting the DMA address to the newly added buffer in active[], it set it
to the buffer that was currently running.
This would effectively disable the ping-pong and cause clicks/lost data.
Fixes#1491
The serial port reset logic was calling `sleep_ms()` which ended up doing
a task switch...while the other core was frozen and everything was supposed
to be locked.
Use `busy_wait_ms()` which is a tight loop to delay in the reset portion.
Fixes#1486
Since FreeRTOS has real tasks and mutexes with support for priority bumping, actually always try and take a `CoreMutex` instead of seeing if someone else already has it and aborting immediately.
This fix helps ensure things like Serial output in a multi-task system won't get lost.
* Implement the BD_ADDR(char * address_string) constructor.
* Updating implementation to use sscanf.
There is an extra step after the sscanf that checks that we got
six bytes back and if we did not, it will set all bytes in the
address to zero.
* Example using BD_ADDR(const char * address_string)
This example shows how BD_ADDR(const char * address_string) can
be used to create BD_ADDR objects to use for comparisons etc.
* Update LEDeviceScanner.ino formatting
Warn the user that the Pico SDK STDIO calls (stdio_init_all, stdio_usb_init,
stdio_uart_init) are not supported or needed at compile time. See multiple
issues #1433#1347#1273#1251 and others.
* Fix FreeRTOS CoreMutex shim to handle ISRs
Automatically check, when in FreeRTOS, if we're in an ISR and
if so call the correct mutex grab.
Thanks to @caveman99 for finding and proposing a solution!
Fixes#1441
* Fix the CoreMutex destructor, too
Fixes#1465
The Adafruit Feather came onboard before the Wire swapping was supported
in the core, so it's backwards from the real definition. Now that swapping is
supported, fix it to match the rest of the boards.
Call `SerialPIO::setInverted(txinv, rxinv)` before `SerialPIO::begin()` to enable.
---------
Co-authored-by: Mykle Hansen <mykle@mykle.com>
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
Update to head of upstream FreeRTOS/SMP branch. Very minor changes.
Remove the custom getreent implementation, use the one that was defined
in the upstream FreeRTOS/smp branch (callback related vs. static vars).
Fixes#1439
Use a real FreeRTOS task, at the highest priority, to idle the other core
while doing flash accesses.
The USB stack seems to have some timing dependent bits which get broken
if FreeRTOS switches out the current task when it's running. Avoid any
issue by disabling preemption on the core for all tud_task calls.
The PendSV handler disable flag can live completely inside the FreeRTOS
variant port, so remove any reference to it in the main core.
Tested using Multicode-FreeRTOS, #1402 and #1441
The USB FIFO interrupts were still being serviced even when the core was
frozen, leading to crashes. Explicitly shut off IRQs on both the victim
and the initiator core when freezing.
Removed the need for hack __holdUpPendSV flag
Fixes#1408
The wl_* types are required in multiple libraries which in turn seem
to have a circular dependency that Platform.IO has issues with in certain
modes.
Avoid the issue by moving the common headers into the core directories
so they will be accessible by all libs.
Move StackThunk to core directory, too
Fixes#1410
The USB Keyboard now has 2 reports (keyboard + consumer control), so when both
Keyboard and Mouse libraries are included, the Mouse must be report 3, not 2.
Update the Mouse and Joystick report IDs appropriately.
Fixes#1394
The Pico_Rand SDK calls gather bits from the HW ROSC at precise intervals.
If there is jitter in the sleep_until() call then the ROSC bit collection
will always think it's failed to acquire the right bit and retry infintitely.
Avoid by wrapping the HW random number calls and the sleep_until() routine.
Only when in FreeRTOS set a flag to silently make sleep_until() into a
busy wait loop while in a random number generation step. When not in the
random code, do the normal sleep_until call.
Fixes#1402
The global USB mutex is auto-shadowed with a FreeRTOS semaphore while in
FreeRTOS mode. Unfortunately, while the core was using the proper
FreeRTOS semaphore to lock access to the USB port, the actual FreeRTOS
USB task was using the naked Pico SDK mutex, leading to cases where it
could acquire the mutex even though some other FreeRTOS task actually
owned the shadowed mutex.
Properly lock the shadowed Semaphore, not mutex_t, in the FreeRTOS
USB periodic task.
Fixes#1370
Adds a simple helper assertion to tell the user how to enable BT if it's
not enabled, instead of some odd compilation warnings about undefined
functions.
Change “N” to “M” and add “HOST” in the USB pins. Only two pins are actually affected; diff appears large to maintain the pleasant aligned-columns format.
Fixes#1356
Mac and Windows have case-insensitive filesystems, so the will find
the internal (all-lowercase) "btstack.h" and not the library's "BTstack.h",
causing compilation errors.
Rename the library and header to avoid the issue.
Allow sending thigns like KEY_MUTE or KEY_SCAN_NEXT from the USB and
Bluetooth Classic keyboard libraries.
BLE requires some add'l magic, not yet discovered.
Pull in latest upstream Keyboard library changes
SDK 1.5 changed the behavior of the underlying CYW43 blob, and it seems
to block MDNS multicast by default. Manually add back the Ethernet MACs
used for MDNS multicast in IPV4 and IPV6.
Fixes#1267
It seems possible now for TCP connection _pcbs to disappear while being
processed, due to the new async context configuration. This would cause
LWIP to panic when a NULL pcb was passed in.
Check for and avoid passing in null PCBs in the ClientContext.
Undo special-casing of sys_check_timeouts wrapper
AdvancedWebServer with heavy F5-refresh and #1274 test both pass.
Fixes#1274
Move the Joystick, Keyboard, and Mouse into a base class which handles
the operation/input, and a subclass which will implement the reporting
as a HID device via USB, Bluetooth Classic, or Bluetooth Low Energy (BLE).
Reduce copies of library code and makes maintainability much better.
* Update to Pico-SDK v1.5
* Hook in pico_rand, use ioctl to set ipv6 allmulti
* Move into PicoSDK LWIP mutex, hack timer sizes
* Utilize much of the PicoSDK infrastructure for WiFi
* Add WiFi::begin(ssid, pass, bssid)
* WiFiMulti to use BSSID, make more robust
WiFiMulti will now be more aggressive and try all matching SSIDs, in order
of RSSI, using the BSSID to identify individual APs in a mesh.
Before, if the highest RSSI AP didn't connect, it would fail immediately.
Now, it will go down the list, ordered by RSSI, to attempt to get a link.
* Add Bluetooth support from Pico-SDK
Able to build and run the HID Keyboard Demo from the Arduino IDE, almost
as-is.
Will probably need to make BT configurable. Enabling BT on a plain WiFi
sketch uses 50KB of flash and 16KB of RAM even if no BT is used.
* Separate picow libs, BT through menus, example
Build normal Pico.a and 4 different options for PicoW IP/BT configuration.
Use IP=>IP/Bluetooth menu to select between options.
* CMakefile rationalization
* Move BT TLV(pairing) out of last 2 flash sectors
The pairing keys for BT are stored at the end of flash by default, but
we use the last sector of flash for EPROM and the penultimate one for
the filesystem. Overwriting those in BT could cause some real exciting
crashes down the line.
Move the store to an app-build specific address using a dummy const
array to allocate space in the application image itself.
* PicoBluetoothHID with BT Mouse, Joystick, Keyboard
Add simple Bluetooth Classic HID helper function and port the existing
USB HID devices to it. Port their examples.
* Protect BT key storage from multicore
* Add short-n-sweet Bluetooth documents
* Add Bluetooth Serial port library
* Turn off BT when the BT libraries exit
Return the pre-existing USB_PRODUCT/MANUFACTURER to the USB host in
the ID stage, allowing for reports like:
[1412958.589070] usb 1-6.3.4.1: New USB device found, idVendor=2e8a, idProduct=f00a, bcdDevice= 1.00
[1412958.589076] usb 1-6.3.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1412958.589079] usb 1-6.3.4.1: Product: Pico W
[1412958.589080] usb 1-6.3.4.1: Manufacturer: Raspberry Pi
[1412958.589081] usb 1-6.3.4.1: SerialNumber: E6614C775B6C7F31
or
[1413190.272233] usb 1-6.3.4.1: New USB device found, idVendor=2e8a, idProduct=1037, bcdDevice= 1.00
[1413190.272239] usb 1-6.3.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1413190.272242] usb 1-6.3.4.1: Product: HunterCat NFC RP2040
[1413190.272243] usb 1-6.3.4.1: Manufacturer: ElectronicCats
[1413190.272244] usb 1-6.3.4.1: SerialNumber: E6614C775B6C7F31
Many examples require that LED_BUILTIN be defined as a constant, so we
can't use a ternary operator to swap between Pico and PicoW LED pins.
Instead, do the check in the digitalWrite/digitalRead/pinMode calls
to cover most of the uses.
Still need it on the command line in platform.txt for upload/etc., but make the
debug script in lib/picoprobe_cmsis_dap.tcl include the adapter speed setting.
The PWMAudio lib is expecting an int16_t value but the example passes a sample cast to uint16_t
So any values from the lookup table that are negative are recast to 0 i think.
So half the sine wave in the case of the example is lost.
Use GNU LD MAX() to ensure the uninitialized RAM portions are after the
OTA region. For most apps this already happens, so there will be no
overhead added.
The uninitted RAM macro would fail because the OTA code would clear out the
first 50KB or so of RAM to copy its code and global values.
Move all global values to the end of RAM in OTA, and then align any uninitted
vars to a 16KB unit to ensure it won't appear in the 1st part of RAM that is
still needed to copy the OTA executable.
In the normal case, without any uninit_ram vars, no additional space is used.
When uninit_ram is used, up to 16KB of space may be lost to get that alignment,
but it will work properly.
Fixes#1188
The stdin/stdout FILEs have an internal mutex which needs to be initted
to a FreeRTOS one, or any sketch with ::printf will hang. Automatically
create and acquire/release the shadowed mutex.
Requires new build of pico-quick-toolchain to function properly. Tested
on preliminary local build.
Without flushing STDOUT, the upload script's output aften are buffered
and not displayed until it completes. Add in flush commands to allow
the IDE to display status as it changes.
USB changes caused FreeRTOS to not be able to swap tasks when the Serial port
was connected. Clear the "stop PendSV" flag after checking for reset signal.
Stop the IDE from reporting large "Serial port not fount"-type errors after
every upload by delaying a bit before the uploader exits to give the OS/Pico
time to renegotiate.
Fixes flashing problems on certain Linux distros by checking all possible mount
locations instead of only the first one to be found.
Make 1200bps reset tickle more robust
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
The USB VID was always being set to the Raspberry Pi foundation code,
causing other brand boards to show up incorrectly.
Remove redundant values from the boards.txt and define a consistent
USB VID/PID and use it in the setup code.
See #1129 for more info
Fixes#1140
````
Converting to uf2, output size: 134144, start address: 0x2000
ERROR: Unable to execute powershell or wmic commands, can't continue.
ERROR: Please make sure either PowerShell or WMIC is installed and in
your %PATH%.
````
Implement the method used in the ESP8266 Web Server to allow user apps to hook into
the HTTP server (to support hooked WebSockets, etc._)
Add example of hook usage
Instead of listing each board three times (normal upload, picoprobe,
and pico-debug uploads), list each board once and use a menu to select
the actual upload method.
Also add in picotool as an upload method for those folks who have trouble
with automounting.
Fix#1111
Mimics the I2S/PWMAudio/Stream interface for ease of use.
* Fix non-32b DMA size transfer calculation in ABM
* Rename wasHolding to isHolding in the I2S/PWM
It is the **current** number of bits left, not the past number.
* Add commented microphone example
* Add docs
Now that we have a default parameter, need to only allow it in C++ since
default values are not part of C spec. Should not affect any users since
only legacy code is in C.
Only 4K total stack, so allocating 400 bytes for a local C string
or 600 bytes for a DHCP response is dangerous. Use static allocations
instead on the heap.
Use the PWM hardware to generate a signal suitable for filtering and
amplifying 16bps audio output.
Refactor the AudioBufferManager to allow sharing with I2S
Add example
The ring buffer worked but had issues with IRQs and the available()
procesing. Because it was a pain to debug, move to a linked list
setup where there are filled and empty buffers to work from,
simplifying the underlying logic.
Allow I2S::available() to return free writing space in OUTPUT mode
to make it saner.
* Increase default number of buffers for 32bps
Gives 2x the time between interrutps to handle I2S callbacks.
* Add setBuffers keyword
Fixes#963
The available space calculation didn't account for the fact that one
of the buffers was currently being output, causing ::available() to
be too large and ::write() to block in that case.
Other parts of the core use temp 256 byte chunks to transmit/move/operate
on data, so do the same here. Will increase effective WebServer sendFile
speeds.
SingleFileDisk allows for exporting a file from the onboard LittleFS
filesystem to a PC through an emulated FAT drive when connected. The
PC can open and copy the file, as well as delete it, but the PC has no
access to the main onboard LittleFS and no actual on-flash FAT
structures are used.
This is handy for things like data loggers. They can run connected to
USB power for some time, and then connected to a PC to dowmload the CSV
log recorded.
It's almost 2023, allow LFN (long file names) on the emulated USB disk.
Reduce the disk buffer size to 64 bytes. The buffer is statically
allocated so it's always present, even in non-USB disk mode, meaning
all apps will pay the RAM price for it. 64 bytes is slower to read
but works and saves ~1/2KB of heap for all apps.
Fixes#1021
The UART hardware will push characters into the receive FIFO even if there
are parity, framing, or other errors. These are invalid and shouldn't be
returned to the application, so drop them if errors detected.
This will also avoid the glitch-induced initial garbage character.
Previously, File::readString used a C-style string as an intermediate
buffer via the String += operator. This treats a NUL byte as a
terminator, making this function work incorrectly if the File contains
binary data.
This commit switches the function to use String::concat, which doesn't
treat NUL bytes any differently (and is a bit faster, because it doesn't
need to use strlen).
When receiving a `QUIT` message, the main thread was trying to tell
the scanner thread to quit - however, what it was actually doing was
creating a local variable that shadowed the global flag used by the
scanner thread. Fix that by ensuring that the main thread uses the
global variable instead.
Fixes#1028
The memcpy to unallocated memory was done in two cases:
1) The 'size' parameter was not multiple of 256.
2) The begin() was called two times and the 2nd call 'size' was greater than 1st time 'size'. (e.g. 1st size=256, 2nd size=512)
Fixes#979
Make sure to read the last byte of I2C data in the case where the IRQ happens
and the STOP signal is also asserted.
Also ensure all branches of the IRQ handler look at the same point in time
value for the IRQ status.
* add rough for scorpio
* Add SCORPIO items from ladyada
* Change PID in makeboards.py instead of boards.txt
* Fix PID in scorpio JSON
* README: Add Feather SCORPIO to supported boards
* Fix PIDs using values from MBAdafruitBoards
Still unsure about pid.[1-7] but let's see what happens
* boards.txt fixed by running makeboards.py
Co-authored-by: lady ada <limor@ladyada.net>
The PWM internals on the RP2040 are based on 8 slices with independent
clocking. Make sure that we init the PWM slice being used only once per
change of frequency/range.
Only init the scaling values one time, because we also adjust the input
scale/frequency values when calculating them. If we ran this twice (i.e.
writing to two slices), it would overwrite the pseudo scale/slow scale
values with 1 causing the wrong PWM values to be set.
Fixes#955
There's a memory leak around the corner: creating the mutex means
that we allocate memory for it, but if we cannot find any free slot in the
FMMap array, we're simply returning a nullptr without ever freeing the
previously allocated memory.
Instead of allocating it out of the free-slot check, do it inside.
While at it, also check if the mutex creation succeeded before assigning
it to a FMMap slot.
A new flexible and powerful "pluggable discovery" system was added to the Arduino boards platform framework. This system
makes it easy for Arduino boards platform authors to use any arbitrary communication channel between the board and
development tools.
Boards platform configurations that use the old property syntax are automatically translated to the new syntax by
Arduino CLI:
https://arduino.github.io/arduino-cli/latest/platform-specification/#sketch-upload-configuration
> For backward compatibility with IDE 1.8.15 and older the previous syntax is still supported
This translation is only done in platforms that use the old syntax exclusively. If `pluggable_discovery` properties are
defined for the platform then the new pluggable discovery-style `upload.tool.<protocol_name>` properties must be defined
for each board as well.
This platform includes a "UF2 Devices" discovery tool for `uf2conv` protocol ports. This tool now uses the modern
Arduino pluggable discovery system. `pluggable_discovery` properties were added to `platform.txt` in order to configure
the Arduino development tools to use this pluggable discovery tool. The `upload.tool.<protocol_name>` properties in
`boards.txt` were not updated at that time.
Global properties of that name were added to platform.txt, but this approach is not provided for by the Arduino Platform
specification:
https://arduino.github.io/arduino-cli/latest/platform-specification/#sketch-upload-configuration
> A specific upload.tool.<protocol_name> property should be defined for every board in boards.txt:
Those missing properties caused uploads to fail for users of the recent versions of Arduino IDE and Arduino CLI with an
error of the form:
Error during Upload: Property 'upload.tool.<protocol_name>' is undefined
(where `<protocol_name>` is the protocol of the selected port, if any)
It is also important to provide compatibility with versions of Arduino development tools from before the introduction of
the modern pluggable discovery system. For this reason, the old style `<board ID>.upload.tool` properties are retained.
Old versions of the development tools will treat the `<board ID>.upload.tool.<protocol_name>` properties as an unused
arbitrary user defined property with no special significance and the new versions of the development tools will do the
same for the `upload.tool` properties.
* analogWrite: fix overflow and wrap value (#917)
-avoid overflow when calculating analogScale * analogFreq, perform
the multiplication in floating point.
-use analogScale - 1 to set the PWM wrap value. Wrap is the highest
value the counter reaches, not the counter period.
* analogWrite: increase frequency range (#917)
- increase frequency range to 10 MHz
- decrease the lowest allowed resolution to 2 bits, and the
minimal analogRange value to 3. This makes 10 MHz output possible
with system clock frequencies down to 50 MHz.
- allow clkdiv values >= 1.0, was 2.0. This makes it possible to
manually set frequency and analogRange so that
frequency * analogRange = system clock frequency.
This gives the best possible frequency accuracy and
resolution.
Random crashes, infinite loops, and other lockups were happening to the PicoW
while under high load from multiple clients.
This seems to have been due to two issues:
* The periodic sys_check_timeouts() call from an alarm/IRQ was happening while
the core was in LWIP code. LWIP is not re-entrant or multi-core/thread safe
so this is a bad thing. Some calls may not have been locked with a manual
addition of the LWIPMutex object to hit this.
* The WiFi driver supplies packet data during an interrupt. PBUF work is
legal in an interrupt, but actually calling netif->input() from an IRQ to
queue up the Ethernet packet for processing is illegal if LWIP is already
in progress.
Rearchitect the LWIP interface to fix these problems:
* Disable interrupts during malloc/etc. to avoid the possibility of the
periodic LWIP timeout check interrupting and potentially calling user
code which did a memory operation
* Wrap all used LWIP calls to note LWIP code will be executing, instead of
manually eyeballing and adding in protection in user code.
* Remove all user code LWIPMutex blocking, the wrapping takes care of it.
* When an Ethernet packet is received by interrupt and we're in LWIP code,
just throw the packet away for now. The upper layers can handle retransmit.
(A possible optimization would be to set the packet aside and add a
housekeeping portion to the LWIP wrappers to netif->input() them when safe).
* Ignore callbacks during TCP connection teardown when the ClientContext
passed from LWIP == nullptr
noInterrupts/interrupts use a stack to allow multiple calls to work
properly. The original code was using a std::stack which will use
malloc() to allocate entry space. This seems like a bad idea, and
makes it so it's impossible to disable interrupts for malloc/free,
etc.
Define a fixed stack size and use straight C code to manage the IRQ
stacks. Slightly more fixed memory requirements, but significantly
lower total RAM requirements and no malloc() dependency.
When moving between different modes or even WiFi.begin/ends, any setting
of the IPs will fail because the internal flag _started was not cleared.
Clear _started on a ::end call.
Fixes#884
Allow the IDE to detect UF2 volumes (i.e. when you hold BOOTDEL and
plug in the board).
Allows the IDE2 to properly upload using OTA and serial.
Fixes#890 and others
Call `rp2040.enableDoubleResetBootloader()` anywhere in the code to
enable the check. W/o that call, the checker will be linked in.
See #892
CORE1 doesn't start until well after the C runtime initialization,
so the flag won't be overwritten.
Also increase timeout to 350ms because OTA bootup can be
slow.
Because OTA has changed the flash map from standard, picotool ends up
crashing or hanging while trying to operate on the current built files.
Remove the binary_info calls and structures completely to avoid any
issue.
Fixes#803
Fixes#795
Replace all CoreMutex and Newlib mutex accesses with FreeRTOS calls
when in FreeRTOS mode. Avoid issues with hange/etc. due to priority
inversion.
No changes to normal operating mode.
Add a FreeRTOS stress test that caught the issue fixed here.
* Add HTTP-parser lib to support ESP32 WebServer
* Add WebServer from ESP32. Only supports HTTP
* Separate HTTP server from the network server
Instead of managing the WiFiServer/WiFiServerSecure in the same object
as the HTTP handling, split them into separate objects. This lets
HTTP and HTTPS servers work without templates or duplicating code.
The HTTP block just gets a `WiFiClient*` and works with that to only
do HTTP processing, while the upper object handles the appropriate
server and client types.
* Add HTTPS server
* Clean up some THandlerFunction refs
* Refactor into a template-ized WebServer/WebServerSecure
* Add DNSServer examples which need WebServer
* Fix CoreMutex infinite recursion crash
Core could crash while Serial debugging was going on and prints were
happening from LWIP/IRQ land and the main app.
* Add HTTPUpdateServer(Secure)
* Add MIME include, optimize WebServer::send(size,len)
When send()ing a large buffer, the WebServer::send() call would
actually convert that buffer into a String (i.e. duplicate it, and
potential issues with embedded \0s in binary data).
Make a simple override to send(size, len) to allow writing from the
source buffer instead.
* Fix WiFiClient::send(Stream), add FSBrowser example
* Add HTTPUpdate class to pull updates from HTTP(S)
* Increase GH runners for pulls
WiFi builds and examples are taking some serious time now
* HTTPUpdate tests build on Pico W
OTA text error messages were getting lost because they were sent in
multiple UDP packets, one per print(). Now collect the full error and
report in a single print, allowing text messages to appear in ESPOTA.
Remove the need to have a separate WiFiClient that's destroyed after
the HTTPClient. Let the object handle its own client, and pass through
any SSL requests.
Also supports the original ::begin methods which need a
WiFiClient(Secure) to be passed in and managed by the app.
According to the Arduino docs, update works just like put, but it first checks if the value is different from the current one.
This is how our put already works, so we just alias update to put and we're done.
Function added to be more compatible with the Arduino API.
Also see #778
There may be an issue in the CYW43 driver that causes a link to never be
reported as going down once it has connected, when it was disassociated or
when the wlan shuts off unexpectedly.
Work around it by clearing the internal link active in a TCP callback for
the CYW43 driver.
Reports disconnection properly now, as well as reconnection.
Fixes#762
rp2040.reboot() would set a reboot timer for 100ms in the future, but then
return to user code and ran it until the timer expired. Now infinite loop
until the WDT fires.
Adds a 12K OTA stub 3rd stage bootloader, which reads new firmware
from the LittleFS filesystem and flashes on reboot.
By storing the OTA commands in a file in flash, it is possible to
recover from a power failure during OTA programming. On power
resume, the OTA block will simply re-program from the beginning.
Support cryptographic signed OTA updates, if desired. Includes
host-side signing logic via openssl.
Add PicoOTA library which encapsulates the file format for
the updater, including CRC32 checking.
Add LEAmDNS support to allow Arduino IDE discovery
Add ArduinoOTA class for IDE uploads
Add MD5Builder class
Add Updater class which supports writing and validating
cryptographically signed binaries from any source (http,
Ethernet, WiFi, Serial, etc.)
Add documentation and readmes.
* Apply @oddstr13 multicast patch to cyw43 driver
* Initial work for enabling IPv6
* Allow accessing CYW43 stats when LWIP_SYS_CHECK_MS is not set
* Use cyw43_set_allmulti to allow receiving multicast
* Add tools/libpico/build to gitignore
Co-authored-by: Odd Stråbø <oddstr13@openshell.no>
FreeRTOS SMP was updated to:
a) Move ths SYSTICK handler, which cannot be disabled and can fire
even with IRQs disabled, to RAM
b) Add a flag from the core to the SYSTICK handler to hold off on
any PendSV (task switch) calls while we are doing the idleOtherCore.
The core now sets this flag, _holdPendSV, and adds add'l FreeRTOS SMP
calls to really, really tell the OS we can't, don't, and better not
be swapped out while writing to flash.
Fixes#719
The send buffers are set to 8 * MSS = ~11.5K. MEM_SIZE is now set to
be larger than that, 16K, in order to help avoid having tcp_write fail
with ENOMEM. The attempt to use a smaller size is still included, which
will allow a tcp_write of up to 16 * 16K = 256K, i.e. all of memory.
Fixes#725
Increases the MEM_SIZE outstanding write buffer to 8K
Allows the ClientContext to attempt to send smaller buffer chunks in the
case where MEM_SIZE won't allow the full tcp_sndbuf() transfer.
Fixes#725
Adds compiler flags to correctly build Cortex-M0/M0+ code variants for
libraries inside of the ARM CMSIS codebase.
This was tested with the Arduino_CMSIS-DSP library.
* Adds support for Challenger RP2040 WiFi boards
* Added Challenger board to makeboards build script
* Adds new challenger board with LTE modem.
* Updated after getting approved PID from Raspberry Pi
* Add support for reverse numbering of analog pins.
* Added minimal HW support for onboard WiFi modem.
* Added challenger-nb-rp2040-wifi and RPICO32 module.
* Updated PID for RPICO32
* Added a simple support class for challenger LTE boards
* Update ChallengerLTE.cpp
Fixed spelling error
* Adds option for setting USB max power in makeboards.py
* Added new board Challenger RP2040 LoRa
* Added new lora board to readme.
* Added missing SERIAL2 and LoRa module GIO pins.
* Added support for enabling UART CTS and RTS pins.
* Updated boards.txt after merge conflict of makeboards.py
* Fixed incorrect indention
* Fixed PR comments
* Add new Challenger RP2040 WiFi/BLE board (https://ilabs.se/challenger-rp2040-wifi-ble-datasheet)
* * Updated PID for WiFi/BLE board
* Added abstraction pins for both versions of wifi modules
* Added support for replacing support class serial port.
* Added support for retrieving support class serial port.
* Fixed spelling errors.
* Updated helper class for Challenger NB board.
* Added Challenger sdrtc and subghz boards.
* Updated readme.
* Re ran makeboards to generate new index.
* Added to possibility to have extra compiler directives for a board.
* Added extra compiler options to JSON generation.
* Allows having a list of extra macros to define
* Fixed incorrect USB PID for Challenger NB board.
* Added board initialization for all wifi boards.
Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
Simple sketches should work without modification, but some modes (listed
in the docs) are not possible to support on the Pico W with BearSSL.
Fixes#691
IPv4-only mode saves 20KB+ of flash memory.
Add some backwards compatibility with the global Arduino Ethernet
class when running in IPv4 only mode.
Fixes#687
* Speed P.IO build by not cloning 2GB of sources
* Document P.IO new option
* Add support for the WiFi chip on the Pico W board.
* USB interrupt now no longer hard coded (conflicted with the WiFi IRQ).
* Add in Pico W board to makeboards.py
* Add in GPIO and variant support
* Initialize WiFi in the Variant
* Use manual LWIP, fix size accounting
* Remove the SDK WiFi overrides
* Pulling in work done in the ESP8266 core.
* Make IPAddress support IPv6
* Build LWIP with IPv4 and IPv6 support
* Use proper MAC
* Avoid cyw_warn crash. Make macro to a comment while building
* Add WiFiServer
* Add WiFiUdp
* Move LWIP-specific support files to LWIP_Ethernet
* Add WiFi::ping (ICMP ping)
* Move ICMP echo (ping) to LWIPIntfDev
* Move hostByName to LwipIntfDev
* Add AP mode with simple DHCP server
* Add some examples and basic ESP8266 compat hacks
* Update Adafruit TinyUSB to fix crash
* Set DHCP hostname
* Make Wifi.begin() return CONNECTED with link + IP
* Return connected() on WiFi::begin
* Fix spurious TCP retransmission
* Protect LWIP from reentrancy
The Pico SDK calls "sys_check_timeouts() from inside a periodic interrupt.
This appears unsafe, as the interrupt could happen while already in the
(non-reentrant) LWIP code.
Block the interrupt from calling sys_check_timeouts by using a global flag
manually set via an RAII recursive lock.
Add interrupt protection macros around critical sections inside LWIP via
the standard defines.
These two changes should make LWIP significantly more stable and long
running.
* Support disconnecting and reconnecting WiFi
* Add WiFiServer simple example
* Update documentation
Fixes#666Fixed#665
When real multicore/lockign support was added to newlib, there was an opaque
field in FILE that was used as a mutex, but was only 4 bytes in size. The
recursive mutexes on the RP2040 are 8 bytes. This mismatch caused corruption
of the FILE structure and crashes of the system when ::printf/::puts/etc. were
run.
Adjust the lock field size in FILE to 8 bytes and rebuild the toolchain to
fix.
No idea why, but when a Picoprobe upload and reset is used, the 2nd core
does not start w/o a __wfe() call on the first one before launch.
Fixes#674Fixes#402
Minor change to keep the core all CPP. Patch just made it into pico-sdk
develop branch allowing recursive mutexes to be auto_init in C++.
Update and rebuild libpico.a.
There was a race condition in making mutexes that were only init in
an __attribute((constructor)) code block. For example, a global
object might do a `malloc` in its constructor which would depend on
the malloc mutex...which may not yet have been initted.
Make them initted in the .data section, instead, which is guaranteed
good before any global constructors are called.
Instead of wrapping the memory functions in the link stage, rebuild
Newlib and enable retargetable locks. Override the weak definitions
in the libc.a with our own, SDK based ones.
The wrapping utilized before catches app-level memory allocations
but misses allocations inside Newlib libc (like printf/etc.).
Each core needs its own _impure_ptr or else crashes like the one seen
in parallel printf_floats can happen. Enable it in the toolchain
build and implement a simple swapper here.
FreeRTOS SMP doesn't support Newlib's dynamic reent which is needed
to allow save MT support. Minor patch to FreeRTOS and update the
FreeRTOS variant.cpp and setup to support it.
The realloc() wrapper was included in the develop branch of pico-sdk, so
use it instead of a local, unreproducible version of the SDK.
Should have no effect on code.
* Shift arduino attribute higher in JSON file
* Try out PlatformIO CI
* Trigger CI
* Clone recursively, actually use own repo
* Fix YAML
* Build Verbose
* Revert to checkout@v2 version, add TinyUSB to examples
* Try fix TInyUSB example
* Pull repo recursively
* Use v3 after all, correct path to example
* Only do CI on PR
* Update board generation, use renamed function
* Update documentation with new platform integration state
* Remove accidentally pushed file
* Use correct update command
* Use correct highlighting
* Use correct language
* Add section on debugging
* Add docs on filesystem, minor corrections
* Use -iprefix in compilation, but still expose all include paths to IDE
* Add exception and RTTI support, document them
* Fix typo
Remove MIDI support from the core's main TinyUSB. MIDI is still supported
using the Adafruit TinyUSB library, just like before (the core never
did use it).
Compile the Pico-SDK using `-Os`
Remove unneeded warning in UF2 upload
Blink.ino shows a savings of 3.5KB flash and 400 bytes of RAM.
For comparison, with this PR blink.ino reports:
````
Sketch uses 49908 bytes (3%) of program storage space. Maximum is 1568768 bytes.
Global variables use 7024 bytes (2%) of dynamic memory, leaving 255120 bytes for local variables. Maximum is 262144 bytes.
````
As comparison, using the MBED core blink.ino reports:
````
Sketch uses 78882 bytes (0%) of program storage space. Maximum is 16777216 bytes.
Global variables use 42780 bytes (15%) of dynamic memory, leaving 227556 bytes for local variables. Maximum is 270336 bytes.
````
So, with this PR we use **37% less flash** and and **87% less RAM**
for simple sketches.
This PR includes a pico-sdk built using the fix in
https://github.com/raspberrypi/pico-sdk/pull/864
To properly fix it requires a new pico-sdk release. but until then I am
building against my own fork of pico-sdk and including the binary.
When 1.3.2 is out (and assuming my PR is approved) I'll update the pico-sdk
link.
Fixes#614
Fixes a hang found while debugging #614. Do all memory allocations and
USB descriptor setup in main code prior to `tusb_init()`. Avoids potential
deadlock in cases where the app is allocating while the USB port is being
set up.
When get.py is run in a script the percent-update printouts shown while
downloading the toolchain end up as 100s to 1000s of lines in log files.
When stdout is not a terminal, avoid printing these percentages and
shrink logfiles significantly. Errors/etc. are still reported as normal.
Free up 4K of RAM and 6K of flash when no exceptions are enables (default).
The original toolchain was including exception code in libstdc++ by default.
Reduce installation by ~50MB and download by ~25M by removing unused LTO
gcc support.
Fixes#609 and a niggling slowness in uploads. Try to find the drive
in a loop for 10 seconds, instead of only checking once after 10 seconds.
Avoid 100% CPU usage while waiting for Pico drive
Add plumbing to allow `Wire`, `Serial1`, `SPI1` to map to the 2nd
hardware unit for devices where the PCB layout only brings out the
2nd port.
Fix the Seeedstudio XAIO pins
Fixes#594
Rewrite the I2S code from scratch to eliminate the dependence on the
pico-extras implementation and to support I2S input as well.
8-bit, 16-bit, 24-bit, and 32-bit words are supported.
Multiple I2S ports are allowed (theoretically up to 6 because
2 DMA channels are required per port).
I2S input and I2S output are supported.
Add input example
Fixes#535Fixes#99Fixes#562
The chip supports 133MHz and the other Pico core already defaults to
the higher speed, so make 133 the default.
It can still be changed through the menus and will stay at 125 unless
pre-existing users change it so they will see no difference.
To remove compiler warning the valid core macro was modified to only check
that the core passed in was < # of total cores. Unfortunately there are
parts of the FreeRTOS code where the passed in core # is -1. The upstream
catches this and returns FALSE, but my hacked version returned TRUE. This
caused interesting memory corruption errors and crashes when the
current task block[-1] was updated.
Undo the change and fix the 1 spot where a warning happens instead.
Undo the forced compiler -O0 for port.c, it was only masking the fault.
Use low power WFE when idle.
Set PORT.C to built `-O0` always because it seems to occasinally end
up with interrupts disabled in task code, causing the SYSTICK never to
fire and killing task switching.
No need for dynamic exceptions. We don't move the execbase.
Adds code to define which pins are used, moving them from the defaults, which are the same as the only three analogue input pins, and adding comments to explain how to change them.
The original didn't give any clues about which pins were used, which isn't ideal for a beginner - it was necessary to look at the code for the library, to work that out.
The new code redundantly defines a pWS pin number (as pBCLK+1), which isn't used in the example, but is meant as a reminder to the person using it, of how to wire up WS.
Using all the work from @hfellner and others, add FreeRTOS
SMP support.
Allow idling cores through the FreeRTOS FIFO queue to
allow for file system and EEPROM support.
Make delay a weak function so FreeRTOS can override.
Add cycle count support under FreeRTOS using a PIO SM.
Use a task-based approach for handling the USB periodic work
instead of the IRQ-based one in the main core.
Set 8 prio levels so it fits in 3 bits nicely (0..7).
I receive mails weekly asking how to use `SoftwareSerial` on this core.
Avoid the issue by including a simple wrapper class around `SerialPIO`
which gives the proper class name and constructor parameters.
Note that inverted mode is not supported.
Adjust the 1/2 bit time to match the number of extra cycles in the actual
PIO loop.
Throw out the entire start bit, which results in sampling the data at the
midpoint and not the starting time of a bit (which was causing random
failures on read data).
Tested at 300bps all the way to 2,000,000bps using a loopback connection.
Fixes#360
* Avoid "chunkiness" of UART FIFO availability
The UART FIFO will generate an IRQ to transfer data into the SerialUART
FIFOs either every 4 received bytes, or every 4 idle byte times. This
causes the ::available count to report "0" until either of those two
cases happen, causing a potentially delay in data becoming available to
the app.
Change the code to pull data from the HW FIFO on a read/available/peek.
Use a non-blocking mutex and IRQ disabling to safely empty the FIFO from
user space. The mutex added to the IRQ is non-blocking and will be
a single CAS the vast majority of the time, so it should not impact the
Serial performance.
Fixes#464 and others where `setPollingMode()` was needed as a workaround.
Make sure we have all mutexes locked before we disable the port and free
the queue to avoid evil cases.
Only init the mutexes once, on object creation.
In polled mode, don't bother acquiring/releasing the fifo mutex.
When begin() is called on an already running port, call end() to clean
up the old data/etc. before making a new queue/config. This avoids a
memory leak and potential write-after-free case.
The PIO and state machine were hard wired, so this caused problems if they were not free. The approach used by the Servo library has been adopted so a free PIO and SM are searched.
The DMA_IRQ_0 was grabbed exclusively, but this conflicts with SPI DMA use. The interrupt is now shared, but has been allocated the highest possible priority.
Since the PDM PIO use is receive only, the PIO state machine RX FIFO's can be joined to reduce DMA interrupt load.
GDB for non-Linux systems was built w/o expat which caused odd behavior
under Windows and other systems (i.e. breakpoints not working, etc.)
New toolchain manually builds cross-compiled libexpat and ensures it is
used, fixing the issue.
Windows OpenOCD binaries now come from manually built and tested copies
(using a real Windows system).
Fixes#478Fixes#457Fixes#456
and probably others...
Fixes#472
Instead of using interrupts, explicitly call the IRQ handler dueing Serial
read/peek/available calls.
Add to keywords.txt for syntax hilighting.
Add poll calls in the SerialUART::write-like calls (write,
flush, etc.)
Really remove division from IRQ routines/
Microsoft is deprecating WMIC, so fall back to a Powershell call in
case of failure to ruin WMIC.
Belt and suspenders, set PowerShell non-interactive mode and null STDIN.
Fixes#468
The FIFO limit was set to 1/2, or 16 bytes on POR and not set by the core,
so for low baud this could result in a LONG time without data moving from
hardware FIFO to the SW ring buffer and timeouts/etc.
Now use the API call which sets it to 1/8, or 4 bytes of data to speed up
the transfer 4x.
Also avoid using the divider in the IRQ routine because it is not clear
from the docs of the Pico SDK IRQ callback routine preserves divider
state or not. If not, doing division in an IRQ could result in random
data corruption in the main app.
Add memory barriers to ensure the order of data into RAM is preserved
and that GCC doesn't reorder writes.
Most other boards and the MBED RP2040 support analogReadResolution which
just shifts read data around as needed, with a default of only 10b of
resolution. The Pico ADC technically supports 12b, but only has about
8b of real data after noise, so you're not really losing anything in the
general case.
Fixes#460
Fixes a crash of the builder script, `board.get("build.variant", None)` will throw an exception if the `build.variant` was not found (and not return `None` as the fallback value), but an empty string works, so check against that.
USB power defines moved directly into the board files, but still ensure that the macro always exists (with a default fallback value) to not fail the build.
Keyboard class now has support for non-en_US layouts, and documentation has
been added to the Mouse class.
Thanks to @rico0260 for letting me know about the update, and for the initial PR!
The Pico HW seems to generate an interrupt on the end of every I2C
write cycle, even if the slave address wasn't actually targeted.
This would cause the onReceive method to be called with a 0-len
parameter for every write on the I2C bus.
Now, only call onReceive if there is 1 or more bytes of data available.
SdFat used to point to unnamed commit in the ESP8266SdFat repo.
Master in that repo has now been moved to that commit, so make this
core use the master branch for sanity's sake.
When the Serial software FIFOs overeflowed, the IRQ handler would not
read any more data from the hardware FIFOs. This would cause the
IRQ handler to be continually called as soon as it exited since the
HW FIFOS were not empty.
Now always read every available HW FIFO entry and throw out any that
don't fit in the SW FIFO.
Also fix a too long by half stop bit timing in the PIOSerial receiver.
Defines USBD_MAX_POWER_MA as a static 250mA, which is correct for all the boards supported in platform-raspberrypi (aka, RaspberryPi Pico and Nano RP2040 Connect)
Adds support to the core for PIO-based, software-created UARTs, up to 8 (the number of PIO state machines) possible.
By using a custom program on the PIO state machines, it allows for very high bit rates and does not require CPU or interrupts.
Bit widths from 5- to 8-bits, 1 or 2 stop bits, and even/odd/none parity are supported.
PR #379 was an ugly hack which works only if you poll the Serial port more
frequently than ~8 byte times.
This PR replaces the polling with an IRQ based lockless writer/reader queue
so that even if you only read every 32 byte times, the Serial1/2 port should
not lose data. It also should use less CPU and allow for somewhat higher
throughput.
Leave the SPI port initted after a transaction, and when a new one comes in
check if it is the same settings we're already running. If so, do nothing.
If not, deinit and reinit. In general the settings will be identical, so
this will speed things up massively.
Fixes#392
* Remove redundant/wrong second board.mcu in boards.txt
Fixes#380
Boards.txt had the setting board.mcu twice. The first one was correct,
while the second one wasn't and shouldn't have been there. Remove it.
* Include fix from @rei-vilo in #381
Because the hardware FIFO is quite small and doesn't report the actual number
of bytes available, implement a software FIFO that will pull all available
bytes out of the HW FIFO on any Serial call. It's not as efficient or as
bulletproof as an IRQ based method, but it is simpler to implement and can
help with issues like #378
Fixes#348
Add the RTC header path in the SDK to the Arduino build path. Also add
pico_utils to the libpico.a for the datetime_to_str call.
Note that the pico_sdk has a bug in the datetime.h header so you need to
manually bracket the include file as "C":
extern "C" {
#include "pico/util/datetime.h"
}
By default RTTI (Run-Time Type Information) is disabled because most apps
don't need run time type info enabled. However, certain libraries expect
to be able to query types of objects at runtime, so add a menu to enable it.
In `pinMode()` I think it would be better to call `gpio_disable_pulls()` on the ulPin when ulMode == INPUT.
Adding `gpio_disable_pulls(RP_PIN);` after `pinMode(RP_PIN, INPUT);` solves the issue.
* Add package.json
To make package easily integratable with PlatformIO
* Correct name back to original one
* Format package.json
* Add first shot at builder script
* Add USB stack flags, fix compile flags
* Formatting
* Add more link & USB flags
* Build Boot2 bootloader
* Formatting
* Generate linkerscript, linker fixes
* Fix linkflags, make firmware runnable
* Update USB flags and RAM size
* Correct USB flags, add dynamic sketch partitioning
* Restructure filesystem size and flash size logic into platform code
* Move C++ only flags to CXXFLAGS
* Add PlatformIO documentation
* Link to new platform.io document in the docs TOC
* Fix typos in platformio docs
* Fix one additional typo in platformio.rst
* Update docs
* Remove wrongly commited build folder
Per #276, #277, #274 there seems to be an issue with interrupts and some
other low-level ARM operations when using the distributed libstdc++.
Use the default libstdc++ built with the toolchain, instead.
Fixes#277Fixes#276Fixes#274
* Adds support for Challenger RP2040 WiFi boards
* Added Challenger board to makeboards build script
* Adds new challenger board with LTE modem.
* Updated after getting approved PID from Raspberry Pi
When LittleFS.begin() or SDFS.begin() is called after the filesystem is
already mounted, don't unmount/remount. When an unmount happens, all old
Files become invalid (but the core doesn't know this), so you would end
up with random crashes in FS code.
Now, check for _mounted, and if so just return immediately from begin().
Wire::requestFrom() returns the number of bytes read from the slave. In
the case of error, the slave can end up returning a very large integer
for PICO_GENERIC_ERROR which would then be used as the # of bytes read
causing crashes and errors.
Running TalkingToMyself without connecting the I2C ports would show
this behavior.
Now, when PICO_GENERIC_ERROR is returned, set the read-back buffer len
to 0 explicitly.
When a Python MSI/etc. is installed under Windows, it sets a global
PYTHONHOME and other variables. Our shipped Python can end up using
these variables and attempt to load the wrong PYC files and fail
to run.
Avoid by using -I isolated mode in Python calls
Fixes#252
The PWM HW can only divide 125MHZ sysclk by 1...256. That's only down to
about 500khz. If the max count of the PWM (analogWriteScale) is too low
then the actual PWM period will be much less than desired (and PWM frequency
of course much higher).
For example, at analogWriteFreq(100); analogWriteScale(256); the true
PWM period would be 125M / 256 (pwmdiv) / 256 (scale) = ~2khz.
Conversely, at high frequencies and large scales it is impossible to achieve
the requested frequency and a much lower one would be generated. For
example: freq(60K), scale(32768). PWM period = 125M / 1 (pwmdiv) / 32768 =
~4kHz.
Avoid this by adjusting the analogWrite scale in the core to either increase
the PWM count for low frequencies, or decrease it for high frequencies.
This is done behind the scenes and code is not required to be changed.
The PWM frequency will still not be perfcetly exact due to the divider HW
and clocks involved, but it will be very close across the whole range.
Fixes#234
The Pico SDK has some magic with const pointers that generates lots of
"ignored qualifer" warnings on the more pedantic modes. To clean the
normal builds up, disable this warning for now. At some point a PR to
the PICO-SDK may be indicated.
Fixes#236
Compiler warning flags were completely ignored/missed in platform.txt.
Add them, as normal, and include -Werror=return-type because GCC will
produce crashing apps when a function return value is missing.
* update included tinyusb to 1.2.0
move tusb_config.h from core to library for more portability
* pump tinyusb
* update tinyusb to 1.3.0
* try to fix ci warning
Use the 24-bit SYSTICK peripheral, wrapped in logic to extend it to a
full 32 or 64bits. W/o the wrapper, SYSTICK will wrap around in ~100ms.
Adds rp2040.getCycleCount() and rp2040.getCycleCount64()
Clean up the libpico build process as crt0.S from the pico-sdk should
be directly used.
Clean up the keywords file.
Fixes#222
The HW needs to have the TXC_ABRT flag cleared when a slave transmission is
cut short by the master, or else it will effectively break the I2C bus and
never recover.
The O_CREAT/etc. flags on the Pico are a full 32-bits in size, but the
core was generating a flag for SdFat using an 8-bit type, so all the
O_CREAT, O_TRUNC, O_APPEND, etc. flags got cut off.
Fix the flag size.
Fixes#214
Fixes a hang when reading from the Serial UART ports because before the
core would pause indefinitely for the next character.
Now, wait up to Serial.setTimeout() milliseconds and if it times out
return -1 to the app.
Fixes#210
The PIO programs that generate tone() and Servo() use the TX FIFO to
receive updates to the period/duty cycle.
The original code would push into the FIFO (potentially blocking the
app if the FIFO was full) and generate at least one cycle of every
value written into the control. Basically, the output would
lag the changes by 1 cycle or more (which could be 20ms+ on Servo).
Fix this by clearing any old, ungrabbed values from the FIFO before
sending a new one to the program. Instead of a FIFO, there is
effectively now just a control register and updates will be immediate.
Update the Siren.ino example with delays because now the tone() calls
will not block and run 10x+ faster.
Many functions are defined inside the api/Common.h, so remove them from
the Arduino.h header to have them appear only once.
Fix up the abs() macro to avoid macro problems, add round()
GCC 10.2 has a bug which causes Windows to rebuild every library on every
compile, instead of caching the first results.
Upgrade to GCC 10.3 which has this fixed.
Add proper OpenOCD executables for non-Linux x86_64 archs.
* add two variant files
* add trinkey and stemma friend
* add fast SPI transfer using pico-sdk blocks
* update makeboards.py for new variants
- STEMMA Friend RP2040
- Trinkey RP2040 QT
* run astyle on SPI library
* fix auto -> ssize type
* astyled
* woops ssizet != sizet!
* a nice day for a new board definition! this is a macropad with 12 keys, oled and rotary encoder
Co-authored-by: hathach <thach@tinyusb.org>
Fixes#121
Supersedes #185
Redo the PIO program to allow the tone generator on a pin to be updated
without interruption, at waveform boundaries. This allows for things like
sirens or slurs to be implemented simply.
Use an alarm, not the PIO hardware, to manage time-limited tones().
Add a simple siren example.
When multiple libraries contain files matching an #include directive in the program, the Arduino build system must pick
one to use for compilation. Multiple factors are used in order to make an intelligent determination of which library is
best.
In order to enhance this determination, the closeness of match between the library.properties name value and the
filename in the #include directive is being added as one of those factors. This new factor is referred to as
"Library Name Priority".
Unfortunately, this change can result in platform bundled libraries which had previously been correctly correctly chosen
no longer being given priority over their equivalent standalone libraries, which may be incompatible or not optimized
for the platform's boards.
This priority inversion only occurs when all the following conditions are true:
- There is a standalone library installed which provides a header filename collision.
- The platform bundled library is architecture optimized (e.g., architectures=esp32).
- The standalone library is architecture compatible (architectures=*).
- The standalone library has equal "Folder Name Priority".
- The standalone library has better "Library Name Priority" (e.g., name=SD vs name=SD(ESP32) for a library with primary
header file SD.h.
The fix is to simply give the platform bundled library a perfect "Library Name Priority".
Some platform bundled libraries were given a modified name as a workaround to a bug in the Arduino IDE's Library Manager
which caused Library Manager to always show the library as updatable under specific circumstances. That bug was fixed in
Arduino IDE 1.8.6, ~3 years ago.
Fixes#169
Trying to change pinout while running, or to an illegal configuration,
will now immediately panic() with an error message. Such an attempt
is a pretty big problem since pinouts are hardware related/static.
Prior code would fail silently and return false, but nobody checked
the setXXX return values, anyway.
Fixes#167
For Serial when selecting TinyUSB. Can't include in the core because Arduino IDE
will not link in libraries called from the core. Instead, add the header to all
the standard libraries in the hope it will still catch some user cases where they
use these libraries.
See https://github.com/earlephilhower/arduino-pico/issues/167#issuecomment-848622174
Ensure no stray files get sucked into the release ZIP by using a clean CI
image to build the package and JSON file. Auto-populate the draft with
the git commits since the last release.
Fixes#171
Under Windows, it is very hard to make a symlink and by default git won't
make one to the Arduino API directory, causing annoying build errors.
Avoid the issue by duplicating the ArduinoAPI directory explicitly and using
CI to verify that there are no differences between the two.
Fixes#27
As @vslinuxdotnet discovered, sometimes the Pico firmware update emulated USB
stick does not get automounted under Linux. Add logic to attempt to use
standard tools to mount it to the uploader, only tried if no drives are
detected normally.
* add missing character for debug level "Wire"
if Debug Level "Wire" is chosen, the compiler posts error
> arm-none-eabi-g++: error: DDEBUG_RP2040_WIRE: No such file or directory
Add the missing '-' to correct the issue.
* change must be made via makeboards.py
The generator script needs to be fixed and rerun. If we just update the boards.txt, changes will be lost on a rebuild.
* Update boards.txt
boards.txt as generated by revised makeboards.py
* correct spelling issue for CI tool
* initial tinyusb lib port
* add Adafruit_TinyUSB_Arduino as submodules
* add yield() to main loop
* sync with tinyusb lib latest
* add USB manufacturer and product
* fix typo in tinyusb lib
* sync with master
updating implementation
* Rationalize link stage command line
Make the build process less insane.
* clean up delay
* clean up platform and board
* update makeboards.py for generating usbstack menu
* update tinyusb lib to 1.0.0
Add definitions for compatibility to many platforms and libraries
- clockCyclesPerMicrosecond()
- clockCyclesToMicroseconds(a)
- microsecondsToClockCycles(a)
Older builds included C++ locale information in RAM/flash as well as a
bunch of exception code which can't get called since they're not enabled.
Remove them by adjusting final link command and not instantiating them
in main.cpp in the first place.
Blink went from:
> Sketch uses 215604 bytes (10%) of program storage space. Maximum is 2093056 bytes.
> Global variables use 18152 bytes (6%) of dynamic memory, leaving 243992 bytes for local variables. Maximum is 262144 bytes.
To:
> Sketch uses 56112 bytes (5%) of program storage space. Maximum is 1044480 bytes.
> Global variables use 12152 bytes (4%) of dynamic memory, leaving 249992 bytes for local variables. Maximum is 262144 bytes.
For a savings of **155KB of flash** and **6KB of RAM**
Most users w/the Library Manager will get a little nervous with the GH site.
The ReadTheDocs site includes links to the GH site, too, so they can still
find the origin.
BOOTSEL needs to be multicore protected, too.
Reading BOOTSEL required disabling the flash interface, so the other
core needs to be idles while this runs.
Make the PIO program object multicore safe, too, so that if both cores
try to load a program they won't step on each other.
Update pico-sdk to 1.1.2
Add methods to block the opposite core while doing flash updates.
Ensure opposite core is stopped in LittleFS and EEPROM while doing
flash updates.
Update documentation with new calls.
Support running code on the second core by adding a setup1() and/or
a loop1() routine to a sketch. These functions operate exactly like
the normal Arduino ones, and anything they call will be run on
the second core automatically.
Add a simple multicore example.
Can't have cores/rp2040/api in the include path because the Arduino API
dir has a "String.h" file. On Windows, because it is case-insensitive
normally, this overrides the POSIX "string.h" header leading to bad
stuff.
Add manual redirect includes for commonly accessed headers in the
cores/rp2040 path instead.
for b in $(cut -f1 -d. /home/runner/work/arduino-pico/arduino-pico/boards.txt | sed 's/#.*//' | sed 's/^menu$//' | sort -u); do
cnt=$((cnt + 1))
rem=$((cnt % 2))
if [ $rem == ${{ matrix.chunk }} ]; then
pio ci --board=$b -O "platform_packages=framework-arduinopico@symlink:///home/runner/work/arduino-pico/arduino-pico" libraries/rp2040/examples/Bootsel/Bootsel.ino
# Arduino-Pico [](https://gitter.im/arduino-pico/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Raspberry Pi Pico Arduino core, for all RP2040 boards
Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
This is a port of the RP2040 (Raspberry Pi Pico processor) to the Arduino ecosystem.
This is a port of Arduino to the RP2040 (Raspberry Pi Pico processor) and RP2350 (Raspberry Pi Pico 2 processor). It uses the bare Raspberry Pi Pico SDK and a custom GCC 14.2/Newlib 4.3 toolchain and supports ARM and RISC-V cores.
It uses a custom toolset with GCC 10.2 and Newlib 4.0.0, not depending on system-installed prerequisites. https://github.com/earlephilhower/pico-quick-toolchain
# Documentation
See https://arduino-pico.readthedocs.io/en/latest/ along with the examples for more detailed usage information.
There is automated discovery of boards in bootloader mode, so they show up in the IDE, and the upload command works using the Microsoft UF2 tool (included).
# Contributing
Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blob/master/docs/contrib.rst) for more information on submitting pull requests and porting libraries or sketches to this core.
# Detailed Documentation
Refer to the examples and https://arduino-pico.readthedocs.io/en/latest/ for more detailed usage information.
If Win32 long paths are not enabled, and `git` not configured to use them then there
may be errors when attempting to clone the submodules.
To install via GIT (for latest and greatest versions):
````
mkdir -p ~/Arduino/hardware/pico
@ -45,22 +217,15 @@ cd ~/Arduino/hardware/pico/rp2040
git submodule update --init
cd pico-sdk
git submodule update --init
cd pico-extras
git submodule update --init
cd ../tools
python3 ./get.py
`````
# Installing both Arduino and CMake
Tom's Hardware presented a very nice writeup on installing `arduino-pico` on both Windows and Linux, available at https://www.tomshardware.com/how-to/program-raspberry-pi-pico-with-arduino-ide
If you follow Les' step-by-step you will also have a fully functional `CMake`-based environment to build Pico apps on if you outgrow the Arduino ecosystem.
# Uploading Sketches
To upload your first sketch, you will need to hold the BOOTSEL button down while plugging in the Pico to your computer.
Then hit the upload button and the sketch should be transferred and start to run.
After the first upload, this should not be necessary as the `arduino-pico` core has auto-reset support.
After the first upload, this should not be necessary as the `arduino-pico` core has auto-reset support.
Select the appropriate serial port shown in the Arduino Tools->Port->Serial Port menu once (this setting will stick and does not need to be
touched for multiple uploads). This selection allows the auto-reset tool to identify the proper device to reset.
Them hit the upload button and your sketch should upload and run.
@ -72,72 +237,55 @@ follow the initial procedure of holding the BOOTSEL button down while plugging i
The onboard flash filesystem for the Pico, LittleFS, lets you upload a filesystem image from the sketch directory for your sketch to use. Download the needed plugin from
If you have built a Raspberry Pi Picoprobe, you can use OpenOCD to handle your sketch uploads and for debugging with GDB.
Under Windows a local admin user should be able to access the Picoprobe port automatically, but under Linux `udev` must be told about the device and to allow normal users access.
To set up user-level access to Picoprobes on Ubuntu (and other OSes which use `udev`):
````
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", GROUP="users", MODE="0666"' | sudo tee -a /etc/udev/rules.d/98-PicoProbe.rules
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE="660", GROUP-"plugdev"' | sudo tee -a /etc/udev/rules.d/98-PicoProbe.rules
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE="660", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/98-PicoProbe.rules
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000f", MODE="660", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/98-PicoProbe.rules
sudo udevadm control --reload
sudo udevadm trigger -w -s usb
````
The first line creates a file with the USB vendor and ID of the Picoprobe and tells UDEV to give users full access to it. The second causes `udev` to load this new rule. Note that you will need to unplug and re-plug in your device the first time you create this file, to allow udev to make the device node properly.
The first line creates a device file in `/dev` matching the USB vendor and product ID of the Picoprobe, and it enables global read+write permissions. The second line causes `udev` to load this new rule. The third line requests the kernel generate "device change" events that will cause our new `udev` rule to run.
If for some reason the device file does not appear, manually unplug and re-plug the USB connection and check again. The output from `dmesg` can reveal useful diagnostics if the device file remains absent.
Once Picoprobe permissions are set up properly, then select the board "Raspberry Pi Pico (Picoprobe)" in the Tools menu and upload as normal.
# Debugging with Picoprobe, OpenOCD, and GDB
The installed tools include a version of OpenOCD (in the pqt-openocd directory) and GDB (in the pqt-gcc directory). These may be used to run GDB in an interactive window as documented in the Pico Getting Started manuals from the Raspberry Pi Foundation.
# Status of Port
Relatively stable and very functional, but bug reports and PRs always accepted.
* digitalWrite/Read
* shiftIn/Out
* SPI master
* analogWrite/PWM
* tone/noTone
* Wire/I2C Master and Slave
* EEPROM
* USB Serial(ACM) w/automatic reboot-to-UF2 upload)
* Hardware UART
* Servo, glitchless
* Overclocking and underclocking from the menus
* analogRead and Pico chip temperature
* Filesystems (LittleFS and SD/SDFS)
* I2S audio output
* printf (i.e. debug) output over USB serial
The RP2040 PIO state machines (SMs) are used to generate jitter-free:
* Servos
* Tones
* I2S Output
# Tutorials from Across the Web
Here are some links to coverage and additional tutorials for using `arduino-pico`
* The File:: class is taken from the ESP8266. See https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html
* Arduino Support for the Pi Pico available! And how fast is the Pico? - https://youtu.be/-XHh17cuH5E
* Demonstration of Servos and I2C in Korean - https://cafe.naver.com/arduinoshield/1201
# Contributing
If you want to contribute or have bugfixes, drop me a note at <earlephilhower@yahoo.com> or open an issue/PR here.
The installed tools include a version of OpenOCD (in the pqt-openocd directory) and GDB (in the pqt-gcc directory). These may be used to run GDB in an interactive window as documented in the Pico Getting Started manuals from the Raspberry Pi Foundation. Use the command line `./system/openocd/bin/openocd -f ./lib/rp2040/picoprobe_cmsis_dap.tcl` or `./system/openocd/bin/openocd -f ./lib/rp2350/picoprobe_cmsis_dap.tcl` from the `git` installation directory.
# Licensing and Credits
* The [Arduino IDE and ArduinoCore-API](https://arduino.cc) are developed and maintained by the Arduino team. The IDE is licensed under GPL.
* The [RP2040 GCC-based toolchain](https://github.com/earlephilhower/pico-quick-toolchain) is licensed under under the GPL.
* The [Pico-SDK](https://github.com/raspberrypi/pico-sdk) and [Pico-Extras](https://github.com/raspberrypi/pico-extras) are by Raspberry Pi (Trading) Ltd and licensed under the BSD 3-Clause license.
* [Arduino-Pico](https://github.com/earlephilhower/arduino-pico) core files are licenses under the LGPL.
* The [Pico-SDK](https://github.com/raspberrypi/pico-sdk) is by Raspberry Pi (Trading) Ltd and licensed under the BSD 3-Clause license.
* [Arduino-Pico](https://github.com/earlephilhower/arduino-pico) core files are licensed under the LGPL.
* [LittleFS](https://github.com/ARMmbed/littlefs) library written by ARM Limited and released under the [BSD 3-clause license](https://github.com/ARMmbed/littlefs/blob/master/LICENSE.md).
* [UF2CONV.PY](https://github.com/microsoft/uf2) is by Microsoft Corporatio and licensed under the MIT license.
* Some filesystem code taken from the [ESP8266 Arduino Core](https://github.com/esp8266/Arduino) and licensed under the LGPL.
* [UF2CONV.PY](https://github.com/microsoft/uf2) is by Microsoft Corporation and licensed under the MIT license.
* Networking and filesystem code taken from the [ESP8266 Arduino Core](https://github.com/esp8266/Arduino) and licensed under the LGPL.
* DHCP server for AP host mode from the [Micropython Project](https://micropython.org), distributed under the MIT License.
* [FreeRTOS](https://freertos.org) is copyright Amazon.com, Inc. or its affiliates, and distributed under the MIT license.
* [lwIP](https://savannah.nongnu.org/projects/lwip/) is (c) the Swedish Institute of Computer Science and licenced under the BSD license.
* [BearSSL](https://bearssl.org) library written by Thomas Pornin, is distributed under the [MIT License](https://bearssl.org/#legal-details).
* [UZLib](https://github.com/pfalcon/uzlib) is copyright (c) 2003 Joergen Ibsen and distributed under the zlib license.
* [LEAmDNS](https://github.com/LaborEtArs/ESP8266mDNS) is copyright multiple authors and distributed under the MIT license.
* [http-parser](https://github.com/nodejs/http-parser) is copyright Joyent, Inc. and other Node contributors.
* WebServer code modified from the [ESP32 WebServer](https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer) and is copyright (c) 2015 Ivan Grokhotkov and others.
* [Xoshiro-cpp](https://github.com/Reputeless/Xoshiro-cpp) is copyright (c) 2020 Ryo Suzuki and distributed under the MIT license.
* [FatFS low-level filesystem](http://elm-chan.org/fsw/ff/) code is Copyright (C) 2024, ChaN, all rights reserved.
* [TLSF memory manager for PSRAM from Espressif fork](https://github.com/espressif/tlsf) of [original](https://github.com/mattconte/tlsf) by Matthew Conte is copyright Matthew Conte and licensed under the MIT license.
* [ESPHost library](https://github.com/Networking-for-Arduino/ESPHost) is LGPL licensed by its maintainers.
// Warn users trying to use Pico SDK's STDIO implementation
#include<pico/stdio.h> // Ensure it won't be re-included elsewhere
#undef stdio_uart_init
#define stdio_uart_init(...) static_assert(0, "stdio_uart_init is not supported or needed. Either use Serial.printf() or set the debug port in the IDE to Serial/1/2 and use printf(). See https://github.com/earlephilhower/arduino-pico/issues/1433#issuecomment-1540354673 and https://github.com/earlephilhower/arduino-pico/issues/1433#issuecomment-1546783109")
#undef stdio_init_all
#define stdio_init_all(...) static_assert(0, "stdio_init_all is not supported or needed. Either use Serial.printf() or set the debug port in the IDE to Serial/1/2 and use printf(). See https://github.com/earlephilhower/arduino-pico/issues/1433#issuecomment-1540354673 and https://github.com/earlephilhower/arduino-pico/issues/1433#issuecomment-1546783109")
#undef stdio_usb_init
#define stdio_usb_init(...) static_assert(0, "stdio_usb_init is not supported or needed. Either use Serial.printf() or set the debug port in the IDE to Serial/1/2 and use printf(). See https://github.com/earlephilhower/arduino-pico/issues/1433#issuecomment-1540354673 and https://github.com/earlephilhower/arduino-pico/issues/1433#issuecomment-1546783109")
// ARM toolchain doesn't provide itoa etc, provide them
if(*rrp&POWMAN_CHIP_RESET_HAD_POR_BITS){// POR: power-on reset (brownout is separately detected on RP2350)
returnPWRON_RESET;
}
if(*rrp&POWMAN_CHIP_RESET_HAD_RUN_LOW_BITS){// RUN pin
returnRUN_PIN_RESET;
}
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
returnDEBUG_RESET;
}
if(*rrp&POWMAN_CHIP_RESET_HAD_GLITCH_DETECT_BITS){// power supply glitch
returnGLITCH_RESET;
}
if(*rrp&POWMAN_CHIP_RESET_HAD_BOR_BITS){// power supply brownout reset