OpenNuvoton / M031BSP

BSP for M031 Series MCU
Apache License 2.0
15 stars 16 forks source link

Debugging issues with Keil uVision and ULINKplus/Nu-Link2-Pro debug adapter #14

Open mf301 opened 2 years ago

mf301 commented 2 years ago

When using Keil uVision with a ULINKplus debug adapter on a M031 target, the reset type "HW RESET" does not work. Opening a debug connection fails with the error "Could not stop Cortex-M device! Please check the JTAG cable."

Reset types "Autodetect" and "SYSRESETREQ" work fine, but do not perform a full reset (e.g. VECMAP remains unchanged).

ARM Keil support pointed out, that in case of special reset requirements the relevant debug sequence has to be implemented in the DFP by the chip manufacturer (see https://arm-software.github.io/CMSIS_5/Pack/html/debug_description.html#resetSystem). It looks like the standard debug sequences do not work properly.

kchuang1 commented 2 years ago

Hi,

If you use ULINK with problem on Keil, you can use Nu-Link or Nu-Link Pro for debugging. By the way, Nuvoton's M031 NuMaker board is already with the Nu-link2-ME for it. You can use it with Keil without problem. https://direct.nuvoton.com/tw/nu-link

Regarding VECMAP, it is only changed dependent on the CBS setting which can be set by ICP tool.

mf301 commented 2 years ago

We recently ordered a Nu-Link2-Pro debugger, with this debugger reset type "HW RESET" is working properly. Unfortunately there are issues with this adapter, too. When using reset types "Autodetect" and "SYSRESETREQ" somehow (maybe by the debugger internally?) VECMAP is set to zero, but if enabled WDT will continue to run. This creates a problem when the downloaded application enables WDT, as during flash download this will lead to a watchdog reset. This issue applies both to the ULINKplus and Nu-Link2-Pro debugger.

kchuang1 commented 2 years ago

What is your setting for WDT_CTL[31] in your coding? Please set it as "0" to hold the WDT up counter while CPU is held by ICE.

I tested with below sample, and it still can work fine without reset by WDT. https://github.com/OpenNuvoton/M031BSP/tree/master/SampleCode/StdDriver/WDT_TimeoutWakeupAndReset

mf301 commented 2 years ago

WDT is configured as follows: WDT_CTL = 0x00000382 WDT_ALTCTL = 0x00000003 38.4kHZ LIRC is used as watchdog clock, we are using a M031LE3AE target.

With a program size of about 42kB and reset method set to "SYSRESETREQ" in the debugger configuration menu the problem occurs, as MCU reset doesn't stop the WDT and download is effectively interrupted by a watchdog reset.

kchuang1 commented 2 years ago

WDT_TimeoutWakeupAndReset.zip

Hi,

I enlarged the code size to about 44KB and setting as yours. It doesn't have problem similar as yours. Attached file is the modified sample in my test. My suggest is

  1. Stop WDT if WDT reset flag is set as soon as possible.
  2. Enable WDT as later as possible.

Or, you can provide your code for our test.