S32DS 3.5 Debug issue with O3 optimization

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32DS 3.5 Debug issue with O3 optimization

跳至解决方案
893 次查看
Li_Chen
Contributor III

I update my S32DS ID to 3.5 and running the Port_Example_S32K344 example on S32K3X4EVB-Q172 board using PEmicro Debugger. It works as expected, but If I changed optimization level from -Os to -O3, I encountered the 'Break at address "0x0" with no debug information available, or outside of program code' error and cannot debug any more. I'm using SW32K3_RTD_4.4_R21-11_3.0.0_D2303_DS_updatesite

debug_setting.png

debug_error.png

0 项奖励
回复
1 解答
820 次查看
Li_Chen
Contributor III

I find the root cause is inside startup code. If change Optimization level to Os in the Startup_Code folder, the code could run as expected. 

Startup_Os.png

If Change to O3, the problem will happen after vldr d7, [r1] instruction inside startup.c/init_data_bss function. This is corresponding to the c code ram[j] = rom[j]; where is to copy rom data from __INIT_INTERRUPT_START address 0x00400800 to __RAM_INTERRUPT_START DTCM address 0x20000000. If using Os settup, the assembly is using different instruction ldr.w r7, [r1, r4, lsl #2] and str.w r7, [r0, r4, lsl #2].

Wondering If you have any better explanation or workaround about failure case if using O3 optimization.

O3_1.png

在原帖中查看解决方案

0 项奖励
回复
3 回复数
821 次查看
Li_Chen
Contributor III

I find the root cause is inside startup code. If change Optimization level to Os in the Startup_Code folder, the code could run as expected. 

Startup_Os.png

If Change to O3, the problem will happen after vldr d7, [r1] instruction inside startup.c/init_data_bss function. This is corresponding to the c code ram[j] = rom[j]; where is to copy rom data from __INIT_INTERRUPT_START address 0x00400800 to __RAM_INTERRUPT_START DTCM address 0x20000000. If using Os settup, the assembly is using different instruction ldr.w r7, [r1, r4, lsl #2] and str.w r7, [r0, r4, lsl #2].

Wondering If you have any better explanation or workaround about failure case if using O3 optimization.

O3_1.png

0 项奖励
回复
795 次查看
Li_Chen
Contributor III
Add volatile to those variables fix the issue:
volatile const uint32 * rom;
volatile const uint8 * rom8;
volatile uint32 * ram;
volatile uint8 * ram8;
0 项奖励
回复
854 次查看
VaneB
NXP TechSupport
NXP TechSupport

Hi @Li_Chen 

Check the following post. It has information related to the topic that might be useful to you. 

Is the MCU function and performance exactly the same for (-O3) and (-Os)?

 

B.R.

VaneB

0 项奖励
回复