cancel
Showing results for 
Search instead for 
Did you mean: 

Define and use data sections in the Touchgfx simulator?

awiernie
Senior II

Can I use memory data sections in the SIMULATOR of TouchGFX?

 

I want to add something like

{
    setError(1); // 1 will be replaced by an unique constant (enum) 
    #if USE_ADD_INFO_FOR_ERROR
    ADD_INFO_FOR_ERROR(1, "some explanation for error 1");
    #endif
}

add various places in the source code and print them in the simulator in the main() function w/o calling ADD_INFO_FOR_ERROR before. 

This would work with:

#define ADD_INFO_FOR_ERROR(INTEGERVALUE, CONSTANTTEXT) \
    static const struct { \
        int index; \
        const char *text; \
    } entry_##INTEGERVALUE __attribute__((section(".add_info_section"), used)) = {INTEGERVALUE, CONSTANTTEXT};

 This compiles with the productive system but with the simulator, it is not possible or I do not know how to access the data section. 

3 REPLIES 3

Hello @awiernie ,

To be honest, I'm a bit confused about what you are trying to achieve. Do you want to display some information in the debugger? 
And, what do you mean by productive system?
When you run an application on the target, there is a linker script that defines these memory sections, however, the simulator just runs on RAM, and it is compiled by gcc. Therefore, you might be able to replicate the steps for running the application using arm-gcc on the target, but I have never tried it myself.

Mohammad MORADI
ST Software Developer | TouchGFX

Productive system is the embedded system, not the Simulator. I use the simulator for module tests and generating some infos, like a list of error messages. I want to put comments about error messages in the source code in local funtions near the call of error message function. If I would define them as described, they would be stored in a data section, which could be read in the main()-Function of the simulator w/o need to execute anything else.

 

An alternative would be, to put the comments in C/C++ comments together with any key and scan the source code with a tool in order to extracting these. 

 

 

Okay, yes, it is possible to achieve it on embedded systems since we have more control over the RAM structure. However, to be honest, I have never tried to do something similar, therefore, I might not have a good idea of how to implement it.
But I assume a static analyzer can help you achieve your goal. 

Best regards,

Mohammad MORADI
ST Software Developer | TouchGFX