Skip to content

Commit 7b4b4cc

Browse files
authored
Merge branch 'micropython:master' into esp32_bitstream
2 parents 3d26557 + 1b0cdc0 commit 7b4b4cc

File tree

170 files changed

+2416
-1101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+2416
-1101
lines changed

.github/workflows/ports_qemu.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ concurrency:
2020

2121
jobs:
2222
build_and_test_arm:
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
ci_func: # names are functions in ci.sh
27+
- bigendian
28+
- sabrelite
29+
- thumb
2330
runs-on: ubuntu-latest
2431
steps:
2532
- uses: actions/checkout@v4
2633
- name: Install packages
2734
run: source tools/ci.sh && ci_qemu_setup_arm
28-
- name: Build and run test suite
29-
run: source tools/ci.sh && ci_qemu_build_arm
35+
- name: Build and run test suite ci_qemu_build_arm_${{ matrix.ci_func }}
36+
run: source tools/ci.sh && ci_qemu_build_arm_${{ matrix.ci_func }}
3037
- name: Print failures
3138
if: failure()
3239
run: tests/run-tests.py --print-failures

.github/workflows/ports_unix.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,43 @@ jobs:
262262
- name: Print failures
263263
if: failure()
264264
run: tests/run-tests.py --print-failures
265+
266+
sanitize_address:
267+
runs-on: ubuntu-latest
268+
steps:
269+
- uses: actions/checkout@v4
270+
- name: Install packages
271+
run: source tools/ci.sh && ci_unix_coverage_setup
272+
- name: Build
273+
run: source tools/ci.sh && ci_unix_sanitize_address_build
274+
- name: Run main test suite
275+
run: source tools/ci.sh && ci_unix_sanitize_address_run_tests
276+
- name: Test merging .mpy files
277+
run: source tools/ci.sh && ci_unix_coverage_run_mpy_merge_tests
278+
- name: Build native mpy modules
279+
run: source tools/ci.sh && ci_native_mpy_modules_build
280+
- name: Test importing .mpy generated by mpy_ld.py
281+
run: source tools/ci.sh && ci_unix_coverage_run_native_mpy_tests
282+
- name: Print failures
283+
if: failure()
284+
run: tests/run-tests.py --print-failures
285+
286+
sanitize_undefined:
287+
runs-on: ubuntu-latest
288+
steps:
289+
- uses: actions/checkout@v4
290+
- name: Install packages
291+
run: source tools/ci.sh && ci_unix_coverage_setup
292+
- name: Build
293+
run: source tools/ci.sh && ci_unix_sanitize_undefined_build
294+
- name: Run main test suite
295+
run: source tools/ci.sh && ci_unix_sanitize_undefined_run_tests
296+
- name: Test merging .mpy files
297+
run: source tools/ci.sh && ci_unix_coverage_run_mpy_merge_tests
298+
- name: Build native mpy modules
299+
run: source tools/ci.sh && ci_native_mpy_modules_build
300+
- name: Test importing .mpy generated by mpy_ld.py
301+
run: source tools/ci.sh && ci_unix_coverage_run_native_mpy_tests
302+
- name: Print failures
303+
if: failure()
304+
run: tests/run-tests.py --print-failures

