Skip to content
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

Support for teleprobe "exports" #19

Open
plaes opened this issue Dec 22, 2023 · 0 comments
Open

Support for teleprobe "exports" #19

plaes opened this issue Dec 22, 2023 · 0 comments

Comments

@plaes
Copy link
Contributor

plaes commented Dec 22, 2023

Currently teleprobe is mostly used as a remote CI tool, where one continuously flashes same devices with different firmwares - ie static devices and dynamic firmware.
Another scenario for teleprobe would be series testing/flashing of devices together with certain data-logging and calibration tests where one wants to save some device-specific information into database: ie chip-specific information like serial numbers and calibration results and also include data from companion chips (flashes, RTCs etc.).

I have a minimal draft PoC implemented in #20:

Demo:

 INFO  teleprobe::run > run_from_ram: true
 INFO  teleprobe::run > flashing program...
 INFO  teleprobe::run > flashing done!
 INFO  device         > 0.000000 Hello World!
 INFO  device         > 0.100128 slept for 100 ms
 INFO  device         > 0.100433 old: _TELEPROBE_INFO_VAR1: ptr = 0x20001732, val = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 
 INFO  device         > 0.101745 new: _TELEPROBE_INFO_VAR1: ptr = 0x20001732, val = [119, 48, 48, 116, 119, 48, 48, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 
 INFO  device         > 0.103210 Test OK
 INFO  teleprobe::run > Found: _TELEPROBE_INFO_VAR1 -> w00tw00t

From firmware side the changes are currently minimal:

  1. Define a static mut array and make sure it's not demangled and kept in firmware:
#[used]
#[no_mangle]
static mut _TELEPROBE_INFO_VAR1: [u8; 64] = [0; 64];
  1. Populate this array with data:
async fn main(..) {
    unsafe {
        let data = b"w00tw00t";
        _TELEPROBE_INFO_VAR1[..data.len()].copy_from_slice(data);
        // info!("_TELEPROBE_INFO_VAR1: ptr = {:?}, val = {:?} ", &mut _TELEPROBE_INFO_VAR1 as * mut _, _TELEPROBE_INFO_VAR1);
    }
}

Some ideas that I have:

  1. Symbol autodiscovery instead of harcoded list - use .teleprobe.exports section and some macro magic from Rust side to populate the section with a list of exported variables (and ideally their addresses). (I tried to implement something, but my rust- and ld-foo isn't strong enough).
  2. Client side vs server side handling - there's already some section parsing happening in the client side, so we should create a list of "required" symbols and pass this info to server.
  3. Support for other data types than byte arrays (via symbol demangling?).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant