#Ubuntu esp8266 serial port
Explore tagged Tumblr posts
Text
Learning Docker Crap
Look! I made a shitty container! https://github.com/amckeeota/cad01_esp8266_docker_setup
So let’s say you keep destroying your development environment because you “clearly know what you’re doing.” Maybe it’s a good idea to use docker. I don’t know man, as I see more projects I want to develop on different boards, I’m seeing how having a Dockerfile in every repo just makes sense. I get that you could put it up on a dockerhub and download it but I like the idea of getting everything you need from one place and that, for now, is from the github repo.
Just tried to learn Docker in a day which is pretty possible. It’s basically a virtual environment where you can make a bunch of changes that don’t necessarily influence your host system. It would be good for embedded development because you always need a toolchain (sometimes a specific toolchain version), certain additional software packages installed, and then, of course, the sdk.
If you don’t have those installed on your local machine, it would be nice if all you had to do was just run a set of commands and get everything set up so you don’t have to deal with that shit.
Here’s what you do.
The Model Demo
Here’s the demo repo we’ll use:
https://github.com/amckeeota/cad01_esp8266_docker_setup
You can just follow the readme or keep going down this post if you want to see what I did.
Install Docker
Do it. Here: https://docs.docker.com/engine/install/
Find Instructions to Setup your Build Environment
For my example, I’m using ESP8266 instructions but do anything.
Here’s how you setup the toolchain:
Linux: https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/linux-setup.html
Windows: https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/windows-setup.html
Mac OS: https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html
and here’s how you setup the SDK:
https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html
(Scroll past the toolchain section)
Turn the Instructions into a Dockerfile
Think of Dockerfiles like Makefiles made out of bash scripts. They basically say
“Hey, make this an Ubuntu machine. Also, Run these commands. Also, expose these ports”
You build it which gives you an image. After that, you can run that image and enter it like the Matrix.
I basically just copied all the instructions from the toolchain and SDK setup and put them into Dockerfile form.
For the toolchain, this from my Dockerfile covers all the installation instructions:
RUN apt update && apt install -y \ gcc \ git \ wget \ make \ libncurses-dev \ flex \ bison \ gperf \ python \ python-pip \ python-serial \ curl
RUN mkdir esp && \ cd esp && \ curl https://dl.espressif.com/dl/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz --output xtensa.tar.gz && \ tar -xzf xtensa.tar.gz
ENV PATH=$PATH:/esp/xtensa-lx106-elf/bin
Then the SDK portion is the next bit:
ENV IDF_PATH=/esp/ESP8266_RTOS_SDK RUN cd esp && \ python --version && \ git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git && \ cd ESP8266_RTOS_SDK && \ python -m pip install --user -r requirements.txt
And there’s a final bit to put us directly into the hello_world folder so we can check our work by running
make menuconfig
and
make flash
Alright, now build your docker image using something like this:
docker build -t dockerinit .
and run it using something like this:
docker run -v $PWD:/home --device=/dev/ttyUSB0 --rm -it dockerinit
That should put you right into the hello_world folder where you can try make menuconfig and make flash.
BAM! Done, son!
0 notes