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