Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DRN88/fae511ddc3089dd35fe1a31a958c7029 to your computer and use it in GitHub Desktop.
Save DRN88/fae511ddc3089dd35fe1a31a958c7029 to your computer and use it in GitHub Desktop.
Micropython esp-open-sdk build esp toolchain esp8266 espressif ubuntu 20.04

Micropython esp-open-sdk build esp toolchain esp8266 espressif ubuntu 20.04

Get sources

git clone https://github.com/micropython/micropython
git clone --recursive https://github.com/pfalcon/esp-open-sdk

Packages

sudo apt-get -y install python2 python2.7-dev make autoconf build-essential net-tools htop git wget gperf bison binutils-doc cpp-doc gcc-9-locales debian-keyring g++-multilib g++-9-multilib gcc-9-doc gcc-multilib libtool flex bison gdb gcc-doc gcc-9-multilib glibc-doc bzr libstdc++-9-doc texinfo help2man libtool libtool-bin libtool-doc libncurses-dev

Apply diff to fix bash version check

--- crosstool-NG/configure.ac	2021-08-25 19:51:42.124229514 +0000
+++ crosstool-NG/configure.ac-good	2021-08-25 19:59:30.942518084 +0000
@@ -190,7 +190,7 @@
 AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
     [AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
         [[_BASH_ver=$($ac_path__BASH --version 2>&1 \
-                     |$EGREP '^GNU bash, version (3\.[1-9]|4)')
+                     |$EGREP '^GNU bash, version ([0-9\.]+)')
           test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
         [AC_MSG_RESULT([no])
          AC_MSG_ERROR([could not find bash >= 3.1])])])

remove --dry-run to patch

user@espbuilder:~/build/esp-open-sdk# patch --dry-run -p0 < bashfix.patch 

fix missing "expat 2.1.0".

wget "https://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0-RENAMED-VULNERABLE-PLEASE-USE-2.3.0-INSTEAD.tar.gz/download" -O "expat-2.1.0.tar.gz"

# extract it from "tar.gz"
tar -xzf "expat-2.1.0.tar.gz"

# rebuild archive but as "tar.xz"
tar -cJf expat-2.1.0.tar.xz expat-2.1.0

# copy the "expat-2.1.0.tar.xz" to the proper location
mkdir -p crosstool-NG/.build/tarballs/
cp expat-2.1.0.tar.xz crosstool-NG/.build/tarballs/

# You might need to clean up before re-running make
rm -Rfv crosstool-NG/.build/src/expat-2.1.0 crosstool-NG/.build/src/.expat-2.1.0.extracting

temp swap Python to version 2

# https://github.com/pfalcon/esp-open-sdk/issues/339
cd /usr/bin/
sudo ln -sf python2 python

Build it

make # -j4

tail the build log

user1@espbuilder:~/esp-open-sdk$ tail -f crosstool-NG/build.log

After successful build, swap it back to version 3

# https://github.com/pfalcon/esp-open-sdk/issues/339
cd /usr/bin/
sudo ln -sf python3 python
...

make[4]: Leaving directory '/home/user1/esp-open-sdk/lx106-hal'
make[3]: Leaving directory '/home/user1/esp-open-sdk/lx106-hal'
make[2]: Leaving directory '/home/user1/esp-open-sdk/lx106-hal'
make[1]: Leaving directory '/home/user1/esp-open-sdk/lx106-hal'

Xtensa toolchain is built, to use it:

export PATH=/home/user1/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

Espressif ESP8266 SDK is installed, its libraries and headers are merged with the toolchain

user1@espbuilder:~/esp-open-sdk$ 
@DRN88
Copy link
Author

DRN88 commented Aug 26, 2021

Build micropython esp8266

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2.7 get-pip.py
pip2 install pyserial

# Get micropython source
git clone --recursive https://github.com/micropython/micropython
cd micropython

cd ports/esp8266

export PATH=/home/user1/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

make -j 4
user1@espbuilder:~/micropython/ports/esp8266$ make -j 4
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Create build-GENERIC/firmware-combined.bin
esptool.py v1.2
flash     32848
 .text    30720 at 0x40100000
 .data    1012 at 0x3ffe8000
 .rodata  1080 at 0x3ffe8400
padding   4016
irom0text 589736
total     626600
md5       e400e4b47b695a9bb60a31af10a2c959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment