8000 Merge from master. · davidgiven/micropython@2965502 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2965502

Browse files
committed
Merge from master.
2 parents ad8c5c4 + e9c898c commit 2965502

File tree

124 files changed

+3663
-561
lines changed

Some content is hidden

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

124 files changed

+3663
-561
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,10 @@ body:
1111
1212
* If you have a question \"How Do I ...?\", please post it on [GitHub Discussions](https://github.com/orgs/micropython/discussions/) or [Discord](https://discord.gg/RB8HZSAExQ) instead of here.
1313
* For missing or incorrect documentation, or feature requests, then please [choose a different issue type](https://github.com/micropython/micropython/issues/new/choose).
14-
- type: checkboxes
15-
id: terms
16-
attributes:
17-
label: Checks
18-
description: |
19-
Before submitting your bug report, please go over these check points:
20-
options:
21-
- label: |
22-
I agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone.
23-
required: true
24-
- label: |
25-
I've searched for [existing issues](https://github.com/micropython/micropython/issues) matching this bug, and didn't find any.
26-
required: true
14+
15+
#### Existing issue?
16+
17+
* Please search for [existing issues](https://github.com/micropython/micropython/issues) matching this bug before reporting.
2718
- type: input
2819
id: port-board-hw
2920
attributes:
@@ -33,7 +24,7 @@ body:
3324
placeholder: |
3425
esp32 port, ESP32-Fantastic board.
3526
validations:
36-
required: true
27+
required: true
3728
- type: textarea
3829
id: version
3930
attributes:
@@ -101,6 +92,17 @@ body:
10192
description: |
10293
Is there anything else that might help to resolve this issue?
10394
value: No, I've provided everything above.
95+
- type: dropdown
96+
id: code-of-conduct
97+
attributes:
98+
label: Code of Conduct
99+
description: |
100+
Do you agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone?
101+
options:
102+
- "Yes, I agree"
103+
multiple: true
104+
validations:
105+
required: true
104106
- type: markdown
105107
attributes:
106108
value: |

.github/ISSUE_TEMPLATE/documentation.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ body:
99
This form is for reporting issues with the documentation or examples provided with MicroPython.
1010
1111
If you have a general question \"How Do I ...?\", please post it on [GitHub Discussions](https://github.com/orgs/micropython/discussions/) or [Discord](https://discord.gg/RB8HZSAExQ) instead of here.
12-
- type: checkboxes
13-
id: terms
14-
attributes:
15-
label: Checks
16-
description: |
17-
Before submitting your bug report, please go over these check points:
18-
options:
19-
- label: |
20-
I agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone.
21-
required: true
22-
- label: |
23-
I've searched for [existing issues](https://github.com/micropython/micropython/issues) and didn't find any that matched.
24-
required: true
12+
13+
#### Existing issue?
14+
15+
* Please search for [existing issues](https://github.com/micropython/micropython/issues) before reporting a new one.
2516
- type: input
2617
id: page
2718
attributes:
@@ -38,6 +29,17 @@ body:
3829
Please describe what was missing from the documentation and/or what was incorrect/incomplete.
3930
validations:
4031
required: true
32+
- type: dropdown
33+
id: code-of-conduct
34+
attributes:
35+
label: Code of Conduct
36+
description: |
37+
Do you agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone?
38+
options:
39+
- "Yes, I agree"
40+
multiple: true
41+
validations:
42+
required: true
4143
- type: markdown
4244
attributes:
4345
value: |

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,10 @@ body:
1515
1616
* If you have a question \"How Do I ...?\", please post it on GitHub Discussions or Discord instead of here.
1717
* Could this feature be implemented as a pure Python library? If so, please open the request on the [micropython-lib repository](https://github.com/micropython/micropython-lib/issues) instead.
18-
- type: checkboxes
19-
id: terms
20-
attributes:
21-
label: Checks
22-
description: |
23-
Before submitting your feature request, please go over these check points:
24-
options:
25-
- label: |
26-
I agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone.
27-
required: true
28-
- label: |
29-
I've searched for [existing issues](https://github.com/micropython/micropython/issues) regarding this feature, and didn't find any.
30-
required: true
18+
19+
#### Existing issue?
20+
21+
* Please search for [existing issues](https://github.com/micropython/micropython/issues) before opening a new one.
3122
- type: textarea
3223
id: feature
3324
attributes:
@@ -51,14 +42,32 @@ body:
5142
MicroPython aims to strike a balance between functionality and code size. Can this feature be optionally enabled?
5243
5344
If you believe the usefulness of this feature would outweigh the additional code size, please explain. (It's OK to say you're unsure here, we're happy to discuss this with you.)
54-
- type: checkboxes
45+
- type: dropdown
5546
id: implementation
5647
attributes:
5748
label: Implementation
49+
description: |
50+
What is your suggestion for implementing this feature?
51+
52+
(See also: [How to sponsor](https://github.com/sponsors/micropython#sponsors), [How to submit a Pull Request](https://github.com/micropython/micropython/wiki/ContributorGuidelines).)
5853
options:
59-
- label: I intend to implement this feature and would submit a Pull Request if desirable.
60-
- label: I hope the MicroPython maintainers or community will implement this feature.
61-
- label: I would like to [Sponsor](https://github.com/sponsors/micropython#sponsors) development of this feature.
54+
- I hope the MicroPython maintainers or community will implement this feature
55+
- I intend to implement this feature and would submit a Pull Request if desirable
56+
- I would like to sponsor development of this feature
57+
multiple: true
58+
validations:
59+
required: true
60+
- type: dropdown
61+
id: code-of-conduct
62+
attributes:
63+
label: Code of Conduct
64+
description: |
65+
Do you agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone?
66+
options:
67+
- "Yes, I agree"
68+
multiple: true
69+
validations:
70+
required: true
6271
- type: markdown
6372
attributes:
6473
value: |

.github/ISSUE_TEMPLATE/security.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,11 @@ body:
99
1010
1. For issues that are readily exploitable or have high impact, please email contact@micropython.org instead.
1111
1. If this is a question about security, please ask it in [Discussions](https://github.com/orgs/micropython/discussions/) or [Discord](https://discord.gg/RB8HZSAExQ) instead.
12-
- type: checkboxes
13-
id: terms
14-
attributes:
15-
label: Checks
16-
description: |
17-
Before submitting your bug report, please go over these check points:
18-
options:
19-
- label: |
20-
I agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone.
21-
required: true
22-
- label: I wish to report a specific security issue that is **not readily exploitable and does not have high impact** for MicroPython developers or users.
23-
required: true
24-
- label: |
25-
I've searched for [existing issues](https://github.com/micropython/micropython/issues) and didn't find any that matched.
26-
required: true
12+
13+
#### Existing issue?
14+
15+
* Please search for [existing issues](https://github.com/micropython/micropython/issues) before reporting a new one.
16+
2717
- type: input
2818
id: port-board-hw
2919
attributes:
@@ -57,3 +47,14 @@ body:
5747
* How does the attacker exploit this issue?
5848
validations:
5949
required: true
50+
- type: dropdown
51+
id: code-of-conduct
52+
attributes:
53+
label: Code of Conduct
54+
description: |
55+
Do you agree to follow the MicroPython [Code of Conduct](https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md) to ensure a safe and respectful space for everyone?
56+
options:
57+
- "Yes, I agree"
58+
multiple: true
59+
validations:
60+
required: true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: qemu-riscv port
2+
3+
on:
4+
push:
5+
pull_request:
6+
paths:
7+
- '.github/workflows/*.yml'
8+
- 'tools/**'
9+
- 'py/**'
10+
- 'extmod/**'
11+
- 'shared/**'
12+
- 'lib/**'
13+
- 'drivers/**'
14+
- 'ports/qemu-arm/main.c'
15+
- 'ports/qemu-riscv/**'
16+
- 'tests/**'
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build_and_test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Install packages
28+
run: source tools/ci.sh && ci_qemu_riscv_setup
29+
- name: Build and run test suite
30+
run: source tools/ci.sh && ci_qemu_riscv_build
31+
- name: Print failures
32+
if: failure()
33+
run: grep --before-context=100 --text "FAIL" ports/qemu-riscv/build/console.out

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ In addition, the following ports are provided in this repository:
114114
- [nrf](ports/nrf) -- Nordic Semiconductor nRF51 and nRF52.
115115
- [pic16bit](ports/pic16bit) -- Microchip PIC 16-bit.
116116
- [powerpc](ports/powerpc) -- IBM PowerPC (including Microwatt)
117-
- [qemu-arm](ports/qemu-arm) -- QEMU-based emulated target, for testing)
117+
- [qemu-arm](ports/qemu-arm) -- QEMU-based Arm emulated target (for testing)
118+
- [qemu-riscv](ports/qemu-riscv) -- QEMU-based RISC-V emulated target (for testing)
118119
- [renesas-ra](ports/renesas-ra) -- Renesas RA family.
119120
- [rp2](ports/rp2) -- Raspberry Pi RP2040 (including Pico and Pico W).
120121
- [samd](ports/samd) -- Microchip (formerly Atmel) SAMD21 and SAMD51.

extmod/modlwip.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ typedef struct _lwip_socket_obj_t {
326326
int8_t state;
327327
} lwip_socket_obj_t;
328328

329+
static inline bool socket_is_timedout(lwip_socket_obj_t *socket, mp_uint_t ticks_start) {
330+
return socket->timeout != -1 && (mp_uint_t)(mp_hal_ticks_ms() - ticks_start) >= socket->timeout;
331+
}
332+
329333
static inline void poll_sockets(void) {
330334
mp_event_wait_ms(1);
331335
}
@@ -1036,26 +1040,22 @@ static mp_obj_t lwip_socket_accept(mp_obj_t self_in) {
10361040
// accept incoming connection
10371041
struct tcp_pcb *volatile *incoming_connection = &lwip_socket_incoming_array(socket)[socket->incoming.connection.iget];
10381042
if (*incoming_connection == NULL) {
1039-
if (socket->timeout == 0) {
1043+
mp_uint_t ticks_start = mp_hal_ticks_ms();
1044+
for (;;) {
10401045
MICROPY_PY_LWIP_EXIT
1041-
m_del_obj(lwip_socket_obj_t, socket2);
1042-
mp_raise_OSError(MP_EAGAIN);
1043-
} else if (socket->timeout != -1) {
1044-
mp_uint_t retries = socket->timeout / 100;
1045-
while (*incoming_connection == NULL) {
1046+
poll_sockets();
1047+
MICROPY_PY_LWIP_REENTER
1048+
if (*incoming_connection != NULL) {
1049+
break;
1050+
}
1051+
if (socket_is_timedout(socket, ticks_start)) {
10461052
MICROPY_PY_LWIP_EXIT
1047-
if (retries-- == 0) {
1048-
m_del_obj(lwip_socket_obj_t, socket2);
1053+
m_del_obj(lwip_socket_obj_t, socket2);
1054+
if (socket->timeout == 0) {
1055+
mp_raise_OSError(MP_EAGAIN);
1056+
} else {
10491057
mp_raise_OSError(MP_ETIMEDOUT);
10501058
}
1051-
mp_hal_delay_ms(100);
1052-
MICROPY_PY_LWIP_REENTER
1053-
}
1054-
} else {
1055-
while (*incoming_connection == NULL) {
1056-
MICROPY_PY_LWIP_EXIT
1057-
poll_sockets();
1058-
MICROPY_PY_LWIP_REENTER
10591059
}
10601060
}
10611061
}
@@ -1130,21 +1130,21 @@ static mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
11301130
MICROPY_PY_LWIP_EXIT
11311131

11321132
// And now we wait...
1133-
if (socket->timeout != -1) {
1134-
for (mp_uint_t retries = socket->timeout / 100; retries--;) {
1135-
mp_hal_delay_ms(100);
1136-
if (socket->state != STATE_CONNECTING) {
1137-
break;
1138-
}
1139-
}
1140-
if (socket->state == STATE_CONNECTING) {
1141-
mp_raise_OSError(MP_EINPROGRESS);
1133+
mp_uint_t ticks_start = mp_hal_ticks_ms();
1134+
for (;;) {
1135+
poll_sockets();
1136+
if (socket->state != STATE_CONNECTING) {
1137+
break;
11421138
}
1143-
} else {
1144-
while (socket->state == STATE_CONNECTING) {
1145-
poll_sockets();
1139+
if (socket_is_timedout(socket, ticks_start)) {
1140+
if (socket->timeout == 0) {
1141+
mp_raise_OSError(MP_EINPROGRESS);
1142+
} else {
1143+
mp_raise_OSError(MP_ETIMEDOUT);
1144+
}
11461145
}
11471146
}
1147+
11481148
if (socket->state == STATE_CONNECTED) {
11491149
err = ERR_OK;
11501150
} else {

extmod/modnetwork.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,15 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_hostname_obj, 0, 1, mod_n
144144
#if LWIP_VERSION_MAJOR >= 2
145145
MP_DEFINE_CONST_FUN_OBJ_KW(mod_network_ipconfig_obj, 0, mod_network_ipconfig);
146146
#endif
147+
#if MICROPY_PY_NETWORK_NINAW10
148+
MP_DEFINE_CONST_FUN_OBJ_KW(mod_network_ipconfig_obj, 0, network_ninaw10_ipconfig);
149+
#endif
147150

148151
static const mp_rom_map_elem_t mp_module_network_globals_table[] = {
149152
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_network) },
150153
{ MP_ROM_QSTR(MP_QSTR_country), MP_ROM_PTR(&mod_network_country_obj) },
151154
{ MP_ROM_QSTR(MP_QSTR_hostname), MP_ROM_PTR(&mod_network_hostname_obj) },
152-
#if LWIP_VERSION_MAJOR >= 2
155+
#if LWIP_VERSION_MAJOR >= 2 || MICROPY_PY_NETWORK_NINAW10
153156
{ MP_ROM_QSTR(MP_QSTR_ipconfig), MP_ROM_PTR(&mod_network_ipconfig_obj) },
154157
#endif
155158

extmod/modnetwork.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ extern int mp_mod_network_prefer_dns_use_ip_version;
8383
#endif
8484
#elif defined(MICROPY_PORT_NETWORK_INTERFACES)
8585

86+
#if MICROPY_PY_NETWORK_NINAW10
87+
mp_obj_t network_ninaw10_ipconfig(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
88+
#endif
89+
8690
struct _mod_network_socket_obj_t;
8791

8892
typedef struct _mod_network_nic_protocol_t {

extmod/modplatform.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
#elif defined(__NEWLIB__)
8484
#define MICROPY_PLATFORM_LIBC_LIB "newlib"
8585
#define MICROPY_PLATFORM_LIBC_VER _NEWLIB_VERSION
86+
#elif defined(_PICOLIBC__)
87+
#define MICROPY_PLATFORM_LIBC_LIB "picolibc"
88+
#define MICROPY_PLATFORM_LIBC_VER _PICOLIBC_VERSION
8689
#else
8790
#define MICROPY_PLATFORM_LIBC_LIB ""
8891
#define MICROPY_PLATFORM_LIBC_VER ""

extmod/network_lwip.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,23 @@ mp_obj_t mod_network_nic_ipconfig(struct netif *netif, size_t n_args, const mp_o
297297
char plain_ip[IPADDR_STRLEN_MAX];
298298
char *split = strchr(input_str, '/');
299299
const char *addr_str = input_str;
300+
int to_copy = MIN(sizeof(plain_ip) - 1, addr_len);
301+
memcpy(plain_ip, addr_str, to_copy);
300302
if (split) {
301-
int to_copy = sizeof(plain_ip) - 1;
302303
if (split - addr_str < to_copy) {
303304
to_copy = split - addr_str;
304305
}
305-
memcpy(plain_ip, addr_str, to_copy);
306306
mp_obj_t prefix_obj = mp_parse_num_integer(split + 1, strlen(split + 1), 10, NULL);
307307
prefix_bits = mp_obj_get_int(prefix_obj);
308+
if (mp_obj_str_get_qstr(args[0]) == MP_QSTR_addr4) {
309+
uint32_t mask = -(1u << (32 - prefix_bits));
310+
ip_addr_set_ip4_u32_val(netmask, ((mask & 0xFF) << 24) | ((mask & 0xFF00) << 8) | ((mask >> 8) & 0xFF00) | ((mask >> 24) & 0xFF));
311+
}
312+
} else {
313+
netmask = netif->netmask;
308314
}
309-
if (mp_obj_str_get_qstr(args[0]) == MP_QSTR_addr4) {
310-
uint32_t mask = -(1u << (32 - prefix_bits));
311-
ip_addr_set_ip4_u32_val(netmask, ((mask & 0xFF) << 24) | ((mask & 0xFF00) << 8) | ((mask >> 8) & 0xFF00) | ((mask >> 24) & 0xFF));
312-
}
313-
if (!ipaddr_aton(addr_str, &ip_addr)) {
315+
plain_ip[to_copy] = '\0';
316+
if (!ipaddr_aton(plain_ip, &ip_addr)) {
314317
mp_raise_ValueError(MP_ERROR_TEXT("invalid arguments"));
315318
}
316319
if ((mp_obj_str_get_qstr(args[0]) == MP_QSTR_addr6) != IP_IS_V6(&ip_addr)

0 commit comments

Comments
 (0)
0