Commit Graph

14460 Commits

Author SHA1 Message Date
Chris Swan
86c3c1d80d github/workflows: Bump actions/checkout to v3.
The existing actions/checkout@v2 is causing Node v12 deprecation warnings
to be shown in GitHub Actions.  v3 uses Node v16, which will stop the
warnings.
2022-11-11 13:25:27 +11:00
Angus Gratton
b3e38ac632 stm32/spi: Downgrade SPIHandle definitions to static.
Seems unused outside of spi.c, spi_obj[] array is the expected way to
iterate these.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-11-11 13:23:24 +11:00
David Lechner
ea07ab04f8 webassembly/library: Make use of CustomEvent detail property.
This changes the CustomEvent for stdout to use the existing `detail`
property of CustomEvent instead of adding a `data` property.

Signed-off-by: David Lechner <david@pybricks.com>
2022-11-11 13:21:28 +11:00
Damien George
0698dd72ea py/emitnative: Ensure load_subscr does not clobber existing REG_ARG_2.
Follow up from a similar fix in 426785a19e

Fixes issue #6314.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-11 12:25:32 +11:00
Damien George
451ded8d7b tests/basics: Add exp file for builtin_str_hex test.
Because bytes.hex() only supports the sep argument since Python 3.8.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-10 11:44:49 +11:00
David Lechner
0eead94181 lib/libm: Use __asm__ instead of asm.
`asm` is not part of the C standard and causes a complier error when
`-std=c99` is used. `__asm__` is the recommended alternative.

https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/alternate-keywords.html

Signed-off-by: David Lechner <david@pybricks.com>
2022-11-10 11:36:41 +11:00
iabdalkader
71881116e6 extmod/extmod.mk: Set default mbedtls config file in extmod Makefile. 2022-11-09 18:43:13 +01:00
robert-hh
eefd946e60 esp32/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:58:39 +11:00
robert-hh
a495eb432f esp8266/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:58:10 +11:00
robert-hh
2426ddb575 stm32/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:57:46 +11:00
robert-hh
acadc0a7dc rp2/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:57:17 +11:00
robert-hh
8afa6df23d mimxrt/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:56:43 +11:00
Damien George
3bb371c5f2 unix/variants: Change mip package to mip-cmdline.
mip-cmdline adds command-line support to mip, useful for the unix port, via
micropython -m mip ...

Signed-off-by: Damien George <damien@micropython.org>
2022-11-09 14:58:54 +11:00
Damien George
1531a7c8ca lib/micropython-lib: Update submodule to latest.
This brings in mip-cmdline, espflash, use of machine.dht_readinto, and
other improvements to existing libraries.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-09 14:58:49 +11:00
iabdalkader
345f1d2395 rp2/cyw43_configport: Make sure only core0 executes a __WFI().
This commit executes __WFI() on core 0 only to avoid core1 locking up since
it doesn't enable any interrupts by default (except for `SIO_IRQ_PROC1`).
This fixes a lockup when calling `cyw43_do_ioctl` from core1.

Fixes issue #9597.
2022-11-09 12:00:10 +11:00
robert-hh
d68e3b03b1 esp32/usb: Add a timeout to usb_tx_strn().
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up.  This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
2022-11-09 11:16:55 +11:00
robert-hh
5d473d3093 mimxrt/mphalport: Add a timeout to mp_hal_stdout_tx_strn().
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up.  This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
2022-11-09 11:16:25 +11:00
robert-hh
ca63ead2d8 samd/mphalport: Add a timeout to mp_hal_stdout_tx_strn().
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up.  This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
2022-11-09 11:15:24 +11:00
robert-hh
8447fef9f9 rp2/mphalport: Add a timeout to mp_hal_stdout_tx_strn().
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up.  This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.

Fixes issue #9634.
2022-11-09 11:12:53 +11:00
Patrick
d0687e90ab esp32: Add 32MiB partition table templates.
Signed-off-by: Patrick <patrick@joytech.com.au>
2022-11-09 10:57:44 +11:00
Jared Hancock
a2fd382c34 extmod/modlwip: Use actual errno in exception for error in listen.
The actual underlying error number raised from the lwIP subsystem when
attempting to listen on a socket is swallowed and replaced with an
out-of-memory error which is confusing.

