ESP2866-dev reset's after using function ets_vsprintf
Posted: Sun Feb 21, 2016 4:57 pm
Hi Everyone,
First, I would like to disclaim that I'm a complete newbie with the esp2866 (and hardware stuff) so I will try to make a full description of my steps (apologise for the big text).
I've recently acquired a ESP8266-EVB-BAT https://www.olimex.com/Products/IoT/ESP8266-EVB-BAT/open-source-hardware from Olimex that comes with the MOD-WIFI-ESP8266-DEV https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/open-source-hardware.
I've downloaded the github code that they recommend from their gihub https://github.com/OLIMEX/ESP8266 and followed the instructions for SDK installation (esp-open-sdk) that also includes the compiler xtensa-lx106-elf.
Everything goes right, until the compilation of their example https://github.com/OLIMEX/ESP8266/tree/master/IoT%20Firmware/olimex.
When I tried to compile with the non-boot version (through the gen_misc.sh script or just by typing "make"), that for what I understood the diference is that doesn't have access to Espressif cloud (right?), it gives an error of "section `.text' will not fit in region `iram1_0_seg'":
Complete Error:
xtensa-lx106-elf-gcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade -lssl -lsmartconfig -lcrypto user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a user/modules/.output/eagle/debug/lib/libmod.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/Espressif/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
note that I'm selecting the option 3 (2024kb) in the STEP 5: "choose spi size".
I tried to follow what I found in the web and in their documentation 2A-ESP8266__Getting_Started_Guide__EN_V1.5_20160217.pdf where they mention that due to the fact that I have a 2048kb spi flash, I could change the eagle.app.v6.ld (\esp_iot_sdk\ld), len of irom0_0_seg to 0xC0000. So i did it but still have the same error (i did the make clean, yes).
So, I've tried to do it with boot (with support to Support Cloud Update) meaning that I compiled the boo1.bin and boot2.bin and it went well through the gen_misc.sh script.
note: A very strange thing happens after this compile. If I type "make" it successfully generates the [color=#0000BF]eagle.flash.bin and eagle.irom0text.bin successfully (the non boot version) but if I do "make clean" it gives the same error as before. Anyway, this was just a note. [/color]
After the compilation of the user1.bin and the user2.bin:
In my first flash to the esp2866 I flashed everything:
~/Software/esptool/esptool.py --port /dev/cu.usbserial write_flash 0x00000 bin/boot_v1.5.bin 0x01000 bin/upgrade/user1.2048.new.3.bin 0x1FE000 bin/blank.bin 0x1FC000 bin/esp_init_data_default.bin 0x81000 bin/upgrade/user2.2048.new.3.bin - I hope it makes sense, if doesn't please let me know.
in my next flash's I only flash the boot1.bin and the boot2.bin as are the only binaries that change after compilation (and makes sense).
Everything goes well and I can connect to the ap through my computer and getting the answer from the web server. Though, when I access to the end point http://192.168.4.1/wifi-scan the esp2866 reset's. After checking the serial log's (and making some debug on code) I figured out that it crashes in the file user_json.c inside the function json_sprint when the code try to call the function ets_vsprintf.
Full code of the function json_sprintf:
The reset message is the Watchdog reason code that not always shows the same codes inside the boot mode. Last time it showed rst cause:4, boot mode:(1,7)
I tried to read in different documentations, blogs and forum posts but I'm still in one step before of the answers that I'm seeking. For what I've read, people says that I need to do some pull up or down to change the boot mode, but I cannot understand exactly what are the differences between the modes and why I need to change mine, as I can in fact do an update through uart. I read that the wifi-esp2866-dev comes by default in flash mode (whatever that means) but I'm using the (ESP8266-EVB-BAT) that I guess somehow that it changes the boot mode because I can update it through uart. Probably my understand about the modes is not correct.
I also read in this link https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes that the first value of the boot mode:(x,y) is referred to the three low bits of x {MTDO, GPIO0, GPIO2} but I couldn't figure out what the y means. Anyway, this is really confusing to me as sometimes in the place of x appears 1 or 3 depending of the situation and in the place of x appears 6 or 7.
Now the questions:
1. What are the reasons why it crashes after the ets_vsprintf call and what are your suggestions to solve this problem?
2. What are the differences between non-boot and boot when compiling
3. Does the boot of the last question is the same boot information that the boot mode?
4. What are the differences between the boot modes and why should use any of those? It's only for flashing purposes? Meaning that if I can flash, I should not worry about this subject?
5. After it crashes, the system sometimes doesn't restarts automatically meaning that somehow it's stucked receiving errors of boot mode and reset reason in a loop until I flash it again.
I apologise for this long post, but I want to make sure that I'm learning well and it may help others newbies like me in the future. Thanks for your answers.
Best,
First, I would like to disclaim that I'm a complete newbie with the esp2866 (and hardware stuff) so I will try to make a full description of my steps (apologise for the big text).
I've recently acquired a ESP8266-EVB-BAT https://www.olimex.com/Products/IoT/ESP8266-EVB-BAT/open-source-hardware from Olimex that comes with the MOD-WIFI-ESP8266-DEV https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/open-source-hardware.
I've downloaded the github code that they recommend from their gihub https://github.com/OLIMEX/ESP8266 and followed the instructions for SDK installation (esp-open-sdk) that also includes the compiler xtensa-lx106-elf.
Everything goes right, until the compilation of their example https://github.com/OLIMEX/ESP8266/tree/master/IoT%20Firmware/olimex.
When I tried to compile with the non-boot version (through the gen_misc.sh script or just by typing "make"), that for what I understood the diference is that doesn't have access to Espressif cloud (right?), it gives an error of "section `.text' will not fit in region `iram1_0_seg'":
Complete Error:
xtensa-lx106-elf-gcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade -lssl -lsmartconfig -lcrypto user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a user/modules/.output/eagle/debug/lib/libmod.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/Espressif/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
note that I'm selecting the option 3 (2024kb) in the STEP 5: "choose spi size".
I tried to follow what I found in the web and in their documentation 2A-ESP8266__Getting_Started_Guide__EN_V1.5_20160217.pdf where they mention that due to the fact that I have a 2048kb spi flash, I could change the eagle.app.v6.ld (\esp_iot_sdk\ld), len of irom0_0_seg to 0xC0000. So i did it but still have the same error (i did the make clean, yes).
So, I've tried to do it with boot (with support to Support Cloud Update) meaning that I compiled the boo1.bin and boot2.bin and it went well through the gen_misc.sh script.
note: A very strange thing happens after this compile. If I type "make" it successfully generates the [color=#0000BF]eagle.flash.bin and eagle.irom0text.bin successfully (the non boot version) but if I do "make clean" it gives the same error as before. Anyway, this was just a note. [/color]
After the compilation of the user1.bin and the user2.bin:
In my first flash to the esp2866 I flashed everything:
~/Software/esptool/esptool.py --port /dev/cu.usbserial write_flash 0x00000 bin/boot_v1.5.bin 0x01000 bin/upgrade/user1.2048.new.3.bin 0x1FE000 bin/blank.bin 0x1FC000 bin/esp_init_data_default.bin 0x81000 bin/upgrade/user2.2048.new.3.bin - I hope it makes sense, if doesn't please let me know.
in my next flash's I only flash the boot1.bin and the boot2.bin as are the only binaries that change after compilation (and makes sense).
Everything goes well and I can connect to the ap through my computer and getting the answer from the web server. Though, when I access to the end point http://192.168.4.1/wifi-scan the esp2866 reset's. After checking the serial log's (and making some debug on code) I figured out that it crashes in the file user_json.c inside the function json_sprint when the code try to call the function ets_vsprintf.
Full code of the function json_sprintf:
Code: Select all
char ICACHE_FLASH_ATTR *json_sprintf(char *buffer, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
debug("It shows this message\n");
ets_vsprintf(buffer, fmt, args);
debug("Doesn't show this message\n");
va_end(args);
return buffer;
}
The reset message is the Watchdog reason code that not always shows the same codes inside the boot mode. Last time it showed rst cause:4, boot mode:(1,7)
I tried to read in different documentations, blogs and forum posts but I'm still in one step before of the answers that I'm seeking. For what I've read, people says that I need to do some pull up or down to change the boot mode, but I cannot understand exactly what are the differences between the modes and why I need to change mine, as I can in fact do an update through uart. I read that the wifi-esp2866-dev comes by default in flash mode (whatever that means) but I'm using the (ESP8266-EVB-BAT) that I guess somehow that it changes the boot mode because I can update it through uart. Probably my understand about the modes is not correct.
I also read in this link https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes that the first value of the boot mode:(x,y) is referred to the three low bits of x {MTDO, GPIO0, GPIO2} but I couldn't figure out what the y means. Anyway, this is really confusing to me as sometimes in the place of x appears 1 or 3 depending of the situation and in the place of x appears 6 or 7.
Now the questions:
1. What are the reasons why it crashes after the ets_vsprintf call and what are your suggestions to solve this problem?
2. What are the differences between non-boot and boot when compiling
3. Does the boot of the last question is the same boot information that the boot mode?
4. What are the differences between the boot modes and why should use any of those? It's only for flashing purposes? Meaning that if I can flash, I should not worry about this subject?
5. After it crashes, the system sometimes doesn't restarts automatically meaning that somehow it's stucked receiving errors of boot mode and reset reason in a loop until I flash it again.
I apologise for this long post, but I want to make sure that I'm learning well and it may help others newbies like me in the future. Thanks for your answers.
Best,