Problem on building ESP8266 port's firmware

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Kowa92
Posts: 18
Joined: Fri Apr 03, 2020 7:39 pm
Location: Italy

Problem on building ESP8266 port's firmware

Post by Kowa92 » Sat Apr 18, 2020 6:03 pm

Hi all!

I'm trying to build a fresh MicroPython firmware for ESP8266 using Ubuntu 18.04. I follow these tutorials:

1. https://github.com/pfalcon/esp-open-sdk
2. https://github.com/micropython/micropyt ... ng-Started
3. https://github.com/micropython/micropyt ... ts/esp8266

and

4. https://youtu.be/jG7WBY_vmpE

The build of MicroPython firmware for unix systems works well.. instead the one for ESP8266 doesn't work correctly. Once i flashed the firmware just compiled (firmware-combined.bin) into ESP8266 through esptool.py, i cannot upload any files to its file system:
Thonny.PNG
Thonny.PNG (35.59 KiB) Viewed 5321 times
While the correct behavior with your official firmware (esp8266-20191220-v1.12.bin) is:
Thonny1.PNG
Thonny1.PNG (36.48 KiB) Viewed 5321 times

-> The question is: Where i'm wrong? :roll:
-> Has anyone else ever experienced this problem?


NB: For transfer the firmware into ESP8266 i used the tecnique of drag and drop the "firmware-combined.bin" from VM to host. After i flashed it using esptool.py (i'dont use the command "make deploy"). See https://youtu.be/jG7WBY_vmpE?t=1775

PS: I noticed that the "make axtls" command does not work on ports/unix (says: make: Nothing to be done for 'axtls'.) or ports/esp8266 (says make: *** No rule to make target 'axtls'. Stop.).

PSS: These commands "make -C ports/esp8266 submodules" and "make -C mpy-cross" after the build of unix port doesn't do anything (doesn't take effect) on esp8266 port.

Thanks to all!

Greetings

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Problem on building ESP8266 port's firmware

Post by jimmo » Sat Apr 18, 2020 11:34 pm

Which build process are you using. I strongly recommend the docker approach in the third link your provided.

How are you accessible the device filesystem? Is that Thonny?

What if you try and access the filesystem from the repl instead? (i.e. "import os", os.listdir() etc, and reading writing files with open() ).

