J-Flash ARM烧写Nor Flash时出错:PC of target system has unexpected value after programming

本文解决了使用J-FlashARM烧写NorFlash时出现的“PCoftargetsystemhasunexpectedvalueafterprogramming”错误。通过调整初始化序列中的延迟时间至2毫秒,提高了烧写成功率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【已解决】J-Flash ARM烧写Nor Flash时出错:PC of target system has unexpected value after programming

【问题】

最近在用J-Flash ARM去烧写TQ2440板子上的Nor Flash,但是在烧写过程中,经常会出错:

PC of target system has unexpected value after programming

如图:


但是需要说明一点的是,在此之前,有段时间一直用此工具烧写Nor Flash的,都是很顺利,N多次,都没有任何出错的。

而现在出这样的错误的几率是9/10,即搞个好多次,才能偶尔又一次成功烧写的,搞得很是郁闷,严重影响心情和调试效率。

【解决过程】

1. 看着这现象,貌似是RAM不稳定或者没有初始化好,而导致J-Flash ARM运行有问题,没有正常烧写。

所以去尝试取消了RAM,即Options -> Project Settings -> CPU中,取消Use target RAM(faster)的话,好像是不会出错的,但是烧写起来,速度就太慢了,是一个一个字节烧写的,烧个200多K的u-boot.bin的话,估计得几十分钟,所以无法忍受。

还是需要用到Use target RAM(faster)来实现快速烧写的,这个只要一二十秒即可。

2.后来又去更改JTAG的工作频率,从很低的100KHZ到很高的4MHz,12MHz等,或者是Auto模式,都试了试,但是还是会出错。

3. 后来又去折腾,更改很多设置,看看是否有用。最后的最后,幸运地,终于找到解决办法了:

Options -> Project Settings -> CPU -> 'Use following init sequence:'中,默认只有一行:

0 reset 0 0ms reset and Halt target,

然后选中该行,点击Edit,修改Delay为2ms,确定,即可。

如图:


即在通过JTAG去reset重启目标开发板之后,再delay延迟个2毫秒,等待板子各种硬件都稳定了,然后再通过J-Flash ARM去烧写Nor Flash,此时就都一切正常了。

额外说句:

后来输入英文“PC of target system has unexpected value after programming”的时候,发现google上,也有对应的帖子的,只是自己之前没发现而已,惭愧啊。

不过刚去看其解决方法,倒是和我不太一样,其是把'Use following init sequence中的动作从默认的reset改为Halt,即使cpu暂停,使得CPU不会乱跑,然后接下来去烧写nor flash,也就正常了。而我此处的是reset后,等待2ms,目的也是等待系统稳定。目的相同,实现方法不同而已。

刚又看到别人讨论此现象的原因,说是可能是watchdog还在运行,导致系统reset,所以程序跑飞了,所以才出错的。

个人感觉不是很像,如果是watchdog还在运行导致出错,那么我们上面的reset后,多加的2ms的delay后,也还是会出错才对,但是我这里是可以解决问题,不会出错的,所以,感觉是系统reset后,需要一段时间,等稳定下来,继续操作,才正常的。

不过有空是可以尝试去设置关闭watchdog,看看是否能解决问题。

经过尝试,发现添加对应动作去在reset后,关闭watchdog:

0x53000000= 0x0; /* make sure bit5=0 to disable watchdog */

如图:


但是再去烧写nor flash,还是会出错,所以,可以确定不是watchdog的问题,而很可能是TQ2440在reset后,系统稳定性的问题,需要有个延迟以等待系统稳定。

【总结】

1.遇到问题,还是需要大胆地多去折腾折腾,最后往往会有效果的。即使没解决问题,也会有新的发现的。

【引用】

1.Solved: J-Flash ARM: PC of target system has unexpected value after 。。。

http://lesca.me/blog/2011/02/25/solved-j-flash-arm-pc-of-target-system-has-unexpected-value-after/

2. 使用J-Link下载程序到Nor Flash3650395344

http://blog.mcuol.com/User/Leo_lei/Article/36503_1.htm


### ST-Link Flash Download Failed Target DLL Cancelled Solution When encountering a "ST-Link flash download failed, target DLL cancelled" issue, several factors could contribute to this problem. The error might be due to hardware issues with the ST-Link programmer or software configuration problems on the development environment side. #### Verify Hardware Connections and Functionality Ensure all connections between the microcontroller board and the computer are secure and functioning correctly. Check for any loose cables or damaged pins which can cause communication failures during programming sessions[^1]. #### Update Drivers and Software Tools Outdated drivers may not fully support newer versions of firmware files leading to unexpected errors like cancellation by the target DLL. Installing latest driver packages from official sources ensures compatibility while also providing bug fixes that address common issues encountered during flashing processes[^2]. ```bash # Example command line instruction for updating STM32CubeProgrammer tool STM32_Programmer_CLI.exe -c port=SWD freq=4000 reset=HWRST ``` #### Adjust Configuration Settings Appropriately Incorrect settings within project configurations such as incorrect memory addresses specified under linker scripts will result in failure messages similar to what has been described here. Reviewing these parameters carefully against datasheets provided by manufacturers helps prevent mismatches causing operation cancellations at runtime level. #### Utilize Diagnostic Features Provided By IDEs/Tools Most integrated development environments (IDEs) along with specialized tools offer diagnostic features enabling users to capture detailed logs about operations performed including those related specifically towards downloading binaries onto targets via debug probes like ST-LINK/V2-1. These insights assist greatly in pinpointing exact causes behind unsuccessful attempts made previously so corrective actions can then follow accordingly based upon gathered information obtained through analysis conducted using available resources present inside chosen platforms used throughout projects involving embedded systems design work. --related questions-- 1. What steps need to be taken before attempting another flash download after experiencing a 'target DLL cancelled' message? 2. How do outdated drivers affect the functionality of an ST-Link device when interfacing with various types of MCUs? 3. In what ways does misconfiguration within one's development setup lead directly to errors seen during program deployment phases targeting ARM Cortex-M series processors? 4. Can you provide examples where specific adjustments were necessary within certain sections found inside typical .ld script files utilized across multiple compiler chains supporting different architectures but still adhering closely enough together regarding syntax rules applied generally speaking amongst them all?
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值