Debug works but not running standalone

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

Debug works but not running standalone

跳至解决方案
1,160 次查看
il_andil
Contributor I

Hi,

I'm using microcontroller MKL02Z32CAF4 installed on a custom PCB and i program it with MCUExpresso IDE version 11.5; I use MCU-Link debug probe with v 3.133 firmware; my SKD is SDK_2.x_FRDM-KL02Z, but I also used SDK_2.x_MKL02Z32xxx4 and the result is the same.

When I flash the MCU (using SWD) with entering the debug mode, I can step through the code, continue the execution and I see with an oscilloscope a pin on a PCB toggling in an infinite loop (that is all the code is doing).

However, when I flash using GUI Flash Tool (or I just power of and then on after debugging session), then nothing happens - it seems like the code isn't running.

I've read a few posts in this forum and didn't find an answer that worked.

Here are a bit more details: I do mass erase, and do SOFT reset handling, and a reset on connection and on completion.

il_andil_1-1710435468079.png

 

Please help - is there any settings I can check? Does the IDE do something magical in the debug mode that makes the code run, but just flashing it won't work.

标签 (2)
标记 (1)
0 项奖励
回复
1 解答
1,054 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls try to set the flash configuration field with:

__attribute__ ((used,section(".FlashConfig"))) const struct {

unsigned int word1;

unsigned int word2;

unsigned int word3;

unsigned int word4;

} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFBFE};

 

xiangjun_rong_0-1710815741950.png

The FTFA_FOPT[NMI_DIS] bit will be cleared

Hope it can help you

BR

XiangJun Rong

在原帖中查看解决方案

0 项奖励
回复
9 回复数
145 次查看
JKPAPER_DELOPT_SR
Contributor I

Hello, I am facing a similar issue with MIMXRT1064 custom board. But above mentioned options are not avaliable in the startup file. Please help

 

0 项奖励
回复
1,138 次查看
ErichStyger
Senior Contributor V

Hi @il_andil ,

a) are you using semihosting in your code? If so, if your hardfault handler does not deal with it without debugger, then it might block the target. See https://mcuoneclipse.com/2023/03/09/using-semihosting-the-direct-way/

b) Do you use anything from the cycle counter register? It is initialized by default by the debugger, but if you are using it from your application, then DWT needs to be initialized by the application: https://mcuoneclipse.com/2017/01/30/cycle-counting-on-arm-cortex-m-with-dwt/

c) If your device has an EzPort, make sure it is not entering the loader mode, check https://mcuoneclipse.com/2016/12/22/disabling-ezport-on-nxp-kinetis-to-solve-power-on-issues/ 

d) Attach to the running (well, blocked) target with the debugger to see what is going on: https://mcuoneclipse.com/2021/04/25/attach-with-the-debugger-to-a-running-target/ 

 

I hope this helps,

Erich

0 项奖励
回复
1,124 次查看
il_andil
Contributor I
@ErichStyger
a) semihosting is disabled.
I will check your links on (b), (c), (d)
/Andrii
0 项奖励
回复
1,131 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

From hardware perspective, you have to write the application code to internal flash instead of RAM, secondly, pls check the PTA5(Reset_b) pin, the Reset pin must be driven High or float(),there is internal pull-up resistor for the pinPTA5, so it is high if the pin is float.

Hope it can give you a clue.

BR

XiangJun Rong

0 项奖励
回复
1,125 次查看
il_andil
Contributor I

@xiangjun_rong

The reset_b pin is floating. The issue is that in standalone mode I see on an oscilloscope that reset_b goes LOW for 30us. 

I think I do write the code into the internal flash.

 

0 项奖励
回复
1,092 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

From software perspective, Erich has given you a lot of suggestion.

From hardware perspective, pls check the PTB5(NMI_b) pin logic, you'd better configure it high by connecting a 10K ohm pull-up resistor so that the NMI interrupt can not happen. Or clear the FTFA_FOPT[NMI_DIS] bit in the application code.

Pls have a check

BR

XiangJun Rong

0 项奖励
回复
1,080 次查看
il_andil
Contributor I

@xiangjun_rong 

The NMI_b pin is driven to the GND on the custom PCB I use. Do you think this could explain why I see resets?

Could you guide me on how to clear  FTFA_FOPT[NMI_DIS] bit from the application code?

/Andrii

0 项奖励
回复
1,055 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls try to set the flash configuration field with:

__attribute__ ((used,section(".FlashConfig"))) const struct {

unsigned int word1;

unsigned int word2;

unsigned int word3;

unsigned int word4;

} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFBFE};

 

xiangjun_rong_0-1710815741950.png

The FTFA_FOPT[NMI_DIS] bit will be cleared

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复
1,042 次查看
il_andil
Contributor I

@xiangjun_rong this did the trick. Thanks a lot!

0 项奖励
回复