From bca790cf65c44fe67d6628158d838a8d0801a86d Mon Sep 17 00:00:00 2001 From: Bernhard Nebel Date: Thu, 16 Jan 2025 22:58:17 +0100 Subject: [PATCH] V4.0.4 --- docs/changelog.md | 5 +++++ docs/manual.md | 22 ++++++++++--------- dw-link/dw-link.ino | 22 ++++++++++++++----- examples/pio-varblink/platformio.ini | 32 ++++++++++++++++------------ 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index a97a3f9..91e6c3b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,10 @@ # Changelog for dw-link +## Version 4.0.4 +- Changes in platform.ini files +- Change: Giving a more informative error message when the stuck-at-1 + error is diagnosed because of capacitive load on the reset line + ## Version 4.0.3 (03-Jan-2025) - ISP programming got a watch dog timer so that after a wrong choice the debugger will recover after 4 seconds diff --git a/docs/manual.md b/docs/manual.md index dd75fe9..13a483e 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -556,16 +556,16 @@ Finally, there are commands that control the settings of the debugger and the MC | monitor dwire [+\|-] | **+** activate debugWIRE; **-** disables debugWIRE; without any argument, it will report MCU type and whether debugWIRE is enabled (*) | | monitor reset | resets the MCU (*) | | monitor mcu [*mcu-name*] | If no argument is given, the MCU dw-link is connected to is printed. Otherwise, it is checked whether the given *mcu-name* matches the connected MCU and if not, a fatal error (5) is signaled. | -| monitor ckdiv [1\|8] | **1** unprograms the CKDIV8 fuse, **8** programs it; without an argument, the state of the fuse is reported (*) | -| monitor oscillator [r\|a\|x\|e\|s] | set clock source to **r**c osc., **a**lternate rc osc., **x**tal, **e**xternal osc., or **s**low osc. (128 kHz); without argument, it reports the fuse setting (*) | -| monitor breakpoint [h\|s] | set number of allowed breakpoints to 1, when **h**ardware breakpoint only, or 25, when also **s**oftware breakpoints are permitted; without argument it reports setting | -| monitor speed [l\|h] | set communication speed limit to **l**ow (=150kbps) or to **h**igh (=300kbps); without an argument, the current communication speed and limit is printed | +| monitor ckdiv [1\|8] | **1** unprograms the CKDIV8 fuse, **8** programs it; without an argument, the state of the fuse is reported (*+) | +| monitor oscillator [r\|a\|x\|e\|s] | set clock source to **r**c osc., **a**lternate rc osc., **x**tal, **e**xternal osc., or **s**low osc. (128 kHz); without argument, it reports the fuse setting (*+) | +| monitor breakpoint [h\|s] | set the number of allowed breakpoints to 1, when **h**ardware breakpoint only, or 25, when also **s**oftware breakpoints are permitted; without argument, it reports setting | +| monitor speed [l\|h] | set the communication speed limit to **l**ow (=150kbps) or to **h**igh (=300kbps); without an argument, the current communication speed and speed limit is printed | | monitor singlestep [s\|u] | Sets single stepping to **s**afe (no interrupts) or **u**nsafe (interrupts can happen); without an argument, it reports the state | -| monitor lasterror | print error number of last fatal error | -| monitor flashcount | reports on how many flash-page write operation have taken place since start | +| monitor lasterror | print error number of the last fatal error | +| monitor flashcount | reports on how many flash-page write operations have taken place since the start | | monitor timeouts | report number of timeouts (should be 0!) | -All of the commands marked with (*) reset the MCU. +All of the commands marked with (*) reset the MCU. The ones marked with (+) need to take the MCU out of the debugWIRE mode and afterwards in again. @@ -1068,8 +1068,9 @@ Error # | Meaning 2 | Connection error: MCU type is not supported 3 | Connection error: Lock bits or BOOTRST could not be cleared 4 | Connection error: MCU has PC with stuck-at-one bits -5 | MCU type does not match -6 | Unknown connection error +5 | Connection error: Reset line has a capacitive load +6 | MCU type does not match +7 | Unknown connection error 101 | No free slot in breakpoint table 102 | Packet length too large 103 | Wrong memory type @@ -1197,7 +1198,7 @@ Initial version * New fatal error: Wrong MCU type (caused by monitor mcu command) * Renamed fatal error 3 * The *boards manager URLs* have changed: a suffix `_plus_Debug` has been added to the core name. -* Simplified paltoformIO.ini +* Simplified platoformio.ini * Corrected statement about the meaning of BREAK when the debugger is not active * `monitor mcu` command listed * Description of how to use the AutoDW jumper added @@ -1206,3 +1207,4 @@ Initial version * Added notes that you cannot debug the UNO, but need to select ATmega328 * Added notes about the target board and potentially using external powering * Edited the problem description for locked up hardware debugger/serial line +* New fatal error: capacitive load on the reset line diff --git a/dw-link/dw-link.ino b/dw-link/dw-link.ino index 36949da..a5e9a40 100644 --- a/dw-link/dw-link.ino +++ b/dw-link/dw-link.ino @@ -127,8 +127,9 @@ #define CONNERR_UNSUPPORTED_MCU 2 // connection error: MCU not supported #define CONNERR_LOCK_BITS 3 // connection error: lock bits are set #define CONNERR_STUCKAT1_PC 4 // connection error: MCU has PC with stuck-at-one bits -#define CONNERR_WRONG_MCU 5 // wrong MCU (detected by monitor mcu command) -#define CONNERR_UNKNOWN 6 // unknown connection error +#define CONNERR_CAPACITIVE_LOAD 5 // connection error: Reset has a capacitive load +#define CONNERR_WRONG_MCU 6 // wrong MCU (detected by monitor mcu command) +#define CONNERR_UNKNOWN 7 // unknown connection error #define NO_FREE_SLOT_FATAL 101 // no free slot in BP structure #define PACKET_LEN_FATAL 102 // packet length too large #define WRONG_MEM_FATAL 103 // wrong memory type @@ -1099,11 +1100,21 @@ boolean gdbConnect(boolean verbose) DEBLN(conncode); if (conncode == 1) { #if STUCKAT1PC - mcu.stuckat1byte = (DWgetWPc(false) & ~((mcu.flashsz>>1)-1))>>8; - //DEBPR(F("stuckat1byte=")); DEBLNF(mcu.stuckat1byte,HEX); + if (mcu.sig == 0x9205 || mcu.sig == 0x930A) { + mcu.stuckat1byte = (DWgetWPc(false) & ~((mcu.flashsz>>1)-1))>>8; + DEBPR(F("stuckat1byte=")); DEBLNF(mcu.stuckat1byte,HEX); + } else { + conncode = -5; + } #else mcu.stuckat1byte = 0; - if (DWgetWPc(false) > (mcu.flashsz>>1)) conncode = -4; + if (DWgetWPc(false) > (mcu.flashsz>>1)) { + if (mcu.sig == 0x9205 || mcu.sig == 0x930A) { + conncode = -4; + } else { + conncode = -5; + } + } #endif } if (conncode == 1) { @@ -1121,6 +1132,7 @@ boolean gdbConnect(boolean verbose) case -2: gdbDebugMessagePSTR(PSTR("***Cannot connect: Unsupported MCU"),-1); break; case -3: gdbDebugMessagePSTR(PSTR("***Cannot connect: Lock bits are set"),-1); break; case -4: gdbDebugMessagePSTR(PSTR("***Cannot connect: PC with stuck-at-one bits"),-1); break; + case -5: gdbDebugMessagePSTR(PSTR("***Cannot connect: Reset line has a capacitive load"),-1); break; default: gdbDebugMessagePSTR(PSTR("***Cannot connect for unknown reasons"),-1); conncode = -CONNERR_UNKNOWN; break; } if (verbose) { diff --git a/examples/pio-varblink/platformio.ini b/examples/pio-varblink/platformio.ini index 263be82..d19b2db 100644 --- a/examples/pio-varblink/platformio.ini +++ b/examples/pio-varblink/platformio.ini @@ -11,26 +11,30 @@ default_envs = debug [env:debug] -extends = env:attiny85 ;; <--- substitute the right board here +extends = env:attiny85 ;; <--- substitute the right board here build_type = debug debug_tool = custom -;;debug_port = /dev/cu.usbmodem211101 ;; <-- specify instead of debug_server with correct serial line -debug_server = /usr/local/bin/dw-server.py - -p 3333 ;; <-- specify instead of debug_port +;;debug_port = /dev/cu.usbmodem01 ;; <-- specify instead of debug_server with correct serial line +debug_server = /usr/local/bin/dw-server.py ;; <-- specify instead of debug_port + -p 3333 debug_init_cmds = define pio_reset_halt_target - monitor reset - end - set serial baud 115200 + monitor reset + end + define pio_reset_run_target + monitor reset + continue + end + set serial baud 115200 target remote $DEBUG_PORT - monitor version - monitor mcu - $LOAD_CMDS - $INIT_BREAK + monitor version + monitor mcu + $LOAD_CMDS + $INIT_BREAK debug_build_flags = - -Og - -g3 - -fno-lto + -Og + -g3 + -fno-lto [env:attiny85] platform = atmelavr