Page 1 of 2

Downloading, Building and Deploying the Firmware

Posted: Sat Mar 05, 2016 10:58 pm
by bill
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.

Re: Downloading, Building and Deploying the Firmware

Posted: Sun Mar 06, 2016 5:09 am
by SpotlightKid
Look at the README in the esp2866 directory of the sources on Github.

Re: Downloading, Building and Deploying the Firmware

Posted: Sun Mar 06, 2016 11:08 am
by deshipu
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.

Re: Downloading, Building and Deploying the Firmware

Posted: Sun Mar 06, 2016 11:11 am
by hjm
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 ('>>>').

Re: Downloading, Building and Deploying the Firmware

Posted: Mon Mar 07, 2016 2:58 am
by bill
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

Re: Downloading, Building and Deploying the Firmware

Posted: Mon Mar 07, 2016 6:12 am
by dhylands
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

Re: Downloading, Building and Deploying the Firmware

Posted: Mon Mar 07, 2016 8:58 am
by hjm
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

Re: Downloading, Building and Deploying the Firmware

Posted: Tue Mar 08, 2016 6:14 am
by pfalcon
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.

Re: Downloading, Building and Deploying the Firmware

Posted: Tue Mar 08, 2016 7:31 am
by SpotlightKid
Just added PR #1879 to clarify the build instructions in esp8266/README.md.

Re: Downloading, Building and Deploying the Firmware

Posted: Wed Mar 09, 2016 3:20 pm
by wayne
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