Code overlapping issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code overlapping issue

Jump to solution
2,512 Views
vinaychitturi
Contributor III

I am facing few issues with the assembly code for the SAF library Scheck_Dma_RamBlockingTransfer and sCheck_CortexM7_ErrRead functions. We have a section In memory map for the int_sram_no_cacheable section where we keep all the three particular sections.

vinaychitturi_0-1755549029711.png

So the issue right now is I am having a working project  with GHS based compiler with similar memory map and it is working good. when we add the BSW stack from third party on the base of working software then we are facing some issues, But the memory map file and everything are same and all the sections are looking good. I am not seeing any memory overlap in the memory section, In each section it has sufficient memory. But I can see the above mentioned functions are kind of overlapping to each other.

Working Project Images:

vinaychitturi_1-1755549029751.png

vinaychitturi_2-1755549029796.png

vinaychitturi_3-1755549029841.png

vinaychitturi_4-1755549029858.png

Non_working project images:

vinaychitturi_5-1755549029889.png

vinaychitturi_6-1755549029963.png

vinaychitturi_7-1755549030016.png

vinaychitturi_8-1755549030028.png

In those comparisons you can see the difference, These functions are kind of overlapping and it is not matching as mentioned in the map file. Currently we are seeing the hardfault handler error while running into these functions.

Can you guys help us to identify why exactly we are seeing this kind of behavior, It would be really beneficial to have a call and bevug this issue. This is kind of stopper for us for the next steps in this project for the integration.

0 Kudos
Reply
1 Solution
2,375 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @vinaychitturi,

Maybe you can aligned the section to 64bytes in the linker file.

. = ALIGN(64);

The SAF version is compatible with certain RTD drivers, and the release notes of the drivers specify the GHS compiler and linker options. Can you check the options in your project?

danielmartynek_0-1755692276855.png

Regarding the MPU, the MPU region must be aligned to its size, this is how ARM specified it. If you have 32KB region, it must be aligned to 32KB. But the size of the region can be also 8KB or 16KB.

 

Regards,

Daniel

View solution in original post

5 Replies
2,395 Views
vinaychitturi
Contributor III

Hello @danielmartynek 

I look the startup code and saw what is happening and why i am seeing the overlapping issue.

Working Project:

vinaychitturi_0-1755634827239.png

vinaychitturi_1-1755634827247.png

vinaychitturi_2-1755634827257.png

vinaychitturi_3-1755634827264.png

In this project as you can see in ROM and RAM sections for the sram_no_cacheable section after .mcal_const_no_cacheable it is taking 68 bytes of gap for the ramcode_no_cacheable. But that gap is present in both RAM and ROM which is good. SO when I am trying to copy I am able to copy the whole section from flash to sram during initialization because of same gap in RAM and ROM 

Non-Working Project:

vinaychitturi_4-1755634827271.png

vinaychitturi_5-1755634827276.png

vinaychitturi_6-1755634827285.png

vinaychitturi_7-1755634827295.png

In this Non-working project as you can see in ROM and RAM sections for the sram_no_cacheable section after .mcal_const_no_cacheable it is taking 4 bytes of gap for the ramcode_no_cacheable in ROM, 68 bytes in RAM. But that gap is not same in both RAM and ROM. SO when I am trying to copy Because of difference in bytes gap in RAM and ROM while copying from flash to sram during initialization it is getting overlapping.

 

I attached both working and non-working one . So now my question is why it is showing different memory alignment in ROM and RAM in these two projects, How can we make the ROM and RAM to have the similar alignment and similar gaps?

 

In the previous reply you mentioned I need to align the 32kb as per the MPU align base address, But we are not utilizing that much non_cacheable memory. In the linker file the whole no_cacehable is only 0x4d00 bytes. What kind of changes do i need to do in the MPU?

vinaychitturi_8-1755635277455.png

 

 

0 Kudos
Reply
2,376 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @vinaychitturi,

Maybe you can aligned the section to 64bytes in the linker file.

. = ALIGN(64);

The SAF version is compatible with certain RTD drivers, and the release notes of the drivers specify the GHS compiler and linker options. Can you check the options in your project?

danielmartynek_0-1755692276855.png

Regarding the MPU, the MPU region must be aligned to its size, this is how ARM specified it. If you have 32KB region, it must be aligned to 32KB. But the size of the region can be also 8KB or 16KB.

 

Regards,

Daniel

2,438 Views
vinaychitturi
Contributor III

Hello @danielmartynek 

I shared the linker files and startup code, I will also look into the startup code sequence as you mentioned.

 

0 Kudos
Reply
2,424 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Thank you for the files.

I have noticed that the MPU region that starts at __RAM_NO_CACHEABLE_START has size of 32KB. That means the MPU region should be aligned to the size. 

Can you try aligning it to 32KB = 0x8000?

https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Optional-Memory-Protection-U...

danielmartynek_0-1755612841881.png

I'm not saying this is the root cause, but it should be aligned.

 

Regards,

Daniel

0 Kudos
Reply
2,457 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @vinaychitturi,

If the MAP file shows correct placements, the issue likely lies in the code copying process from Flash to SRAM.

Could you please share the linker script and the startup code responsible for copying the code to SRAM?

Additionally, you can place a watchpoint at the SRAM addresses where the affected functions are supposed to reside. Then, step through the startup code to observe how the memory is being initialized and whether any corruption or misalignment occurs during the copy process.

 

Regards,

Daniel 

0 Kudos
Reply