The above link is to the d1_mini_pro.json. The used variant is the same (pinout), but flash sizes are different.
The related python commands are
But the “SPIFFS_END” value overflows a 32-bit integer, so if you print the values using
def __fetch_spiffs_size(target, source, env):
fetch_spiffs_size(env)
print("SPIFFS_END is " + hex(env["SPIFFS_END"]))
print("SPIFFS_START is " + hex(env["SPIFFS_START"]))
print("Diff is " + hex( env["SPIFFS_END"] - env["SPIFFS_START"]))
return (target, source)
you get
SPIFFS_END is -0x6000
SPIFFS_START is 0x200000
Diff is -0x206000
"mkspiffs" -c data -p 256 -b 8192 -s -2121728 .pio\build\d1_mini_pro\spiffs.bin
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Further debugging pins the problem down in fetch_spiffs_size()
# esptool flash starts from 0
for k in ("SPIFFS_START", "SPIFFS_END"):
print("k = %s, value = %s" % (k, hex(env[k])))
_value = 0
if env[k] < 0x40300000:
_value = env[k] & 0xFFFFF
elif env[k] < 0x411FB000:
_value = env[k] & 0xFFFFFF
_value -= 0x200000 # correction
else:
_value = env[k] & 0xFFFFFF
_value += 0xE00000 # correction
env[k] = _value
Seems to give the correct values
k = SPIFFS_START, value = 0x40400000
k = SPIFFS_END, value = 0x411fa000
(segment as approx 14MB long as linkerfile says)
But are then the SPIFFS_END value seems to be wrongly corrected for the esptool program to (0x411fa000 & 0xFFFFFF) - 0x200000 = -0x6000
So I really have no idea where the magic numbers and corrections above are coming from except for that the SPI flash starts at 0x40200000 in the memory map.
@ivankravets@valeros This looks like a bug in the esp8266 main.py for large 16MB flash chips, please have a look. What doesn’t simply
env[k] = env[k] - 0x40200000
work? That does produce the correct commandline "mkspiffs" -c data -p 256 -b 8192 -s 14655488 .pio\build\d1_mini_pro\spiffs.bin and doesn’t crash anymore