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

User avatar
By cnlohr
#56202 I am running in a really odd problem. When I compile for use without any SDK, my code seems to execute at 52 MHz, not 80 MHz. This is reflected both in the ets_delay_us and in the baud rate divisor. What has to be done to switch the ESP to 80 MHz after boot?

(This is needed to make the USB bootloader work)
User avatar
By cnlohr
#56207 Never mind. Igrr explained it.

When bootloader runs, PLL is not enabled yet, this is done in one of closed source libraries. I would have expected to see 26 MHz frequency, but maybe there is an option to use 2*XTAL... I will check.


For loaded programs — not really, as SDK startup code resets frequency to 80MHz. For the USB stack I can imagine switching from 80 to 52 can be a lot of work... I will see if I can pull some bits from closed source libs to enable 80MHz at boot.
Because this is not necessary for normal (non-USB) boot, I want to check if cable is connected first. If it is, I will load the rest of USB code and libphy into RAM, set frequency, and then initialize USB.


That part of the 8266 is not publicly documented, so I can't give you any pointers.

I'm on vacation now, back to office next week; will look up those 10 lines of code with are needed to switch frequency. Then I'll make a branch of Arduino with 80Mhz enabled in bootloader, so that you can try running esp-usb there.
User avatar
By cnlohr
#56218 pvxx had the solution...

Code: Select all    if(rom_i2c_readReg(103,4,1) != 136) { // 8: 40MHz, 136: 26MHz
        //if(get_sys_const(sys_const_crystal_26m_en) == 1) { // soc_param0: 0: 40MHz, 1: 26MHz, 2: 24MHz
            // set 80MHz PLL CPU
            rom_i2c_writeReg(103,4,1,136);
            rom_i2c_writeReg(103,4,2,145);
        //}
    }
User avatar
By RichardS
#56220 Nice work I saw the non-SDK 2.5K loader! Exciting....

RichardS