Comments (11)
Can you refer to the exact line where you see a 32-bit pointer read from the rom?
from rp-hal.
We use rom_table_lookup
which is supplied by the bootrom, so technically speaking we are not accessing the rom directly. If this function read 16-bit pointer value then we are fine :)
Hopefully it works like that. If not, well no pi pico has ever worked properly :O
from rp-hal.
from rp-hal.
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 *table
will read four bytes (a *const _
) from memory: 0x14 .. 0x17. You should only read 0x14 and 0x15 and add two zero bytes. You should probably set FUNC_TABLE to be a *const u16, then do a core::ptr::volatile_read(), then cast the u16 to a usize, then pass that to the rom_table_function.
In your ASM listing, I think LDR R0, [R0]
will do a 32-bit read from the address 0x14. That LDR
should be an LDRH
.
But maybe I'm wrong, and this code works fine as-is? Maybe I've read the datasheet wrong?
from rp-hal.
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)
from rp-hal.
I think it's the same because jumping to 0x0014 is the same as jumping to 0x00000014 but essentially you are right
from rp-hal.
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
from rp-hal.
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.
from rp-hal.
I didn't notice the double const*😳
from rp-hal.
I am fixing it right now, why should I use core::ptr::volatile_read
and not just regular deref?
from rp-hal.
I would use it because it is more explicit that you are loading from a specific address in flash.
from rp-hal.
Related Issues (20)
- ClockManager "partial move" with RealTimeClock HOT 12
- API ergonomics for ADC free running mode when not using FIFO HOT 2
- UART example does not appear to work on Pico W HOT 2
- PWM get_max_duty() off by one HOT 4
- ADC should report conversion errors
- AdcFifo not configurable with DynPin HOT 4
- PRI PICO with SH1106 128x64 pixel Display - i2c issue HOT 18
- slow startup of XOSC HOT 1
- GPIO pins should have inherent infallible methods HOT 1
- Clock errors cannot be printed with deft
- I2C on GPIO24/25 not working HOT 13
- Update terminology for I2C (and possibly other peripherals)
- Input Enable now turned off on ADC capable GPIOs (Errata RP2040-E6) HOT 2
- Missing impls for Pin<_, DynFunction, _> HOT 12
- Should there be a default impl for hal::serial::blocking::Write? HOT 3
- Support use of slice for Program code HOT 1
- Note on how to acquire Pin's number as an integer HOT 1
- ERROR probe_rs::cmd::run: Failed to attach to RTT continuing... HOT 5
- Crates.io version HOT 2
- ADC read blocks HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rp-hal.