Open HokageM opened 8 months ago
I tried to initialize the ETB without using the board
struct to avoid the need of a filesystem.
This is my prototype code:
// initialize persistent buffer for trace data
const size_t etb_buffer_size = 20;
int32_t etb_buffer[etb_buffer_size];
cs_devices_t devices;
// Needed?
//board board_m7 = {.do_registration=do_registration_stm32h7,
// .n_cpu=1,
// .hardware="STM32H7"};
//board_m7.do_registration(&devices);
// Get ETB
devices.etb = cs_device_get(0x5C014000);
// Optionally configs if needed
cs_trace_enable(devices.etb);
cs_checkpoint(); // Enables all configs
cs_get_trace_data(&devices, etb_buffer, etb_buffer_size);
However, upon examining the source code of cs_device_get(0x..)
and cs_device_find
, respectively, I realized that they search within a global structure named cs_global G
for a device with the physical address "0x..".
But how is this G
initialized? How do I need to configure G
s.t. it knows the address of my ETB?
Alternatively, can I just initialize a cs_device etb
manually and set device.etb = &etb
?
A device needs to be registered to CSAL with cs_device_register
before it can be found with cs_device_get
. I'd suggest you treat the board registration as example code only, and register the devices directly. CSAL itself doesn't start off knowing the address of any devices. You need to register devices by using cs_device_register()
, passing in the physical address, and CSAL will read the device's ID registers to discover the device type. It returns a device handle (actually the address of the CSAL object). And then you can tell CSAL about the ATB connections (ETM, funnels, ETB etc.) using cs_atb_register
. Generally, it's not necessary to deal with the global structure G - this keeps a list of all the registered devices, as it sometimes needs to iterate through them all, and it lets you retrieve a device by address, but normally you'd remember the device object handle you get at registration time and control the device through that.
I have a Cortex-M7 microcontroller (STM32H7), which does not have a filesystem. For tracing the ETB data with
cs_get_trace_data
, acs_device_t
object is needed, which needs to be registered on aboard
object. Aboard
object contains the board name inhardware
, which needs "to be matched to a read from/proc/cpuinfo
".How can I initialize the
board
andcs_device_t
without a filesystem