This commit passes the underlying error message from the lwIP subsystem to
the appropriate OSError exception.
2022-11-09 10:48:53 +11:00
iabdalkader
ecd4d54391 extmod/extmod.cmake: Allow overriding the default MBEDTLS_CONFIG_FILE. 2022-11-08 23:50:17 +11:00
iabdalkader
ebb1a4ecb0 stm32/boards/ARDUINO_PORTENTA_H7: Add custom mbedtls config. 2022-11-08 23:46:06 +11:00
iabdalkader
d2c2846820 stm32/Makefile: Allow overriding the default MBEDTLS_CONFIG_FILE. 2022-11-08 23:43:43 +11:00
iabdalkader
efe7dac0aa stm32/mbedtls: Enable mbedtls certificate time validation.
This is a reimplementation of b560b9fe71 for
the stm32 port.
2022-11-08 23:41:03 +11:00
robert-hh
9d0aefe719 samd/boards/SEEED_WIO_TERMINAL: Enable using the 32kHz crystal.
That was missing from the configuration.
2022-11-08 23:26:24 +11:00
robert-hh
fadfc30547 samd/README: Update README to reflect recent changes to the port.
Most of the content of README.md became obsolete and was replaced by the
documentation of MicroPython.  Instead, README.md now shows build
instructions like the other ports.
2022-11-08 23:25:39 +11:00
robert-hh
b3ce059767 docs/samd/pinout: Fix the pin numbering for the default assignments.
It still used the 'old' pin numbers.
2022-11-08 23:24:35 +11:00
robert-hh
144e5ec645 samd/mcu/samd51: Use an additional manifest.py for SAMD51 boards.
Including the uasyncio scripts and the drivers for DHT, DS18x20 and
onewire.  The uasyncio scripts need about 8k of flash and are not included
for the SAMD21 boards by default.
2022-11-08 23:22:26 +11:00
Matt Trentini
e65b12a1b9 docs/library/machine: Add machine.memX to docs with brief example. 2022-11-08 23:12:34 +11:00
Jim Mussared
2c8dab7ab4 py/objarray: Detect bytearray(str) without an encoding.
This prevents a very subtle bug caused by writing e.g. `bytearray('\xfd')`
which gives you `(0xc3, 0xbd)`.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-11-08 23:09:22 +11:00
Simon Arlott
f8b0ae32d3 py/builtinimport: Fix crash handling "weak link" module names.
There are two calls to mp_builtin___import__():
1. ports/unix/main.c:main_() which provides a str in args[0]
2. py/runtime.c:mp_import_name() which provides a qstr in args[0]

The default implementation of mp_builtin___import__() is
mp_builtin___import___default() which has a different implementation based
on MICROPY_ENABLE_EXTERNAL_IMPORT.

If MICROPY_ENABLE_EXTERNAL_IMPORT is disabled then the handling of weak
links assumes that args[0] is a `const char *`, when it is either a str or
qstr object.

Use the existing qstr of the module name instead, and also use a vstr
instead of strcpy() to ensure no overflow occurs.
2022-11-08 23:03:21 +11:00
Simon Arlott
43dd3ea74d shared/runtime/gchelper_native: Fix pointer cast on x86_64.
gc_helper_collect_regs_and_stack() is casting a pointer to uint32_t; the
variables involved are always pointers so it should be using uintptr_t.
2022-11-08 19:15:37 +11:00
Damien George
5987130afd webassembly/Makefile: Change compiler optimisation from O3 to Os.
Emscripten strongly advises the use of optimisation when compiling with
ASYNCIFY enabled.  Testing the difference betwen O3 and Os for various
configurations gives:

    flags                      firmware.wasm   micropython.js  perf
    -O3 -s ASYNCIFY            1342003          212845         0 (baseline)
    -O3 -s ASYNCIFY -s WASM=0        -         7064750         -30%
    -O3                         367131          196569         +140%
    -O3 -s WASM=0                    -         2818260         +30%
    -Os -s ASYNCIFY            1135450          213064         +40%
    -Os -s ASYNCIFY -s WASM=0        -         6239768         -30%
    -Os                         295028          196569         +180%
    -Os -s WASM=0                    -         2271358         +30%

The first row is prior to this commit.  The second and third columns show
firmware size (add them to get the total size).  The fourth column shows
the approximate change in performance compared to the baseline.  The
performance was measured using run-perfbench.py and the error was large, up
to 20%, although general trends in the change in performance could still be
seen.

In summary, using using Os instead of O3 makes it a little bit faster in
all cases, and smaller output (wasm/js) in all cases.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-07 17:18:42 +11:00
Damien George
1ed740b152 webassembly/README: Update README to describe new stdout behaviour.
Signed-off-by: Damien George <damien@micropython.org>
2022-11-07 17:18:31 +11:00
Nicholas H.Tollervey
db978d7155 webassembly: Dispatch micropython-print via document not mp_js_stdout. 2022-11-07 15:09:56 +11:00
Damien George
2d406f2226 webassembly: Support piping in a program on stdin.
The performance benchmark suite can now be run on the webassembly port.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-03 23:35:22 +11:00
Damien George
7a505d57dc webassembly: Change "stack" argument to "heapsize".
Because that's what mp_js_init() takes as its argument.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-03 18:47:48 +11:00
Damien George
d65edaa232 webassembly: Use Date's now() instead of getTime().
Using now() is a bit faster because it doesn't need to create a new Date.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-03 18:47:48 +11:00
Damien George
49ce93eeec github/workflows: Print test failures for webassembly workflow.
Signed-off-by: Damien George <damien@micropython.org>
2022-11-03 18:47:48 +11:00
Damien George
329f8252b9 tests/run-perfbench: Support --heapsize argument and pass to executable.
Signed-off-by: Damien George <damien@micropython.org>
2022-11-03 17:33:25 +11:00
Damien George
b52fe52d31 tools/makemanifest.py: Fix printing of mpy_cross.CrossCompileError.
This change was missed by 5852fd7708

