Skip to content
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

FlashEEPROM.readMem() causes reset on esp8266 #837

Closed
ceremcem opened this issue Apr 8, 2016 · 10 comments
Closed

FlashEEPROM.readMem() causes reset on esp8266 #837

ceremcem opened this issue Apr 8, 2016 · 10 comments
Labels
ESP8266 This is only a problem on ESP8266 devices

Comments

@ceremcem
Copy link

ceremcem commented Apr 8, 2016

While following the documentation, I faced with the following situation:

getFile = function(){
  var f;
  f = new (require("FlashEEPROM"))(0x076000);
  f.endAddr = f.addr + 1024;
  return f;
};
>f = getFile()
={ 
  "flash": function () { [native code] }, 
  "addr": 483328, "endAddr": 484352 }
>f.read(0)
=new Uint8Array([104, 101, 108, 108, 111])
>E.toString(f.read(0))
="hello"
>f.readMem(0)
=" ets Jan  8 2013,rst cause:4, boot mode:(3,7)
wdt reset
load 0x40100000, len 1396, room 16 
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4 
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4 
tail 8
chksum 0xc0
csum 0xc0
2nd boot version : 1.4(b1)
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 4Mbit(256KB+256KB)
jump to run user1 @ 1000
rlrl��Loading 6525 bytes from flash...
Running onInit()...
connected? err= null info { 
  "ip": "192.168.2.193", 
  "netmask": "255.255.255.0", 
  "gw": "192.168.2.101", 
  "mac": "18:fe:34:d6:72:f6"
 }
@gfwilliams gfwilliams added the ESP8266 This is only a problem on ESP8266 devices label Apr 8, 2016
@gfwilliams
Copy link
Member

Thanks - I guess this might be something to do with how flash memory is mapped into the address space. Presumably E.memoryArea should add some offset to addresses that are in flash.

For now, just use f.read() - which should work fine? readMem is only really useful when you're storing massive amounts of data.

@ceremcem
Copy link
Author

ceremcem commented Apr 8, 2016

Okay, f.read() works fine and suffices right now.

@MaBecker
Copy link
Contributor

MaBecker commented Dec 9, 2016

@ceremcem - can this be closed ?

@gulfaraz
Copy link

@MaBecker readMem still resets the esp8266

@MaBecker
Copy link
Contributor

@gulfaraz - can you add sample code ?

@ceremcem
Copy link
Author

@MaBecker Is my sample code passing your tests?

@MaBecker
Copy link
Contributor

@ceremcem - did some testing

E.memoryArea() is the reboot cause for this reboot on ESPs

@MaBecker
Copy link
Contributor

@gfwilliams - I guess this has todo with "ESP reads 4byte from flash"

https://github.com/espruino/Espruino/blob/master/src/jswrap_espruino.c#L751

Can you give some hints how to fix this ?

@gfwilliams
Copy link
Member

The ESP8266 is incapable of reading just a single byte from flash memory, it must read 4.

There is a bit of code somewhere - an exception handler - which will handle the exception and read the single byte.

I think @tve was against it at the time as it's pretty slow, but I think in this case it might be a good idea. Modifying all of Espruino so it never attempts to access a single byte element of a flat string at any point would be a bit of a nightmare (and would leave the code looking pretty ragged) - but the exception handler would fix the few cases where it was a problem.

@MaBecker
Copy link
Contributor

So its f.read() for now and lets close this.

gfwilliams added a commit that referenced this issue Sep 15, 2017
ESP8266: Enable unaligned reads for ESP8266_4MB (fix #1240,#837)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ESP8266 This is only a problem on ESP8266 devices
Projects
None yet
Development

No branches or pull requests

4 participants