Olimex Support Forum

Microcontrollers => ESP8266 => Topic started by: meinereiner on December 19, 2016, 10:39:26 am

Title: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 10:39:26 am
Hi,

I'm experimenting with the "olimex-iot-firmware-esp8266" and as a start I just want to build and deploy a version.

When I just deploy a prebuild version, everything is working like a charm:
esptool/esptool.py --baud 576000 write_flash 0x00000 bin/boot_v1.5.bin 0x01000 bin/upgrade/EVB_ONLY/user1.2048.new.3.bin 0x81000 bin/upgrade/EVB_ONLY/user2.2048.new.3.bin 0x100000 bin/blank.bin 0x1FC000 bin/esp_init_data_default.bin 0x1FE000 bin/blank.bin --flash_size 16m
The board boots up and I can connect to it an use the REST interface.

When I'm taking the source code as it is from GitHub and just build it:
make clean && make APP=1 && make APP=2
(I do not build it for a specific device, I habe also tested it to build up for EVB_ONLY)
Then uploading it:
esptool/esptool.py --baud 576000 write_flash 0x00000 bin/boot_v1.5.bin 0x01000 bin/upgrade/user1.2048.new.3.bin 0x81000 bin/upgrade/user2.2048.new.3.bin 0x100000 bin/blank.bin 0x1FC000 bin/esp_init_data_default.bin 0x1FE000 bin/blank.bin --flash_size 16m
From the serial console it doesn't look strange so far. I only do not see the Wifi. When I reboot the device endy up in an endless loop.

I have also tried to upload user2 via the HTTP. Same.
I also tried just to upload the two newly build files. Same.

What am I doing wrong?
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: JohnS on December 19, 2016, 11:06:07 am
Is the one that fails bigger (for example)?

Otherwise you could use diff etc to find what's changed.

John
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 01:41:17 pm
Can you compare your binaries with those from https://github.com/OLIMEX/olimex-iot-firmware-esp8266/tree/master/bin/upgrade/EVB_ONLY

Are they the same or different?

How you setup your toolchain?

I'm currently using https://github.com/pietrushnic/esp-open-sdk
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 02:14:55 pm
Thanks for your answers!

I'm currently using a docker image to build the files:
https://github.com/vowstar/esp8266
https://hub.docker.com/r/vowstar/esp8266/
I had some issues on local installation on conflicting libraries on my machine so I've chossen the docker image.

I have configured the SDK_BASE manually to ensure that I'm using the sources of 2.0.

Why so ever, the reulting bin files do differ (compared to https://github.com/OLIMEX/olimex-iot-firmware-esp8266/tree/master/bin/upgrade/EVB_ONLY) when I build it by my own.

Any idea why?
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 02:31:42 pm
I had similar issues when moving my environment to a different computer. I tried using toolchain from https://github.com/pfalcon/esp-open-sdk and result was the same you describe.

Using https://github.com/pietrushnic/esp-open-sdk solved my problem.
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 02:36:58 pm
@PeterW: Thanks for your hint. I will give it a try.
Stupid question: Did you just clone it and set the PATH variables correctly or did you do other things as well?
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 02:51:03 pm
As I remember

1. I cloned it
2. build it make STANDALONE=y (it took about 25-30 minutes)
3. manually set the path.
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 03:34:39 pm
Ok I have checked it out and compited it again and uploaded via website just user2. Same.

By the way: old way as well as new way tells me when I upload in the last line on the console a wdt reset:


ets Jan  8 2013,rst cause:1, boot mode:(1,7)


ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 03:50:24 pm
Can you try

esptool/esptool.py \
--port /dev/ttyUSB0 \
--baud 576000 \
write_flash \
0x00000  bin/boot_v1.6.bin \
0x01000  bin/upgrade/user1.2048.new.3.bin \
0x81000  bin/upgrade/user2.2048.new.3.bin \
0x100000 bin/blank.bin \
0x101000 bin/blank.bin \
0x102000 bin/blank.bin \
0x103000 bin/blank.bin \
0x1FC000 bin/esp_init_data_default.bin \
0x1FE000 bin/blank.bin \
--flash_size 16m


There are some changes in esp_init_data_default.bin for version 2.0.0 of the SDK
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 04:11:15 pm
Unfortuantely the same...

The new flash script doesn't accept "--flash_size 16m" anymore.

Just to sum it up again what I did:
- I have downloaded and build the toolchain with the link mentioned above (esp-open-sdk). I added that path where the toolchain is to the PATH
- I have checked out the Olimex project from github
- I placed the SDK 2.0 in the tools folder
- I have build APP=1
make SDK_BASE=".../tools/ESP8266_SDK" FLAVOR="release" APP=1
- I have build APP=2
make SDK_BASE=".../tools/ESP8266_SDK" FLAVOR="release" APP=2
- I have uploaded:
.../esp-open-sdk/esptool/esptool.py --port /dev/ttyUSB0 --baud 576000 write_flash 0x00000  bin/boot_v1.6.bin 0x01000  bin/upgrade/user1.2048.new.3.bin 0x81000  bin/upgrade/user2.2048.new.3.bin 0x100000 bin/blank.bin 0x101000 bin/blank.bin 0x102000 bin/blank.bin 0x103000 bin/blank.bin 0x1FC000 bin/esp_init_data_default.bin 0x1FE000 bin/blank.bin

Then the reset happens!
[Remark: I have just shorted my path with ... in the example above]



EDIT:
By the way: When I build the entire files:

Generate eagle.flash.bin and eagle.irom0text.bin successully in folder bin.
eagle.flash.bin-------->0x00000
eagle.irom0text.bin---->0x40000

and flash them:

...esptool/esptool.py --port /dev/ttyUSB0 --baud 576000 write_flash 0x00000  bin/eagle.flash.bin 0x40000  bin/eagle.irom0text.bin
]
Then the device is in an endless loop as well, but a different one. I only see tons of bytes beeing send out via UART.
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 04:26:29 pm
olimex-iot-firmware-esp8266 includes SDK 2.0.0 there is no need overwrite the SDK. There are minor changes in our makefiles.

Can you try it without replacing the SDK.

make clean
make DEVICE=EVB_ONLY APP=1
make clean
make DEVICE=EVB_ONLY APP=2
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 04:34:44 pm
It is still sontstantly resetting when I flash:
.../esp-open-sdk/esptool/esptool.py --port /dev/ttyUSB0 --baud 576000 write_flash 0x00000  bin/boot_v1.6.bin 0x01000  bin/upgrade/EVB_ONLY/user1.2048.new.3.bin 0x81000  bin/upgrade/EVB_ONLY/user2.2048.new.3.bin 0x100000 bin/blank.bin 0x101000 bin/blank.bin 0x102000 bin/blank.bin 0x103000 bin/blank.bin 0x1FC000 bin/esp_init_data_default.bin 0x1FE000 bin/blank.bin
The bins user1 and user2 are build with
make DEVICE=EVB_ONLY APP=...
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 04:39:18 pm
What is the output of
xtensa-lx106-elf-gcc -v
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 05:03:08 pm
[I only replaced by path with ...]

xtensa-lx106-elf-gcc -v
Using built-in specs.
COLLECT_GCC=xtensa-lx106-elf-gcc
COLLECT_LTO_WRAPPER=.../esp-open-sdk/xtensa-lx106-elf/libexec/gcc/xtensa-lx106-elf/4.8.2/lto-wrapper
Target: xtensa-lx106-elf
Configured with: .../esp-open-sdk/crosstool-NG/.build/src/gcc-4.8.2/configure --build=x86_64-build_unknown-linux-gnu --host=x86_64-build_unknown-linux-gnu --target=xtensa-lx106-elf --prefix=.../esp-open-sdk/xtensa-lx106-elf --with-local-prefix=.../esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --disable-libmudflap --with-sysroot=.../esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG 1.20.0' --disable-__cxa_atexit --with-gmp=.../esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpfr=.../esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpc=.../esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-isl=.../esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-cloog=.../esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-libelf=.../esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --enable-lto --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --enable-languages=c,c++
Thread model: single
gcc version 4.8.2 (crosstool-NG 1.20.0)
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 19, 2016, 06:04:06 pm
It looks OK. I'm out of ideas for now. I'll try to reproduce the problem with clean install. This can take some time.
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 19, 2016, 07:03:20 pm
Thanks for your help!

If you like to you can also use the docker toolchain. The behaviour was the same:
https://hub.docker.com/r/vowstar/esp8266/
Once installed docker and pulled the image in the link above you can easily compile. Just navigate in the terminal to the project location and execute the following command:


docker run --rm -ti -v `pwd`:/build vowstar/esp8266 /bin/bash -c "cd /build/; make clean && make APP=1 DEVICE=EVB_ONLY && make APP=2 DEVICE=EVB_ONLY"


