Detailed examples - #pragma section compiler command function is applied to the cover to its scope whether subroutine

In the previous blog [ link script (Linker Script) application example (a) using the copy table will be loaded into RAM to run function ], we are the first step in using the #pragma section command PFlashProgram storage function to block .flash_driver, specific procedures are as follows:

#pragma section ".flash_driver" ax

void PFlashProgram( uint32 flash, uint32 addr, uint32 word_l, uint32 word_u )
{
    uint32 load_cnt;
    uint16 endinitSfty_pw = IfxScuWdt_getSafetyWatchdogPasswordInline();

    IfxFlash_enterPageMode(addr);

    /* wait until unbusy */
    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);

    /* write 32 bytes (8 doublewords) into assembly buffer */
    for (load_cnt = 0; load_cnt < 4; load_cnt++)
    {
        IfxFlash_loadPage2X32(addr, word_l, word_u);
    }

    /* write page */
    IfxScuWdt_clearSafetyEndinitInline(endinitSfty_pw);
    IfxFlash_writePage(addr);
    IfxScuWdt_setSafetyEndinitInline(endinitSfty_pw);

    /* wait until unbusy */
    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);
}
#pragma section

Map file after compilation as can be seen PFlashProgram function generator block size is 280 bytes . After the contents of the following functions to adjust recompiled, but also to verify the IfxFlash_enterPageMode, IfxFlash_waitUnbusy Functions and the like IfxFlash_loadPage2X32 simultaneously stored when the segment is stored .flash_driver PFlashProgram function block. The reason this question is noteworthy, because if not it will be stored in the sub-function segment, when the subroutine will default in the ROM (Flash), then PFlashProgram to perform its function subroutine stored in RAM instead of Flash from taking instruction. Since the TC297 does not support Flash Flash operating function where it will be erased (Flash mostly have this feature) (Flash function must operate in RAM or Flash Bank in another run to perform the erase operation) , PFlashProgram can not successfully to write to the PFlash. Also, learn #pragma section command This feature also helps programmers to grasp for code storage and implementation.

Linker version: GNU ld version (GNU Binutils) 2.20 (TriCore) using BFD version (GNU Binutils) 2.20 (v2.3), Tool Version v2.7
Name of linker executable: c:/hightec/toolchains/tricore/v4.9.1.0-infineon-2.0/bin/../lib/gcc/tricore/4.9.4/../../../../tricore/bin/ld.exe
Date of link run: Thu Sep 05 10:42:28 2019
Name of linker map file: Flash_test.map

>>> Symbols (global (S = g) and static (S = l); sorted by address)

============================================================================================================================================================
Start      End        Size S Name                                   Memory      O-Sec        I-Sec         Input object                                     
============================================================================================================================================================
0x00000290 0x00000290    0 g __TRICORE_DERIVATE_MEMORY_MAP__        *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK0_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK1_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK2_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000800 0x00000800    0 g LCF_HEAP_SIZE                          *ABS*       *ABS*        *ABS*         *ABS*
0x00000800 0x00000800    0 g LCF_USTACK0_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000800 0x00000800    0 g LCF_USTACK1_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000800 0x00000800    0 g LCF_USTACK2_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*

......................

0x800f6000 0x800f6000    0 g __TRAPTAB_CPU2                         pfls0       .traptab_tc2 .traptab_tc2  Flash_test.elf
0x800f6200 0x800f62f3  244 g IfxCpu_Trap_vectorTable1               pfls0       .traptab_tc1 .traptab_cpu1 0_Src\4_McHal\Tricore\Cpu\Trap\IfxCpu_Trap.o
0x800f6200 0x800f6200    0 g LCF_TRAPVEC1_START                     *ABS*       *ABS*        *ABS*         *ABS*
0x800f6200 0x800f6200    0 g __TRAPTAB_CPU1                         pfls0       .traptab_tc1 .traptab_tc1  Flash_test.elf
0x90008000 0x90008000    0 g _SMALL_DATA4_                          *ABS*       *ABS*        *ABS*         *ABS*
0x90008000 0x90008000    0 g __A9_MEM                               *ABS*       *ABS*        *ABS*         *ABS*
0xc0000000 0xc0000117  280 g PFlashProgram                          psram_local .code2ram    .flash_driver 0_Src\0_AppSw\Tricore\Demo_Illd\FlashDemo.o

 (1) First, comment out the five sub-functions associated with the operation of Flash, and then recompile to see map files. Visible PFlashProgram generated function block size becomes 136 bytes , indicating whether these five functions corresponding to the operation of Flash block size of 144 (280-136) byte it? We continue to test

