Skip to content

Commit c2a6eb6

Browse files
authored
Merge branch 'micropython:master' into feature-zephyr-lightsleep
2 parents 9189442 + d01a981 commit c2a6eb6

File tree

412 files changed

+19764
-2369
lines changed

Some content is hidden

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

412 files changed

+19764
-2369
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/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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ The known limitations are:
7070
So, if your C code has writable data, make sure the data is defined globally,
7171
without an initialiser, and only written to within functions.
7272

73+
The native module is not automatically linked against the standard static libraries
74+
like ``libm.a`` and ``libgcc.a``, which can lead to ``undefined symbol`` errors.
75+
You can link the runtime libraries by setting ``LINK_RUNTIME = 1``
76+
in your Makefile. Custom static libraries can also be linked by adding
77+
``MPY_LD_FLAGS += -l path/to/library.a``. Note that these are linked into
78+
the native module and will not be shared with other modules or the system.
79+
7380
Linker limitation: the native module is not linked against the symbol table of the
7481
full MicroPython firmware. Rather, it is linked against an explicit table of exported
7582
symbols found in ``mp_fun_table`` (in ``py/nativeglue.h``), that is fixed at firmware

docs/esp32/quickref.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,30 @@ The :class:`network.WLAN` class in the :mod:`network` module::
8383

8484
import network
8585

86-
wlan = network.WLAN(network.WLAN.IF_STA) # create station interface
87-
wlan.active(True) # activate the interface
88-
wlan.scan() # scan for access points
89-
wlan.isconnected() # check if the station is connected to an AP
86+
wlan = network.WLAN() # create station interface (the default, see below for an access point interface)
87+
wlan.active(True) # activate the interface
88+
wlan.scan() # scan for access points
89+
wlan.isconnected() # check if the station is connected to an AP
9090
wlan.connect('ssid', 'key') # connect to an AP
91-
wlan.config('mac') # get the interface's MAC address
92-
wlan.ipconfig('addr4') # get the interface's IPv4 addresses
91+
wlan.config('mac') # get the interface's MAC address
92+
wlan.ipconfig('addr4') # get the interface's IPv4 addresses
9393

9494
ap = network.WLAN(network.WLAN.IF_AP) # create access-point interface
95-
ap.config(ssid='ESP-AP') # set the SSID of the access point
96-
ap.config(max_clients=10) # set how many clients can connect to the network
97-
ap.active(True) # activate the interface
95+
ap.config(ssid='ESP-AP') # set the SSID of the access point
96+
ap.config(max_clients=10) # set how many clients can connect to the network
97+
ap.active(True) # activate the interface
9898

9999
A useful function for connecting to your local WiFi network is::
100100

101101
def do_connect():
102-
import network
103-
wlan = network.WLAN(network.WLAN.IF_STA)
102+
import machine, network
103+
wlan = network.WLAN()
104104
wlan.active(True)
105105
if not wlan.isconnected():
106106
print('connecting to network...')
107107
wlan.connect('ssid', 'key')
108108
while not wlan.isconnected():
109-
pass
109+
machine.idle()
110110
print('network config:', wlan.ipconfig('addr4'))
111111

112112
Once the network is established the :mod:`socket <socket>` module can be used
@@ -747,7 +747,7 @@ See :ref:`machine.SDCard <machine.SDCard>`. ::
747747

748748
import machine, os, vfs
749749

750-
# Slot 2 uses pins sck=18, cs=5, miso=19, mosi=23
750+
# On original ESP32, slot 2 uses pins sck=18, cs=5, miso=19, mosi=23
751751
sd = machine.SDCard(slot=2)
752752
vfs.mount(sd, '/sd') # mount
753753

0 commit comments

Comments
 (0)