Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work?

Post by Jibun no kage » Mon Aug 15, 2022 8:36 pm

Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work? Every one I have tried either crashes trying to create the tool chain (or chokes on some thing odd, like bash 3.1 not found when bash 5.1 is installed. I was able to create the MicroPython Unix port as illustrated below but when I try to build the esp8266 port with default board GENERIC, crashed again.

// Custom MicroPython Firmware Image
//
// Add Custom Scripts To ./micropython/ports/esp8266/modules/ Folder
//

# cd /data
# apt-get install build-essential libffi-dev git pkg-config
# apt-get install make unrar-free autoconf automake libtool gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python3-dev python3 python3-serial sed git unzip bash help2man wget bzi
# apt-get install libtool-bin

# git clone https://github.com/micropython/micropython
# cd micropython
# cd mpy-cross
# pwd
/data/micropython/mpy-cross

// The mpy-cross is build for the host system, not the target platform
# make
[...]
LINK build/mpy-cross
text data bss dec hex filename
303644 17168 856 321668 4e884 build/mpy-cross

# cd ..
# pwd

// Build MicroPython Unix Port...
# python3 -V
Python 3.9.2
# gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# cd ports/unix
# make submodules
# make
LINK build-standard/micropython
text data bss dec hex filename
537161 59000 2288 598449 921b1 build-standard/micropython

# cd build-standard/micropython
# ./micropython
MicroPython v1.19.1-284-ga16a330da on 2022-08-15; linux [GCC 10.2.1] version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> print('Goodbye, And Thanks For All The Fish!')
Goodbye, And Thanks For All The Fish!

How to I build the generic esp8266 port?

# cd /data/micropython/ports/esp8266
# make submodules
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Updating submodules: lib/axtls lib/berkeley-db-1.xx lib/micropython-lib
Synchronizing submodule url for '../../lib/axtls'
Synchronizing submodule url for '../../lib/berkeley-db-1.xx'
Synchronizing submodule url for '../../lib/micropython-lib'

Need xtensa?

// Get xtensa?
# cd /data
# wget https://dl.espressif.com/dl/xtensa-lx10 ... d64.tar.gz
--2022-08-15 12:54:11-- https://dl.espressif.com/dl/xtensa-lx10 ... d64.tar.gz
Resolving dl.espressif.com (dl.espressif.com)... 13.226.225.34, 13.226.225.64, 13.226.225.74, ...
Connecting to dl.espressif.com (dl.espressif.com)|13.226.225.34|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 88885561 (85M) [application/gzip]
Saving to: ‘xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz’
xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux- 100%[===========================================================================================>] 84.77M 23.5MB/s in 4.6s
2022-08-15 12:54:17 (18.6 MB/s) - ‘xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz’ saved [88885561/88885561]

# mkdir esp
# cd esp
# tar -xzf /data/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz
# ls -l
total 4
drwxr-xr-x 8 root root 4096 Sep 21 2020 xtensa-lx106-elf
# nano ~/.profile
// Add...
export PATH="$PATH:/data/esp/xtensa-lx106-elf/bin"
// Logout Then Login...
# printenv PATH

Try again...

// Build MicroPython ESP8266 Port...
# cd ports/esp8266
# make submodules
# make
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build-GENERIC/genhdr/qstr.i.last
xtensa-lx106-elf-gcc: error: unrecognized command line option '-mforce-l32'; did you mean '--force-link'?

Clearly I am missing something! Help! Thanks. Want to create a firmware image that has just enough MicroPython to support UART and asyncio based MQTT, i.e. let me use mqtt_as module.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work?

Post by Roberthh » Tue Aug 16, 2022 6:29 am

I tried the compile and it worked. Which version of the xtensa gcc compiler do you use? Mine is:

esp-open-sdk$ xtensa-lx106-elf-gcc --version
xtensa-lx106-elf-gcc (crosstool-NG crosstool-ng-1.22.0-60-g37b07f6f) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Edit:
What is the result of:

which xtensa-lx106-elf-gcc

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work?

Post by stijn » Tue Aug 16, 2022 6:39 am

Jibun no kage wrote:
Mon Aug 15, 2022 8:36 pm
Looked at 10s of examples of how to compile esp8266 firmware
Did you check the official one, https://github.com/micropython/micropyt ... ts/esp8266? Or alternatively https://github.com/micropython/micropyt ... ci.sh#L154 also works fine.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work?

Post by pythoncoder » Tue Aug 16, 2022 8:44 am

Follow the official instructions using docker with the pre-built toolchain.
Peter Hinch
Index to my micropython libraries.

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: Looked at 10s of examples of how to compile esp8266 firmware, and none of them actually work?

Post by Jibun no kage » Wed Aug 17, 2022 2:02 am

Thanks for the links... Apparently I never found those via Google... likely lost in the noise of what I found?

Post Reply