-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibly broken generated sketch #130
Comments
can confirm this, for the moment i create https://github.com/Links2004/Arduino/tree/esp8266_dev1 |
Just built WiFIScan and mDNS sample sketches and they run fine.
|
if i only add:
it is still working if i use the changes in the ok i build the Blink |
blink @ 80Mhz |
@av1024 are you compiling on Windows as well? |
@igrr witch version of the xtensa-lx106-elf compiler you use on linux? xtensa-lx106-elf-gcc.exe --version i test one from the 17.02.2015 (from the 1.6.1 zip) and a version from 25.02.2015. |
I'm on a Mac. |
yes, branch lx106-g++, commit 7c6bc14. |
i dont find the commit sha1 i try to build b404fb9ec3a5c59e6b4d90741d39f7d1937431cd for windows hope this will work in mingw |
I'm not sure this is a toolchain issue. Why would windows toolchain stop working after some minor changes to the code? Actually OP mentioned that the bootloader output ends with main.c. If I do full erase then I do get this:
Perhaps something is wrong with the binary image generation? |
i get the same bootloader messages |
@igrr, Linux Mint x64. xtensa version the same as above |
if you have ssh you can use X11-Forwarding |
I did it! )) Google and @Links2004 helped me ) $ git log Merge pull request #127 from Links2004/esp8266 === generic 80MHz 8266: -rw-rw-r-- 1 av av 31776 апр. 27 21:57 Blink.cpp_00000.bin $ md5sum *.bin UPD: The aedf97a give exactly the same output... |
@Links2004 can you please upload the Blink.cpp.elf and two .bin files somewhere? (wetransfer.com should be good) |
i also get the same message, when i upload using the arduino ide and when i upload using an external app (running on windows) ets Jan 8 2013,rst cause:1, boot mode:(3,7) ets_main.c |
Unfortunately I can't reproduce the issue myself. |
here is the elf file as well as both bin files compiled from the "HelloServer" example in the ide |
Thanks for the files!
Verified that esptool produces identical binaries from your elf file:
So at least esptool output doesn't depend on the platform.
The bootloader output is as follows:
And then the sketch runs okay, trying to connect to some WiFi... |
it is strange i test bb082c9 and the blink is working but if i compile code who is working in #links2004/esp8266_dev1 is broken. tested on a ESP-7 and ESP-12 module @80Mhz |
at the moment i think the problem comes form the last SDK merge, they increase the possible size i try to write a sketch to test the real flash size of the hardware. May we have different Flash chips on our boards. |
#include <Arduino.h>
extern "C" {
#include "user_interface.h"
}
#define SERIAL_OUT Serial
bool test_flash_ll(uint32_t pAddr) {
uint32_t tmp;
if(spi_flash_read(pAddr, &tmp, 1) == SPI_FLASH_RESULT_OK) {
return true;
}
return false;
}
bool test_flash(uint32_t pAddr) {
SERIAL_OUT.print(F("[Flash] addr: 0x"));
SERIAL_OUT.print(pAddr, HEX);
SERIAL_OUT.print(" - ");
SERIAL_OUT.print(pAddr, DEC);
SERIAL_OUT.print(" ");
if(test_flash_ll(pAddr)) {
SERIAL_OUT.println("OK");
return true;
}
SERIAL_OUT.println("FAIL");
return false;
}
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(115200);
Serial1.begin(921600);
Serial1.setDebugOutput(true);
SERIAL_OUT.println();
for(uint8_t t = 4; t > 0; t--) {
SERIAL_OUT.print(F("[SETUP] BOOT WAIT "));
SERIAL_OUT.print(t);
SERIAL_OUT.println(F("..."));
SERIAL_OUT.flush();
delay(1000);
}
SERIAL_OUT.print(F("[SETUP] Flash ID: 0x"));
SERIAL_OUT.println(spi_flash_get_id(), HEX);
#define Mbit ((1024*1024)/8)
uint32_t step = Mbit; //1 Mbit
uint32_t addr = Mbit;
while(1) {
if(test_flash(addr)) {
addr += step;
} else {
step /=2;
addr -= step;
}
if(step <= 1) {
test_flash(addr);
break;
}
}
SERIAL_OUT.println("----------------------");
SERIAL_OUT.print(F("[Flash] Size: 0x"));
SERIAL_OUT.print(addr, HEX);
SERIAL_OUT.print(" - ");
SERIAL_OUT.println(addr, DEC);
SERIAL_OUT.println("Fin.");
}
// The loop function is called in an endless loop
void loop()
{
//Add your repeated code here
} my output:
|
@Links2004, confirmed. Have the same result on both "valid" and "non-valid (aedf97a)" builds using ESP-07 module |
if i use the official flash (http://bbs.espressif.com/viewtopic.php?f=7&t=25) tool i get
but the application dont run :( esptool.py does the espressif says
is but at the moment i am out of ideas. |
ok i try to use the boot.bin from to sdk in between the bootloader and the app. good case:
bad one:
may it deepens on the size of the code. good:
bad:
anyone an idea or an hint? |
I ran your sketch on my module and the size is the same:
|
the flash ID reference to this chip: F25L32QA from ESMT http://www.esmt.com.tw/DB/manager/upload/F25L32Q.pdf |
SDK reads the flash chip size from the 0x00000 binary header (it's in the first dword). So since esptool generates binaries which have "4Mbit" hard-coded, SDK won't try to access flash above that. |
@Links2004 can you revert the latest SDK update to check if it is responsible for this issue? We need to narrow down on the exact change that leads to this error. |
ok then i get |
Hmm, did you do a full revert? |
Try reverting my smartconfig merge as well then.
|
it test different versions and remove different code. when i get the size from:
to
for example all is working. it look for me like it is not a code problem in first case. to get this size info run:
|
I have removed my smartconfig change, this should also reduce the size of .irom0.text — does the latest trunk work for you? |
no last trunk is not working.
i try to create some simple dummy code to trigger the bug. |
ok her is the bug trigger: #include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <OneWire.h>
#include <Wire.h>
extern "C" {
#include "user_interface.h"
}
const char* ssid = "your-ssid";
const char* password = "your-password";
const char const_text[] = "STILL WORKING! const";
const char text[] = "STILL WORKING! ram";
#define SERIAL_OUT Serial1
//macro to create easy "functions" to fill the space costs 304Byte of .irom0.text per macro call
#define TEST_FUNCTION(a) \
uint32_t test_##a##_dummy(void) { \
uint32_t test = 1; \
test += millis(); \
test %= 123335; \
if(test == 1) test *= 2; \
if(test == 3) test = 2; \
if(test == 3) test /= 2; \
if(test == 5) test += 2; \
if(test == 6) test -= a; \
if(test == 7) test %= 2; \
if(test == 9) test = 442; \
if(test == 51) test += 65462; \
if(test == 32) test = 2; \
if(test == 23) test /= 2; \
if(test == 35) test += 2; \
if(test == 56) test -= 2; \
if(test == 77) test %= 2; \
if(test == 99) test = 442; \
if(test == 521) test += 65462; \
test *= 2; \
test += 2; \
test -= 2; \
test /= 2; \
if(test == 35) test += 2; \
if(test == 56) test -= 2; \
if(test == 77) test %= a; \
if(test == 99) test = 442; \
if(test == a) test += 65462; \
test *= 2; \
test += 2; \
test -= 2; \
test /= 2; \
if(test == 35) test += 2; \
if(test == 56) test -= 2; \
if(test == 77) test %= 2; \
if(test == 99) test = a; \
if(test == 521) test += 65462; \
return test; \
}
TEST_FUNCTION(1)
TEST_FUNCTION(2)
TEST_FUNCTION(3)
TEST_FUNCTION(4)
TEST_FUNCTION(5)
TEST_FUNCTION(6)
TEST_FUNCTION(7)
TEST_FUNCTION(8)
TEST_FUNCTION(9)
TEST_FUNCTION(10)
TEST_FUNCTION(11)
TEST_FUNCTION(12)
TEST_FUNCTION(13)
TEST_FUNCTION(14)
TEST_FUNCTION(15)
TEST_FUNCTION(16)
TEST_FUNCTION(17)
TEST_FUNCTION(18)
TEST_FUNCTION(19)
TEST_FUNCTION(20)
TEST_FUNCTION(21)
TEST_FUNCTION(22)
TEST_FUNCTION(23)
TEST_FUNCTION(24)
TEST_FUNCTION(25)
TEST_FUNCTION(26)
TEST_FUNCTION(27)
TEST_FUNCTION(28)
TEST_FUNCTION(29)
TEST_FUNCTION(30)
TEST_FUNCTION(31)
TEST_FUNCTION(32)
TEST_FUNCTION(33)
TEST_FUNCTION(34)
TEST_FUNCTION(35)
TEST_FUNCTION(36)
TEST_FUNCTION(37)
TEST_FUNCTION(38)
TEST_FUNCTION(39)
TEST_FUNCTION(40)
TEST_FUNCTION(41)
TEST_FUNCTION(42)
TEST_FUNCTION(43)
TEST_FUNCTION(44)
TEST_FUNCTION(45)
TEST_FUNCTION(46)
TEST_FUNCTION(47)
TEST_FUNCTION(48)
TEST_FUNCTION(49)
TEST_FUNCTION(50)
TEST_FUNCTION(51)
TEST_FUNCTION(52)
TEST_FUNCTION(53)
TEST_FUNCTION(54)
TEST_FUNCTION(55)
TEST_FUNCTION(56)
TEST_FUNCTION(57)
TEST_FUNCTION(58)
//TEST_FUNCTION(59) //commend this in an you get "ets_main.c"
void setup()
{
Serial.begin(115200);
Serial1.begin(921600);
Serial1.setDebugOutput(true);
SERIAL_OUT.println();
for(uint8_t t = 4; t > 0; t--) {
SERIAL_OUT.print(F("[SETUP] BOOT WAIT "));
SERIAL_OUT.print(t);
SERIAL_OUT.println(F("..."));
SERIAL_OUT.flush();
delay(1000);
}
SERIAL_OUT.print(F("[SETUP] Flash ID: 0x"));
SERIAL_OUT.println(spi_flash_get_id(), HEX);
WiFi.softAP("ESP8266_BOOTED");
WiFi.begin(ssid, password);
SERIAL_OUT.println(text);
SERIAL_OUT.println(const_text);
for(uint16_t i = 1; i < 128; i++) {
SERIAL_OUT.print("TEST_FUNCTION(");
SERIAL_OUT.print(i);
SERIAL_OUT.println(")");
}
}
void loop()
{
} MEMORY USAGE BAD CASE:
WORKING CASE:
tested with 69eb31a on windows. may you need to add on more of the macro calls, will depend on your compiler does other optimizations then the windows one. may the exact boarder is 0x2FFFF
|
I believe I am hitting the same issue. Tried it with the latest bits and still repos. (this requires https://github.com/Makuna/Task, into Documents\Arduino\libraries) uncomment the define WONT_WORK to get it to fail. #include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WifiUdp.h>
#include <Task.h>
// #define WONT_WORK
WiFiUDP udpServer;
#define WLAN_SSID "<SSID>"
#define WLAN_PASS "<PASSWORD>"
#define CoapMulticastIPv4Address 0xBB0100e0 // 224.0.1.187 reversed byte order
#define CoapPort 5683
void printUdpData(uint8_t* data, uint16_t count)
{
Serial.print(F("Data: ("));
Serial.print(count);
Serial.print(F(")"));
for (int i = 0; i < count; i++)
{
Serial.print(F(" 0x"));
Serial.print(data[i], HEX);
}
Serial.println();
}
#if defined(WONT_WORK)
void checkConnection(uint32_t deltaTime)
{
static wl_status_t s_lastStatus = WL_CONNECTED;
wl_status_t status;
status = (wl_status_t)WiFi.status();
if (status != s_lastStatus)
{
if (status == WL_CONNECTED)
{
Serial.println(F("Regained Connection!"));
}
else
{
Serial.println(F("Lost Connection!"));
}
s_lastStatus = status;
}
}
FunctionTask checkConnectionTask(checkConnection, MsToTaskTime(20000)); // every 20 seconds
void ServiceUdp(uint32_t deltaTime)
{
int16_t result = 0;
result = udpServer.parsePacket();
if (result != 0)
{
Serial.println("\r\nReceived:\r\n");
Serial.print("got udp packet from ");
Serial.print(udpServer.remoteIP());
Serial.print(" to ");
Serial.println(udpServer.destinationIP());
uint8_t data[512];
if (udpServer.read(data, min(result, sizeof(data))) != result)
{
Serial.println("(not enought data)?");
}
else
{
printUdpData(data, result);
}
}
}
FunctionTask serviceUdpTask(ServiceUdp, MsToTaskTime(2)); // every 2 ms
#endif // WONT_WORK
TaskManager taskManager;
void setup() {
// give the human time to connect the serial monitor
delay(10000);
Serial.begin(115200);
Serial.println("Starting things off");
Serial.flush();
wl_status_t status;
WiFi.mode(WIFI_STA);
status = (wl_status_t)WiFi.begin(WLAN_SSID, WLAN_PASS);
if (status == WL_NO_SHIELD)
{
Serial.println(F("Radio Dead!"));
return;
}
Serial.println(F("Getting Dhcp address..."));
{
uint8_t dhcpWait = 250; // 25 seconds
while (dhcpWait > 0)
{
status = (wl_status_t)WiFi.status();
if (status == WL_CONNECTED)
{
IPAddress address = WiFi.localIP();
if (INADDR_NONE != address)
{
Serial.println("ip !");
dhcpWait = 1;
}
else
{
status = WL_DISCONNECTED;
}
}
delay(100);
dhcpWait--;
}
}
if (status != WL_CONNECTED)
{
Serial.println(F("Failed to get DHCP address!"));
return;
}
Serial.println(F("Got Address!"));
// multicast connect
if (!udpServer.beginMulticast(WiFi.localIP(),
IPAddress(CoapMulticastIPv4Address),
CoapPort))
{
Serial.println(F("No server Udp started"));
return;
}
Serial.println(F("Server Udp started"));
taskManager.Setup();
#if defined(WONT_WORK)
taskManager.StartTask(&checkConnectionTask);
taskManager.StartTask(&serviceUdpTask);
#endif // WONT_WORK
Serial.println(F("Running!"));
}
void loop() {
taskManager.Loop();
} Working
Not Working
|
can you run |
may it is an problem of the bootloader / flash tools. if the last address of the flash is below 0x00070000 all is working fin. may the memory is mapped like this for some strange reason: this only an idea but it would explain the probe well. looking for a way to do a full dump over 0x00000000 to 0x000DFFFF to confirm this. |
ok no memory mapping problem. but the address 0x00000 - 0x00FFF goes to value 0xFF if i flash the bad case files. dump cmd for esptool.py
if i change the flash order of the in the esptool.py from
to
all is working. |
Guys, please use xtensa-lx106-elf-size -A -x otherwise it's damn hard to
|
Ooh, I've read somewhere on the russian forum about a bug in the ROM function that erases (incorrect amount of) the flash prior to upload. This looks terribly like it. Let me find the reference... |
Here is the relevant part of esptool.py which supposedly works around the flash erase bug:
@Links2004 can you please try with this fix applied to esptool.py? |
i allways get
at the end but the device is running
|
i change the handling in def flash_finish(self, reboot = False):
pkt = struct.pack('<I', int(not reboot))
ret = self.command(ESPROM.ESP_FLASH_END, pkt)[1]
if ret != "\0\0":
#raise Exception('Failed to leave Flash mode')
print 'Failed to leave Flash mode 0000 != %s ' % (ret.encode("hex")), then i get
and all is working fine. |
It's a pity those changes from Espressif weren't mainlined into the esptool.py. |
Short summary of the bug in SPIEraseArea (thanks to SpLab from esp8266.ru/forum): |
@Links2004 pushed the fix to https://github.com/igrr/esptool-ck |
final we have the esptool-ck and esptool.py working again 👍 |
Created an issue for esptool.py, I hope the fix will be integrated there as well: |
updated esptool-ck for windows is available here: |
Info: last git version c9b5dde need |
Even better, use the release from github. Appveyor is known to be slow/unresponsive at times... |
Just confirming, this fixes my problem. |
The latest (f1e6a72) commit seems broken for me... Looks like uploaded code does not start. After reboot standard text at 74480bps displayed, ends with "main.c" and neither Serial nor digitalWrite don't work.
The total sketch size is 19kb bigger comparing to old (pre str_tok fix) commit (257308 vs 230776 bytes
The full erase (write blank512k) does not solves issue
The text was updated successfully, but these errors were encountered: