-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Hassferter
committed
Aug 4, 2017
1 parent
11aecb8
commit 871e22a
Showing
21 changed files
with
2,344 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM ubuntu | ||
|
||
|
||
MAINTAINER ESP32-Toolchain | ||
|
||
#USER root | ||
|
||
|
||
# Update aptitude with new repo | ||
RUN apt-get update | ||
|
||
# Install software | ||
RUN apt-get install -y git | ||
RUN apt-get install git wget make libncurses-dev flex bison gperf python python-serial -y | ||
|
||
#RUN useradd -d /esp32/ -m -s /bin/bash esp32 | ||
|
||
RUN mkdir -p /home/esp | ||
|
||
# Set the working directory to ~/esp/esp-idf | ||
WORKDIR /home/esp | ||
|
||
RUN wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz | ||
RUN tar -xzf xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz | ||
|
||
|
||
#clone GIT | ||
RUN git clone --recursive https://github.com/espressif/esp-idf.git | ||
|
||
#go to example directory | ||
#WORKDIR home/esp/hello_world | ||
#RUN make -j5 | ||
# Copy the current directory contents into the container at /app | ||
#ADD . /home/app | ||
|
||
WORKDIR /home/app | ||
|
||
|
||
ENV PATH $PATH:"/home/esp/xtensa-esp32-elf/bin" | ||
ENV IDF_PATH "/home/esp/esp-idf" | ||
|
||
RUN echo $PATH | ||
RUN echo $IDF_PATH | ||
|
||
|
||
CMD /bin/bash | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a | ||
# project subdirectory. | ||
# | ||
|
||
PROJECT_NAME := hello-world | ||
#this Flag is needed for setting all additional needed as default | ||
BATCH_BUILD=1 | ||
|
||
include $(IDF_PATH)/make/project.mk | ||
|
||
|
||
build: | ||
subdirectory docker build --rm -t esp32 . | ||
|
||
esp32: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 \ | ||
-e CROSSBAR_HTTP_BRIDGE \ | ||
-e WIFI_KEY \ | ||
-e WIFI_SSID \ | ||
make -j5 # build the project | ||
|
||
esp32_monitor: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 \ | ||
make monitor # execute the monitor | ||
|
||
esp32_flash: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-e CROSSBAR_HTTP_BRIDGE \ | ||
-e WIFI_KEY \ | ||
-e WIFI_SSID \ | ||
-it esp32 \ | ||
make flash # flash the program to the chip | ||
|
||
esp32_all: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-e WIFI_KEY \ | ||
-e CROSSBAR_HTTP_BRIDGE \ | ||
-e WIFI_SSID \ | ||
-it esp32 \ | ||
make -j5 flash monitor # build and flash the program and load the monitor | ||
|
||
esp32_bash: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-e WIFI_KEY \ | ||
-e CROSSBAR_HTTP_BRIDGE \ | ||
-e WIFI_SSID \ | ||
-it esp32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Docker for ESP32 | ||
|
||
this library contains examples for working with an ESP32 and uses the IDE and the toolchain in a docker container. | ||
|
||
## What you need | ||
- a ESP-chip | ||
- [docker installed on your pc](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/) | ||
|
||
## Build docker container | ||
|
||
First thing you have to build the docker container. | ||
Clone the docker-file in a folder of your choice | ||
Run: | ||
```console | ||
make build | ||
``` | ||
it will take a while depend on your download speed and build a docker container named "esp32" | ||
|
||
## Build and flash your project | ||
|
||
There are different ways to use the makefile: | ||
|
||
```console | ||
make esp32 | ||
``` | ||
will just build your project into a folder named "build" | ||
|
||
```console | ||
make esp32_monitor | ||
``` | ||
will start the debugging serial monitor for your ESP32 only | ||
|
||
```console | ||
make esp32_flash | ||
``` | ||
will only build and flash your program to your ESP32 | ||
|
||
```console | ||
make esp32_all | ||
``` | ||
will build and flash your program and start the debug monitor after flashing | ||
|
||
|
||
```console | ||
make esp32_bash | ||
``` | ||
|
||
this will start an interactive bash environment in your docker container. this is a great thing for development cause you only have to build the whole library once you open the container. | ||
Next time it will only compile the changes you made. | ||
|
||
## Configure the Makefile | ||
|
||
of course its possible two adapt the make file for your project and there are several things you need to know: | ||
|
||
If you want to set environment variables you have to put an ```-e``` in Front of your variable name like: | ||
```console | ||
-e WIFI_KEY | ||
``` | ||
if its a known variable or | ||
```console | ||
-e WIFI_KEY ="foo" | ||
``` | ||
if its a new one | ||
|
||
if you want to avoid to be asked your project settings you have to set the make variable ```BATCH_BUILD=1``` | ||
now the IDE will set all the settings to the default values and most of the times the build will be successful | ||
If there are special settings needed there will be a error prompt and you have to run | ||
```console | ||
make esp32_bash | ||
make menuconfig | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM ubuntu | ||
|
||
|
||
MAINTAINER ESP32-Toolchain | ||
|
||
#USER root | ||
|
||
|
||
# Update aptitude with new repo | ||
RUN apt-get update | ||
|
||
# Install software | ||
RUN apt-get install -y git | ||
RUN apt-get install git wget make libncurses-dev flex bison gperf python python-serial -y | ||
|
||
#RUN useradd -d /esp32/ -m -s /bin/bash esp32 | ||
|
||
RUN mkdir -p /home/esp | ||
|
||
# Set the working directory to ~/esp/esp-idf | ||
WORKDIR /home/esp | ||
|
||
RUN wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz | ||
RUN tar -xzf xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz | ||
|
||
|
||
#clone GIT | ||
RUN git clone --recursive https://github.com/espressif/esp-idf.git | ||
|
||
#go to example directory | ||
#WORKDIR home/esp/hello_world | ||
#RUN make -j5 | ||
# Copy the current directory contents into the container at /app | ||
#ADD . /home/app | ||
|
||
WORKDIR /home/app | ||
|
||
|
||
ENV PATH $PATH:"/home/esp/xtensa-esp32-elf/bin" | ||
ENV IDF_PATH "/home/esp/esp-idf" | ||
|
||
RUN echo $PATH | ||
RUN echo $IDF_PATH | ||
|
||
|
||
CMD /bin/bash | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# | ||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a | ||
# project subdirectory. | ||
# | ||
|
||
PROJECT_NAME := hello-world | ||
|
||
BATCH_BUILD=1 | ||
include $(IDF_PATH)/make/project.mk | ||
|
||
|
||
build: | ||
sudo docker build --rm -t esp32 . | ||
|
||
esp32: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 \ | ||
make -j5 # build the project | ||
|
||
esp32_monitor: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 \ | ||
make monitor # execute the monitor | ||
|
||
esp32_flash: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 \ | ||
make flash # flash the program to the chip | ||
|
||
esp32_all: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 \ | ||
make -j5 flash monitor # build and flash the program and load the monitor | ||
|
||
esp32_bash: | ||
docker run \ | ||
--device=/dev/ttyUSB0 \ | ||
-v ${shell pwd}:/home/app \ | ||
-it esp32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Hello World Example | ||
|
||
Starts a FreeRTOS task to print "Hello World" | ||
|
||
it will be compiled and flashed with help of docker | ||
|
||
no additional environment-variables or settings needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# | ||
# "main" pseudo-component makefile. | ||
# | ||
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Hello World Example | ||
This example code is in the Public Domain (or CC0 licensed, at your option.) | ||
Unless required by applicable law or agreed to in writing, this | ||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
#include <stdio.h> | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "esp_system.h" | ||
#include "esp_spi_flash.h" | ||
|
||
|
||
void app_main() | ||
{ | ||
printf("Hello world! \n"); | ||
|
||
/* Print chip information */ | ||
esp_chip_info_t chip_info; | ||
esp_chip_info(&chip_info); | ||
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ", | ||
chip_info.cores, | ||
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", | ||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); | ||
|
||
printf("silicon revision %d, ", chip_info.revision); | ||
|
||
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), | ||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); | ||
|
||
for (int i = 10; i >= 0; i--) { | ||
printf("Restarting in %d seconds...\n", i); | ||
vTaskDelay(1000 / portTICK_PERIOD_MS); | ||
} | ||
printf("Restarting now.\n"); | ||
fflush(stdout); | ||
esp_restart(); | ||
} |
Oops, something went wrong.