This will mount your project folder (the current location) to /build, you navigate there and exevute the build. The files will be put as usual to your project folder.

You dont have to, maybe it makes only the analysation easiert.
But in my last tries I did not use docker at all, just a local installation of the toolchain where you've provided the link.

Hopefully you find something as I'm also out of ideas!
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 20, 2016, 10:29:59 am
Here is what I have tested on two different computers:



###
### TOOLCHAIN INSTALL
###
cd ~
git clone --recursive https://github.com/pietrushnic/esp-open-sdk.git
cd esp-open-sdk/
make STANDALONE=n

### remove old SDK that come with toolchain
rm -rf esp_iot_sdk*
rm -rf sdk

PATH=$HOME/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

###
### FIRMWARE BUILD
###
cd ~
git clone https://github.com/OLIMEX/olimex-iot-firmware-esp8266.git
cd olimex-iot-firmware-esp8266/

### Build no device binaries
make clean
make APP=1
make clean
make APP=2

### Build EVB_ONLY binaries
make clean
make APP=1 DEVICE=EVB_ONLY
make clean
make APP=2 DEVICE=EVB_ONLY

### to deploy no device binaries use
python esptool/esptool.py \
        --port /dev/ttyUSB0 \
        --baud 576000 \
        write_flash \
                0x00000  bin/boot_v1.6.bin \
                0x01000  bin/upgrade/user1.2048.new.3.bin \
                0x81000  bin/upgrade/user2.2048.new.3.bin \
                0x100000 bin/blank.bin \
                0x101000 bin/blank.bin \
                0x102000 bin/blank.bin \
                0x103000 bin/blank.bin \
                0x1FC000 bin/esp_init_data_default.bin \
                0x1FE000 bin/blank.bin \
        --flash_size 16m

### to deploy EVB_ONLY binaries use
python esptool/esptool.py \
        --port /dev/ttyUSB0 \
        --baud 576000 \
        write_flash \
                0x00000  bin/boot_v1.6.bin \
                0x01000  bin/upgrade/EVB_ONLY/user1.2048.new.3.bin \
                0x81000  bin/upgrade/EVB_ONLY/user2.2048.new.3.bin \
                0x100000 bin/blank.bin \
                0x101000 bin/blank.bin \
                0x102000 bin/blank.bin \
                0x103000 bin/blank.bin \
                0x1FC000 bin/esp_init_data_default.bin \
                0x1FE000 bin/blank.bin \
        --flash_size 16m



The result
When compare binaries from my original setup with those compiled on other machines they are all different but  are with exactly same size.

When deployed to the board all worked as expected.

Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 21, 2016, 06:38:16 pm
I cannot finally confirm that it is working but why so ever this time it looks better with the build. At least the ESP is not resetting constantly!  ;D

The only difference are the following 3 lines from what I did and I thing the rm was mainly my issue:  :-X

make STANDALONE=n

### remove old SDK that come with toolchain
rm -rf esp_iot_sdk*
rm -rf sdk



But I wil give it a try and let you know again.
Thank you very much so far for your help!

But one, stupid question: Why is APP1 and APP2 compiled seperately?
Isn't there a way to compile one global image or to make at least one time a make? Sure I can create a shell script in order to do that but when I want to integrate it in an IDE for instance it is not that handy.
I understand that there are those two parts ...
Can you quickly give me some hints?!
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: PeteW on December 22, 2016, 11:49:05 am
QuoteBut one, stupid question: Why is APP1 and APP2 compiled seperately?


There is no such thing as "stupid question".

We need two binary images user1.*.bin and user2.*.bin to be able to support Firmware Over The Air (FOTA) updates. SDK requires if user1 image is active to upload user2 image which is stored at different address. After upload is complete we mark user2 image as active and reboot the board. With this approach if connection drops during upgrade we will not end with corrupted firmware.

I do not know exactly how APP=1 and APP=2 affects SDK build process. So I prefer to play safe and compile binaries separately.
Title: Re: Build and deployment issues with olimex-iot-firmware-esp8266
Post by: meinereiner on December 23, 2016, 07:49:32 pm
OK understood. Thank you for explaining!

But then it wouldn't be necessary to upload via serial connection every time user1 and user2, right?
Isnt there a way to compile one common image that can be only flashed via serial? Because when I make it without the app and get such an eagle file that I flash, I have my original behaviour back again.

Anyway: I think I can now continue. Thank you very much for your help!