Downloading, Building and Deploying the Firmware

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
bill
Posts: 2
Joined: Sat Mar 05, 2016 10:44 pm

Downloading, Building and Deploying the Firmware

Post by bill » Sat Mar 05, 2016 10:58 pm

Could someone please outline the process of downloading, building then deploying the firmware for a beginner?

There are probably a lot of people like me that have used the Arduino IDE to program the Huzzah/ESP8266 but would like to begin to learn how to install the MicroPython firmware in preparation for future releases.

SpotlightKid
Posts: 377
Joined: Wed Apr 08, 2015 5:19 am

Re: Downloading, Building and Deploying the Firmware

Post by SpotlightKid » Sun Mar 06, 2016 5:09 am

Look at the README in the esp2866 directory of the sources on Github.

User avatar
deshipu
Posts: 1342
Joined: Thu May 28, 2015 5:54 pm

Re: Downloading, Building and Deploying the Firmware

Post by deshipu » Sun Mar 06, 2016 11:08 am

You can also try this tutorial: https://learn.adafruit.com/building-and ... e-esp8266/
Except the wifi example at the end doesn't work anymore, because things got moved around and renamed.

hjm
Posts: 5
Joined: Sat Mar 05, 2016 12:42 pm

Re: Downloading, Building and Deploying the Firmware

Post by hjm » Sun Mar 06, 2016 11:11 am

bill wrote:Could someone please outline the process of downloading, building then deploying the firmware for a beginner?

There are probably a lot of people like me that have used the Arduino IDE to program the Huzzah/ESP8266 but would like to begin to learn how to install the MicroPython firmware in preparation for future releases.
@Bill, yes was same for me. What is important to realize is that there are crucial steps involved before trying to compile the MicroPython code. AdaFruit has a tutorial on how to set up MicroPython on their Huzzah boards:

Since I'm working from Linux machines didn't find that very helpful.

For setting up the ESP SDK I've used this tutorial (steps 1-3).

This could take a while to compile (over 2 hours on my RPi3, around half an hour I think on my Ubuntu 15.04 Nuc).

Then I did a 'git clone' from Github MicroPython repo:

Code: Select all

git clone git@github.com:micropython/micropython.git
cd micropython/
git submodule update --init
At first I did not read the instructions carefully, and forgot that last line, similar to another poster on this subforum.

On my Ubuntu box I had a collision between Python2 and Python3 (that was specific to my own setup), which I solved by simply changing the 'shebang' from the /opt/esp-open-sdk/esptool/esptool.py script to point explicitly to Python2.

After that everything ran smooth:

Code: Select all

cd esp8266/
make
make PORT=/dev/ttyUSB0 deploy 
Obviously you should check for the port where your machine finds the ESP8266 module. And unless you're using the Huzzah Feather board, you need to put the to put the board in bootload mode. But both these things will be similar to when working with the Arduino IDE.

Connecting to the REPL can be done with 'screen' on Linux machines:

Code: Select all

screen /dev/ttyUSB0 115200
You'll get a completely blank terminal. Don't forget to press enter one more time to get the prompt ('>>>').

bill
Posts: 2
Joined: Sat Mar 05, 2016 10:44 pm

Re: Downloading, Building and Deploying the Firmware

Post by bill » Mon Mar 07, 2016 2:58 am

hjm,
I am using a Debian Jessie 8.3 system. So I skipped the Rpi instructions in the Instuctables and started at sudo apt-get update.
That part seemed to go well.

I've got this point in your instructions:

Code: Select all

git clone git@github.com:micropython/micropython.git
and this is the error I got:

Code: Select all

bill@debian:/opt/esp-open-sdk$ git clone git@github.com:micropython/micropython.git
Cloning into 'micropython'...
Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
I have entered that line both as a user and root with no success. I do have access rights to all the files in the esp-open-sdk folder.

I'm not sure what to do next.
Thanks for your help,
Bill

User avatar
dhylands
Posts: 3067
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Downloading, Building and Deploying the Firmware

Post by dhylands » Mon Mar 07, 2016 6:12 am

bill wrote:hjm,
I've got this point in your instructions:

Code: Select all

