Anybody know a way to pass command lines through openocd?

I’m writing code that has the ability to select things like bit depth at run time but I keep having to compiling it into the code when it would be faster to be able to pass parameters down through argc,argv as usual via openocd?

(I guess I could just add an options menu to my code to change it instead, but I’ve been meaning to ask about command line parameters)

Thanks

-Dave

I don’t know a way to pass args with argc/argv but there is the write_memory command General Commands (OpenOCD User’s Guide) that might be helpful :

# Send command to OpenOCD
echo "write_memory 0x20050000 8 { 0x01 };reset run;exit" | nc 127.0.0.1 4444
// Read param in C
char* param = 0x20050000; // Not sure exactly where to put it

I’ve never tried it though. Maybe I’m all wrong.

Another way, that I use often, is to attach gdb, break on main(), set the value with p param = 1 then continue execution.

1 Like