Banner_AURIX_Security-Solution Banner_AURIX_Security-Solution Banner_AURIX_Security-Solution Banner_AURIX_Security-Solution


infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 8 of 8

Thread: read the data stack contents

  1. #1
    New Member New Member rbennour is on a distinguished road
    Join Date
    Feb 2019
    Posts
    7
    Points
    47.5

    read the data stack contents

    I just bought the TFT Aurix_TC277 microcontroller and started programming with Hightec.
    I am beginner with the aurix.

    so I need your help,
    I have to read the contents of the memory after running a program.
    for example, I work on the CUP0, I know that all the data is stored in the DMI and I also know the size of this memory, which is 120 KB.

    I want to know if it is possible with Aurix to read the contents of this memory after running a program?

    and i want to know if he can read the contents of the memory using another kernel not to touch the program running on the core0?

    the need is to trace all values written in memory of program execution

    if you have documents or an example, send it to me.

  2. #2
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    130
    Points
    2567.5
    Hi Rihab,

    I have created the attached example. To run it click the tiny down arrow within the build button, and build the tsim target from here. You can also enable the "Make Target" view and double-click the tsim target. The expected output (console-TAB) should be:

    Code:
    Lowest: 0xd0000890
    Highest: 0xd0001890
    F(20) = 4181
    Stack Usage: 1228 bytes
    Let me know if you have questions.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software
    ?????

  3. #3
    New Member New Member rbennour is on a distinguished road
    Join Date
    Feb 2019
    Posts
    7
    Points
    47.5
    Thank you for your answer,
    can you explain it more please, does the code you created, allows to display the contents of the stack, during the execution of the program?
    I am studying and understanding the functionality of TSIM.
    can you tell me how I can install TSIM

    best regards

  4. #4
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    130
    Points
    2567.5

    Hi Rihab,

    <snip> can you explain it more please <snip>
    Sure. Have a look at this recording (password: Blomkamp). I'm going relatively fast, but the aim is to give you a quick overview. Note first of all TSIM is part of the product. No need to install it. The Makefile.targets pulls it from the correct location. This makefile itself is being pulled by the master makefile that is created when you build the project for the first time.

    Next note functions init_stack() (line #20) and stack_usage() (line #27). The former initialises the stack with a predefined value 0xBADDCAFE. The latter reads it back after some stack usage. Based on the values that were overwritten through this usage I make a ballpark estimate. Be sure to check the mapfile (read_stack.map, also created after your initial build) as well. In here you can cross-reference the results of the output console.

    Stack labels __lc_b_ustack and __lc_e_ustack are created in the hightec.ld linker script. They are derived from existing system symbols __USTACK and __USTACK_SIZE that are declared in memory-tc27xx.x. This system script is pulled from <toolset>/lib/gcc/tricore/4.9.4 which itself implicitly (through the INSERT command) pulls elf32tricore.x which resides in <toolset>/tricore/lib/ldscripts. As a whole they create your entire memory map.

    My first build breaks in the example. I'm not sure why, but removing the dot character solves the issue and produces the build as I predicated it. Note that the recording purposely has a limited lifetime. It will last you 1 week so be sure to download it.

    If you have any further questions, just let me know.

    Best regards,

    Henk-Piet Glas
    Principal Technical Specialist
    Embedded Software

  5. #5
    New Member New Member rbennour is on a distinguished road
    Join Date
    Feb 2019
    Posts
    7
    Points
    47.5
    thank you so much
    it's clear to me,
    I just have related questions:
    - I did not understand the stack_usage function why return 4 * (__lc_e_ustack - p); what does it mean 4

    - is the stack_usage function used to count the number of bytes used in the stack?
    Last edited by rbennour; Jul 10th, 2019 at 06:05 AM.

  6. #6
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    130
    Points
    2567.5

    Hi Rihab,

    Concerning your followup questions. When you subtract two integer pointers you will get the number of integer indexes between those two pointers. Since the aim is to find out how many bytes have been used, I then multiply it by four. Your second question is correct; it calculates how much stack was used by the following statement:

    Code:
    printf("F(20) = %d\n", F(20));
    This statement emulates a specific user application. I used a recursive function to force off some stack activity.

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software

  7. #7
    New Member New Member rbennour is on a distinguished road
    Join Date
    Feb 2019
    Posts
    7
    Points
    47.5
    Hello Henk.

    K, thanks,
    it helped me too much.
    just last question please,
    since now I know the highest and lowest address of the stack so the number of bytes used in the stack, I created a function that reads what is written in this address range to see what which is written in the stack, so I did that :

    int pile_start =0xd0000890;
    int size =0x1890;
    void read_stack()
    {
    ptrdiff_t i;
    for ( i = pile_start; i < size; i++)
    {
    printf("pile = %d \n", *( unsigned char * )(pile_start+i));
    }
    }

    and after I had on the consol values like that :
    stack = 217
    stack = 173
    stack = 0
    stack = 48
    stack = 128
    stack = 242
    stack = 139
    stack = 2
    stack = 40
    stack = 66
    stack = 223
    stack = 4
    .....
    ...
    ..


    like that, I think that it does not make sense this display there,
    Normally it must have values, symbols and addresses in the stack
    * is my way of displaying the stack is not correct?

  8. #8
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    130
    Points
    2567.5

    Hi Rihab,

    Stack allocation is a dynamic process, managed by the compiler. Automatics such as you describe have a certain lifetime. They move into focus and after a while they disappear again. As an end-user you're really not that interested for as long as things are running smooth and efficiently.

    If you want to dump what's physically being allocated onto the stack at any point in time, it's probably best to inspect the disassembly instead. Your own dump is just an integer dump of whatever has been placed onto the stack, but you can't tell what's what from that. You also can't tell from that, what's life and what isn't.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.