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

Initializing a board without filesystem or a cs_device without board #19

Open
HokageM opened this issue Mar 13, 2024 · 2 comments
Open

Comments

@HokageM
Copy link

HokageM commented Mar 13, 2024

I have a Cortex-M7 microcontroller (STM32H7), which does not have a filesystem.
For tracing the ETB data with cs_get_trace_data, a cs_device_t object is needed, which needs to be registered on a board object.
A board object contains the board name in hardware, which needs "to be matched to a read from /proc/cpuinfo ".

struct board { 
[..]
const char *hardware; /**< Name of the hardware - to be matched to a read from `/proc/cpuinfo` */
}

How can I initialize the board and cs_device_t without a filesystem

@HokageM HokageM changed the title Initialising a board without cpuinfo Initializing a board without cpuinfo Mar 13, 2024
@HokageM HokageM changed the title Initializing a board without cpuinfo Initializing a board without filesystem Mar 14, 2024
@HokageM HokageM changed the title Initializing a board without filesystem Initializing a board without filesystem or a cs_device without board Mar 18, 2024
@HokageM
Copy link
Author

HokageM commented Mar 18, 2024

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?

@algrant-arm
Copy link
Contributor

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.

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

2 participants