Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By noop
#2487 I've been bricking modules like they were going out of style. ;-)

I was unable to dump the flash region, but was able to grab the ram snapshot:
./esptool.py --port /dev/ttyUSB3 dump_mem 0x40000000 65536 iram0.bin

AT+GMR returns 00160901 (pic has additional oem fw signatures etc.)
esp8266ex_ver2_v90_oem_fw.png


Symptoms on native Ubuntu 12.04 64bit workstation:
Both example modified AT project binaries and compiled source (git pull Nov 10) will fail to boot into running code.
Dual booting into windows for the first time in a year =) I managed to run XTCOM_UTIL.exe to attempt installing the same binary flash images. This also required power cycling the device each time it successfully completed writing the chip (pulling the RST pin low did not allow writing to the device twice in a row.) Unfortunately, this method also produced nonfunctional units at 9600/57600/115200, and will simply echo back typed characters at 115200.
Known working binary:
known_working_at_gpio_demo.zip

Compiled with SDK binary:
compiled_SDK_at_demo.zip


---------------------
./esptool.py --port /dev/ttyUSB3 write_flash 0x00000 flash.bin
Connecting...
Erasing flash...
Writing at 0x00007c00... (96 %)
Leaving...
Traceback (most recent call last):
File "./esptool.py", line 351, in <module>
esp.flash_finish(False)
File "./esptool.py", line 188, in flash_finish
raise Exception('Failed to leave Flash mode')
Exception: Failed to leave Flash mode

./esptool.py --port /dev/ttyUSB3 write_flash 0x40000 rom.bin
Connecting...
Erasing flash...
Writing at 0x00061400... (99 %)
Leaving...
Traceback (most recent call last):
File "./esptool.py", line 351, in <module>
esp.flash_finish(False)
File "./esptool.py", line 188, in flash_finish
raise Exception('Failed to leave Flash mode')
Exception: Failed to leave Flash mode

---------------------
Currently nonworking installation method used on Ubuntu 12.0.4.1 64:

sudo apt-get install git autoconf build-essential gperf bison flex texinfo libtool libncurses5-dev wget gawk libc6-dev-i386
sudo mkdir -p /opt/Espressif
sudo chown `whoami`:`whoami` /opt/Espressif

cd /opt/Espressif
git clone -b lx106 git://github.com/jcmvbkbc/crosstool-NG.git
cd crosstool-NG
./bootstrap && ./configure --prefix=`pwd` && make && make install
./ct-ng xtensa-lx106-elf
./ct-ng build

#SDK
wget -O esp_iot_sdk_v0.9.2_14_10_24.zip http://bbs.espressif.com/download/file.php?id=9
#unzip the attachment to /opt/Espressif/ESP8266_SDK/
mkdir -p /opt/Espressif/ESP8266_SDK/
cp -fr * /opt/Espressif/ESP8266_SDK/
#libs
wget -O /opt/Espressif/ESP8266_SDK/lib/libc.a https://github.com/esp8266/esp8266-wiki ... ibs/libc.a
wget -O /opt/Espressif/ESP8266_SDK/lib/libhal.a https://github.com/esp8266/esp8266-wiki ... s/libhal.a
#headers
cd /opt/Espressif/
wget -O /opt/Espressif/include.tgz https://github.com/esp8266/esp8266-wiki ... nclude.tgz
tar -xvzf include.tgz

#Legacy SDK Patch (left out for now)
wget -O esp_iot_sdk_v0.9.2_patch.rar http://bbs.espressif.com/download/file.php?id=12

#UART RX bug patch
wget -O FRM_ERR_PATCH.rar http://bbs.espressif.com/download/file.php?id=10
#1.REPLACE LIBPHY.A IN SDK/LIB
#2.ADD libpp.a SDK/LIB
cp libphy.a /opt/Espressif/ESP8266_SDK/lib/
cp libpp.a /opt/Espressif/ESP8266_SDK/lib/

#3.MODIFY
nano /opt/Espressif/ESP8266_SDK/app/Makefile
nano /opt/Espressif/ESP8266_SDK/examples/IoT_Demo/Makefile

#4.ADD "-lpp \" AS BELOW
-lgcc \
-lhal \
-lpp \
-lphy \
-lnet80211 \
-llwip \
-lwpa \
-lmain \
-lssc \
-lssl

#BOOTLOADER tool
cd /opt/Espressif/
wget -O /opt/Espressif/esptool_0.0.2.orig.tar.gz https://github.com/esp8266/esp8266-wiki ... rig.tar.gz
tar -xvzf esptool_0.0.2.orig.tar.gz
cd esptool
make clean
make

#Update Nov 10
cd /opt/Espressif/crosstool-NG
git pull
rm -rf .build/src
./ct-ng build

#Flash dump tools
mkdir -p /opt/Espressif/flashtool
cd /opt/Espressif/flashtool
git clone https://github.com/themadinventor/esptool.git
sudo pip install pyserial
sudo easy_install -U pyserial


#AT demos
cd ~/APPS
mkdir esp_sources
cd esp_sources
#AT demo v0.19 is based on SDK v0.9.2.
wget -O at_v0.19_14_10_30.zip http://bbs.espressif.com/download/file.php?id=13
unzip at_v0.19_14_10_30.zip
#comment out nano /opt/Espressif/ESP8266_SDK/include/osapi.h
//#include user_config.h

wget -O Makefile https://raw.githubusercontent.com/esp82 ... e.Makefile
#edit esptool path Makefile
#update ports, esp binary /esptool path and python tool path
ESPTOOL ?= /opt/Espressif/flashtool/esptool/esptool.py
FLASH_TOOL ?= /opt/Espressif/esptool/esptool

#add pp lib to dep
LIBS = c gcc hal pp phy net80211 lwip wpa upgrade upgrade_ssl main

make
make flash
#And another brick is born no matter which firmware flash tool was used...
=(

If anyone can verify the flash output binary images are at least functional it could eliminate possible sources of the problem.
Perhaps I was sent another module type... but they physically look like these:
http://www.electrodragon.com/w/Wi07c#Pi ... .28V090.29

Cheers,
You do not have the required permissions to view the files attached to this post.
User avatar
By jcmvbkbc
#2495
noop wrote:The repo code base compiled fine from Nov 3 to Nov 10.
...
However, I can't verify the compiled output with a working unit.

You can compare final ELF files generated by old and new toolchain. In 99.9% of cases they should be identical. If they're not please share those ELFs so I could take a look.