-->
Page 1 of 2

Boot speed 52MHz not 80?

PostPosted: Fri Oct 07, 2016 2:57 pm
by cnlohr
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)

Re: Boot speed 52MHz not 80?

PostPosted: Fri Oct 07, 2016 4:28 pm
by cnlohr
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.

Re: Boot speed 52MHz not 80?

PostPosted: Fri Oct 07, 2016 10:04 pm
by cnlohr
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);
        //}
    }

Re: Boot speed 52MHz not 80?

PostPosted: Fri Oct 07, 2016 10:36 pm
by RichardS
Nice work I saw the non-SDK 2.5K loader! Exciting....

RichardS