-->
Page 1 of 2

AT firmware and SPI Flash sizes

PostPosted: Tue May 26, 2015 12:06 am
by esp03madness
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?

Re: AT firmware and SPI Flash sizes

PostPosted: Tue May 26, 2015 7:33 am
by esp03madness
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)

Re: AT firmware and SPI Flash sizes

PostPosted: Wed May 27, 2015 12:35 am
by esp03madness
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?

Re: AT firmware and SPI Flash sizes

PostPosted: Wed May 27, 2015 12:52 am
by esp03madness
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?