Skip to content

Commit abbf972

Browse files
authored
Merge branch 'micropython:master' into master
2 parents fea0eff + 431b791 commit abbf972

File tree

627 files changed

+23660
-4303
lines changed

Some content is hidden

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

627 files changed

+23660
-4303
lines changed

.github/workflows/ports_alif.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: alif 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/alif/**'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build_alif:
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
ci_func: # names are functions in ci.sh
26+
- alif_ae3_build
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Install packages
31+
run: source tools/ci.sh && ci_alif_setup
32+
- name: Build ci_${{matrix.ci_func }}
33+
run: source tools/ci.sh && ci_${{ matrix.ci_func }}

.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: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ jobs:
7171
runs-on: ubuntu-latest
7272
steps:
7373
- uses: actions/checkout@v4
74+
- uses: actions/setup-python@v5
75+
# Python 3.12 is the default for ubuntu-24.04, but that has compatibility issues with settrace tests.
76+
# Can remove this step when ubuntu-latest uses a more recent Python 3.x as the default.
77+
with:
78+
python-version: '3.11'
7479
- name: Install packages
7580
run: source tools/ci.sh && ci_unix_coverage_setup
7681
- name: Build
@@ -169,23 +174,6 @@ jobs:
169174
if: failure()
170175
run: tests/run-tests.py --print-failures
171176

172-
settrace:
173-
runs-on: ubuntu-latest
174-
steps:
175-
- uses: actions/checkout@v4
176-
- uses: actions/setup-python@v5
177-
# Python 3.12 is the default for ubuntu-24.04, but that has compatibility issues with settrace tests.
178-
# Can remove this step when ubuntu-latest uses a more recent Python 3.x as the default.
179-
with:
180-
python-version: '3.11'
181-
- name: Build
182-
run: source tools/ci.sh && ci_unix_settrace_build
183-
- name: Run main test suite
184-
run: source tools/ci.sh && ci_unix_settrace_run_tests
185-
- name: Print failures
186-
if: failure()
187-
run: tests/run-tests.py --print-failures
188-
189177
settrace_stackless:
190178
runs-on: ubuntu-latest
191179
steps:
@@ -262,3 +250,53 @@ jobs:
262250
- name: Print failures
263251
if: failure()
264252
run: tests/run-tests.py --print-failures
253+
254+
sanitize_address:
255+
runs-on: ubuntu-latest
256+
steps:
257+
- uses: actions/checkout@v4
258+
- uses: actions/setup-python@v5
259+
# Python 3.12 is the default for ubuntu-24.04, but that has compatibility issues with settrace tests.
260+
# Can remove this step when ubuntu-latest uses a more recent Python 3.x as the default.
261+
with:
262+
python-version: '3.11'
263+
- name: Install packages
264+
run: source tools/ci.sh && ci_unix_coverage_setup
265+
- name: Build
266+
run: source tools/ci.sh && ci_unix_sanitize_address_build
267+
- name: Run main test suite
268+
run: source tools/ci.sh && ci_unix_sanitize_address_run_tests
269+
- name: Test merging .mpy files
270+
run: source tools/ci.sh && ci_unix_coverage_run_mpy_merge_tests
271+
- name: Build native mpy modules
272+
run: source tools/ci.sh && ci_native_mpy_modules_build
273+
- name: Test importing .mpy generated by mpy_ld.py
274+
run: source tools/ci.sh && ci_unix_coverage_run_native_mpy_tests
275+
- name: Print failures
276+
if: failure()
277+
run: tests/run-tests.py --print-failures
278+
279+
sanitize_undefined:
280+
runs-on: ubuntu-latest
281+
steps:
282+
- uses: actions/checkout@v4
283+
- uses: actions/setup-python@v5
284+
# Python 3.12 is the default for ubuntu-24.04, but that has compatibility issues with settrace tests.
285+
# Can remove this step when ubuntu-latest uses a more recent Python 3.x as the default.
286+
with:
287+
python-version: '3.11'
288+
- name: Install packages
289+
run: source tools/ci.sh && ci_unix_coverage_setup
290+
- name: Build
291+
run: source tools/ci.sh && ci_unix_sanitize_undefined_build
292+
- name: Run main test suite
293+
run: source tools/ci.sh && ci_unix_sanitize_undefined_run_tests
294+
- name: Test merging .mpy files
295+
run: source tools/ci.sh && ci_unix_coverage_run_mpy_merge_tests
296+
- name: Build native mpy modules
297+
run: source tools/ci.sh && ci_native_mpy_modules_build
298+
- name: Test importing .mpy generated by mpy_ld.py
299+
run: source tools/ci.sh && ci_unix_coverage_run_native_mpy_tests
300+
- name: Print failures
301+
if: failure()
302+
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:

.github/workflows/ruff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
# ruff version should be kept in sync with .pre-commit-config.yaml
11-
- run: pipx install ruff==0.9.6
10+
# ruff version should be kept in sync with .pre-commit-config.yaml & also micropython-lib
11+
- run: pipx install ruff==0.11.6
1212
- run: ruff check --output-format=github .
1313
- run: ruff format --diff .

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@
6868
[submodule "lib/arduino-lib"]
6969
path = lib/arduino-lib
7070
url = https://github.com/arduino/arduino-lib-mpy.git
71+
[submodule "lib/alif_ensemble-cmsis-dfp"]
72+
path = lib/alif_ensemble-cmsis-dfp
73+
url = https://github.com/alifsemi/alif_ensemble-cmsis-dfp.git
74+
[submodule "lib/alif-security-toolkit"]
75+
path = lib/alif-security-toolkit
76+
url = https://github.com/micropython/alif-security-toolkit.git

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ repos:
1212
verbose: true
1313
stages: [commit-msg]
1414
- repo: https://github.com/charliermarsh/ruff-pre-commit
15-
# Version should be kept in sync with .github/workflows/ruff.yml
16-
rev: v0.9.6
15+
# Version should be kept in sync with .github/workflows/ruff.yml & also micropython-lib
16+
rev: v0.11.6
1717
hooks:
1818
- id: ruff
1919
- id: ruff-format

CODECONVENTIONS.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,33 +206,65 @@ adhere to the existing style and use `tools/codeformat.py` to check any changes.
206206
The main conventions, and things not enforceable via the auto-formatter, are
207207
described below.
208208

209-
White space:
209+
As the MicroPython code base is over ten years old, not every source file
210+
conforms fully to these conventions. If making small changes to existing code,
211+
then it's usually acceptable to follow the existing code's style. New code or
212+
major changes should follow the conventions described here.
213+
214+
## White space
215+
210216
- Expand tabs to 4 spaces.
211217
- Don't leave trailing whitespace at the end of a line.
212218
- For control blocks (if, for, while), put 1 space between the
213219
keyword and the opening parenthesis.
214220
- Put 1 space after a comma, and 1 space around operators.
215221

216-
Braces:
222+
## Braces
223+
217224
- Use braces for all blocks, even no-line and single-line pieces of
218225
code.
219226
- Put opening braces on the end of the line it belongs to, not on
220227
a new line.
221228
- For else-statements, put the else on the same line as the previous
222229
closing brace.
223230

224-
Header files:
231+
## Header files
232+
225233
- Header files should be protected from multiple inclusion with #if
226234
directives. See an existing header for naming convention.
227235

228-
Names:
236+
## Names
237+
229238
- Use underscore_case, not camelCase for all names.
230239
- Use CAPS_WITH_UNDERSCORE for enums and macros.
231240
- When defining a type use underscore_case and put '_t' after it.
232241

233-
Integer types: MicroPython runs on 16, 32, and 64 bit machines, so it's
234-
important to use the correctly-sized (and signed) integer types. The
235-
general guidelines are:
242+
### Public names (declared in headers)
243+
244+
- MicroPython-specific names (especially any declared in `py/` and `extmod/`
245+
directories) should generally start with `mp_` or `MP_`.
246+
- Functions and variables declared in a header should generally share a longer
247+
common prefix. Usually the prefix matches the file name (i.e. items defined in
248+
`py/obj.c` are declared in `py/obj.h` and should be prefixed `mp_obj_`). There
249+
are exceptions, for example where one header file contains declarations
250+
implemented in multiple source files for expediency.
251+
252+
### Private names (specific to a single .c file)
253+
254+
- For static functions and variables exposed to Python (i.e. a static C function
255+
that is wrapped in `MP_DEFINE_CONST_FUN_...` and attached to a module), use
256+
the file-level shared common prefix, i.e. name them as if the function or
257+
variable was not static.
258+
- Other static definitions in source files (i.e. functions or variables defined
259+
in a .c file that are only used within that .c file) don't need any prefix
260+
(specifically: no `s_` or `_` prefix, and generally avoid adding the
261+
file-level common prefix).
262+
263+
## Integer types
264+
265+
MicroPython runs on 16, 32, and 64 bit machines, so it's important to use the
266+
correctly-sized (and signed) integer types. The general guidelines are:
267+
236268
- For most cases use mp_int_t for signed and mp_uint_t for unsigned
237269
integer values. These are guaranteed to be machine-word sized and
238270
therefore big enough to hold the value from a MicroPython small-int
@@ -241,11 +273,13 @@ general guidelines are:
241273
- You can use int/uint, but remember that they may be 16-bits wide.
242274
- If in doubt, use mp_int_t/mp_uint_t.
243275

244-
Comments:
276+
## Comments
277+
245278
- Be concise and only write comments for things that are not obvious.
246279
- Use `// ` prefix, NOT `/* ... */`. No extra fluff.
247280

248-
Memory allocation:
281+
## Memory allocation
282+
249283
- Use m_new, m_renew, m_del (and friends) to allocate and free heap memory.
250284
These macros are defined in py/misc.h.
251285

docs/develop/natmod.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ Linker limitation: the native module is not linked against the symbol table of t
8181
full MicroPython firmware. Rather, it is linked against an explicit table of exported
8282
symbols found in ``mp_fun_table`` (in ``py/nativeglue.h``), that is fixed at firmware
8383
build time. It is thus not possible to simply call some arbitrary HAL/OS/RTOS/system
84-
function, for example.
84+
function, for example, unless that resides at a fixed address. In that case, the path
85+
of a linkerscript containing a series of symbol names and their fixed address can be
86+
passed to ``mpy_ld.py`` via the ``--externs`` command line argument. That way symbols
87+
appearing in the linkerscript will take precedence over what is provided from object
88+
files, but at the moment the object files' implementation will still reside in the
89+
final MPY file. The linkerscript parser is limited in its capabilities, and is
90+
currently used only for parsing the ESP8266 port ROM symbols list (see
91+
``ports/esp8266/boards/eagle.rom.addr.v6.ld``).
8592

8693
New symbols can be added to the end of the table and the firmware rebuilt.
8794
The symbols also need to be added to ``tools/mpy_ld.py``'s ``fun_table`` dict in the

0 commit comments

Comments
 (0)