-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootrom functions #17
Comments
Can you refer to the exact line where you see a 32-bit pointer read from the rom? |
We use Hopefully it works like that. If not, well no pi pico has ever worked properly :O |
const FUNC_TABLE: *const *const u16 = 0x14 as _;
rom_table_lookup(FUNC_TABLE, some_tag);
fn rom_table_lookup<T>(table: *const *const u16, tag: RomFnTableCode) -> T {
unsafe {
let rom_table_lookup: RomTableLookupFn<T> = core::mem::transmute(ROM_TABLE_LOOKUP_PTR);
rom_table_lookup(*table, u16::from_le_bytes(tag) as u32)
}
} The deref of the table pointer with In your ASM listing, I think But maybe I'm wrong, and this code works fine as-is? Maybe I've read the datasheet wrong? |
Note how the SDK code does a 16-bit read: // Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address) |
I think it's the same because jumping to 0x0014 is the same as jumping to 0x00000014 but essentially you are right |
And in thumb all 16 bit are extended to 32 bit register so yah... I don't have the pico so I can't test it (: Let me know if I am wrong |
Jumping to 0x0014 is the same as jumping to 0x00000014, but using the ROM table doesn't involve jumping to 0x0014 - it involves reading a two-byte value stored at 0x0014..0x0015. |
I didn't notice the double const*😳 |
I am fixing it right now, why should I use |
I would use it because it is more explicit that you are loading from a specific address in flash. |
Does the bootrom table lookup code work? It's just that according to Datasheet section 2.8.3, the Bootrom stores the table addresses as 16-bit values - these need to be read as 16-bit values, then expanded to 32-bit, then converted to the appropriate pointer. I suspect the code as written will read 32-bits from the bootrom, and get thus get the pointer very wrong.
The text was updated successfully, but these errors were encountered: