This setting was missed in df05caea6c. It's
needed for this port to pass its `tests/ports/renesas-ra/modtime.py` test.
Signed-off-by: Damien George <damien@micropython.org>
I2CTarget costs about 8k of flash size on ESP32-S2, and about 11k on
ESP32-C6. The ESP32-C6 only has about 8k remaining, so disable I2CTarget
on that SoC until more flash can be made available.
Signed-off-by: Damien George <damien@micropython.org>
This describes the ROMFS location and size in Pico SDK's binary declaration
format, so it can be read from a .uf2 file for use with various tools.
Signed-off-by: Phil Howard <github@gadgetoid.com>
Adds a Python override of the `machine` module, which delegates to the
built-in module and adds an implementation of `Counter` and `Encoder`,
based on the `esp32.PCNT` class.
Original implementation by: Jonathan Hogg <me@jonathanhogg.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Add a new `esp32.PCNT` class that provides complete, low-level support to
the ESP32 PCNT pulse counting hardware units.
This can be used as a building block to implement the higher-level
`machine.Counter` and `machine.Encoder` classes.
This is enabled by default on all OG, S2, S3, C6 boards, but not on C3 (as
the PCNT peripheral is not supported).
Original implementation by: Jonathan Hogg <me@jonathanhogg.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Supporting readfrom_mem*(). writeto_mem() and a set of IRQs. Enabled by
default for SAMD51 devices and SAMD21 devices with external flash.
Tested with ItsyBitsy M4 and ItsyBitsy M0 with both on-board SoftI2C and a
RP2 Pico as controller.
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: robert-hh <robert@hammelrath.com>
The functionality is similar to the RP2 implementation. The supported
address size is 7 bit. In order to achieve a sufficient response, the
target I2C IRQ handler has to run from RAM, causing much more code moved to
RAM than required.
Tested with Teensy 4.1, MIMXRT1021EVK, MIMXRT1011EVK and MIMXRT1170, using
both a On-Board SoftI2C as controller and a RP2 Pico as external
controller.
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: robert-hh <robert@hammelrath.com>
Instead of requiring the callback to consume/provide the data. This allows
the data to be consumed/provided later on, which will stretch the I2C clock
until that occurs.
Signed-off-by: Damien George <damien@micropython.org>
And add MP_STATIC_ASSERT to statically check that the IRQ names are correct
on the MCU that it's compiled for.
Signed-off-by: Damien George <damien@micropython.org>
The RP2350 PIO2 State Machines (8, 9, 10, 11) did not work. The data
structure used to pass the PIO arguments was missing an entry for PIO2,
thus causing the PIO2 instances to write wrong data to wrong locations.
Fixes issue #17509.
Signed-off-by: Matt Westveld <github@intergalacticmicro.com>
Follow up to 6bfb83e30a, if the variable
`PICO_FLASH_SIZE_BYTES` is not a numeric constant, eg "(2 * 1024 * 1024)",
then it won't pass the GREATER check. So change the if logic to just test
if it's defined.
Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
When building the embedded port on MinGW-w64, I receive the following
error:
fatal error: alloca.h: No such file or directory
MinGW-w64 (used on MSYS2) doesn't include `alloca.h`, but `alloca()` is
provided via `malloc.h` instead. And this fix is also needed for other
Windows build systems.
Signed-off-by: SiZiOUS <sizious@gmail.com>
Following discussions in PR #16666, this commit updates the float
formatting code to improve the `repr` reversibility, i.e. the percentage of
valid floating point numbers that do parse back to the same number when
formatted by `repr` (in CPython it's 100%).
This new code offers a choice of 3 float conversion methods, depending on
the desired tradeoff between code size and conversion precision:
- BASIC method is the smallest code footprint
- APPROX method uses an iterative method to approximate the exact
representation, which is a bit slower but but does not have a big impact
on code size. It provides `repr` reversibility on >99.8% of the cases in
double precision, and on >98.5% in single precision (except with REPR_C,
where reversibility is 100% as the last two bits are not taken into
account).
- EXACT method uses higher-precision floats during conversion, which
provides perfect results but has a higher impact on code size. It is
faster than APPROX method, and faster than the CPython equivalent
implementation. It is however not available on all compilers when using
FLOAT_IMPL_DOUBLE.
Here is the table comparing the impact of the three conversion methods on
code footprint on PYBV10 (using single-precision floats) and reversibility
rate for both single-precision and double-precision floats. The table
includes current situation as a baseline for the comparison:
PYBV10 REPR_C FLOAT DOUBLE
current = 364688 12.9% 27.6% 37.9%
basic = 364812 85.6% 60.5% 85.7%
approx = 365080 100.0% 98.5% 99.8%
exact = 366408 100.0% 100.0% 100.0%
Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
This reduces memory use by reusing objects, and improves identity/equality
relationships of JavaScript objects on the Python side.
In 77bd8fe5b8 PyProxy's were reused when the
same Python object was proxied across to JavaScript. This commit does the
same thing but for JsProxy's going from JS to Python. If an existing
JsProxy reference exists for the JS object about to be proxied across, then
it's reused.
This helps reduce the number of alive objects (memory use), and, more
importantly, improves equality relationships of JavaScript objects on the
Python side. Eg we now get, on the Python side:
import js
print(js.Object == js.Object)
that prints True. Previously it was False.
Note that this change does not make identity work with `is`, for example
`js.Object is js.Object` is actually False. With more work that could be
made True but for now we leave that as-is.
The behaviour with this commit matches Pyodide semantics.
Signed-off-by: Damien George <damien@micropython.org>
This commit adjusts the configuration of the standard zephyr build to use
MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES. That's a lot cleaner than
explicitly enabling/disabling options, and allows boards to more easily
fine-tune the settings, eg select a different feature level.
Features that are now enabled are:
- async/await keyword support
- `filter`, `property` and `reversed` builtins
- `range` attributes
- `str.count()` method
- `array` module with `array.array` object
- `collections` module with `collections.namedtuple` object
- `struct` module with everything
- `id = const()` and constant folding in the compiler
Bulding qemu_cortex_m3, the code size was originally:
Memory region Used Size Region Size %age Used
FLASH: 193864 B 256 KB 73.95%
RAM: 61992 B 64 KB 94.59%
and with this commit it is now:
Memory region Used Size Region Size %age Used
FLASH: 200698 B 256 KB 76.56%
RAM: 61992 B 64 KB 94.59%
That's a mild increase of +6834 bytes flash usage for a good selection of
new features.
Signed-off-by: Damien George <damien@micropython.org>
This commit adjusts the configuration of the minimal zephyr build to use
MICROPY_CONFIG_ROM_LEVEL_MINIMUM. That's a lot cleaner than explicitly
enabling/disabling options.
Prior to this change the minimal build for qemu_cortex_m3 had size:
Memory region Used Size Region Size %age Used
FLASH: 114436 B 256 KB 43.65%
RAM: 26320 B 64 KB 40.16%
and had the following test results (running using the CI settings, ie
`-d basics float --exclude inf_nan_arith`):
352 tests performed (7092 individual testcases)
352 tests passed
254 tests skipped: ...
With the changes here the qemu_cortex_m3 size is now:
Memory region Used Size Region Size %age Used
FLASH: 99428 B 256 KB 37.93%
RAM: 26312 B 64 KB 40.15%
That's a good decrease of about 15k firmware size. And the test suite
still passes with:
342 tests performed (6776 individual testcases)
341 tests passed
265 tests skipped: ...
Signed-off-by: Damien George <damien@micropython.org>
ESP32-C2 ROM prints at 74880bps (same as ESP8266), so need a newline
before first MicroPython output to avoid it being appended on end of
a line of noise.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This is necessary for ESP32-C2 Wi-Fi & BT to work reliably (and for TLS to
work at all). On IDF 5.4.2 the free static RAM goes from 60KB to 100KB, and
there will also be a reduction in lwIP & Wi-Fi memory use at runtime.
The performance trade-off seems low for most use cases, although it will
probably be significant for certain combinations of load (i.e. heavy
TCP/IP, heavy BT throughput, and some peripheral driver functions).
Added as a set of config flags because this is potentially useful on other
SoCs where the goal is to maximise RAM available for MicroPython.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Includes:
esp32/esp32c2: Adapt to target chip ESP32C2.
esp32/esp32c2: Fix heap size is too small to enable Bluetooth.
Signed-off-by: TianShuangKe <qinyun575@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
XOSC_MHZ and XOSC_KHZ may not be defined if we use a custom XIN clock
by defining PLL_SYS_REFDIV etc. calculated by vcocalc.py.
Signed-off-by: Christian Lang <lang.chr86@gmail.com>
All these arguments are of type `mp_{u,}int_t`, but the actual value is
always a small integer. Cast it so that it can format with the `%d/%u`
formatter.
Before, the compiler plugin produced an error in the PYBD_SF6 build, which
is a nanboxing build with 64-bit ints.
Signed-off-by: Jeff Epler <jepler@gmail.com>
During the coverage test, all the values encountered are within the range
of `%d`.
These locations were found using an experimental gcc plugin for `mp_printf`
error checking.
Signed-off-by: Jeff Epler <jepler@gmail.com>
This fixes the following diagnostic produced by the plugin:
error: argument 3: Format ‘%x’ requires a ‘int’ or
‘unsigned int’ (32 bits), not ‘long unsigned int’ [size 64]
[-Werror=format=]
Signed-off-by: Jeff Epler <jepler@gmail.com>
Fixes a bug in the binding of self/this to JavaScript methods.
The new semantics match Pyodide's behaviour, at least for the included
tests.
Signed-off-by: Damien George <damien@micropython.org>
It seems GCC 14 got stricter with warn/errs like -Wsign-compare and types a
"bare number" as a long int that can't be compared to a (unsigned) size_t.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Without this there's a build error on macOS (at least). This was likely
due to a combination of 9b7d85227e and
df05caea6c.
Signed-off-by: Damien George <damien@micropython.org>
There is currently no build using REPR_C in the unix CI tests. As
discussed in PR #16953, this is something that combines well with the
longlong build.
Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
This is a patch release of the IDF. Comparing with 5.4.1, firmware size is
up by about 1.5k on ESP32 and 9k on ESP32-S3. But IRAM usage (of the IDF)
is down by about 500 byte on ESP32 and DRAM usage is down by about 20k on
ESP32 and 10k on ESP32-S3.
Testing on ESP32, ESP32-S2, ESP32-S3 and ESP32-C3 shows no regressions,
except in BLE MTU ordering (the MTU exchange event occuring before the
connect event).
Signed-off-by: Damien George <damien@micropython.org>