├── Dockerfile ├── Dockerfile-From-Scratch ├── LICENSE └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | MAINTAINER Huang Rui vowstar@gmail.com 4 | 5 | ENV PATH=/opt/xtensa-lx106-elf/bin:/opt/xtensa-esp108-elf/bin:/opt/xtensa-esp32-elf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COMPILE=gcc 6 | 7 | RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq \ 8 | && DEBIAN_FRONTEND=noninteractive apt-get install -yq \ 9 | git \ 10 | gcc \ 11 | python2.7 \ 12 | python-pip \ 13 | python-serial \ 14 | libncurses-dev \ 15 | flex \ 16 | bison \ 17 | gperf \ 18 | make \ 19 | wget \ 20 | unzip \ 21 | && git clone --recursive https://github.com/vowstar/xtensa-toolchain.git /opt/xtensa-toolchain \ 22 | && cd /opt/xtensa-toolchain \ 23 | && tar -zxvf xtensa-lx106-elf-linux64.tar.gz -C /opt/ \ 24 | && tar -zxvf xtensa-esp108-elf-linux64.tar.gz -C /opt/ \ 25 | && tar -zxvf xtensa-esp32-elf-linux64.tar.gz -C /opt/ \ 26 | && cp -rf /opt/xtensa-toolchain/library/esp8266/* /opt/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/lib/ \ 27 | && cp -rf /opt/xtensa-toolchain/include/xtensa/* /opt/xtensa-lx106-elf/xtensa-lx106-elf/include/xtensa/ \ 28 | && git clone --recursive https://github.com/igrr/esptool-ck.git /opt/esptool-ck \ 29 | && cd /opt/esptool-ck \ 30 | && make \ 31 | && mv /opt/esptool-ck/esptool /usr/local/bin/ \ 32 | && cd /opt \ 33 | && rm -rf /opt/xtensa-toolchain \ 34 | && rm -rf /opt/esptool-ck \ 35 | && pip install esptool \ 36 | && DEBIAN_FRONTEND=noninteractive apt-get purge -yq \ 37 | -h \ 38 | && DEBIAN_FRONTEND=noninteractive apt-get autoremove -yq --purge \ 39 | && DEBIAN_FRONTEND=noninteractive apt-get clean \ 40 | && rm -rf /var/lib/apt/lists/* \ 41 | && rm -rf /tmp/* 42 | -------------------------------------------------------------------------------- /Dockerfile-From-Scratch: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | MAINTAINER Huang Rui vowstar@gmail.com 4 | 5 | ENV PATH=/opt/xtensa-lx106-elf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COMPILE=gcc 6 | 7 | RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq \ 8 | && DEBIAN_FRONTEND=noninteractive apt-get install -yq \ 9 | git \ 10 | autoconf \ 11 | build-essential \ 12 | gperf \ 13 | bison \ 14 | flex \ 15 | texinfo \ 16 | libtool \ 17 | libncurses5-dev \ 18 | wget \ 19 | apt-utils \ 20 | gawk \ 21 | sudo \ 22 | unzip \ 23 | libexpat-dev \ 24 | help2man \ 25 | python2.7 \ 26 | python2.7-dev \ 27 | python-serial \ 28 | && rm -rf /opt \ 29 | && git clone --recursive https://github.com/pfalcon/esp-open-sdk.git /opt \ 30 | && useradd -M -s /bin/bash -u 1000 build \ 31 | && usermod -a -G dialout build \ 32 | && echo "build ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/build \ 33 | && chmod 0440 /etc/sudoers.d/build \ 34 | && chown -R build /opt \ 35 | && chgrp -R build /opt \ 36 | && cd /opt \ 37 | && su build -c "make STANDALONE=n" \ 38 | && rm -rf $(ls /opt/ | grep -v xtensa-lx106-elf) \ 39 | && DEBIAN_FRONTEND=noninteractive apt-get purge -yq \ 40 | git \ 41 | autoconf \ 42 | build-essential \ 43 | gperf \ 44 | bison \ 45 | flex \ 46 | texinfo \ 47 | libtool \ 48 | libncurses5-dev \ 49 | wget \ 50 | apt-utils \ 51 | gawk \ 52 | unzip \ 53 | libexpat-dev \ 54 | help2man \ 55 | python2.7-dev \ 56 | && DEBIAN_FRONTEND=noninteractive apt-get install -yq \ 57 | make \ 58 | && DEBIAN_FRONTEND=noninteractive apt-get autoremove -yq --purge \ 59 | && DEBIAN_FRONTEND=noninteractive apt-get clean \ 60 | && rm -rf /var/lib/apt/lists/* \ 61 | && rm -rf /tmp/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Huang Rui 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP32, ESP8266 and ESP8285 build environment 2 | [![Docker Pulls](https://img.shields.io/docker/pulls/vowstar/esp8266.svg)](https://hub.docker.com/r/vowstar/esp8266/) [![Docker Stars](https://img.shields.io/docker/stars/vowstar/esp8266.svg)](https://hub.docker.com/r/vowstar/esp8266/) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/vowstar/esp8266/blob/master/LICENSE) 3 | 4 | It is a build environment of espressif's Wi-Fi(or bluetooth) Soc. 5 | 6 | ## Overview 7 | 8 | ### Chip support 9 | 10 | - ESP8266 11 | - ESP8285 12 | - ESP31B 13 | - ESP32 series 14 | 15 | ESP8268 and ESP8689 not tested yet. 16 | 17 | ### Tools 18 | 19 | - xtensa-lx106-elf toolchain 20 | - xtensa-esp108-elf toolchain 21 | - xtensa-esp32-elf toolchain 22 | - esptool-ck 23 | - python and pyserial 24 | 25 | ## Usage 26 | ### Install Docker 27 | [Follow the instructions at https://docs.docker.com/engine/installation/](https://docs.docker.com/engine/installation/) 28 | 29 | ### Run 30 | 31 | Execute some command under this docker image 32 | 33 | ``docker run --rm -ti -v `pwd`:$(somewhere) vowstar/esp8266 $(somecommand)`` 34 | 35 | For example 36 | 37 | ``docker run --rm -ti -v `pwd`:/build vowstar/esp8266 /bin/bash`` 38 | 39 | This can mount host's `` `pwd` `` to container's `` /build `` path. 40 | 41 | ### Programming Hardware 42 | 43 | You could use Host's searial port to programming hardware, such as esp8266,esp32,nemu,device++, etc. 44 | 45 | If you want flash espxx in docker's container, you can export host's serial ports to container, privileged permission needed. 46 | 47 | The parameters is ``-v /dev/host:/dev/container`` 48 | 49 | For example 50 | 51 | ``docker run --name build --rm -ti --device /dev/ttyUSB0:/dev/ttyUSB0 -v `pwd`:/build vowstar/esp8266 /bin/bash`` 52 | 53 | The ``--device`` flag can export a host device in container without privileged mode. 54 | 55 | This can export host's `` /dev/ttyUSB0 `` in container's `` /dev/ttyUSB0 ``. 56 | 57 | And then, use container's esptool to program it. 58 | 59 | #### For esp8266 60 | 61 | ``esptool -cc esp8266 -cp /dev/ttyUSB0 -cd nodemcu -ca 0x00000 -cf 00000.bin -ca 0x40000 -cf 40000.bin`` 62 | 63 | #### For esp32 64 | 65 | ``esptool -cc esp32 -cp /dev/ttyUSB0 -cd nodemcu -ca 0x00000 -cf 00000.bin -ca 0x40000 -cf 40000.bin`` 66 | 67 | ## Set build environment 68 | 69 | ### For esp8266 freertos SDK 70 | 71 | You can build it with ESP_RTOS_SDK for esp8266 by define SDK_BASE environment: 72 | 73 | ``docker run -ti --name esp-builder -e SDK_BASE=/build/esp8266/ESP_RTOS_SDK/ --device /dev/ttyUSB0:/dev/ttyUSB0 -v ~/Projects/2016:/build vowstar/esp8266 /bin/bash`` 74 | 75 | Firstly, you __must__ put ``ESP_RTOS_SDK`` to ``~/Projects/2016/esp8266/ESP_RTOS_SDK`` (aka container's ``/build/esp8266/ESP_RTOS_SDK``). 76 | 77 | Then you can ``make`` your project. 78 | 79 | 80 | ### For esp32's esp-idf 81 | 82 | You can build it with ESP-IDF for esp32 by define IDF_PATH environment: 83 | 84 | ``docker run -ti --name esp-builder -e IDF_PATH=/build/esp32/esp-idf --device /dev/ttyUSB0:/dev/ttyUSB0 -v ~/Projects/2016:/build vowstar/esp8266 /bin/bash`` 85 | 86 | Firstly, you __must__ put ``ESP-IDF`` to ``~/Projects/2016/esp32/ESP-IDF`` (aka container's ``/build/32/ESP-IDF``). 87 | 88 | Then you can ``make`` or ``make menuconfig``, and use ``make flash`` to programming esp32. 89 | 90 | ### For nodemcu project and normal esp8266 project 91 | 92 | ``docker run -ti --name esp-builder --device /dev/ttyUSB0:/dev/ttyUSB0 -v ~/Projects/2016:/build vowstar/esp8266 /bin/bash`` 93 | 94 | No special setting required, just build it. 95 | 96 | 97 | ### Start and enter an old container 98 | 99 | 100 | ``` 101 | docker start esp-builder 102 | docker attach esp-builder 103 | ``` 104 | 105 | ## Special 106 | 107 | ### Export all device to container 108 | 109 | It may dangerous 110 | 111 | ``docker run --name build --rm -ti --privileged -v /dev/ttyUSB0:/dev/ttyUSB0 -v `pwd`:/build vowstar/esp8266 /bin/bash`` 112 | 113 | The ``--privileged`` flag can export all host device in container. May by you like ``--device`` flag to limit container access. 114 | 115 | ### Build esp firmware On Windows/OS X 116 | 117 | If you run docker under a VM, such as [Oracle VM VirtualBox](https://www.virtualbox.org/), the host's serial port and folder should share to VM 118 | image first. You may need share host's USB device which used as serial adapter to VM image, a VirtualBox Extension Pack is needed for USB 2.0 and USB 3.0 devices. 119 | 120 | For example, Mount `` D:\ `` drive on Windows using docker-machine in git bash 121 | 122 | - Share host's `` D:\ `` drive to docker linux images in VirtualBox, and name shared name `` d `` 123 | - Start docker image using docker machine `` docker-machine start default `` or other way 124 | - Mount vboxsf file-system using command below 125 | 126 | `` docker-machine ssh default "sudo mkdir /d && sudo mount -t vboxsf -o uid=1000,gid=50 d /d" `` 127 | 128 | And then, you can play 129 | 130 | `` docker run --rm -ti -v /d/xxx:/build -w "/build" --env "SDK_BASE=/build/ESP_RTOS_SDK/" vowstar/esp8266 bash `` 131 | 132 | `` /d/xxx `` is the host path, `` /build `` is the container PATH, use `` --env `` flag can pass some environment variable in container, such as SDK_PATH and BIN_PATH by espressif. Also you can pass something like `` --env APP=1 --env SPI_SIZE_MAP=2 --env BOOT=new `` for custom and special build. 133 | 134 | Finally, `` make `` and use esptool to program it. Before programming, make sure the host usb to serial adapter is assigned to VirtualBox's linux image. 135 | 136 | OSX is much easier, also need do same work on VirtualBox. 137 | 138 | 139 | ### Build Dockerfile From Scratch 140 | 141 | If you want build from scratch, please use [Dockerfile-From-Scratch](https://github.com/vowstar/esp8266/blob/master/Dockerfile-From-Scratch) 142 | 143 | ## Thanks 144 | This docker image uses [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk). Thanks to the maintainer and creator [Paul Sokolovsky](http://pfalcon-oe.blogspot.com/) who contributed it. 145 | 146 | This Dockerfile is learn [Marcel Stör](https://github.com/marcelstoer)'s [docker-nodemcu-build](https://github.com/marcelstoer/docker-nodemcu-build) who contributed the NodeMCU online building service. 147 | 148 | The toolchain comes from: 149 | - [Arduino ESP8266 project](https://github.com/esp8266/Arduino/blob/master/README.md) 150 | - [Arduino ESP32 project](https://github.com/me-no-dev/ESP31B) 151 | 152 | The program tool [esptool-ck](https://github.com/igrr/esptool-ck) by Christian Klippel, which can programming both esp8266,esp8285 and esp32. 153 | --------------------------------------------------------------------------------