Open Emoun opened 3 months ago
An alternative is to add functionality to the bootloader that calls a bootloader-function on eacher non-main core, whose only job is to load the ISPM. The core then goes back to sleep. This would mean all cores' ISPM are loaded from the beginning and corethread/pthreads does not need to know about the bootloader.
Thanks for looking into this. Let us think about it when there is a need. This is very brittle anyway, as one needs to decide which functions shall be on which core. I do not think we want to have the very same function in all core's ISPMs.
I've just opened this issue to write down my ideas. No plan to actually do any of this yet.
I've also thought about what goes in each core's ISPM. We could also allow additional core-specific section, like .text.spm.0
, .text.spm.1
. This would give us a section for all cores (.text.spm
) and individual sections, though how exactly to map this in memory is an open question.
A maybe not so trivial issue is that all ISPMs are mapped to the same address. Can we have several functions in the .elf file that are mapper to the same address?
I think it is possible in ELF to have sections referencing the same addresses. Though I have no experience with this, so maybe this is a misunderstanding of mine. We'll need to explore and test more.
I think there is some misunderstanding here. In the bootloader, which is the same for all cores, we have these lines
// initialize the content of the I-SPM from the main memory
// copy words not bytes
for (int i = 0; i < get_ispm_size()/4; ++i) {
// starting at 64 K (1 << 16) word address (/4)
*(SPM+(1<<16)/4+i) = *(MEM+(1<<16)/4+i);
}
This is executed by all cores. Now, this might no longer work, for whatever reason, but the intention is that each core copies instructions from the main memory to the SPM.
I think we never had a usable solution for using the I-SPM on all cores, just the first core. And even that we have never really used.
We currently have the issue of the instruction scratchpad (ISPM) not working on non-main cores.
It works on the main core by the bootloader reading the downloaded ELF and putting anything that is in the
.text.spm
section in the ISPM. However, this does not work for other cores since there is no way for the main core to load stuff into other cores' ISPMs, and there is no way for the cores themselves to do it, since they are called using pthreads or coresthread_create.My idea is to update corethread/pthreads such that they call the bootloader on the other cores instead of the given function. The bootloader will be updated such that if it is not called from the main core, it loads the ISPM then runs the required function. This of course requires an update to the bootloader.
This is not totally fleshed out, but I think it would be a good way to use existing functionality in the bootloader to give us access to the ISPMs on non-main cores.