How to access internal flash on esp8266?


I tried to access the internal flash on a NodeMCU V2 board with code following, the code was halt on the line ‘ff = flash.FlashFileStream(start_address,512)’, because I don’t see ‘reading…’ on the console. I’ve tried different start_address but with no luck.

start_address = 0x402F0000
ff = flash.FlashFileStream(start_address,512)

It’s recommended to ‘begin using it from secure addresses towards the end the bytecode (start address of the bytecode can be found in the log console of Zerynth Studio during the uplink operation), leaving a minimum safe place to minimize the chance of clashes.’ but I don’t understand how to find the secure addresses. Can someone help me to access the internal flash? and here’s the output while uploading:

[info] Handshake
[info] symbols: 3
[info] membase 3FFF163C
[info] romstart 4026F000
[info] flash 00091000
[info] Erasing flash
[info] Sending Bytecode: 36144 bytes ( available 593920 )
[info] Uplink done


Can anybody help me? Thanks!


Hi @Zhang_Lance,

unfortunately this seems an issue related to our implementation of the esp8266 read flash function and we will surely fix it with the next patch.
Let me know if you have an urgent need.


there’s no rush, but can you tell me when the next patch will be released?


Hi @Zhang_Lance,

we do not have a precise date a the moment, but you can expect it roughly in two/three weeks.


Is this problem completely fixed? Because I have the problem to flush. Reading the flash works. I also tried different addresses.
I used the flash example and flash address 0x402B0000 or 0x402F0000 and get
[TypeError at line 46 of main]
[raised at line 117 of flash.flush]


Hi @Arne_Radetzky,

unfortunately the problem is fixed for reading but not for writing, we will fix it for the next patch which will be probably released in January.


Thanks for letting me know. I have to say that I really like Zerynth and the work you are doing here.
But I found some other problems with the ESP8266 (NodeMCU V3):

  1. sleep is not working correctly. For example, sleep(20) is not 20x sleep(1). It seems that it works only for values > 200.
# new sleep needed because sleep is not working on NodeMCU V3 ESP8266
# with an oscilloscope the measurement was made that 26 cycles are 1 ms
def sleepNew(ms):
     for i in range(ms):
         for j in range(26):

2) PWM is not working correctly. Presumably because of 1)
3) MQTT service ping seems not to be working correctly. I am disconnected from the service automatically after a few minutes unless I send an own ping regularily, even with ping set to 60 sec. Exception handling is not working here, so if you are disconnected the NodeMCU hangs or resets.
4) small thing: LED0 is D4, At the moment LED0 is not defined.