Chat freely about anything...

User avatar
By esp03madness
#18468 Hello friends, a couple of questions :)

Question 1
I noticed that the bundled AT firmware that comes with the IOT_SDK changed from being made for 512kB flash in 1.0.0 to 1024kB in 1.0.1 and above. But for older devices, which, all have 512kB flash - are we supposed to compile AT firmware ourselves? (Not a hard thing to do, just asking for clarification :oops: )

Question 2
How does one go about establishing the size of their flash chip? Using esptool I can see something like:
Code: Select allManufacturer: c8
Device: 4013


But of course, that doesn't include the size. Searching this board led me to identify my flash as:
Code: Select allGigaDevice: 4Mbits/512Kbyte GD25Q40

Is there an easier way to do this?
User avatar
By esp03madness
#18493 Ok, so I think I can answer (1) by myself. Here are the sizes of the binaries (rom), as compiled with default settings (-g -Os -O2) in Espressif's makefile:

Code: Select allirom0text.bin = 208.1 kB              //these are the espressif binary blobs
flash.bin = 43.3 kB                   //this is the user code
total: 251.4 kB


Here are the maximum rom sizes, depending on flash configuration.

Code: Select allsingle slot:
512kB flash: 496kB rom

dual slot:
512kB flash: 249kB rom (each)
1024kB flash: 512kB rom (each)


Single slot has no second stage bootloader section, and uses most of the flash for storing just one rom (libs+user). The dual slot needs a second stage bootloader and the remaining space is split in two. Thus, the stock AT will just barely not fit into a 512kB flash in a dual slot setup. For this reason, it has been shipped as compiled for a larger (1024kB) flash in a dual slot setup.

There you have it. If you've got an older device with a 512kB flash (which most of them currently are) and you want fresh AT firmware you have to:

1. Compile yourself
2. Compile as single slot (no OTA)
User avatar
By esp03madness
#18569 New wrinkle:

When I write the flash.bin and irom0text.bin to 0x0 and 0x40000, respectively - I get only bootloader output. In other words - something is broken in the usercode.

After flashing with:
Code: Select allesptool.py write_flash 0x00000 flash.bin 0x40000 irom0text.bin


I read back with:
Code: Select allesptool.py read_flash 0x00000 0x80000 dump.bin


And sure enough! The first 0x5000 bytes are erased (all FF's), whereas in flash.bin the first 0x5000 bytes are valid/normal/magic number/etc.

What is going on?
User avatar
By esp03madness
#18571 Some experiment results:

Code: Select allesptool.py write_flash 0x00000 flash.bin 0x40000 irom0text.bin
\-- first 0x5000 bytes nuked

esptool.py write_flash 0x00000 flash.bin 0x40000 irom0text.bin
esptool.py write_flash 0x00000 flash.bin
\-- OK

esptool.py write_flash 0x40000 irom0text.bin 0x00000 flash.bin
\-- OK


What gives? Is this an esptool.py bug?