Announcements

Equip yourself to optimize AURIX™ MCUs for Evs at the EV Webinar. Click here to register.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

AURIX™ Forum Discussions

ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

Hello, We want to use flash overlay in our project, but we think we cannot use flash overlay. With memcpy, we copy the data from the flash to the lmuram part, then we change the data on the ram. Last time we want to write back, we cannot write the data in the ram on the flash. What could be the problem?

0 Likes
1 Solution
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

Thanks for your help it was very helpful. We were able to fix the error

View solution in original post

0 Likes
14 Replies
dw
Moderator
Moderator
Moderator
100 likes received 750 replies posted 10 likes given

Hi ifg, could you please explain a bit more? What platform you used?  Could you share your code on write Flash?

dw

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

I use aurix tricore tc389 development board. my aim here calibration with xcp protocol then we determine to use flash overlay to share resources between ram and flash memory. I can share functions that i used. 

firstly I called memcpy to allocate 128 byte for my 32 element uint32 array . After that ı call 

 

IfxCpu_enableOverlayBlock(IfxCpu_ResourceCpu_0,0,IfxCpu_OverlayMemorySelect_lmu,IfxCpu_OverlayAddressMask_32byte,(uint32) &Test_Map_Cal_Flash,(uint32) &Test_Map_Cal_Ram); (test_map arrays sizes are 32 byte)

Then defined a loop for multiply array element values of test_map_cal_ram.
    for(uint8 i=0; i<31; i++ )
    {
        Test_Map_Cal_Ram[i] += Test_Map_Cal_Ram[i];
    }

IfxFlash_loadPage(&Test_Map_Cal_Ram[0],Test_Map_Cal_Ram[1],Test_Map_Cal_Ram[2]);

 for(offset = 0; offset < (size-1); offset += 0x1)     /* Loop over the page length                */
    {
        Load 2 words of 32 bits each */
     IfxFlash_loadPage
    ((uint32)(&Test_Map_Cal_Ram[offset]),Test_Map_Cal_Ram[offset],Test_Map_Cal_Ram[offset+1]);
     }

 IfxFlash_writePage((uint32)&Test_Map_Cal_Ram[offset]); (I called watchdog and busy functions here I didn't add it because I didn't find it necessary to add)

 

 

 

my sequence like that .
 
Thanks for help,
 
Best Regrads
 
Furkan
0 Likes
dw
Moderator
Moderator
Moderator
100 likes received 750 replies posted 10 likes given

Hi Furkan,

As I known from others, non-cached address for PFLASH and DLMU is suggested. 

After overlay activation, if you write to Flash you can see data is written to DLMU as expected. (same expected value at same expected address) and can be read back using overlay.

void verifyProgramFlash()
{
    uint32 page;                                                /* Variable to cycle over all the pages             */
    uint32 offset;                                              /* Variable to cycle over all the words in a page   */
    uint32 errors = 0;                                          /* Variable to keep record of the errors            */

    /* Verify the written data */
    for(page = 0; page < PFLASH_NUM_PAGE_TO_FLASH; page++)                          /* Loop over all the pages      */
    {
        uint32 pageAddr = PFLASH_STARTING_ADDRESS2 + (page * PFLASH_PAGE_LENGTH);    /* Get the address of the page  */

        for(offset = 0; offset < PFLASH_PAGE_LENGTH; offset += 0x4)                 /* Loop over the page length    */
        {
            /* Check if the data in the Program Flash is correct */
            if(MEM(pageAddr + offset) != DATA_TO_WRITE)
            {
                /* If not, count the found errors */
                errors++;
            }
            g_tempArr[offset/4] = MEM(pageAddr + offset);
        }
    }

    /* If the data is correct, turn on the LED1 */
    if(errors == 0)
    {
        IfxPort_setPinState(LED1, IfxPort_State_low);
    }
    else{

        IfxPort_setPinState(LED2, IfxPort_State_low);
    }
}



void testOverlay()
{

    IfxCpu_enableOverlayBlock(IfxCpu_ResourceCpu_0,0,IfxCpu_OverlayMemorySelect_core0DsprPspr,IfxCpu_OverlayAddressMask_32byte,(uint32) &Test_Map_Cal_Flash,
                (uint32) &Test_Map_Cal_Ram);// (test_map arrays sizes are 32 byte)

}

 

I have tested above code, for PFlash data, the address is 0x800023E0, for DSPR data, the address is 0x70000000, so after activate overlay, if you read data from 0x800023E0, or 0xA00023E0, the data will be from 0x70000000.

Please notice the array address should be take care, the >>5 is used in the iLLD function. So last 5 bit is no use, the source and target address should be suffixed by 0x....00/0x....20/0x....40/0x....60/0x....80/0x....A0/0x....C0/0x....E0

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

Hello,

We tried so many time but we didnt become succed. All our tries we cant use flash overlay so we though we didnt start overlay properly. We cant notice where problem occur in code. Also how we can overlay data from ram to flash is that possible ?. 

0 Likes
dw
Moderator
Moderator
Moderator
100 likes received 750 replies posted 10 likes given

I have attached my source, please notice only Pflash Read is used. If you read from PFlash, the data of DSPR will replace.

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

Thanks for your help it was very helpful. We were able to fix the error

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

Hi again.

Additionally ı want to ask something else. we overlayed successfully from flash to ram but we cant overwrite to constant variables in ROM address. How we can solve it ? . Also we open overlay after hard reset then we don't close it is that true way to use overlay ?. The reason why we keep the overlay open all the time is that we can't write data to the rom address of the constant parameters.

Furkan,

Best Regards,

0 Likes
dw
Moderator
Moderator
Moderator
100 likes received 750 replies posted 10 likes given

I suppose you enable overlay, and write it will mirror to RAM. Could you try disable overlay and flash program the constant parameters?

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

we tried it erases that field but could not write.

0 Likes
dw
Moderator
Moderator
Moderator
100 likes received 750 replies posted 10 likes given

It's suggested to start from Flash Programming example code.

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

I can write data to any address that is not a constant address, using the existing flash write functions. I observed this by trying it. but when constant is a variable and I cannot write data to the address of this constan variable in rom.

 

When I use the constant data address, write to flash and delete functions, it deletes that address but cannot write it.

 

For example,

 

Constant Variable temp_data
erase -> ok
write -> nok
const uint32 temp_data[32]={0,1,2,3,...};

 

Normal Variable temp_data_2
erase -> ok
write -> ok
uint32 temp_data_2[32]={0,1,2,3,...};

 

I think the current flashing functions cannot write to the address of the constant variable.

0 Likes
dw
Moderator
Moderator
Moderator
100 likes received 750 replies posted 10 likes given

Can you try Dflash address?

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

yes, I tried. I can write.

 

 

0 Likes
ifg
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

Hello again,

We are still struggling with this problem can you give us any hints to solve it?

0 Likes