I wonder if this is somehow related to LittleFS which is now the default on ESP8266 (it wasn't on the 1.12 release).

Did you do an erase_flash first before flashing your build firmware-combined image?

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Problem on building ESP8266 port's firmware

Post by bitninja » Sun Apr 19, 2020 12:01 am

Hi,

You should be seeing the exact same thing when you load your own .bin, so there must be something going awry there.

They have updated the build process somewhat since the first video was made... (I should know... I'm the one who made it! :o)

Yes, you no longer have to build AXTLS separately.

I would check against these steps... in case you missed anything...
Should yield you a valid firmware-combined.bin

One thing to note that you are pulling the latest this way which may or may not be what you want.

GL

Kowa92
Posts: 18
Joined: Fri Apr 03, 2020 7:39 pm
Location: Italy

Re: Problem on building ESP8266 port's firmware

Post by Kowa92 » Sun Apr 19, 2020 12:40 pm

jimmo wrote:
Sat Apr 18, 2020 11:34 pm
Which build process are you using. I strongly recommend the docker approach in the third link your provided.
First i used virtualenv on VMware with Ubuntu 19.04 but doesn't work.. After i used only Ubuntu 18.04.. the same bankruptcy results.
jimmo wrote:
Sat Apr 18, 2020 11:34 pm
How are you accessible the device filesystem? Is that Thonny?
Yes, it is Thonny IDE for Windows
jimmo wrote:
Sat Apr 18, 2020 11:34 pm
What if you try and access the filesystem from the repl instead? (i.e. "import os", os.listdir() etc, and reading writing files with open() ).
This is what happens:
Cattura.PNG
Cattura.PNG (20.99 KiB) Viewed 5282 times
jimmo wrote:
Sat Apr 18, 2020 11:34 pm
I wonder if this is somehow related to LittleFS which is now the default on ESP8266 (it wasn't on the 1.12 release).
What do you mean with this sentence?
jimmo wrote:
Sat Apr 18, 2020 11:34 pm
Did you do an erase_flash first before flashing your build firmware-combined image?
Obviously yes

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Problem on building ESP8266 port's firmware

Post by jimmo » Sun Apr 19, 2020 12:53 pm

Kowa92 wrote:
Sun Apr 19, 2020 12:40 pm
jimmo wrote:
Sat Apr 18, 2020 11:34 pm
I wonder if this is somehow related to LittleFS which is now the default on ESP8266 (it wasn't on the 1.12 release).
What do you mean with this sentence?
https://github.com/micropython/micropython/pull/5803

So perhaps one thing you could try is to checkout the v1.12 tag and see if that works.

Kowa92
Posts: 18
Joined: Fri Apr 03, 2020 7:39 pm
Location: Italy

Re: Problem on building ESP8266 port's firmware

Post by Kowa92 » Sun Apr 19, 2020 1:24 pm

bitninja wrote:
Sun Apr 19, 2020 12:01 am
They have updated the build process somewhat since the first video was made... (I should know... I'm the one who made it! :o)
Hello, nice to hear you. Thanks for your well-done video tutorial.
bitninja wrote:
Sun Apr 19, 2020 12:01 am
I do exactly these steps in this order (they are slightly different from yours):
  • sudo apt-get install make unrar-free autoconf automake libtool gcc g++ gperf \
    flex bison texinfo gawk ncurses-dev libexpat-dev python-dev python python-serial \
    sed git unzip bash help2man wget bzip2 libtool-bin
  • git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
  • cd esp-open-sdk
  • make
  • export PATH=/home/vm-user/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
  • cd ..
  • sudo apt-get install build-essential libreadline-dev libffi-dev git pkg-config gcc-arm-none-eabi libnewlib-arm-none-eabi
  • git clone --recurse-submodules https://github.com/micropython/micropython.git
  • cd micropython/mpy-cross
  • make
  • cd ..
  • cd ports/unix
  • make
  • export PATH="$HOME/micropython/ports/unix:$PATH"
  • cd ..
  • cd esp8266/
  • make
And finally i've uploaded the file "ports/esp8266/build-GENERIC/firmware-combined.bin" (exported from VM to host) through esptool.py on Windows to my ESP8266:
Cattura.PNG
Cattura.PNG (49.45 KiB) Viewed 5273 times
- In your opinion, are the steps mentioned above all correct?
- Is there something wrong?
Last edited by Kowa92 on Sun Apr 19, 2020 3:20 pm, edited 1 time in total.

Kowa92
Posts: 18
Joined: Fri Apr 03, 2020 7:39 pm
Location: Italy

Re: Problem on building ESP8266 port's firmware

Post by Kowa92 » Sun Apr 19, 2020 2:33 pm

jimmo wrote:
Sun Apr 19, 2020 12:53 pm
Kowa92 wrote:
Sun Apr 19, 2020 12:40 pm
jimmo wrote:
Sat Apr 18, 2020 11:34 pm
I wonder if this is somehow related to LittleFS which is now the default on ESP8266 (it wasn't on the 1.12 release).
What do you mean with this sentence?
https://github.com/micropython/micropython/pull/5803

So perhaps one thing you could try is to checkout the v1.12 tag and see if that works.
What do you mean with "v1.12 tag"? How can i do to do that?

---------

Maybe, if i well understood, i must update the ESP8266' filesystem from FAT to littleFSv2, right?

As dpgeorge said to https://github.com/micropython/micropython/pull/5803:
This PR changes the esp8266 boards to use littlefs v2 as the filesystem, rather than FAT. Since the esp8266 doesn't expose the filesystem to the PC over USB there's no strong reason to keep it as FAT. Littlefs is smaller in code size, is more efficient in use of flash to store data, is resilient over power failure, and using it saves about 4k of heap RAM, which can now be used for other things.

This is a backwards incompatible change because all existing esp8266 boards will need to update their filesystem after installing new firmware (ie backup old files, install firmware, restore files to new filesystem).
- "PR" stands for?

Anyway, if the response is yes, i have two choices to do that (in my case):
- Actually, what is the default option when i build a MicroPyhton v.12 firmware with "make" command without option? Maybe the "GENERIC_2M" one?

Thanks

Kowa92
Posts: 18
Joined: Fri Apr 03, 2020 7:39 pm
Location: Italy

* UPDATE *

Post by Kowa92 » Sun Apr 19, 2020 2:38 pm

Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
Anyway, if the response is yes, i have two choices to do that (in my case):
This doesn't seems to work.. :(
Cattura.PNG
Cattura.PNG (19.99 KiB) Viewed 5255 times

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Problem on building ESP8266 port's firmware

Post by jimmo » Sun Apr 19, 2020 2:44 pm

Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
What do you mean with "v1.12 tag"? How can i do to do that?

Code: Select all

git checkout v1.12
(And then do a "make submodules" to update the submodules)
Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
Maybe, if i well understood, i must update the ESP8266' filesystem from FAT to littleFSv2, right?
This is why I asked about erase_flash. If you've erased the flash then on first boot MicroPython will create the LittleFS filesystem.
Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
- "PR" stands for?
Pull Request (i.e. a set of changes for review -- https://help.github.com/en/github/colla ... l-requests )
Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
Actually, what is the default option when i build a MicroPyhton v.12 firmware with "make" command without option? Maybe the "GENERIC_2M" one?
Yes the default is "GENERIC" which is the 2MiB version. If you only have 1MiB of flash on your board, then you need to use BOARD=GENERIC_1M.

Sounds like we need to update esp8266/README.md to explain this.

Kowa92
Posts: 18
Joined: Fri Apr 03, 2020 7:39 pm
Location: Italy

Re: Problem on building ESP8266 port's firmware

Post by Kowa92 » Sun Apr 19, 2020 4:35 pm

jimmo wrote:
Sun Apr 19, 2020 2:44 pm
Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
What do you mean with "v1.12 tag"? How can i do to do that?

Code: Select all

git checkout v1.12
If i want to change (clone from git too) previous version of MicroPython, how can i do?
jimmo wrote:
Sun Apr 19, 2020 2:44 pm
Kowa92 wrote:
Sun Apr 19, 2020 2:33 pm
Actually, what is the default option when i build a MicroPyhton v.12 firmware with "make" command without option? Maybe the "GENERIC_2M" one?
Yes the default is "GENERIC" which is the 2MiB version. If you only have 1MiB of flash on your board, then you need to use BOARD=GENERIC_1M.

Sounds like we need to update esp8266/README.md to explain this.
Yes, this is my problem! Once i re-build the ESP8266 firmware i used the "make BOARD=GENERIC_1M", re-flashed it into my ESP8266 and now all works fine! :D So the problem was that. :roll:

PS: Yes, for me you should update esp8266/README.md and write that from the newer version of MicroPhthon (> 1.12), the default memory size building is 2 MiB (if you omit to put option on "make" command).

Post Reply