Skip to content

Commit

Permalink
V3.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
felias-fogg committed Feb 25, 2024
1 parent 53368c5 commit 3c21425
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 32 deletions.
1 change: 0 additions & 1 deletion .pio/build/project.checksum

This file was deleted.

9 changes: 8 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog for dw-link

## Version 3.5.3
## Version 3.5.4

- A few cosmetic changes in comments
- Adding the constants `DW_STOP_CMD` and `DW_RESET_CMD`
- Changing wait time before trying to connect to target from 200 to 400 in powerCycle
-

## Version 3.5.3 (23-Sep-2023)

* ISP programmer: disabling debugWIRE mode when switching into programming mode after 'P' record.
* The above change did not work initially because the IC interrupt was still active and blocked apparently everything else. For this reason:
Expand Down
8 changes: 6 additions & 2 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ The basic adapter is quite limited. It can only supply 20 mA to the target board

Such a board does not need to be very complex. The electronic design is minimalistic. It uses just three MOS-FETs, one LED, one voltage regulator, and some passive components. We need to (conditionally) level-shift the RESET line in a bidirectional manner and the SPI lines unidirectionally. One needs to shift the MISO line from 3.3-5 V up to 5 V, and the MOSI and SCK lines from 5 V down to 3.3-5 V. For the former case, no level shifting is done at all, relying on the fact that the input pins of the hardware debugger recognize a logical one already at 3.0 V. For the RESET line, which is open drain, we rely on the same fact. This means that this hardware debugger cannot deal with systems that use a supply voltage of less than 3 V, though.

