Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By gaber
#40885 FYI: there is a set of memory addresses associated with the RF initconfig on the ESP8266. They are detailed in the file called ESP8266_RF_init.xls in the Flash Tool 2.4 (http://bbs.espressif.com/viewtopic.php?f=5&t=433).

Address 0x30 is important because if it is 1 then you are setup to use the 26MHz crystal, and if 0, then it uses a 40MHz crystal--default is 1, so 26MHz crystal is required. The offset address for that value is different depending upon your code base, but it appears it is quite commonly at 0x7C030. On my setup it is also at that location. Many people are aware of this that are doing the unofficial SDK work -- but I did not see a nice shortcut to changing the crystal setting using esptool.

If you want to use a 40MHz crystal, you need to change a byte in the flash at address 0x7C030 from 1 to 0. If your board has a 26MHz crystal, don't do this.

1. Flash your code to your ESP8266 SPI flash as you normally would using esptool
2. run the following commands to change from 26MHz to 40MHz crystal source (only do this if you physically have a 40MHz crystal on your ESP8266 board): (run each one line by line to make sure each one succeeds)

./esptool.py read_flash 0x7C000 128 rfblock.bin

printf '\x00' | dd conv=notrunc of=rfblock.bin bs=1 seek=$((0x30))

./esptool.py write_flash 0x7C000 rfblock.bin


3. Explanation: The first command reads back the 128 bytes from the RF init block, the second command changes the value at address 0x30 from 0x01 to 0x0, then the third command writes everything back.

4. You may need to hit the reset button after the flash read/write commands to get the chip to wake up into UART debug mode and allow reading/writing spi flash

Hopefully its helpful to somebody.

-Gabe
User avatar
By gaber
#41194 After you create the rfblock.bin file once, you can re-use for later during the flashing process.

For example, here is what I do now:

./esptool.py --port /dev/ttyUSB0 write_flash 0x00000 parse-0x00000.bin 0x40000 parse-0x40000.bin 0x7C000 rfblock-0x7C000.bin

So the 128 byte RF settings block is also written to the flash memory. So you could also just generate different settings binary files using the ESP flash tool 2.4 from windows and use that file. In the windows tool it saves a file called "esp_init_data_setting.bin" which is 128 bytes long. So you just change the name to rfblock-0x7C000.bin and use in the command above.

-Gabe