git clone git@github.com:micropython/micropython.git
That's the SSH URL which is only usable if you have write permissions to the micropython repo (you don't). You need to use the HTTPS URL instead, which is: https://github.com/micropython/micropython.git.

So use:

Code: Select all

git clone https://github.com/micropython/micropython.git

hjm
Posts: 5
Joined: Sat Mar 05, 2016 12:42 pm

Re: Downloading, Building and Deploying the Firmware

Post by hjm » Mon Mar 07, 2016 8:58 am

bill wrote: I am using a Debian Jessie 8.3 system. So I skipped the Rpi instructions in the Instuctables
You'll need to build the ESP SDK first. Although written for RPi, these instructions should work for your Debian system as well.
bill wrote: I've got this point in your instructions:

Code: Select all

git clone git@github.com:micropython/micropython.git
As dhylands remarks, indeed doing it through ssh might be vulnerable for configuration issues. using the https option is more robust. Sorry, I overlooked this aspect.

hjm

pfalcon
Posts: 1143
Joined: Fri Feb 28, 2014 2:05 pm

Re: Downloading, Building and Deploying the Firmware

Post by pfalcon » Tue Mar 08, 2016 6:14 am

Please note that official documentation on how to build both esp-open-sdk and MicroPython are in their respective README files (for MicroPython, both the main README and port-specific README). If some important information is missing, feel free to suggest additions via bug tracker of the respective projects. Please mind that while it may seem that the more information is written, the better, the reality is the opposite - the more written, the less likely people will read it - either in full, or at all. Both projects have pretty long README's already, so any additions should come with strong argumentation ;-).

All other information you find on the Internet is unofficial, oftentimes duplicate information, getting out of date quickly. Feel free to use it at your own risk (please report any issues you find while following it to their original authors, not to us). If you decide to write your own guide, as a courtesy to other users, please explicitly say that it's not official instructions, link to the official ones, and state which date/version/git revision it applies to. Thanks.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

SpotlightKid
Posts: 377
Joined: Wed Apr 08, 2015 5:19 am

Re: Downloading, Building and Deploying the Firmware

Post by SpotlightKid » Tue Mar 08, 2016 7:31 am

Just added PR #1879 to clarify the build instructions in esp8266/README.md.

wayne
Posts: 5
Joined: Wed Mar 09, 2016 2:58 pm

Re: Downloading, Building and Deploying the Firmware

Post by wayne » Wed Mar 09, 2016 3:20 pm

deshipu wrote:You can also try this tutorial: https://learn.adafruit.com/building-and ... e-esp8266/
Except the wifi example at the end doesn't work anymore, because things got moved around and renamed.
In addition, because those instructions install esptool into the host os, if you want to flash the binary from within the VM, then you need to:

1. install the VirtualBox Extension Pack and add the USB device in the VirtualBox GUI for the VM (the VM must be off and the ESP board must be plugged in)

2. Follow Adafruits guide on installing esptool.py, but do it in the guest Ubuntu OS and not your host OS

3. Install the (optional) usbserial and cp210x drivers by running:

Code: Select all

sudo apt-get install linux-image-extra-virtual
4. (Re)Insert the ESP USB cable.

5. Determine the /dev/tty* name of the serial port run:

Code: Select all

ls /sys/bus/usb-serial/devices/
6. Refer back to Adafruit tutorial on installing esptool.py, https://learn.adafruit.com/building-and ... h-firmware


Then after every

Code: Select all

cd /home/vagrant/micropython/esp8266
git pull
make
you can just do something like the following to flash from within the VM:

Code: Select all

sudo esptool.py -p /dev/ttyUSB0 write_flash 0x00 build/firmware-combined.bin
or just

Code: Select all

sudo make PORT=/dev/ttyUSB0 deploy
Note, I had to re-insert the USB cable before the above command would work for me.


Once the firmware is uploaded following command will connect to micropython on the ESP board and give you the REPL prompt :

Code: Select all

sudo screen /dev/ttyUSB0 115200
To exit:

Code: Select all

CTRL-A CTRL-D
Last edited by wayne on Thu Mar 10, 2016 3:00 pm, edited 1 time in total.

Post Reply