.github/workflows/ports_windows.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,36 @@ jobs:
2828
visualstudio: ['2017', '2019', '2022']
2929
include:
3030
- visualstudio: '2017'
31-
runner: windows-latest
3231
vs_version: '[15, 16)'
3332
- visualstudio: '2019'
34-
runner: windows-2019
3533
vs_version: '[16, 17)'
3634
- visualstudio: '2022'
37-
runner: windows-2022
3835
vs_version: '[17, 18)'
3936
# trim down the number of jobs in the matrix
4037
exclude:
4138
- variant: standard
4239
configuration: Debug
4340
- visualstudio: '2019'
4441
configuration: Debug
42+
runs-on: windows-latest
4543
env:
4644
CI_BUILD_CONFIGURATION: ${{ matrix.configuration }}
47-
runs-on: ${{ matrix.runner }}
4845
steps:
4946
- name: Install Visual Studio 2017
5047
if: matrix.visualstudio == '2017'
5148
run: |
5249
choco install visualstudio2017buildtools
5350
choco install visualstudio2017-workload-vctools
5451
choco install windows-sdk-8.1
52+
- name: Install Visual Studio 2019
53+
if: matrix.visualstudio == '2019'
54+
run: |
55+
choco install visualstudio2019buildtools
56+
choco install visualstudio2019-workload-vctools
57+
choco install windows-sdk-8.1
5558
- uses: microsoft/setup-msbuild@v2
5659
with:
5760
vs-version: ${{ matrix.vs_version }}
58-
- uses: actions/setup-python@v5
59-
if: matrix.runner == 'windows-2019'
60-
with:
61-
python-version: '3.9'
6261
- uses: actions/checkout@v4
6362
- name: Build mpy-cross.exe
6463
run: msbuild mpy-cross\mpy-cross.vcxproj -maxcpucount -property:Configuration=${{ matrix.configuration }} -property:Platform=${{ matrix.platform }}
@@ -103,7 +102,7 @@ jobs:
103102
env: i686
104103
- sys: mingw64
105104
env: x86_64
106-
runs-on: windows-2022
105+
runs-on: windows-latest
107106
env:
108107
CHERE_INVOKING: enabled_from_arguments
109108
defaults:

docs/library/esp32.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,31 @@ Functions
1818
Configure whether or not a touch will wake the device from sleep.
1919
*wake* should be a boolean value.
2020

21+
.. note:: This is only available for boards that have touch sensor support.
22+
2123
.. function:: wake_on_ulp(wake)
2224

2325
Configure whether or not the Ultra-Low-Power co-processor can wake the
2426
device from sleep. *wake* should be a boolean value.
2527

28+
.. note:: This is only available for boards that have ULP coprocessor support.
29+
2630
.. function:: wake_on_ext0(pin, level)
2731

2832
Configure how EXT0 wakes the device from sleep. *pin* can be ``None``
2933
or a valid Pin object. *level* should be ``esp32.WAKEUP_ALL_LOW`` or
3034
``esp32.WAKEUP_ANY_HIGH``.
3135

36+
.. note:: This is only available for boards that have ext0 support.
37+
3238
.. function:: wake_on_ext1(pins, level)
3339

3440
Configure how EXT1 wakes the device from sleep. *pins* can be ``None``
3541
or a tuple/list of valid Pin objects. *level* should be ``esp32.WAKEUP_ALL_LOW``
3642
or ``esp32.WAKEUP_ANY_HIGH``.
3743

44+
.. note:: This is only available for boards that have ext1 support.
45+
3846
.. function:: gpio_deep_sleep_hold(enable)
3947

4048
Configure whether non-RTC GPIO pin configuration is retained during

docs/rp2/quickref.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ Use the :mod:`machine.Timer` class::
135135
tim = Timer(period=5000, mode=Timer.ONE_SHOT, callback=lambda t:print(1))
136136
tim.init(period=2000, mode=Timer.PERIODIC, callback=lambda t:print(2))
137137

138+
By default, timer callbacks run as soft IRQs so they can allocate but
139+
are prone to GC jitter and delays. Pass ``hard=True`` to the ``Timer()``
140+
constructor or ``init()`` method to run the callback in hard-IRQ context
141+
instead. This reduces delay and jitter, but see :ref:`isr_rules` for the
142+
restrictions that apply to hard-IRQ handlers.
143+
138144

139145
.. _rp2_Pins_and_GPIO:
140146