#pragma section ".flash_driver" ax

void PFlashProgram( uint32 flash, uint32 addr, uint32 word_l, uint32 word_u )
{
    uint32 load_cnt;
    uint16 endinitSfty_pw = IfxScuWdt_getSafetyWatchdogPasswordInline();

//    IfxFlash_enterPageMode(addr);

    /* wait until unbusy */
//    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);

    /* write 32 bytes (8 doublewords) into assembly buffer */
    for (load_cnt = 0; load_cnt < 4; load_cnt++)
    {
//        IfxFlash_loadPage2X32(addr, word_l, word_u);
    }

    /* write page */
    IfxScuWdt_clearSafetyEndinitInline(endinitSfty_pw);
//    IfxFlash_writePage(addr);
    IfxScuWdt_setSafetyEndinitInline(endinitSfty_pw);

    /* wait until unbusy */
//    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);
}
#pragma section
Linker version: GNU ld version (GNU Binutils) 2.20 (TriCore) using BFD version (GNU Binutils) 2.20 (v2.3), Tool Version v2.7
Name of linker executable: c:/hightec/toolchains/tricore/v4.9.1.0-infineon-2.0/bin/../lib/gcc/tricore/4.9.4/../../../../tricore/bin/ld.exe
Date of link run: Thu Sep 05 18:34:08 2019
Name of linker map file: Flash_test.map

>>> Symbols (global (S = g) and static (S = l); sorted by address)

============================================================================================================================================================
Start      End        Size S Name                                   Memory      O-Sec        I-Sec         Input object                                     
============================================================================================================================================================
0x00000290 0x00000290    0 g __TRICORE_DERIVATE_MEMORY_MAP__        *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK0_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK1_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK2_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
..........
0x800f6200 0x800f6200    0 g __TRAPTAB_CPU1                         pfls0       .traptab_tc1 .traptab_tc1  Flash_test.elf
0x90008000 0x90008000    0 g _SMALL_DATA4_                          *ABS*       *ABS*        *ABS*         *ABS*
0x90008000 0x90008000    0 g __A9_MEM                               *ABS*       *ABS*        *ABS*         *ABS*
0xc0000000 0xc0000087  136 g PFlashProgram                          psram_local .code2ram    .flash_driver 0_Src\0_AppSw\Tricore\Demo_Illd\FlashDemo.o

Now, we commented code outside 5 Flash manipulation functions, map file as follows. See PFlashProgram size becomes 146 bytes 144 bytes, rather than the previously estimated. Why the extra 2 bytes of it? We followed the entire interior of the body of the function statement commenting out all try to see "framework" functions take up much space.

#pragma section ".flash_driver" ax

void PFlashProgram( uint32 flash, uint32 addr, uint32 word_l, uint32 word_u )
{
//    uint32 load_cnt;
//    uint16 endinitSfty_pw = IfxScuWdt_getSafetyWatchdogPasswordInline();

    IfxFlash_enterPageMode(addr);

    /* wait until unbusy */
    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);

    /* write 32 bytes (8 doublewords) into assembly buffer */
//    for (load_cnt = 0; load_cnt < 4; load_cnt++)
//    {
        IfxFlash_loadPage2X32(addr, word_l, word_u);
//    }

    /* write page */
//    IfxScuWdt_clearSafetyEndinitInline(endinitSfty_pw);
    IfxFlash_writePage(addr);
//    IfxScuWdt_setSafetyEndinitInline(endinitSfty_pw);

    /* wait until unbusy */
    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);
}
#pragma section
Linker version: GNU ld version (GNU Binutils) 2.20 (TriCore) using BFD version (GNU Binutils) 2.20 (v2.3), Tool Version v2.7
Name of linker executable: c:/hightec/toolchains/tricore/v4.9.1.0-infineon-2.0/bin/../lib/gcc/tricore/4.9.4/../../../../tricore/bin/ld.exe
Date of link run: Thu Sep 05 18:45:58 2019
Name of linker map file: Flash_test.map

