Skip to content

Commit b053d92

Browse files
committed
update docs
Signed-off-by: Jos Verlinde <[email protected]>
1 parent e3f392c commit b053d92

File tree

4 files changed

+145
-1
lines changed

4 files changed

+145
-1
lines changed

docs/42_using_createstubs.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Using Createstub
2+
3+
## Use MIP to install createstubs on a MCU board
4+
5+
It is possible to install the firmware stubber ( createsubs.py or one of its variants) on a MicroPython board.
6+
This allows you to create the firmware stubs on the board itself, and then copy them to your PC.
7+
8+
mip is a package manager for MicroPython. It is a command line tool that allows you to install packages on a MicroPython board.
9+
In this case it is best to use `mpremote` that has a built-in `mip` command.
10+
11+
Make sure you have the latest version of `mpremote` installed.
12+
```bash
13+
pip install mpremote
14+
```
15+
16+
## Install createstubs
17+
18+
Connect your board to your PC and run the following command:
19+
20+
`mpremote mip install github:josverl/micropython-stubber`
21+
```log
22+
Install github:josverl/micropython-stubber
23+
Installing github:josverl/micropython-stubber/package.json to /lib
24+
Installing: /lib/createstubs.py
25+
Installing: /lib/createstubs_db.py
26+
Installing: /lib/createstubs_mem.py
27+
Installing: /lib/modules.txt
28+
Done
29+
```
30+
31+
## run createstubs
32+
A simple way to run createstubs is to use the `mpremote mount` command to allow the MCU board to directly access the PC's file system.
33+
Then you can run the createstubs.py script directly from the MCU board with outh the need to copy the created files back to the PC.
34+
35+
Navigate to the folder where you want to create the stubs and run the following command:
36+
`mpremote mount . exec "import createstubs"` or
37+
`mpremote mount . exec "import createstubs_mem"` or
38+
39+
40+
## low memory devices
41+
42+
If you have a low memory board, then you can install the cross-compiled variants to reduce the memory footprint durign compilation on the board:
43+
44+
| MicroPython release | .mpy version | command |
45+
|---------------------|--------------|---------|
46+
| v1.19 and up | 6 | `mpremote mip install github:josverl/micropython-stubber/mpy_v6.json` |
47+
| v1.12 - v1.18 | 5 | `mpremote mip install github:josverl/micropython-stubber/mpy_v5.json` |
48+
49+
```log
50+
Install github:josverl/micropython-stubber/mpy_v6.json
51+
Installing github:josverl/micropython-stubber/mpy_v6.json to /lib
52+
Installing: /lib/createstubs_mpy.mpy
53+
Installing: /lib/createstubs_db_mpy.mpy
54+
Installing: /lib/createstubs_mem_mpy.mpy
55+
Installing: /lib/modulelist.txt
56+
```
57+
**Note:** The names of the scripts have changed to createstubs_mpy.py, createstubs_db_mpy.py and createstubs_mem_mpy.py
58+
59+
Navigate to the folder where you want to create the stubs and run the following command:
60+
`mpremote mount . exec "import createstubs_db_mpy"` or
61+
`mpremote mount . exec "import createstubs_mem_mpy"`
62+
63+
## format the stubs and generate the .pyi files
64+
65+
The stubs are generated in a folder called `stubs` in the current folder.
66+
You can use stubber to run the `stubgen` tool to format the stubs and generate the .pyi files.
67+
68+
For example:
69+
```bash
70+
stubber stub -s ./stubs/micropython-v1_19_1-rp2
71+
```
72+
73+
see [MicroPython Package management](https://docs.micropython.org/en/latest/reference/packages.html?highlight=mip#package-management)

docs/45_createstubs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# createstub variants
1+
# Createstub Variants
22

33
There are multiple variants of the script available, in 3 levels of optimisation:
44

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ intro.md
1010
15_cli.rst
1111
20_creating.md
1212
40_firmware_stubs.md
13+
42_using_createstubs.md
1314
45_createstubs.md
1415
50_frozen_stubs.md
1516
55_doc_stubs.md

mip/readme.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Use MIP to install createstubs on a MCU board
2+
3+
It is possible to install the firmware stubber ( createsubs.py or one of its variants) on a MicroPython board.
4+
This allows you to create the firmware stubs on the board itself, and then copy them to your PC.
5+
6+
mip is a package manager for MicroPython. It is a command line tool that allows you to install packages on a MicroPython board.
7+
In this case it is best to use `mpremote` that has a built-in `mip` command.
8+
9+
Make sure you have the latest version of `mpremote` installed.
10+
```bash
11+
pip install mpremote
12+
```
13+
14+
## Install createstubs
15+
16+
Connect your board to your PC and run the following command:
17+
18+
`mpremote mip install github:josverl/micropython-stubber`
19+
```log
20+
Install github:josverl/micropython-stubber
21+
Installing github:josverl/micropython-stubber/package.json to /lib
22+
Installing: /lib/createstubs.py
23+
Installing: /lib/createstubs_db.py
24+
Installing: /lib/createstubs_mem.py
25+
Installing: /lib/modules.txt
26+
Done
27+
```
28+
29+
## run createstubs
30+
A simple way to run createstubs is to use the `mpremote mount` command to allow the MCU board to directly access the PC's file system.
31+
Then you can run the createstubs.py script directly from the MCU board with outh the need to copy the created files back to the PC.
32+
33+
Navigate to the folder where you want to create the stubs and run the following command:
34+
`mpremote mount . exec "import createstubs"` or
35+
`mpremote mount . exec "import createstubs_mem"` or
36+
37+
38+
## low memory devices
39+
40+
If you have a low memory board, then you can install the cross-compiled variants to reduce the memory footprint durign compilation on the board:
41+
42+
| MicroPython release | .mpy version | command |
43+
|---------------------|--------------|---------|
44+
| v1.19 and up | 6 | `mpremote mip install github:josverl/micropython-stubber/mpy_v6.json` |
45+
| v1.12 - v1.18 | 5 | `mpremote mip install github:josverl/micropython-stubber/mpy_v5.json` |
46+
47+
```log
48+
Install github:josverl/micropython-stubber/mpy_v6.json
49+
Installing github:josverl/micropython-stubber/mpy_v6.json to /lib
50+
Installing: /lib/createstubs_mpy.mpy
51+
Installing: /lib/createstubs_db_mpy.mpy
52+
Installing: /lib/createstubs_mem_mpy.mpy
53+
Installing: /lib/modulelist.txt
54+
```
55+
**Note:** The names of the scripts have changed to createstubs_mpy.py, createstubs_db_mpy.py and createstubs_mem_mpy.py
56+
57+
Navigate to the folder where you want to create the stubs and run the following command:
58+
`mpremote mount . exec "import createstubs_db_mpy"` or
59+
`mpremote mount . exec "import createstubs_mem_mpy"`
60+
61+
## format the stubs and generate the .pyi files
62+
63+
The stubs are generated in a folder called `stubs` in the current folder.
64+
you can use stubber to run the `stubgen` tool to format the stubs and generate the .pyi files.
65+
66+
```bash
67+
stubber stub -s .\stubs\micropython-v1_19_1-rp2\
68+
```
69+
70+
see [MicroPython Package management](https://docs.micropython.org/en/latest/reference/packages.html?highlight=mip#package-management)

0 commit comments

Comments
 (0)