Signed-off-by: Damien George <damien@micropython.org>
2022-11-02 14:06:18 +11:00
Damien George
46bb52adf6 webassembly: Add support for VFS and enable VFS_POSIX.
This gets filesystem support working.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-01 13:53:06 +11:00
Damien George
54478eb9e7 webassembly/mpconfigport: Use MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES.
This simplifies the config file.  This is not a no-op, it does enable a few
new features to bring the port in line with this config level.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-01 13:10:45 +11:00
Damien George
da36b84d45 extmod/vfs_posix: Include errno.h and unistd.h headers.
errno.h is needed for the errno variable, and unistd.h is needed for chdir.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-01 13:10:45 +11:00
Damien George
3ed017677b tools/mpremote: Make RemoteFile objects iterable.
So that filesystems mounted with "mpremote mount" can have their files
iterated over, making them consistent with other files.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-31 12:40:17 +11:00
Jim Mussared
3427e12e8f tools/mpremote: Handle FileNotFound exceptions in listdir.
The except handler for OSError didn't include the line that actually calls
os.listdir, so an invalid path wasn't handled correctly.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-31 12:38:25 +11:00
robert-hh
7775523b2d esp32/machine_pwm: Verify PWM is active when config methods are called.
Checks are added for pwm.freq(), pwm_duty(), pwm_duty_u10() and
pwm.duty_u16().  This avoids a core dump on ESP32C3, and misleading error
messages on Xtensa ESP32 devices.
2022-10-31 11:54:46 +11:00
Ihor Nehrutsa
5b2929a0e6 esp32/machine_pin: Fix size of machine_pin_irq_handler array.
Set the size of machine_pin_irq_handler array to GPIO_NUM_MAX:
- Min GPIO_NUM_MAX is 22 for IDF_TARGET_ESP32C3.
- Max GPIO_NUM_MAX is 49 for IDF_TARGET_ESP32S3.

The MP_REGISTER_ROOT_POINTER entry must be hard-coded, because the location
that it's evaluated by the compiler does not include the relevant IDF
header to get a definition of GPIO_NUM_MAX.
2022-10-31 11:42:20 +11:00
Mark Grosen
12f9948151 esp32/machine_i2c: Fix clocks and timeouts for ESP32-C3, ESP32-S3.
Each SoC family has its own clocks and timings/timeouts. For I2C, the
default source clock is either APB (ESP32, ESP32-S2) or XTAL (ESP32-S3,
ESP32-C3) as shown in the datasheets.  Since
machine_i2c.c/machine_hw_i2c_init() uses the default clk_flags (0), the
alternate low-power clock source is never selected in ESP-IDF
i2c.c/i2c_param_config().  There is not an API in i2c.c to get the source
clock frequency, so a compile-time value is used based on SoC family.

Also, the maximum timeout is different across the SoC families, so use the
I2C_LL_MAX_TIMEOUT constant to eliminate the warning from
i2c_set_timeout().

With these changes, the following results were obtained.  The I2C SCL
frequencies were measured with a Saleae logic analyzer.

ESP32 (TTGO T Dislay)
    I2C(0, scl=22, sda=21, freq=101781)  Measured: 100KHz
    I2C(0, scl=22, sda=21, freq=430107)  Measured: 400KHz
    I2C(0, scl=22, sda=21, freq=1212121) Measured: 941KHz

ESP32-S3 (TTGO T-QT)
    I2C(0, scl=34, sda=33, freq=111111)  Measured: 107KHz
    I2C(0, scl=34, sda=33, freq=444444)  Measured: 400KHz
    I2C(0, scl=34, sda=33, freq=1111111) Measured: 842KHz

ESP32-C3 (XIAO ESP32C3)
    I2C(0, scl=7, sda=6, freq=107816)  Measured: 103KHz
    I2C(0, scl=7, sda=6, freq=444444)  Measured: 380KHz
    I2C(0, scl=7, sda=6, freq=1176470) Measured: 800KHz

(ESP32-S2 board was not available for testing.)
2022-10-28 19:06:41 +11:00