At some point the config changed such that no messages above Error level
were compiled into the final binary.
Fixes issue #12815.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Otherwise passing in a non-integer can lead to an invalid memory access.
Thanks to Junwha Hong and Wonil Jang @S2Lab, UNIST for finding the issue.
Fixes issue #13007.
Signed-off-by: Damien George <damien@micropython.org>
If the hard socket limit (default 16) is reached then it's possible that
socket allocation fails but garbage collection would allow it to succeed.
Perform a GC pass and try again before giving up, similar to the logic
elsewhere in MicroPython that tries a GC pass before raising MemoryError.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
LWIP doesn't implement a timeout for blocking connect(), and such a timeout
is not required by POSIX. However, CPython will use the socket timeout for
blocking connect on most platforms. The "principle of least surprise"
suggests we should support it on ESP32 as well (not to mention it's
useful!).
This provides the additional improvement that external exceptions (like
KeyboardInterrupt) are now handled immediately if they happen during
connect(). Previously Ctrl-C would not terminate a blocking connect until
connect() returned, but now it will.
Fixes issue #8326.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit changes the Arduino board identifiers to correspond to their
official names. This helps to identify boards at runtime. At the moment
the Arduino Portenta H7 is reported as PORTENTA which is unfortunate as now
there is another Portenta board (Portenta C33) supported in MicroPython.
Also made the other identifiers for flash and network name consistent,
removed the incorrectly used MICROPY_PY_SYS_PLATFORM identifiers, and added
missing MICROPY_PY_NETWORK_HOSTNAME_DEFAULT identifiers.
Boards affected:
- stm32: ARDUINO_PORTENTA_H7, ARDUINO_GIGA, ARDUINO_NICLA_VISION
- renesas-ra: ARDUINO_PORTENTA_C33
- esp32: ARDUINO_NANO_ESP32
- rp2: ARDUINO_NANO_RP2040_CONNECT
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
Configuration:
- Clock is HSE, CPU runs at 250MHz.
- REPL on USB and UART connected to the ST-Link interface.
- Storage is configured for internal flash memory.
- Three LEDs and one user button.
- Ethernet is enabled.
Signed-off-by: Rene Straub <rene@see5.ch>
Replaces the previous all-zeroes "TODO" serial number.
Requires refactoring the low-level unique_id routine out from modmachine.c.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Change the rp2 and renesas-ra ports to use the helper function.
Saves copy-pasta, at the small cost of one more function call in the
firmware (if not using LTO).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Functionality and code size don't really change, but removes port-specific
code in favour of shared code.
(The MSC implemented in shared/tinyusb depends on some functions in the
pico-sdk, so this change doesn't make this available for samd.)
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
See the commit a00c9d56db for a detailed description of the problem, a
regression introduced in 26d503298.
Same approach here as the linked fix for rp2 (applied unconditionally here
as this port only supports USB-CDC for stdin/stdout).
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The recent change in bcbdee2357 means that
TinyUSB can no longer be run from within a soft (or hard) IRQ handler, ie
when the scheduler is locked. That means that Python code that calls
`print(...)` from within a scheduled function may block indefinitely if the
USB CDC buffers are full.
This commit fixes that problem by explicitly running the TinyUSB stack when
waiting within stdio tx/rx functions.
Signed-off-by: Damien George <damien@micropython.org>
Fixes undefined behavior when calling vfs_posix_file_ioctl with
MP_STREAM_CLOSE as request because that casts away the constness and
assigns -1 to the object's fd member.
Fixes issue #12670.
Signed-off-by: stijn <stijn@ignitron.net>
Similar to 3883f29485 where this change was
implemented for threads: when the Bluetooth IRQ handler is called the
thread state is not not zero-initialized and thus we need to manually set
this to NULL.
Fixes issue #12239.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This adds the sync version of the LoRa driver (and the base WL55 driver).
Adds +13.6kiB (212.6 -> 226.2). Limit for this board is 232kiB.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
If you have a variable frequency and pulse width, and you want to optimize
pulse resolution, then you must do a calculation beforehand to ensure you
normalize the array to keep all list values within bound. That calculation
requires RMT.source_freq(), RMT.clock_div(), and this 32767 constant.
Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
To create an esp32.RMT() instance with an optimum (i.e. highest resolution)
clock_div is currently awkward because you need to know the source clock
frequency to calculate the best clock_div, but unfortunately that is only
currently available as an source_freq() method on the instance after you
have already created it. So RMT.source_freq() should really be a class
method, not an instance method. This change is backwards compatible for
existing code because you can still reference that function from an
instance, or now also, from the class.
Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
Previously the TinyUSB task was run in the ISR immediately after the
interrupt handler. This approach gives very similar performance (no change
in CDC throughput tests) but reduces the amount of time spent in the ISR,
and allows TinyUSB callbacks to run in thread mode.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This change:
- Has a small code size reduction.
- Should slightly improve overall performance. The old hook code
seemed to use between 0.1% and 1.6% of the total CPU time doing no-op
calls even when no USB work was required.
- USB performance is mostly the same, there is a small increase in
latency for some workloads that seems to because sometimes the hook
usbd_task() is called at the right time to line up with the next USB host
request. This only happened semi-randomly due to the timing of the hook.
Improving the wakeup latency by switching rp2 to tickless WFE allows the
usbd_task() to run in time for the next USB host request almost always,
improving performance and more than offsetting this impact.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
dcd_event_handler() is called from the IRQ when a new DCD event is queued
for processing by the TinyUSB thread mode task. This lets us queue the
handler to run immediately when MicroPython resumes.
Currently this relies on a linker --wrap hack to work, but a PR has been
submitted to TinyUSB to allow the function to be called inline from
dcd_event_handler() itself.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Speeds up importing files from mounted filesystem.
Also fix the return code for invalid / unsupported ioctl requests.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Add a .ico file with common icon image size, created from
vector-logo-2.png, and embed it into the resulting executable.
Signed-off-by: stijn <stijn@ignitron.net>
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings. At this stage only esp32 implements
this class, so the code for the bindings comes from that port.
The documentation is also updated to reflect the esp32's behaviour of
ADCBlock.connect().
Signed-off-by: Damien George <damien@micropython.org>
This handles the case where an empty bytes/bytearray/str could pass in
NULL as the str argument (with length zero). This would result in UB in
strncmp. Even though our bare-metal implementation of strncmp handles
this, best to avoid it for when we're using system strncmp.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
C99 says that strncmp has UB for either string being NULL, so the
current behavior is technically correct, but it's an easy fix to handle
this case correctly.
7.1.4: "unless explicitly stated otherwise in the detailed
description... if an argument to a function has ...null pointer.. the
behavior is undefined".
7.21.1: "Unless explicitly stated otherwise in the description of a
particular function in this subclause, pointer arguments on such a call
shall still have valid values, as described in 7.1.4".
Also make the same change for the minimal version in bare-arm/lib.c.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Remove port-specific test directories and excluded tests from
tinytest-codegen, and let it read said information from an external file.
This way tinytest-codegen is not limited to always generate tests for the
`qemu-arm` target.
This allows having port-specific test directory and excluded tests for more
than one QEMU bare-metal target.
The `qemu-arm` port Makefile was modified to work with the generator
changes and a tests profile file was added to said port.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Changing the baudrate requires a complete re-configuration of the Sercom
device, which is put into a separate rather large function. This new
machine_uart_set_baudrate() function will be useful for future drivers such
as Bluetooth.
Signed-off-by: robert-hh <robert@hammelrath.com>
Fixes are:
- Only emit ADC table entries for pins that aren't cpu-hidden
(i.e. ignore `X,-Y` rows).
- Only use the P channels on H7.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The main motivation for doing this was to reduce the latency when the
system is woken by a USB interrupt. The best_effort_wfe_or_timeout()
function calls into the pico-sdk dynamic timer framework which sets up a
new dynamic timer instance each time, and then has to tear it down before
continuing after a WFE.
Testing Python interrupt latency, it seems to be improved by about 12us
(from average of 46us to 34us running a Pin IRQ). C-based "scheduled
nodes" should see even lower latency.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>