@@ -27,60 +27,116 @@ Documentation is available at http://docs.micropython.org/en/latest/esp8266/quic
27
27
Build instructions
28
28
------------------
29
29
30
- You need the esp-open-sdk toolchain (which provides both the compiler and libraries), which
31
- you can obtain using one of the following two options:
32
-
33
- - Use a Docker image with a pre-built toolchain (** recommended** ).
34
- To use this, install Docker, then prepend
35
- ` docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk ` to the start
36
- of the mpy-cross and firmware ` make ` commands below. This will run the commands using the
37
- toolchain inside the container but using the files on your local filesystem.
38
-
39
- - or, install the esp-open-sdk directly on your PC, which can be found at
40
- < https://github.com/pfalcon/esp-open-sdk > . Clone this repository and
41
- run ` make ` in its directory to build and install the SDK locally. Make sure
42
- to add toolchain bin directory to your PATH. Read esp-open-sdk's README for
43
- additional important information on toolchain setup.
44
- If you use this approach, then the command below will work exactly.
45
-
46
- Add the external dependencies to the MicroPython repository checkout:
30
+ You need the esp-open-sdk toolchain, which provides both the compiler and libraries.
31
+
32
+ There are two ways to do this:
33
+ - By running the toolchain in [ Docker] ( https://www.docker.com/ ) (** recommended** ).
34
+ - By installing a pre-built toolchain and adding it to your ` $PATH ` .
35
+
36
+ Regardless of which toolchain you use, the first step is to make sure required
37
+ submodules are available:
38
+
47
39
``` bash
48
40
$ make -C ports/esp8266 submodules
49
41
```
42
+
50
43
See the README in the repository root for more information about external
51
44
dependencies.
52
45
53
- The MicroPython cross-compiler must be built to pre-compile some of the
54
- built-in scripts to bytecode. This can be done using:
46
+ __ Building with Docker__
47
+
48
+ Once you have installed Docker, you can run all of the following build
49
+ commands inside the Docker container by prefixing them with `docker
50
+ run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk ...command...`.
51
+ This will automatically download the Docker image provided by @larsks which
52
+ contains the full toolchain and SDK.
53
+
54
+ Then you need to compile the MicroPython cross-compiler (` mpy-cross ` ). From
55
+ the root of this repository, run:
56
+
55
57
``` bash
56
- $ make -C mpy-cross
58
+ $ docker run --rm -v $HOME :$HOME -u $UID -w $PWD larsks/esp-open-sdk make -C mpy-cross
59
+ ```
60
+
61
+ ** Note:** The ` mpy-cross ` binary will likely only work inside the Docker
62
+ container. This will not be a problem if you're only building ESP8266
63
+ firmware, but if you're also working on other ports then you will need to
64
+ recompile for your host when switching between ports. To avoid this, use
65
+ the local toolchain instead.
66
+
67
+ Then to compile the ESP8266 firmware:
68
+
69
+ ```
70
+ $ cd ports/esp8266
71
+ $ docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make -j BOARD=GENERIC
72
+ ```
73
+
74
+ This will produce binary images in the ` build-GENERIC/ ` subdirectory.
75
+ Substitute the board for whichever board you're using.
76
+
77
+ __ Building with a local toolchain__
78
+
79
+ First download the pre-built toolchain (thanks to @jepler from Adafruit). You
80
+ will need to find somewhere to put it in your filesystem, e.g. ` ~/espressif ` .
81
+ Create that directory first if necessary.
82
+
83
+ ```
84
+ $ cd ~/espressif # Change as necessary
85
+ $ wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz
86
+ $ tar zxvf xtensa-lx106-elf-standalone.tar.gz
87
+ $ rm xtensa-lx106-elf/bin/esptool.py # Use system version of esptool.py instead.
88
+ ```
89
+
90
+ Then append this to your ` $PATH ` variable so the compiler binaries can be
91
+ found:
92
+
93
+ ```
94
+ $ export "PATH=$HOME/espressif/xtensa-lx106-elf/bin/:$PATH"
57
95
```
58
- (Prepend the Docker command if using Docker, see above)
59
96
60
- Then, to build MicroPython for the ESP8266, just run:
97
+ (You will need to do this each time you start a new terminal)
98
+
99
+ Then you need to compile the MicroPython cross-compiler (` mpy-cross ` ). From
100
+ the root of this repository, run:
101
+
61
102
``` bash
103
+ $ make -C mpy-cross
104
+ ```
105
+
106
+ Then to compile the ESP8266 firmware:
107
+
108
+ ```
62
109
$ cd ports/esp8266
63
- $ make
110
+ $ make -j BOARD=GENERIC
64
111
```
65
- (Prepend the Docker command if using Docker, see above)
66
112
67
- This will produce binary images in the ` build-GENERIC/ ` subdirectory. If you
68
- install MicroPython to your module for the first time, or after installing any
69
- other firmware, you should erase flash completely:
113
+ This will produce binary images in the ` build-GENERIC/ ` subdirectory.
114
+ Substitute the board for whichever board you're using.
115
+
116
+
117
+ Installing MicroPython
118
+ ----------------------
119
+
120
+ To communicate with the board you will need to install ` esptool.py ` . This can
121
+ be obtained from your system package manager or from PyPi via ` pip ` .
122
+
123
+ If you install MicroPython to your module for the first time, or after
124
+ installing any other firmware, you should erase flash completely:
125
+
70
126
``` bash
71
127
$ esptool.py --port /dev/ttyXXX erase_flash
72
128
```
73
129
74
- You can install esptool.py either from your system package manager or from PyPi.
75
-
76
130
Erasing the flash is also useful as a troubleshooting measure, if a module doesn't
77
131
behave as expected.
78
132
79
133
To flash MicroPython image to your ESP8266, use:
80
134
``` bash
81
135
$ make deploy
82
136
```
83
- (This should not be run inside Docker as it will need access to the serial port.)
137
+
138
+ (If using the Docker instructions above, do not run this command via Docker as
139
+ it will need access to the serial port. Run it directly instead.)
84
140
85
141
This will use the ` esptool.py ` script to download the images. You must have
86
142
your ESP module in the bootloader mode, and connected to a serial port on your PC.
0 commit comments