Skip to content

Commit ab4036e

Browse files
authored
Merge branch 'micropython:master' into samd_i2c
2 parents 4f8af0b + 3e085c3 commit ab4036e

File tree

11 files changed

+22
-37
lines changed

11 files changed

+22
-37
lines changed

.github/workflows/code_size.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ concurrency:
2424

2525
jobs:
2626
build:
27-
runs-on: ubuntu-20.04
27+
runs-on: ubuntu-22.04
2828
steps:
2929
- uses: actions/checkout@v4
3030
with:

.github/workflows/code_size_comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111

1212
jobs:
1313
comment:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
steps:
1616
- name: 'Download artifact'
1717
id: download-artifact

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ build/
1111
build-*/
1212
docs/genrst/
1313

14-
# Test failure outputs
14+
# Test failure outputs and intermediate artefacts
1515
tests/results/*
16+
tests/ports/unix/ffi_lib.so
1617

1718
# Python cache files
1819
__pycache__/

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
url = https://github.com/micropython/axtls.git
44
[submodule "lib/libffi"]
55
path = lib/libffi
6-
url = https://github.com/atgreen/libffi
6+
url = https://github.com/libffi/libffi
77
[submodule "lib/lwip"]
88
path = lib/lwip
99
url = https://github.com/lwip-tcpip/lwip.git

lib/libffi

Submodule libffi updated 324 files

ports/unix/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ ifeq ($(MICROPY_STANDALONE),1)
168168
# Build libffi from source.
169169
GIT_SUBMODULES += lib/libffi
170170
DEPLIBS += libffi
171-
LIBFFI_CFLAGS := -I$(shell ls -1d $(BUILD)/lib/libffi/out/lib/libffi-*/include)
171+
LIBFFI_CFLAGS := -I$(shell ls -1d $(BUILD)/lib/libffi/include)
172172
ifeq ($(MICROPY_FORCE_32BIT),1)
173173
LIBFFI_LDFLAGS = $(BUILD)/lib/libffi/out/lib32/libffi.a
174174
else

ports/unix/alloc.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,6 @@ void mp_unix_mark_exec(void) {
8585
}
8686
}
8787

88-
#if MICROPY_FORCE_PLAT_ALLOC_EXEC
89-
// Provide implementation of libffi ffi_closure_* functions in terms
90-
// of the functions above. On a normal Linux system, this save a lot
91-
// of code size.
92-
void *ffi_closure_alloc(size_t size, void **code);
93-
void ffi_closure_free(void *ptr);
94-
95-
void *ffi_closure_alloc(size_t size, void **code) {
96-
size_t dummy;
97-
mp_unix_alloc_exec(size, code, &dummy);
98-
return *code;
99-
}
100-
101-
void ffi_closure_free(void *ptr) {
102-
(void)ptr;
103-
// TODO
104-
}
105-
#endif
106-
10788
MP_REGISTER_ROOT_POINTER(void *mmap_region_head);
10889

10990
#endif // MICROPY_EMIT_NATIVE || (MICROPY_PY_FFI && MICROPY_FORCE_PLAT_ALLOC_EXEC)

ports/unix/modffi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ static mp_obj_t return_ffi_value(ffi_union_t *val, char type) {
191191
case 'i':
192192
case 'l':
193193
return mp_obj_new_int((ffi_sarg)val->ffi);
194+
case 'I':
195+
// On RV64, 32-bit values are stored as signed integers inside the
196+
// holding register.
197+
return mp_obj_new_int_from_uint(val->ffi & 0xFFFFFFFF);
194198
case 'B':
195199
case 'H':
196-
case 'I':
197200
case 'L':
198201
return mp_obj_new_int_from_uint(val->ffi);
199202
case 'q':
@@ -334,7 +337,8 @@ static mp_obj_t mod_ffi_callback(size_t n_args, const mp_obj_t *pos_args, mp_map
334337
const char *rettype = mp_obj_str_get_str(rettype_in);
335338

336339
mp_int_t nparams = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(paramtypes_in));
337-
mp_obj_fficallback_t *o = mp_obj_malloc_var(mp_obj_fficallback_t, params, ffi_type *, nparams, &fficallback_type);
340+
mp_obj_fficallback_t *o = (mp_obj_fficallback_t *)m_tracked_calloc(offsetof(mp_obj_fficallback_t, params) + sizeof(ffi_type *) * nparams, sizeof(uint8_t));
341+
o->base.type = &fficallback_type;
338342

339343
o->clo = ffi_closure_alloc(sizeof(ffi_closure), &o->func);
340344

ports/unix/mpconfigport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ typedef long mp_off_t;
117117
#define MICROPY_HELPER_LEXER_UNIX (1)
118118
#define MICROPY_VFS_POSIX (1)
119119
#define MICROPY_READER_POSIX (1)
120-
#ifndef MICROPY_TRACKED_ALLOC
121-
#define MICROPY_TRACKED_ALLOC (MICROPY_BLUETOOTH_BTSTACK)
120+
#if MICROPY_PY_FFI || MICROPY_BLUETOOTH_BTSTACK
121+
#define MICROPY_TRACKED_ALLOC (1)
122122
#endif
123123

124124
// VFS stat functions should return time values relative to 1970/1/1

tools/ci.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ function ci_code_size_setup {
5555
sudo apt-get install gcc-multilib
5656
gcc --version
5757
ci_gcc_arm_setup
58+
ci_gcc_riscv_setup
5859
}
5960

6061
function ci_code_size_build {
6162
# check the following ports for the change in their code size
62-
PORTS_TO_CHECK=bmusxpd
63+
PORTS_TO_CHECK=bmusxpdv
6364
SUBMODULES="lib/asf4 lib/berkeley-db-1.xx lib/btstack lib/cyw43-driver lib/lwip lib/mbedtls lib/micropython-lib lib/nxp_driver lib/pico-sdk lib/stm32lib lib/tinyusb"
6465

6566
# starts off at either the ref/pull/N/merge FETCH_HEAD, or the current branch HEAD
@@ -421,6 +422,7 @@ CI_UNIX_OPTS_QEMU_ARM=(
421422
CI_UNIX_OPTS_QEMU_RISCV64=(
422423
CROSS_COMPILE=riscv64-linux-gnu-
423424
VARIANT=coverage
425+
MICROPY_STANDALONE=1
424426
)
425427

426428
function ci_unix_build_helper {
@@ -691,16 +693,12 @@ function ci_unix_qemu_arm_run_tests {
691693
}
692694

693695
function ci_unix_qemu_riscv64_setup {
694-
. /etc/os-release
695-
for repository in "${VERSION_CODENAME}" "${VERSION_CODENAME}-updates" "${VERSION_CODENAME}-security"
696-
do
697-
sudo add-apt-repository -y -n "deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports ${repository} main"
698-
done
699696
sudo apt-get update
700-
sudo dpkg --add-architecture riscv64
701-
sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libffi-dev:riscv64
697+
sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
702698
sudo apt-get install qemu-user
703699
qemu-riscv64 --version
700+
sudo mkdir /etc/qemu-binfmt
701+
sudo ln -s /usr/riscv64-linux-gnu/ /etc/qemu-binfmt/riscv64
704702
}
705703

706704
function ci_unix_qemu_riscv64_build {

0 commit comments

Comments
 (0)