Skip to content

Commit a08deef

Browse files
committed
micropython: update to v1.19.1
- rebase upstream patches - update pybricksdev package for mpy-cross ABI v6 compatibility - change from using PYBRICKS_PORT_BUILTIN_MODULES to - make use of new MICROPY_BANNER_NAME_AND_VERSION option MP_REGISTER_MODULE() - fix other compile errors due to upstream changes - automatic code formatting changes - change javascript package to @pybricks/mpy-cross-v6
1 parent 77d7aff commit a08deef

Some content is hidden

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

44 files changed

+491
-484
lines changed

.github/workflows/npm-mpy-cross.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,23 @@ name: Publish mpy-cross web assembly package
33
on:
44
push:
55
tags:
6-
- '@pybricks/mpy-cross-**'
6+
- '@pybricks/mpy-cross-v6/*'
77

88
jobs:
99
npm_mpy_cross:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
defaults:
1212
run:
1313
working-directory: npm/mpy-cross
1414
steps:
15-
- uses: mymindstorm/setup-emsdk@v7
16-
with:
17-
version: 1.39.12
1815
- uses: actions/checkout@v2
1916
with:
2017
submodules: true
21-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v3
2219
with:
23-
node-version: '10.x'
20+
node-version: '16.x'
2421
registry-url: 'https://registry.npmjs.org'
22+
- run: sudo apt-get update && sudo apt-get install -y emscripten
2523
- run: yarn install
2624
- run: yarn build
2725
- run: yarn publish

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- Overhauled the control code to make it smaller and more numerically robust
2929
while using higher position resolution where it is available.
3030
- Changed drive base default speed to go a little slower.
31+
- Updated MicroPython to v1.19.
3132

3233
[support#662]: https://github.com/pybricks/support/issues/662
3334
[support#665]: https://github.com/pybricks/support/issues/665

bricks/ev3dev/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,9 @@ SRC_C += $(addprefix ports/unix/,\
205205
input.c \
206206
main.c \
207207
modmachine.c \
208-
modos.c \
209208
modtime.c \
210209
modufcntl.c \
211210
modummap.c \
212-
moduos_vfs.c \
213211
moduselect.c \
214212
mpthreadport.c \
215213
)

bricks/ev3dev/brickconfig.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,3 @@
3838
#define PYBRICKS_PY_ROBOTICS (1)
3939
#define PYBRICKS_PY_TOOLS (1)
4040
#define PYBRICKS_PY_USIGNAL (1)
41-
42-
#define MICROPY_PORT_INIT_FUNC pybricks_init()
43-
#define MICROPY_PORT_DEINIT_FUNC pybricks_deinit()
44-
#define MICROPY_MPHALPORT_H "ev3dev_mphal.h"
45-
#define MICROPY_PY_SYS_PATH_DEFAULT (".frozen:~/.pybricks-micropython/lib:/usr/lib/pybricks-micropython")
46-
47-
extern const struct _mp_obj_module_t pb_package_pybricks;
48-
#define _PYBRICKS_PACKAGE_PYBRICKS \
49-
{ MP_OBJ_NEW_QSTR(MP_QSTR__pybricks), (mp_obj_t)&pb_package_pybricks },
50-
51-
extern const struct _mp_obj_module_t pb_module_bluetooth;
52-
extern const struct _mp_obj_module_t pb_module_media_ev3dev;
53-
extern const struct _mp_obj_module_t pb_module_usignal;
54-
55-
#define PYBRICKS_PORT_BUILTIN_MODULES \
56-
_PYBRICKS_PACKAGE_PYBRICKS \
57-
{ MP_ROM_QSTR(MP_QSTR_bluetooth_c), MP_ROM_PTR(&pb_module_bluetooth) }, \
58-
{ MP_ROM_QSTR(MP_QSTR_media_ev3dev_c), MP_ROM_PTR(&pb_module_media_ev3dev) }, \
59-
{ MP_ROM_QSTR(MP_QSTR_usignal), MP_ROM_PTR(&pb_module_usignal) },

bricks/ev3dev/ev3dev_mphal.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <assert.h>
2828
#include <errno.h>
29+
#include <fcntl.h>
2930
#include <signal.h>
3031
#include <stdlib.h>
3132
#include <string.h>
@@ -157,3 +158,14 @@ void mp_hal_delay_ms(mp_uint_t ms) {
157158
break;
158159
}
159160
}
161+
162+
void mp_hal_get_random(size_t n, void *buf) {
163+
#ifdef _HAVE_GETRANDOM
164+
RAISE_ERRNO(getrandom(buf, n, 0), errno);
165+
#else
166+
int fd = open("/dev/urandom", O_RDONLY);
167+
RAISE_ERRNO(fd, errno);
168+
RAISE_ERRNO(read(fd, buf, n), errno);
169+
close(fd);
170+
#endif
171+
}

bricks/ev3dev/ev3dev_mphal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ static inline void mp_hal_delay_us(mp_uint_t us) {
5454
}
5555
#define mp_hal_ticks_cpu() 0
5656

57+
void mp_hal_get_random(size_t n, void *buf);
58+
5759
#define RAISE_ERRNO(err_flag, error_val) \
5860
{ if (err_flag == -1) \
5961
{ mp_raise_OSError(error_val); } }

bricks/ev3dev/modbluetooth.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ const mp_obj_module_t pb_module_bluetooth = {
7777
.base = { &mp_type_module },
7878
.globals = (mp_obj_dict_t *)&ev3dev_bluetooth_globals,
7979
};
80+
81+
MP_REGISTER_MODULE(MP_QSTR_bluetooth_c, pb_module_bluetooth);

bricks/ev3dev/modmedia_ev3dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ const mp_obj_module_t pb_module_media_ev3dev = {
3232
.globals = (mp_obj_dict_t *)&pb_module_media_ev3dev_globals,
3333
};
3434

35+
MP_REGISTER_MODULE(MP_QSTR_media_ev3dev_c, pb_module_media_ev3dev);
36+
3537
#endif // PYBRICKS_PY_MEDIA_EV3DEV
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: MIT
22
# Copyright (c) 2018-2020 The Pybricks Authors
33

4-
from _pybricks import version
4+
from pybricks_c import version

bricks/ev3dev/modules/pybricks/ev3devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""Classes for LEGO MINDSTORMS EV3 Devices."""
55

66
# import those ev3devices that are already written in MicroPython-style C code.
7-
from _pybricks.ev3devices import (
7+
from pybricks_c.ev3devices import (
88
InfraredSensor,
99
ColorSensor,
1010
TouchSensor,

0 commit comments

Comments
 (0)