Skip to content

Commit 64c62f8

Browse files
jimmodpgeorge
authored andcommitted
README: Simplify and update, and move unix section to separate file.
Changes are: - Remove unix- and stm32-specific sections (move unix to its own README.md), stm32 was duplicated. - Add links to GitHub Discussions and Discord. - Update information about the project. - Add a getting started section. - Explain `make submodules`. Signed-off-by: Jim Mussared <[email protected]> Signed-off-by: Damien George <[email protected]>
1 parent d108fc9 commit 64c62f8

File tree

2 files changed

+181
-151
lines changed

2 files changed

+181
-151
lines changed

README.md

+111-151
Original file line numberDiff line numberDiff line change
@@ -15,174 +15,134 @@ code-base, including project-wide name changes and API changes.
1515

1616
MicroPython implements the entire Python 3.4 syntax (including exceptions,
1717
`with`, `yield from`, etc., and additionally `async`/`await` keywords from
18-
Python 3.5). The following core datatypes are provided: `str` (including
19-
basic Unicode support), `bytes`, `bytearray`, `tuple`, `list`, `dict`, `set`,
20-
`frozenset`, `array.array`, `collections.namedtuple`, classes and instances.
21-
Builtin modules include `sys`, `time`, and `struct`, etc. Select ports have
22-
support for `_thread` module (multithreading). Note that only a subset of
23-
Python 3 functionality is implemented for the data types and modules.
24-
25-
MicroPython can execute scripts in textual source form or from precompiled
26-
bytecode, in both cases either from an on-device filesystem or "frozen" into
27-
the MicroPython executable.
28-
29-
See the repository http://github.com/micropython/pyboard for the MicroPython
30-
board (PyBoard), the officially supported reference electronic circuit board.
31-
32-
Major components in this repository:
33-
- py/ -- the core Python implementation, including compiler, runtime, and
18+
Python 3.5 and some select features from later versions). The following core
19+
datatypes are provided: `str`(including basic Unicode support), `bytes`,
20+
`bytearray`, `tuple`, `list`, `dict`, `set`, `frozenset`, `array.array`,
21+
`collections.namedtuple`, classes and instances. Builtin modules include
22+
`os`, `sys`, `time`, `re`, and `struct`, etc. Select ports have support for
23+
`_thread` module (multithreading), `socket` and `ssl` for networking, and
24+
`asyncio`. Note that only a subset of Python 3 functionality is implemented
25+
for the data types and modules.
26+
27+
MicroPython can execute scripts in textual source form (.py files) or from
28+
precompiled bytecode (.mpy files), in both cases either from an on-device
29+
filesystem or "frozen" into the MicroPython executable.
30+
31+
MicroPython also provides a set of MicroPython-specific modules to access
32+
hardware-specific functionality and peripherals such as GPIO, Timers, ADC,
33+
DAC, PWM, SPI, I2C, CAN, Bluetooth, and USB.
34+
35+
Getting started
36+
---------------
37+
38+
See the [online documentation](https://docs.micropython.org/) for API
39+
references and information about using MicroPython and information about how
40+
it is implemented.
41+
42+
We use [GitHub Discussions](https://github.com/micropython/micropython/discussions)
43+
as our forum, and [Discord](https://discord.gg/RB8HZSAExQ) for chat. These
44+
are great places to ask questions and advice from the community or to discuss your
45+
MicroPython-based projects.
46+
47+
For bugs and feature requests, please [raise an issue](https://github.com/micropython/micropython/issues/new/choose)
48+
and follow the templates there.
49+
50+
For information about the [MicroPython pyboard](https://store.micropython.org/pyb-features),
51+
the officially supported board from the
52+
[original Kickstarter campaign](https://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers),
53+
see the [schematics and pinouts](http://github.com/micropython/pyboard) and
54+
[documentation](https://docs.micropython.org/en/latest/pyboard/quickref.html).
55+
56+
Contributing
57+
------------
58+
59+
MicroPython is an open-source project and welcomes contributions. To be
60+
productive, please be sure to follow the
61+
[Contributors' Guidelines](https://github.com/micropython/micropython/wiki/ContributorGuidelines)
62+
and the [Code Conventions](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
63+
Note that MicroPython is licenced under the MIT license, and all contributions
64+
should follow this license.
65+
66+
About this repository
67+
---------------------
68+
69+
This repository contains the following components:
70+
- [py/](py/) -- the core Python implementation, including compiler, runtime, and
3471
core library.
35-
- mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts
72+
- [mpy-cross/](mpy-cross/) -- the MicroPython cross-compiler which is used to turn scripts
3673
into precompiled bytecode.
37-
- ports/unix/ -- a version of MicroPython that runs on Unix.
38-
- ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar
39-
STM32 boards (using ST's Cube HAL drivers).
40-
- ports/minimal/ -- a minimal MicroPython port. Start with this if you want
41-
to port MicroPython to another microcontroller.
42-
- tests/ -- test framework and test scripts.
43-
- docs/ -- user documentation in Sphinx reStructuredText format. Rendered
44-
HTML documentation is available at http://docs.micropython.org.
45-
46-
Additional components:
47-
- ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
48-
mostly to control code size.
49-
- ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1
50-
(preliminary but functional).
51-
- ports/pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers.
52-
- ports/cc3200/ -- a version of MicroPython that runs on the CC3200 from TI.
53-
- ports/esp8266/ -- a version of MicroPython that runs on Espressif's ESP8266 SoC.
54-
- ports/esp32/ -- a version of MicroPython that runs on Espressif's ESP32 SoC.
55-
- ports/nrf/ -- a version of MicroPython that runs on Nordic's nRF51 and nRF52 MCUs.
56-
- extmod/ -- additional (non-core) modules implemented in C.
57-
- tools/ -- various tools, including the pyboard.py module.
58-
- examples/ -- a few example Python scripts.
59-
60-
The subdirectories above may include READMEs with additional info.
74+
- [ports/](ports/) -- platform-specific code for the various ports and architectures that MicroPython runs on.
75+
- [lib/](lib/) -- submodules for external dependencies.
76+
- [tests/](tests/) -- test framework and test scripts.
77+
- [docs/](docs/) -- user documentation in Sphinx reStructuredText format. This is used to generate the [online documentation](http://docs.micropython.org).
78+
- [extmod/](extmod/) -- additional (non-core) modules implemented in C.
79+
- [tools/](tools/) -- various tools, including the pyboard.py module.
80+
- [examples/](examples/) -- a few example Python scripts.
6181

6282
"make" is used to build the components, or "gmake" on BSD-based systems.
6383
You will also need bash, gcc, and Python 3.3+ available as the command `python3`
6484
(if your system only has Python 2.7 then invoke make with the additional option
65-
`PYTHON=python2`).
85+
`PYTHON=python2`). Some ports (rp2 and esp32) additionally use CMake.
86+
87+
Supported platforms & architectures
88+
-----------------------------------
89+
90+
MicroPython runs on a wide range of microcontrollers, as well as on Unix-like
91+
(including Linux, BSD, macOS, WSL) and Windows systems.
92+
93+
Microcontroller targets can be as small as 256kiB flash + 16kiB RAM, although
94+
devices with at least 512kiB flash + 128kiB RAM allow a much more
95+
full-featured experience.
96+
97+
The [Unix](ports/unix) and [Windows](ports/windows) ports allow both
98+
development and testing of MicroPython itself, as well as providing
99+
lightweight alternative to CPython on these platforms (in particular on
100+
embedded Linux systems).
101+
102+
The ["minimal"](ports/minimal) port provides an example of a very basic
103+
MicroPython port and can be compiled as both a standalone Linux binary as
104+
well as for ARM Cortex M4. Start with this if you want to port MicroPython to
105+
another microcontroller. Additionally the ["bare-arm"](ports/bare-arm) port
106+
is an example of the absolute minimum configuration, and is used to keep
107+
track of the code size of the core runtime and VM.
108+
109+
In addition, the following ports are provided in this repository:
110+
- [cc3200](ports/cc3200) -- Texas Instruments CC3200 (including PyCom WiPy).
111+
- [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3).
112+
- [esp8266](ports/esp8266) -- Espressif ESP8266 SoC.
113+
- [mimxrt](ports/mimxrt) -- NXP m.iMX RT (including Teensy 4.x).
114+
- [nrf](ports/nrf) -- Nordic Semiconductor nRF51 and nRF52.
115+
- [pic16bit](ports/pic16bit) -- Microchip PIC 16-bit.
116+
- [powerpc](ports/powerpc) -- IBM PowerPC (including Microwatt)
117+
- [qemu-arm](ports/qemu-arm) -- QEMU-based emulated target, for testing)
118+
- [renesas-ra](ports/renesas-ra) -- Renesas RA family.
119+
- [rp2](ports/rp2) -- Raspberry Pi RP2040 (including Pico and Pico W).
120+
- [samd](ports/samd) -- Microchip (formerly Atmel) SAMD21 and SAMD51.
121+
- [stm32](ports/stm32) -- STMicroelectronics STM32 family (including F0, F4, F7, G0, G4, H7, L0, L4, WB)
122+
- [teensy](ports/teensy) -- Teensy 3.x.
123+
- [webassembly](ports/webassembly) -- Emscripten port targeting browsers and NodeJS.
124+
- [zephyr](ports/zephyr) -- Zephyr RTOS.
66125

67126
The MicroPython cross-compiler, mpy-cross
68127
-----------------------------------------
69128

70-
Most ports require the MicroPython cross-compiler to be built first. This
71-
program, called mpy-cross, is used to pre-compile Python scripts to .mpy
72-
files which can then be included (frozen) into the firmware/executable for
73-
a port. To build mpy-cross use:
129+
Most ports require the [MicroPython cross-compiler](mpy-cross) to be built
130+
first. This program, called mpy-cross, is used to pre-compile Python scripts
131+
to .mpy files which can then be included (frozen) into the
132+
firmware/executable for a port. To build mpy-cross use:
74133

75134
$ cd mpy-cross
76135
$ make
77136

78-
The Unix version
79-
----------------
80-
81-
The "unix" port requires a standard Unix environment with gcc and GNU make.
82-
x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well
83-
as ARM and MIPS. Making full-featured port to another architecture requires
84-
writing some assembly code for the exception handling and garbage collection.
85-
Alternatively, fallback implementation based on setjmp/longjmp can be used.
86-
87-
To build (see section below for required dependencies):
88-
89-
$ cd ports/unix
90-
$ make submodules
91-
$ make
92-
93-
Then to give it a try:
94-
95-
$ ./micropython
96-
>>> list(5 * x + y for x in range(10) for y in [4, 2, 1])
97-
98-
Use `CTRL-D` (i.e. EOF) to exit the shell.
99-
Learn about command-line options (in particular, how to increase heap size
100-
which may be needed for larger applications):
101-
102-
$ ./micropython -h
103-
104-
Run complete testsuite:
105-
106-
$ make test
107-
108-
Unix version comes with a builtin package manager called upip, e.g.:
109-
110-
$ ./micropython -m upip install micropython-pystone
111-
$ ./micropython -m pystone
112-
113-
Browse available modules on
114-
[PyPI](https://pypi.python.org/pypi?%3Aaction=search&term=micropython).
115-
Standard library modules come from
116-
[micropython-lib](https://github.com/micropython/micropython-lib) project.
117-
118137
External dependencies
119138
---------------------
120139

121-
Building MicroPython ports may require some dependencies installed.
122-
123-
For Unix port, `libffi` library and `pkg-config` tool are required. On
124-
Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`
125-
(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.
126-
127-
Other dependencies can be built together with MicroPython. This may
128-
be required to enable extra features or capabilities, and in recent
129-
versions of MicroPython, these may be enabled by default. To build
130-
these additional dependencies, in the port directory you're
131-
interested in (e.g. `ports/unix/`) first execute:
140+
The core MicroPython VM and runtime has no external dependencies, but a given
141+
port might depend on third-party drivers or vendor HALs. This repository
142+
includes [several submodules](lib/) linking to these external dependencies.
143+
Before compiling a given port, use
132144

145+
$ cd ports/name
133146
$ make submodules
134147

135-
This will fetch all the relevant git submodules (sub repositories) that
136-
the port needs. Use the same command to get the latest versions of
137-
submodules as they are updated from time to time. After that execute:
138-
139-
$ make deplibs
140-
141-
This will build all available dependencies (regardless whether they
142-
are used or not). If you intend to build MicroPython with additional
143-
options (like cross-compiling), the same set of options should be passed
144-
to `make deplibs`. To actually enable/disable use of dependencies, edit
145-
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.
146-
For example, to build SSL module (required for `upip` tool described above,
147-
and so enabled by default), `MICROPY_PY_USSL` should be set to 1.
148-
149-
For some ports, building required dependences is transparent, and happens
150-
automatically. But they still need to be fetched with the `make submodules`
151-
command.
152-
153-
The STM32 version
154-
-----------------
155-
156-
The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated
157-
bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils,
158-
arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here:
159-
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
160-
161-
To build:
162-
163-
$ cd ports/stm32
164-
$ make submodules
165-
$ make
166-
167-
You then need to get your board into DFU mode. On the pyboard, connect the
168-
3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other
169-
on the bottom left of the board, second row from the bottom).
170-
171-
Then to flash the code via USB DFU to your device:
172-
173-
$ make deploy
174-
175-
This will use the included `tools/pydfu.py` script. If flashing the firmware
176-
does not work it may be because you don't have the correct permissions, and
177-
need to use `sudo make deploy`.
178-
See the README.md file in the ports/stm32/ directory for further details.
179-
180-
Contributing
181-
------------
182-
183-
MicroPython is an open-source project and welcomes contributions. To be
184-
productive, please be sure to follow the
185-
[Contributors' Guidelines](https://github.com/micropython/micropython/wiki/ContributorGuidelines)
186-
and the [Code Conventions](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
187-
Note that MicroPython is licenced under the MIT license, and all contributions
188-
should follow this license.
148+
to ensure that all required submodules are initialised.

ports/unix/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
The Unix version
2+
----------------
3+
4+
The "unix" port requires a standard Unix-like environment with gcc and GNU
5+
make. This includes Linux, BSD, macOS, and Windows Subsystem for Linux. The
6+
x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well as
7+
ARM and MIPS. Making a full-featured port to another architecture requires
8+
writing some assembly code for the exception handling and garbage collection.
9+
Alternatively, a fallback implementation based on setjmp/longjmp can be used.
10+
11+
To build (see section below for required dependencies):
12+
13+
$ cd ports/unix
14+
$ make submodules
15+
$ make
16+
17+
Then to give it a try:
18+
19+
$ ./build-standard/micropython
20+
>>> list(5 * x + y for x in range(10) for y in [4, 2, 1])
21+
22+
Use `CTRL-D` (i.e. EOF) to exit the shell.
23+
24+
Learn about command-line options (in particular, how to increase heap size
25+
which may be needed for larger applications):
26+
27+
$ ./micropython -h
28+
29+
To run the complete testsuite, use:
30+
31+
$ make test
32+
33+
The Unix port comes with a builtin package manager called upip, e.g.:
34+
35+
$ ./micropython -m upip install micropython-pystone
36+
$ ./micropython -m pystone
37+
38+
Browse available modules on
39+
[PyPI](https://pypi.python.org/pypi?%3Aaction=search&term=micropython).
40+
Standard library modules come from the
41+
[micropython-lib](https://github.com/micropython/micropython-lib) project.
42+
43+
External dependencies
44+
---------------------
45+
46+
The `libffi` library and `pkg-config` tool are required. On Debian/Ubuntu/Mint
47+
derivative Linux distros, install `build-essential`(includes toolchain and
48+
make), `libffi-dev`, and `pkg-config` packages.
49+
50+
Other dependencies can be built together with MicroPython. This may
51+
be required to enable extra features or capabilities, and in recent
52+
versions of MicroPython, these may be enabled by default. To build
53+
these additional dependencies, in the unix port directory first execute:
54+
55+
$ make submodules
56+
57+
This will fetch all the relevant git submodules (sub repositories) that
58+
the port needs. Use the same command to get the latest versions of
59+
submodules as they are updated from time to time. After that execute:
60+
61+
$ make deplibs
62+
63+
This will build all available dependencies (regardless whether they are used
64+
or not). If you intend to build MicroPython with additional options
65+
(like cross-compiling), the same set of options should be passed to `make
66+
deplibs`. To actually enable/disable use of dependencies, edit the
67+
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the
68+
options. For example, to build SSL module (required for the `upip` tool
69+
described above, and so enabled by default), `MICROPY_PY_USSL` should be set
70+
to 1.

0 commit comments

Comments
 (0)