Skip to content

Commit

Permalink
bootloader: check previously used clock frequency at run time
Browse files Browse the repository at this point in the history
In the situation when bootloader was compiled for 240MHz, and app was
compiled for 160MHz, and the chip is a revision 0 chip, the
bootloader will assume that the application has also been running at
240MHz. This will cause the chip to lock up later. Modify this to use
a run time check of DPORT_CPUPERIOD_SEL, which indicates which of the
PLL frequencies was used.

Closes espressif/esp-idf#2731.
  • Loading branch information
igrr committed Feb 28, 2019
1 parent 3e40611 commit 6ca6ed5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/bootloader_support/src/bootloader_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ void bootloader_clock_configure()
/* Set CPU to 80MHz. Keep other clocks unmodified. */
int cpu_freq_mhz = 80;

/* On ESP32 rev 0, switching to 80MHz if clock was previously set to
/* On ESP32 rev 0, switching to 80/160 MHz if clock was previously set to
* 240 MHz may cause the chip to lock up (see section 3.5 of the errata
* document). For rev. 0, switch to 240 instead if it was chosen in
* menuconfig.
* document). For rev. 0, switch to 240 instead if it has been enabled
* previously.
*/
uint32_t chip_ver_reg = REG_READ(EFUSE_BLK0_RDATA3_REG);
if ((chip_ver_reg & EFUSE_RD_CHIP_VER_REV1_M) == 0 &&
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240) {
DPORT_REG_GET_FIELD(DPORT_CPU_PER_CONF_REG, DPORT_CPUPERIOD_SEL) == 2) {
cpu_freq_mhz = 240;
}

Expand Down

0 comments on commit 6ca6ed5

Please sign in to comment.