Closed arjanmels closed 4 years ago
Working nicely, ready to merge after #11 is merged
Would you mind rebasing now #11 has been merged?
Will do (probably tomorrow)
Rebased.
Also added enabling of cache on APP CPU (this is not done by the bootloader as the memory range overlaps). Becomes relevant when running code from flash (#16).
@MabezDev & @Gasper Please note that this pull request also has a couple of changes to efuse.rs slipped in to align the fields to this module (e.g. u32 for core count and Herz units for frequency.
Small fixes. Should be good to go!
I don't think those efuse.rs functions are used anywhere else, so feel free to break them.
I quickly checked the code against reference manual, but haven't tested it yet, I wonder if some of these things might be unintentional:
For the CPU stall you use constant 0x21
, while TRM says 0x86
:
You flush the cache before checking if the CPU is already, running ( https://github.com/esp-rs/esp32-hal/pull/15/files#diff-1c70323480a69dae0d91c911d05d952bR125 ). According to TRM, the cache will not be back-written, and will just be cleared, so some cached data could be lost on the running core:
The start_core
function can only be used for APP core, so you could remove that runtime-checked parameter core
. This way you could also simplify flush_cache
and enable_cache
, since they are not public and cannot be called for PRO core.
Btw, calling start_core
with a main-like function seems very beautiful and user-friendly to me.
The 0x86 is divided over bit in the C0 and C1 registers. (upper 6 bits in C1, lower 2 bit in C0: 10000110=0x86, split in: 100001=0x21 10=002).
Flushing before run check: you are right: I will correct.
You are in principle right. I can imagine some future use cases for the flush cache and enable cache for both cores, so I prefer to keep these generic.
start_core is a matter of taste: keep it aligned to other similar functions, or indeed custom for APP_CORE.
The other matter of taste is the core id for the other functions: use a u32, u8, or switch to an enum: the enum can be checked at compile time, but I am also considering future work for the esp32s (single core) or maybe future esp32xxx with who knows how many cores..
As they are a matter of taste, I will take votes and will update accordingly ;-)
I wonder if they picked 0x86 as some kind of joke: it's quite arbitrary
@MabezDev @jeandudey Can this one be merged?
Apologies for the delay! This looks good to me :)
Thanks!
Adds support for dual core mode
Builds on pull request #11, so that one should be merged first