drivers/esp-hosted/esp_hosted_bthci_uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int esp_hosted_hci_cmd(int ogf, int ocf, size_t param_len, const uint8_t *param_
7272
// Receive HCI event packet, initially reading 3 bytes (HCI Event, Event code, Plen).
7373
for (mp_uint_t start = mp_hal_ticks_ms(), size = 3, i = 0; i < size;) {
7474
while (!mp_bluetooth_hci_uart_any()) {
75-
MICROPY_EVENT_POLL_HOOK
75+
mp_event_wait_ms(1);
7676
// Timeout.
7777
if ((mp_hal_ticks_ms() - start) > HCI_COMMAND_TIMEOUT) {
7878
error_printf("timeout waiting for HCI packet\n");
@@ -126,7 +126,7 @@ int mp_bluetooth_hci_controller_init(void) {
126126
if (mp_bluetooth_hci_uart_any()) {
127127
mp_bluetooth_hci_uart_readchar();
128128
}
129-
MICROPY_EVENT_POLL_HOOK
129+
mp_event_wait_ms(1);
130130
}
131131

132132
#ifdef MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY

drivers/esp-hosted/esp_hosted_wifi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int esp_hosted_request(CtrlMsgId msg_id, void *ctrl_payload) {
243243

244244
static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
245245
CtrlMsg *ctrl_msg = NULL;
246-
for (mp_uint_t start = mp_hal_ticks_ms(); ; mp_hal_delay_ms(10)) {
246+
for (mp_uint_t start = mp_hal_ticks_ms(); ; mp_event_wait_ms(10)) {
247247
if (!esp_hosted_stack_empty(&esp_state.stack)) {
248248
ctrl_msg = esp_hosted_stack_pop(&esp_state.stack, true);
249249
if (ctrl_msg->msg_id == msg_id) {
@@ -264,8 +264,6 @@ static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
264264
if ((mp_hal_ticks_ms() - start) >= timeout) {
265265
return NULL;
266266
}
267-
268-
MICROPY_EVENT_POLL_HOOK
269267
}
270268

271269
// If message type is a response, check the response struct's return value.

examples/natmod/random/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ ifeq ($(ARCH),xtensa)
1414
MPY_EXTERN_SYM_FILE=$(MPY_DIR)/ports/esp8266/boards/eagle.rom.addr.v6.ld
1515
endif
1616

17+
ifeq ($(ARCH),$(filter $(ARCH),armv6m armv7m))
18+
# Link with libm.a for soft-float helper functions
19+
LINK_RUNTIME = 1
20+
endif
21+
1722
include $(MPY_DIR)/py/dynruntime.mk

extmod/machine_pulse.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,35 @@
3030

3131
#if MICROPY_PY_MACHINE_PULSE
3232

33-
MP_WEAK mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) {
33+
mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) {
34+
mp_uint_t nchanges = 2;
3435
mp_uint_t start = mp_hal_ticks_us();
35-
while (mp_hal_pin_read(pin) != pulse_level) {
36-
if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) {
37-
return (mp_uint_t)-2;
38-
}
39-
}
40-
start = mp_hal_ticks_us();
41-
while (mp_hal_pin_read(pin) == pulse_level) {
42-
if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) {
43-
return (mp_uint_t)-1;
36+
for (;;) {
37+
// Sample ticks and pin as close together as possible, and always in the same
38+
// order each time around the loop. This gives the most accurate measurement.
39+
mp_uint_t t = mp_hal_ticks_us();
40+
int pin_value = mp_hal_pin_read(pin);
41+
42+
if (pin_value == pulse_level) {
43+
// Pin is at desired value. Flip desired value and see if we are done.
44+
pulse_level = 1 - pulse_level;
45+
if (--nchanges == 0) {
46+
return t - start;
47+
}
48+
start = t;
49+
} else {
50+
// Pin hasn't changed yet, check for timeout.
51+
mp_uint_t dt = t - start;
52+
if (dt >= timeout_us) {
53+
return -nchanges;
54+
}
55+
56+
// Allow a port to perform background task processing if needed.
57+
#ifdef MICROPY_PY_MACHINE_TIME_PULSE_US_HOOK
58+
MICROPY_PY_MACHINE_TIME_PULSE_US_HOOK(dt);
59+
#endif
4460
}
4561
}
46-
return mp_hal_ticks_us() - start;
4762
}
4863

4964
static mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *args) {

extmod/modlwip.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,12 @@ static mp_uint_t lwip_tcp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_
825825
// Check for any pending errors
826826
STREAM_ERROR_CHECK(socket);
827827

828+
if (socket->state == STATE_LISTENING) {
829+
// original socket in listening state, not the accepted connection.
830+
*_errno = MP_ENOTCONN;
831+
return -1;
832+
}
833+
828834
if (socket->incoming.tcp.pbuf == NULL) {
829835

830836
// Non-blocking socket or flag

0 commit comments

Comments
 (0)