For downshifting, we use the output pins of the hardware debugger in an open drain configuration and have pull-up resistors connected to the target supply voltage. These have to be particularly strong because some possible target boards, e.g., the Arduino UNO, use the SCK line for driving an LED with a series resistor of 1kΩ. For this reason, we use 680Ω pull-up resistors which guarantee that the signal level is above 3V on the SCK line, when we supply the board with 5V. These pull-ups will be disabled when no ISP programming is active, giving full control of the two lines to the target system. The schematic looks as follows.
For downshifting, we use the output pins of the hardware debugger in an open drain configuration and have pull-up resistors connected to the target supply voltage. These have to be particularly strong because some possible target boards, e.g., the Arduino UNO, use the SCK line for driving an LED with a series resistor of 1kΩ. For this reason, we use 680Ω pull-up resistors that guarantee that the signal level is above 3V on the SCK line, when we supply the board with 5V. These pull-ups will be disabled when no ISP programming is active, giving the target system full control of the two lines. The schematic looks as follows (thanks to **[gwideman](https://github.com/gwideman)** for the reworked schematic).

![KiCad-Schematic](../pcb/schematic.png)

Expand Down Expand Up @@ -675,7 +675,7 @@ Label | Left | Middle | Right
--- | --- | --- | ---
**Supply** | **5 V** are supplied to the target | **extern**: target needs its own supply and power cycling has to be done manually | **3.3 V** are supplied to the target
**Pullup** | There is **no** pull-up resistor connected to RESET |   | A **10 kΩ** pull-up resistor is connected to the RESET line of the target
**Auto_DW** | Atomatic transitions to and from debugWIRE mode is **off** | | Automatic transitions to and from debugWIRE mode is **on**
**Auto_DW** | Atomatic transitions to and from debugWIRE mode is **off** | | Automatic transitions to and from debugWIRE mode is **on**. This is the default and *recommended* mode!

<a name="section8"></a>

Expand Down Expand Up @@ -842,6 +842,10 @@ My experience is that 230400 bps works only with UNO boards. The Arduino Nano ca

A further (unlikely) reason for a failure in connecting to the host might be that a different communication format was chosen (parity, two stop bits, ...).

#### Problem: When connecting to the target using the *target remote* command, you do not get an error message, but the system LED is still off and there is apparently no connection

This happens when you select the `AutoDW-off` jumper option on the dw-link board. In this case, you have to initiaite the connection with the `monitor dwire +` command. And in the end before you disconnect you should switch back into normal mode with `monitor dwire -`. Usually, you wantg to have the jumper in the `on` position.

#### Problem: In response to the `monitor dwire +` command, you get the error message *Cannot connect: ...*

Depending on the concrete error message, the problem fix varies.
Expand Down
Binary file modified docs/manual.pdf
Binary file not shown.
35 changes: 27 additions & 8 deletions docs/wishlist.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# Wish list for dw-link

##### List of unsolved issues:

* When trying to debug the UNO board clone with the problematic Atmega16U2 that I have, a lot of strange things happen:
* With the real UNO board, we cannot even execute the target remote command.
* dw-link, seems to hang, the LA does not show any activity on the serial lines
* the get remote debug reports that the packages are sent but nothing is replied
* even when connecting to another board and resetting, this state continues
* only disconnecting the USB line and reconnecting resets the connection between the UNO and the host
* Works much better with the SEEEduino 4.2, however here it can happen:
* the target MCU is only halfway into dW mode, i.e., neither ISP works nor do we get an 'U' after a break.
* With the AZdelivery board
* I have seen problem in uploading the firmware
* I also saw the same problem as with the real UNO and I also saw a restart for no good reason.
* So, this is probably not a good start at all.
* The UNO compatible board by AZdelivery did not work at all.
* In summary, I do not recommend to use AZdelivery UNO compatible boards
* Perhaps, this is just a problem with this board. However, it would still be nice to know why these things can happen at all. I currently do not have the slightest idea.

##### List of tasks to work on:

* write a short debug description for PIO

* produce short youtube video to promote dw-link probe

* use "blink modes" in order to highlight embedded programming, perhaps in a video?
* use "blinkmodes.ino" in order to highlight embedded programming, perhaps in a video?

* try to use seer GUI again

* clean up Gede interface

* no multiple main breaks oints
* reloading files in GUI when reloading files

* Implement SCK500v2 protocol
* Implement STK500v2 protocol

* try integration of tool into IDE 2.0 again

Expand All @@ -37,9 +52,13 @@



##### List of tasks done:

* clean up Gede interface

#### List of tasks done:
* no multiple main breaks oints

* reloading files in GUI when reloading files

* write/design setup for UNO debugging with connected USB cable

Expand Down
32 changes: 19 additions & 13 deletions dw-link/dw-link.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
// because relevant input ports are not in the I/O range and therefore the tight timing
// constraints are not satisfied.

#define VERSION "3.5.3"
#define VERSION "3.5.4"

// some constants, you may want to change
// --------------------------------------
#ifndef PROGBPS
#define PROGBPS 19200 // ISP programmer communication speed
#endif
Expand All @@ -48,10 +49,11 @@
// #define STUCKAT1PC 1 // allow also MCUs that have PCs with stuck-at-1 bits
// #define HIGHSPEEDDW 1 // allow for DW speed up to 250 kbps

// these should stay undefined for the ordinary user
// these constants should stay undefined for the ordinary user
// -----------------------------------------------------------
// #define TXODEBUG 1 // allow debug output over TXOnly line
// #define CONSTDWSPEED 1 // constant communication speed with target
// #define OFFEX2WORD 1 // instead of simu. use offline execution for 2-word instructions
// #define TXODEBUG 1 // allow debug output over TXOnly line
// #define SCOPEDEBUG 1 // activate scope debugging on PORTC
// #define FREERAM 1 // measure free ram
// #define UNITALL 1 // enable all unit tests
Expand Down Expand Up @@ -158,6 +160,10 @@
// instruction codes
const unsigned int BREAKCODE = 0x9598;

// some dw commands
const byte DW_STOP_CMD = 0x06;
const byte DW_RESET_CMD = 0x07;

// some GDB variables
struct breakpoint
{
Expand Down Expand Up @@ -395,7 +401,7 @@ const mcu_info_type mcu_info[] PROGMEM = {
{0x948B, 16, 0, 8, 16, 0x31, 64, 0, 0x1F00, 0x1C, 0x1F, 0x22, 0xFF, 0x20, 0x3F, 0x23, 1, at90pwm161}, // untested

{0x9483, 16, 0, 8, 16, 0x31, 64, 0, 0x1F00, 0x1F, 0x22, 0x22, 0xFF, 0x20, 0x3F, 0xFF, 1, at90pwm216316}, // untested
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL},
};

const byte maxspeedexp = 4; // corresponds to a factor of 16
Expand Down Expand Up @@ -472,7 +478,7 @@ DEBDECLARE();

/****************** Interrupt routines *********************/

// catch undefined/unwantd irqs: should not happen at all
// catch undefined/unwanted irqs: should not happen at all
ISR(BADISR_vect)
{
reportFatalError(BAD_INTERRUPT_FATAL, false);
Expand Down Expand Up @@ -1020,7 +1026,7 @@ inline void gdbHelp(void) {
gdbSendReply("OK");
}

// "monitor dwire [+|-]"
// "monitor dwire [+|-]" or "target remote"
// try to enable debugWIRE
// this might imply that the user has to power-cycle the target system
boolean gdbConnect(boolean verbose)
Expand Down Expand Up @@ -1208,14 +1214,14 @@ boolean powerCycle(boolean verbose)
while (retry < 20) {
//DEBPR(F("retry=")); DEBLN(retry);
if (retry%3 == 0) { // try to power-cycle
//DEBLN(F("Power cycle!"));
DEBLN(F("Power cycle!"));
power(false); // cutoff power to target
//_delay_ms(500);
_delay_ms(200);
power(true); // power target again
//_delay_ms(200); // wait for target to startup
_delay_ms(100);
//DEBLN(F("Power cycling done!"));
DEBLN(F("Power cycling done!"));
}
if ((retry++)%3 == 0 && retry >= 3) {
do {
Expand All @@ -1226,7 +1232,7 @@ boolean powerCycle(boolean verbose)
} while (b == '-');
}
//_delay_ms(1000);
_delay_ms(200);
_delay_ms(400);
if (targetDWConnect()) {
setSysState(CONN_STATE);
return true;
Expand All @@ -1237,7 +1243,7 @@ boolean powerCycle(boolean verbose)

void power(boolean on)
{
//DEBPR(F("Power: ")); DEBLN(on);
DEBPR(F("Power: ")); DEBLN(on);
if (on) {
pinMode(VSUP, OUTPUT);
digitalWrite(VSUP, HIGH);
Expand Down Expand Up @@ -2348,7 +2354,7 @@ int targetSetFuses(Fuses fuse)
if (fuse == CkSlow && mcu.slowosc == 0xFF) return -5; // this chip cannot run with 128 kHz
if (fuse == CkARc && mcu.arosc == 0xFF) return -6;
if (doBreak()) {
dw.sendCmd((const byte[]) {0x06}, 1); // leave debugWIRE mode
dw.sendCmd((const byte[]) {DW_STOP_CMD}, 1); // leave debugWIRE mode
}
if (!enterProgramMode()) return -1;
sig = ispGetChipId();
Expand Down Expand Up @@ -2687,7 +2693,7 @@ void targetStep(void)
// reset the MCU
boolean targetReset(void)
{
dw.sendCmd((const byte[]) {0x07}, 1, true); // return before last bit is sent so that we catch the break
dw.sendCmd((const byte[]) {DW_RESET_CMD}, 1, true); // return before last bit is sent so that we catch the break

if (expectBreakAndU()) {
DEBLN(F("RESET successful"));
Expand Down Expand Up @@ -3739,7 +3745,7 @@ void measureRam(void)

int freeRam(void)
{
extern unsigned int __heap_start;
extern unsigned int __heap_start;
extern void *__brkval;

int free_memory;
Expand Down
16 changes: 9 additions & 7 deletions examples/blinkmodes/blinkmodes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@

#define LEDPIN LED_BUILTIN
#define BUTTON 2
#define BUTTONGND 4

volatile byte counter = 0; // the counter for blinking, it counts ms
volatile byte mode = 0; // the mode of the b linker
volatile unsigned long lastpress = 0;// when was button pressed last?
byte counter = 0; // the counter for blinking, it counts ms
volatile byte mode = 0; // the mode of the blinker
unsigned long lastpress = 0; // when was button pressed last?

const byte debounce_ms = 100; // the debounce time in ms

void setup() {
Serial.begin(19200);
Serial.println(F("\nblinkmode V1.0.0"));
pinMode(LEDPIN, OUTPUT); // initialize LEDPIN
pinMode(BUTTONGND, OUTPUT); // make neighboring pin GND for the button
pinMode(BUTTON, OUTPUT); // initialize button
TIMSK0 |= _BV(OCIE0A); // enable Timer0 Compare Match A interrupt
OCR0A = 0x80; // set interrupt time between two millis interrupts
Expand All @@ -38,8 +36,12 @@ void loop() {

if (Serial.available()) {
c = Serial.read();
if (isupper(c)) Serial.write(tolower(c));
else if (islower(c)) Serial.write(toupper(c));
if (isupper(c)) {
c = tolower(c);
} else if (islower(c)) {
c = toupper(c);
}
Serial.print(c);
}
}

Expand Down

0 comments on commit 3c21425

Please sign in to comment.