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
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
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
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
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.
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
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).
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.
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.
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
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.
* 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
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.
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
* 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