>>> Symbols (global (S = g) and static (S = l); sorted by address)

============================================================================================================================================================
Start      End        Size S Name                                   Memory      O-Sec        I-Sec         Input object                                     
============================================================================================================================================================
0x00000290 0x00000290    0 g __TRICORE_DERIVATE_MEMORY_MAP__        *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK0_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK1_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK2_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
..........
0x800f6200 0x800f6200    0 g __TRAPTAB_CPU1                         pfls0       .traptab_tc1 .traptab_tc1  Flash_test.elf
0x90008000 0x90008000    0 g _SMALL_DATA4_                          *ABS*       *ABS*        *ABS*         *ABS*
0x90008000 0x90008000    0 g __A9_MEM                               *ABS*       *ABS*        *ABS*         *ABS*
0xc0000000 0xc0000091  146 g PFlashProgram                          psram_local .code2ram    .flash_driver 0_Src\0_AppSw\Tricore\Demo_Illd\FlashDemo.o

 It can be seen from the map file, a function of the empty size of 2 bytes. Here we know the function of the total size is 280 bytes, wherein the function "framework" occupies 2 bytes, 5 bytes Flash operation 144 accounting functions, and other functions account statements 134 bytes.

This, we can conclude this post the most important conclusion: #pragma section command is stored to a function block, it will also call subroutine stored in the segments together.

#pragma section ".flash_driver" ax

void PFlashProgram( uint32 flash, uint32 addr, uint32 word_l, uint32 word_u )
{
//    uint32 load_cnt;
//    uint16 endinitSfty_pw = IfxScuWdt_getSafetyWatchdogPasswordInline();

//    IfxFlash_enterPageMode(addr);

    /* wait until unbusy */
//    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);

    /* write 32 bytes (8 doublewords) into assembly buffer */
//    for (load_cnt = 0; load_cnt < 4; load_cnt++)
//    {
//        IfxFlash_loadPage2X32(addr, word_l, word_u);
//    }

    /* write page */
//    IfxScuWdt_clearSafetyEndinitInline(endinitSfty_pw);
//    IfxFlash_writePage(addr);
//    IfxScuWdt_setSafetyEndinitInline(endinitSfty_pw);

    /* wait until unbusy */
//    IfxFlash_waitUnbusy(flash, IfxFlash_FlashType_P0);
}
#pragma section
Linker version: GNU ld version (GNU Binutils) 2.20 (TriCore) using BFD version (GNU Binutils) 2.20 (v2.3), Tool Version v2.7
Name of linker executable: c:/hightec/toolchains/tricore/v4.9.1.0-infineon-2.0/bin/../lib/gcc/tricore/4.9.4/../../../../tricore/bin/ld.exe
Date of link run: Thu Sep 05 18:52:56 2019
Name of linker map file: Flash_test.map

>>> Symbols (global (S = g) and static (S = l); sorted by address)

============================================================================================================================================================
Start      End        Size S Name                                   Memory      O-Sec        I-Sec         Input object                                     
============================================================================================================================================================
0x00000290 0x00000290    0 g __TRICORE_DERIVATE_MEMORY_MAP__        *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK0_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK1_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
0x00000400 0x00000400    0 g LCF_ISTACK2_SIZE                       *ABS*       *ABS*        *ABS*         *ABS*
..........
0x800f6200 0x800f6200    0 g __TRAPTAB_CPU1                         pfls0       .traptab_tc1 .traptab_tc1  Flash_test.elf
0x90008000 0x90008000    0 g _SMALL_DATA4_                          *ABS*       *ABS*        *ABS*         *ABS*
0x90008000 0x90008000    0 g __A9_MEM                               *ABS*       *ABS*        *ABS*         *ABS*
0xc0000000 0xc0000001    2 g PFlashProgram                          psram_local .code2ram    .flash_driver 0_Src\0_AppSw\Tricore\Demo_Illd\FlashDemo.o

 

Guess you like

Origin www.cnblogs.com/uestcliming666/p/11468251.html