dcwbrown / dwire-debug

Simple stand-alone debugger for AVR DebugWIRE chips connected directly to an FT232R/CH340/DigiSpark/LittleWire on Linux or Windows.
GNU General Public License v2.0
191 stars 33 forks source link

ATTiny44A works only when reading sended bytes is disabled #38

Open mironovdm opened 6 years ago

mironovdm commented 6 years ago

Works fine with ATTiny13A and CP210x. But doesn't work with ATTiny44A, because when tried to connect I got this message:

Unconnected.                            > device com5
WriteDebug, byte 1 of 1: Read 92 expected f3

SerialRead expected 24 bytes, received 18 bytes
07  92  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  55

So we see that device responds with its signature 9207 but there is no sended 0xF3 byte in receiving buffer wich dwdebug tryes to read. I tried to disable reading sended bytes in function SerialSendBytes() in Serial.c and modified it to:

void SerialSendBytes(struct SPort *port, const u8 *out, int outlen) {
  Write(port->handle, out, outlen);
  return;
}

And now dwdebug see the avr:

Unconnected.                            > verbose
Unconnected.                            > device com4
Debug: devicename 'com', n 4.
Debug. DwFindPort(s, 4, 0)
 -- ConnectSerialPort entry. SPort: kind s, index 4, character -1, baud 0, handle $0, portname COM4.
COM4 Trying COM4, baud rate 150000, break length 0050, skipping [00], received 00000000, scale 20%
Trying COM4, baud rate 030000, break length 0050, skipping [0], received 01111000: 8 010110000, scale 40%
Trying COM4, baud rate 012000, break length 0050, skipping [0], received 10010011: 7 013000000, scale 85%
Trying COM4, baud rate 010200, break length 0050, skipping [0], received 01101001: 8 042000000, scale 85%
Trying COM4, baud rate 008670, break length 0050, skipping [0], received 10101101: 7 051000000, scale 95%
Trying COM4, baud rate 008236, break length 0050, skipping [0], received 01010101: expected result.
Finding upper bound.
Trying COM4, baud rate 008400, break length 0012, skipping [0], received 10110101: 7 051000000
Finding lower bound.
Trying COM4, baud rate 008071, break length 0012, skipping [0], received 01010101: expected result.
Trying COM4, baud rate 007909, break length 0012, skipping [0], received 01010101: expected result.
Trying COM4, baud rate 007750, break length 0012, skipping [0], received 01010101: expected result.
Trying COM4, baud rate 007595, break length 0012, skipping [0], received 01010101: expected result.
Trying COM4, baud rate 007443, break length 0012, skipping [0], received 01010101: expected result.
Trying COM4, baud rate 007294, break length 0012, skipping [0], received 10110101: 7 051000000
 -- TryConnectSerialPort complete. SPort: kind s, index 4, character -1, baud 7839, handle $218, portname COM4.
 -- ConnectSerialPort complete. SPort: kind s, index 4, character -1, baud 7839, handle $218, portname COM4.
Connected to ATtiny44 on COM4 at 7839 baud.
0040: bb8a  out   $1a, r24              > r
r0 c1   r4 cf    r8 14   r12 13   r16 4f   r20 b8   r24 00   r28 5f
r1 00   r5 c8    r9 22   r13 5b   r17 9c   r21 32   r25 00   r29 e1
r2 dd   r6 71   r10 bb   r14 9c   r18 00   r22 47   r26 61   r30 3a
r3 af   r7 12   r11 9e   r15 8e   r19 00   r23 9e   r27 00   r31 00
SREG i t h s v n Z c    PC 0040  SP 015f   X 0061   Y e15f   Z 003a
0040: bb8a  out   $1a, r24              >
dcwbrown commented 6 years ago

As far as I remember sent bytes should always show up in the input buffer since the CP210x rx pin sees everything sent on the tx pin.

I've used a tiny84 successfully, I would guess that the 84 and 44 share the same dwire implementation.

If you want to try further, I suggest testing basic programming functionality with the tiny44 entirely out of circuit, just rst/dwire, gnd and vcc connected to the CP210x with very short, separated, wires.

-- Dave.

mironovdm commented 6 years ago

I forgot to mention that for ATTiny44a I have used CH340. CP210x works only with ATTiny13A, but for tiny44a there is such output:

Unconnected.                            > device com4
Debug: devicename 'com', n 4.
Debug. DwFindPort(s, 4, 0)
 -- ConnectSerialPort entry. SPort: kind s, index 4, character -1, baud -1, handle $0, portname COM4.
COM4 ...................................... -- TryConnectSerialPort complete. SPort: kind s, index 4, character -1, baud 7224, handle $264, portname COM4.
 -- ConnectSerialPort complete. SPort: kind s, index 4, character -1, baud 7224, handle $264, portname COM4.
SerialRead expected 2 bytes, received 1 bytes
00
0000: 0006  nop                         > reset
Didn't receive 0x55 on reconnection, got 00.
Clock speed may have changed, trying to re-sync.
...................................... -- TryConnectSerialPort complete. SPort: kind s, index 4, character -1, baud 7224, handle $2ec, portname COM4.
^C

Programming for tiny44a with CH340 works fine:

Unconnected.                            > device com3
Debug: devicename 'com', n 3.
Debug. DwFindPort(s, 3, 0)
 -- ConnectSerialPort entry. SPort: kind s, index 3, character -1, baud 0, handle $0, portname COM3.
COM3 ............. -- TryConnectSerialPort complete. SPort: kind s, index 3, character -1, baud 7826, handle $210, portname COM3.
 -- ConnectSerialPort complete. SPort: kind s, index 3, character -1, baud 7826, handle $210, portname COM3.
Connected to ATtiny44 on COM3 at 7826 baud.
0036: bf85  out   $35, r24              > l
Loading 312 flash bytes from ELF text segment 0 to addresses $0 through $137.
0000: c010  rjmp  0022 (+17)            >