Page 6 of 16

Re: rom_i2c funcs?

PostPosted: Wed Sep 08, 2021 10:35 am
eriksl wrote:This is just by calling rom_i2c_writeReg I guess. So I assume you use the system API function (or direct hardware access) for setting 160 MHz clock to double the PLL CPU clock? Or something else?

As some ranges yield the same frequency, it looks like only some bits are used for PLL/clock divider. I think we should work out which bits are significant and only use these, the other bits may have another function and may be messing up other operation, who knows...

I think 368 MHz already is very good, as the rumours are that the CPU can run up to ~400 Mhz.

I am quit experienced in assembly programming, it's just that it's Z80 and 68000 assembly language ;-). But I do have a document that describes xtensa instructions, so we should be able to figure out what it does. I already read the rom code does some obfuscation by adding and subtracting some "magical" values, bah.

In the end I'd like for us to actually know what I/O addresses are used and them access them directly, without obfuscating rom code. I believe some already had found out some of this.

I found about that on a nosdk8266, here https://github.com/cnlohr/nosdk8266/blob/master/src/nosdk8266.c#L32 Sadly, the trick only works if the speed is 80 MHz :(

I'm pretty sure that if we can unlock the PLL, we can push the entire system to 520 MHz, the PLL divider would be 2 (1040/2). I really think the silicon in the ESP8266EX is capable of that.

If you have a moment later, please look at this https://github.com/cnlohr/nosdk8266/blob/master/useful/rom/disrom.s#L12272, I was doing some experiments, but I always receive garbage through the UART port.

The two possible ways to go would be to experiment with rom_rfpll_set_freq or to find a way to disconnect the PLL splitter and try to bring everything to 1040MHz although I don't know if the ESP8266EX is capable of handling that speed.

Re: rom_i2c funcs?

PostPosted: Wed Sep 08, 2021 10:50 am
by eriksl
I would already be very happy with the CPU running at 400 Mhz and even more if we can keep the APB at 80 Mhz.

I have the code now in front of me. The very first thing that strikes me is that the code is laced with calls to gcc floating point calculation/conversion functions. Very weird. Also some of the code in the routine is garbage, I assume it's data storage, not code.

Re: rom_i2c funcs?

PostPosted: Wed Sep 08, 2021 10:57 am
by eriksl
I can't really find the C function call convention for Xtensa, only the "windowed" variant, which lx106 doesn't have. For the windowed variant, a0 is return address, a1 is stack pointer, a2-a5 are parameters. I hope this also counts for the call0 abi.

Re: rom_i2c funcs?

PostPosted: Wed Sep 08, 2021 10:59 am
by eriksl
This instruction:

Code: Select alladdi   a1, a1, -32

at the top of the function seems to confirm that a1 is the stack pointer. It reserves 32 bytes (probably 8 words) on the stack for "auto" variables.

(read as: load a1 into accumulator, subtract 32 and then store the result in a1).