Embedded Rust Question โ€” G_INPUT_DATA Always Reads as 0 or 0x5555 using pyocd

โš“ Rust    ๐Ÿ“… 2025-10-07    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 6      

surdeus

I'm working on an embedded fuzzing setup running in no_std mode on the nRF52833_xxAA.

I have global statics defined like this:

#[unsafe(no_mangle)]
static mut G_LOCAL_POOL: [[i16; WIDTH]; SEED_CAPACITY] = [[0; WIDTH]; SEED_CAPACITY];

#[unsafe(no_mangle)]
pub static mut G_INPUT_DATA: [i16; WIDTH] = [0; WIDTH];

On the host side (using pyOCD ), I try to read the current input buffer from the target with the following function:

def pull_input_buffer(self):
    """Pull current input buffer G_INPUT_DATA"""
    if not self.g_local_pool_addr:
        return None
    
    input_data = []
    base_addr = self.g_local_pool_addr  # address of G_INPUT_DATA

    for i in range(200):  # WIDTH = 200
        try:
            addr = base_addr + (i * 2)  # 2 bytes per i16
            value = self.target.read16(addr)
            # Convert to signed i16
            if value > 32767:
                value -= 65536
            input_data.append(value)
        except Exception as e:
            logging.error(f"[!] Error reading input at index {i}: {e}")
            input_data.append(0)

    return input_data

However, when I read back the data for logging, every value is always either 0 or 0x5555.

I canโ€™t use heap-based types like Vec or Box because the program runs on a no_std target (chip = "nRF52833_xxAA").

Why might all values in G_INPUT_DATA read as 0 or 0x5555 when using pyOCD , and is there a more reliable way to ensure correct memory writes and reads between the host and the target under no_std ?

1 post - 1 participant

Read full topic

๐Ÿท๏ธ Rust_feed