Florin-Popescu / avarice-unofficial

AVaRICE with support for newer devices
GNU General Public License v2.0
13 stars 8 forks source link

"Wrong length for memory access" with ATmega4809/Atmel-ICE #6

Closed timwalls closed 2 years ago

timwalls commented 2 years ago

Hiya,

So, naturally, nothing is ever simple with the ATmega4809... I just wanted to throw this error at you in case you already know what it is/I'm doing something obviously wrong - otherwise don't worry too much and I will try to dig into what's going on myself.

But, long story short, I'm attempting to debug with an:

I've validated everyhing works fine from a hardware point of view using Microchip Studio on a spare Windows box.

Things appear to get OK - avarice recognises both the programmer and the chip, and appears to correctly read serial number etc. But when I try to stop and debug with GDB, everything responds with:

Failed to read target memory space: wrong length for memory access

Is there anything obvious you can think of before I dive in deep? Here's some debugging log from avarice just in case it helps...

[Sasha:calea-victoriei:Arduino/avarice-snowgoons] timwa% src/avarice -P atmega4809 -d -4u :4242
AVaRICE version 2.14svn20200906, Oct  8 2021 15:59:30

Found HID PID:VID 0x03eb:0x2141, serno J42700029646
Probing for HID max. packet size
Setting max. packet size to 512 from DAP_Info
HID thread started
JTAG config starting.

command "sign-on" [0x01, 0x10]
0E 00 00 00 01 10 00
Received 0x81 0x11 0x00 0x06 0x0e 0x00
read:  0e 00 00 01 80 00

Got message seqno 0 (command_sequence == 0)
response: 01 80 00

command "get info (serial number)" [0x00, 0x00]
0E 00 01 00 00 00 00 81
Received 0x81 0x11 0x00 0x12 0x0e 0x01
read:  0e 01 00 00 81 00 4a 34 32 37 30 30 30 32 39 36 34 36

Got message seqno 1 (command_sequence == 1)
response: 00 81 00 4A 34 32 37 30 30 30 32 39 36 34 36
Found a device, serial number: J42700029646

command "get parameter" [0x01, 0x02]
0E 00 02 00 01 02 00 00 00 05
Received 0x81 0x11 0x00 0x0c 0x0e 0x02
read:  0e 02 00 01 84 01 00 01 29 89 00 00

Got message seqno 2 (command_sequence == 2)
response: 01 84 01 00 01 29 89 00 00
ICE hardware version: 0
ICE firmware version: 1.41 (rel. 137)

command "set parameter" [0x12, 0x01]
0E 00 03 00 12 01 00 00 00 01 05
Received 0x81 0x11 0x00 0x06 0x0e 0x03
read:  0e 03 00 12 80 00

Got message seqno 3 (command_sequence == 3)
response: 12 80 00

command "set parameter" [0x12, 0x01]
0E 00 04 00 12 01 00 00 01 01 02
Received 0x81 0x11 0x00 0x06 0x0e 0x04
read:  0e 04 00 12 80 00

Got message seqno 4 (command_sequence == 4)
response: 12 80 00

command "set parameter" [0x12, 0x01]
0E 00 05 00 12 01 00 01 00 01 08
Received 0x81 0x11 0x00 0x06 0x0e 0x05
read:  0e 05 00 12 80 00

Got message seqno 5 (command_sequence == 5)
response: 12 80 00

command "set parameter" [0x12, 0x01]
0E 00 06 00 12 01 00 02 00 08 00 40 80 40 00 10 80 0F
Received 0x81 0x11 0x00 0x06 0x0e 0x06
read:  0e 06 00 12 80 00

Got message seqno 6 (command_sequence == 6)
response: 12 80 00

command "AVR sign-on" [0x12, 0x10]
0E 00 07 00 12 10 00 00
Received 0x81 0x11 0x00 0x0b 0x0e 0x07
read:  0e 07 00 12 84 00 6d 65 67 61 00

Got message seqno 7 (command_sequence == 7)
response: 12 84 00 6D 65 67 61 00
AVR sign-on responded with mega
Automatic device detection: jtagRead
command "enter progmode" [0x12, 0x15]
0E 00 08 00 12 15 00
Received 0x81 0x11 0x00 0x06 0x0e 0x08
read:  0e 08 00 12 80 00

Got message seqno 8 (command_sequence == 8)
response: 12 80 00

command "read memory" [0x12, 0x21]
0E 00 09 00 12 21 00 B4 00 11 00 00 03 00 00 00
Received 0x81 0x11 0x00 0x0a 0x0e 0x09
read:  0e 09 00 12 84 00 1e 96 51 00

Got message seqno 9 (command_sequence == 9)
response: 12 84 00 1E 96 51 00

command "leave progmode" [0x12, 0x16]
0E 00 0A 00 12 16 00
Received 0x81 0x11 0x00 0x06 0x0e 0x0a
read:  0e 0a 00 12 80 00

Got message seqno 10 (command_sequence == 10)
response: 12 80 00
Reported device ID: 0x9651
Looking for device: atmega4809
Configured for device ID: 0x9651 atmega4809 -- Matched with atmega4809

command "set parameter" [0x12, 0x01]
0E 00 0B 00 12 01 00 02 00 08 00 40 80 40 00 10 80 0F
Received 0x81 0x11 0x00 0x06 0x0e 0x0b
read:  0e 0b 00 12 80 00

Got message seqno 11 (command_sequence == 11)
response: 12 80 00
JTAG config complete.
Preparing the target device for On Chip Debugging.

command "set parameter" [0x12, 0x01]
0E 00 0C 00 12 01 00 03 00 01 00
Received 0x81 0x11 0x00 0x06 0x0e 0x0c
read:  0e 0c 00 12 80 00

Got message seqno 12 (command_sequence == 12)
response: 12 80 00

command "reset" [0x12, 0x30]
0E 00 0D 00 12 30 00 01
Received 0x81 0x11 0x00 0x06 0x0e 0x0d
read:  0e 0d 00 12 80 00

Got message seqno 13 (command_sequence == 13)
response: 12 80 00
read:  0e 00 07 00 12 40 00 00 00 00 01 84 00 30
Event serial 0x0007
caching PC: 0x0000
Waiting for connection on port 4242.
Connection opened by host 127.0.0.1, port 60473.
GDB: <qSupported:multiprocess+;qRelocInsn+>
->GDB: qXfer:memory-map:read+
GDB: <Hg0>
->GDB:
GDB: <qTStatus>
->GDB:
GDB: <?>
->GDB: S05
GDB: <qfThreadInfo>
->GDB:
GDB: <qL1160000000000000000>
->GDB:
GDB: <Hc-1>
->GDB:
GDB: <qC>
->GDB:
GDB: <qAttached>
->GDB:
GDB: <qOffsets>
->GDB:
GDB: <g>

GDB: (Registers)Read 32 bytes from 0x800000
jtagRead
command "read memory" [0x12, 0x21]
0E 00 0E 00 12 21 00 20 00 00 00 00 20 00 00 00
Received 0x81 0x11 0x00 0x27 0x0e 0x0e
read:  0e 0e 00 12 84 00 00 00 81 00 00 00 01 00 00 00 fe 00 00 00 3f 00 00 00 04 00 00 00 73 00 00 00 00 00 00 00 00 00 00

Got message seqno 14 (command_sequence == 14)
response: 12 84 00 00 00 81 00 00 00 01 00 00 00 FE 00 00 00 3F 00 00 00 04 00 00 00 73 00 00 00 00 00 00 00 00 00 00
jtagRead
command "read memory" [0x12, 0x21]
0E 00 0F 00 12 21 00 20 5D 00 00 00 03 00 00 00
Received 0x81 0x11 0x00 0x0a 0x0e 0x0f
read:  0e 0f 00 12 84 00 00 00 00 00

Got message seqno 15 (command_sequence == 15)
response: 12 84 00 00 00 00 00

command "read PC" [0x12, 0x35]
0E 00 10 00 12 35 00
Received 0x81 0x11 0x00 0x0a 0x0e 0x10
read:  0e 10 00 12 83 00 00 00 00 00

Got message seqno 16 (command_sequence == 16)
response: 12 83 00 00 00 00 00
PC = 0
->GDB: 00008100000001000000fe0000003f000000040000007300000000000000000000000000000000
GDB: <qSymbol::>
->GDB:
GDB: <vCont?>
->GDB:
GDB: <Hc0>
->GDB:
GDB: <c>

command "go" [0x12, 0x32]
0E 00 11 00 12 32 00
Received 0x81 0x11 0x00 0x06 0x0e 0x11
read:  0e 11 00 12 80 00

Got message seqno 17 (command_sequence == 17)
response: 12 80 00
Waiting for input.
read:  0e 00 08 00 01 11 00 01 00
Event serial 0x0008

Target went out of sleep
Waiting for input.
interrupted by GDB

command "stop" [0x12, 0x31]
0E 00 12 00 12 31 00 01
Received 0x81 0x11 0x00 0x06 0x0e 0x12
read:  0e 12 00 12 80 00

Got message seqno 18 (command_sequence == 18)
response: 12 80 00
read:  0e 00 09 00 12 40 8d 01 00 00 01 44 00 01
Event serial 0x0009
caching PC: 0x031a
jtagRead
command "read memory" [0x12, 0x21]
0E 00 13 00 12 21 00 20 5D 00 00 00 03 00 00 00
Received 0x81 0x11 0x00 0x0a 0x0e 0x13
read:  0e 13 00 12 84 00 00 00 00 00

Got message seqno 19 (command_sequence == 19)
response: 12 84 00 00 00 00 00
->GDB: T0220:00;21:0000;22:1a030000;
GDB: <qXfer:memory-map:read::0,18a>
->GDB: l<memory-map>
  <memory type="ram" start="0x800000" length="0x20000" />
  <memory type="flash" start="0" length="0xc000">
     <property name="blocksize">0x80</property>
  </memory>
</memory-map>

GDB: <m294,27>

GDB: Read 39 bytes from 0x294
jtagRead
command "read memory" [0x12, 0x21]
0E 00 14 00 12 21 00 C0 94 02 00 00 27 00 00 00
Received 0x81 0x11 0x00 0x07 0x0e 0x14
read:  0e 14 00 12 a0 00 35

Got message seqno 20 (command_sequence == 20)
response: 12 A0 00 35
Failed to read target memory space: wrong length for memory access
->GDB: E01
GDB: <m800300,27>

GDB: Read 39 bytes from 0x800300
jtagRead
command "read memory" [0x12, 0x21]
0E 00 15 00 12 21 00 20 00 03 00 00 27 00 00 00
Received 0x81 0x11 0x00 0x2e 0x0e 0x15
read:  0e 15 00 12 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Got message seqno 21 (command_sequence == 21)
response: 12 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
->GDB: 000000000000000000000000000000000000000000000000000000000000000000000000000000
GDB: <m800327,19>

GDB: Read 25 bytes from 0x800327
jtagRead
command "read memory" [0x12, 0x21]
0E 00 16 00 12 21 00 20 27 03 00 00 19 00 00 00
Received 0x81 0x11 0x00 0x20 0x0e 0x16
read:  0e 16 00 12 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Got message seqno 22 (command_sequence == 22)
response: 12 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
->GDB: 00000000000000000000000000000000000000000000000000
GDB: <m0,27>

GDB: Read 39 bytes from 0x0
jtagRead
command "read memory" [0x12, 0x21]
0E 00 17 00 12 21 00 C0 00 00 00 00 27 00 00 00
Received 0x81 0x11 0x00 0x07 0x0e 0x17
read:  0e 17 00 12 a0 00 35

Got message seqno 23 (command_sequence == 23)
response: 12 A0 00 35
Failed to read target memory space: wrong length for memory access
->GDB: E01
GDB: <m0,2>

GDB: Read 2 bytes from 0x0
jtagRead
command "read memory" [0x12, 0x21]
0E 00 18 00 12 21 00 C0 00 00 00 00 02 00 00 00
Received 0x81 0x11 0x00 0x09 0x0e 0x18
read:  0e 18 00 12 84 00 0c 94 00

Got message seqno 24 (command_sequence == 24)
response: 12 84 00 0C 94 00
->GDB: 0c94
GDB: <m0,27>

GDB: Read 39 bytes from 0x0
jtagRead
command "read memory" [0x12, 0x21]
0E 00 19 00 12 21 00 C0 00 00 00 00 27 00 00 00
Received 0x81 0x11 0x00 0x07 0x0e 0x19
read:  0e 19 00 12 a0 00 35

Got message seqno 25 (command_sequence == 25)
response: 12 A0 00 35
Failed to read target memory space: wrong length for memory access
->GDB: E01
GDB: <m2,2>

GDB: Read 2 bytes from 0x2
jtagRead
command "read memory" [0x12, 0x21]
0E 00 1A 00 12 21 00 C0 02 00 00 00 02 00 00 00
Received 0x81 0x11 0x00 0x09 0x0e 0x1a
read:  0e 1a 00 12 84 00 51 00 00

Got message seqno 26 (command_sequence == 26)
response: 12 84 00 51 00 00
->GDB: 5100
GDB: <m0,27>

GDB: Read 39 bytes from 0x0
jtagRead
command "read memory" [0x12, 0x21]
0E 00 1B 00 12 21 00 C0 00 00 00 00 27 00 00 00
Received 0x81 0x11 0x00 0x07 0x0e 0x1b
read:  0e 1b 00 12 a0 00 35

Got message seqno 27 (command_sequence == 27)
response: 12 A0 00 35
Failed to read target memory space: wrong length for memory access
->GDB: E01
GDB: <m0,1>

GDB: Read 1 bytes from 0x0
jtagRead
command "read memory" [0x12, 0x21]
0E 00 1C 00 12 21 00 C0 00 00 00 00 01 00 00 00
Received 0x81 0x11 0x00 0x07 0x0e 0x1c
read:  0e 1c 00 12 a0 00 35

Got message seqno 28 (command_sequence == 28)
response: 12 A0 00 35
Failed to read target memory space: wrong length for memory access
->GDB: E01
timwalls commented 2 years ago

Actually, apologies to write immediately after, and apologies that this may sound like a stream of consciousness - I've been staring at this all day and I need to put it down before I go crazy, but I think I have a possible culprit. And I want to write it down somewhere so I don't have to discover it all over again in the morning :).

The ATxmega64B3, which is a very, very different device, has a device ID of 0x1E9651. The ATmega4809 on the other hand has a device ID of 0x9651.

Unfortunately it looks like avarice only actually looks at the last 16 bits. So in avarice terms, the '4809 and the x'64B3 both have the same device ID...

I wonder if this is causing avarice to pick up the wrong device information (in particular, that memory map in the debug log is looking very "32 bit" to me), even though I specifically set it to ATmega4809 on the command line... 🤔

Florin-Popescu commented 2 years ago

Hey, sorry for the delay.

The device ID shouldn't matter cause it's overwritten when you pass the device name with -P. The configuration for 4809 looks fine and I don't see anything out of the ordinary in the log.

Same error appeared in #4 but there it looks like a recompile solved it. Maybe take a look there, had some explanations about the memory map reported to GDB. But I'm not so sure what the problem is at the moment.

How do you run GDB? May be some issue there.

Do you have any updates? Will look into it if nothing's changed for you.

Florin-Popescu commented 2 years ago

Hey, it's been a long time since this was brought up. Just wanted to mention that I've discovered a bug giving me the same issue, which should be fixed now in v2.14-7. Give it a try if you are still interested.

dani9 commented 8 months ago

I have the same error with the latest release: output for command: avarice -4 -u -P atmega3208 -d localhost:5000

AVaRICE version 2.14svn20200906, May 15 2022 05:27:16

Found HID PID:VID 0x03eb:0x2141, serno J41800118776
Probing for HID max. packet size
Setting max. packet size to 512 from DAP_Info
JTAG config starting.

command "sign-on" [0x01, 0x10]
HID thread started
0E 00 00 00 01 10 00 
Received 0x81 0x11 0x00 0x06 0x0e 0x00
read:  0e 00 00 01 80 00

Got message seqno 0 (command_sequence == 0)
response: 01 80 00 

command "get info (serial number)" [0x00, 0x00]
0E 00 01 00 00 00 00 81 
Received 0x81 0x11 0x00 0x12 0x0e 0x01
read:  0e 01 00 00 81 00 4a 34 31 38 30 30 31 31 38 37 37 36

Got message seqno 1 (command_sequence == 1)
response: 00 81 00 4A 34 31 38 30 30 31 31 38 37 37 36 
Found a device, serial number: J41800118776

command "get parameter" [0x01, 0x02]
0E 00 02 00 01 02 00 00 00 05 
Received 0x81 0x11 0x00 0x0c 0x0e 0x02
read:  0e 02 00 01 84 01 00 01 2a a1 00 00

Got message seqno 2 (command_sequence == 2)
response: 01 84 01 00 01 2A A1 00 00 
ICE hardware version: 0
ICE firmware version: 1.42 (rel. 161)

command "set parameter" [0x12, 0x01]
0E 00 03 00 12 01 00 00 00 01 05 
Received 0x81 0x11 0x00 0x06 0x0e 0x03
read:  0e 03 00 12 80 00

Got message seqno 3 (command_sequence == 3)
response: 12 80 00 

command "set parameter" [0x12, 0x01]
0E 00 04 00 12 01 00 00 01 01 02 
Received 0x81 0x11 0x00 0x06 0x0e 0x04
read:  0e 04 00 12 80 00

Got message seqno 4 (command_sequence == 4)
response: 12 80 00 

command "set parameter" [0x12, 0x01]
0E 00 05 00 12 01 00 01 00 01 08 
Received 0x81 0x11 0x00 0x06 0x0e 0x05
read:  0e 05 00 12 80 00

Got message seqno 5 (command_sequence == 5)
response: 12 80 00 

command "set parameter" [0x12, 0x01]
0E 00 06 00 12 01 00 02 00 08 00 40 80 40 00 10 80 0F 
Received 0x81 0x11 0x00 0x06 0x0e 0x06
read:  0e 06 00 12 80 00

Got message seqno 6 (command_sequence == 6)
response: 12 80 00 

command "AVR sign-on" [0x12, 0x10]
0E 00 07 00 12 10 00 00 
Received 0x81 0x11 0x00 0x0b 0x0e 0x07
read:  0e 07 00 12 84 00 6d 65 67 61 00

Got message seqno 7 (command_sequence == 7)
response: 12 84 00 6D 65 67 61 00 
AVR sign-on responded with mega
Automatic device detection: jtagRead 
command "enter progmode" [0x12, 0x15]
0E 00 08 00 12 15 00 
Received 0x81 0x11 0x00 0x06 0x0e 0x08
read:  0e 08 00 12 80 00

Got message seqno 8 (command_sequence == 8)
response: 12 80 00 

command "read memory" [0x12, 0x21]
0E 00 09 00 12 21 00 B4 00 11 00 00 03 00 00 00 
Received 0x81 0x11 0x00 0x0a 0x0e 0x09
read:  0e 09 00 12 84 00 1e 95 30 00

Got message seqno 9 (command_sequence == 9)
response: 12 84 00 1E 95 30 00 

command "leave progmode" [0x12, 0x16]
0E 00 0A 00 12 16 00 
Received 0x81 0x11 0x00 0x06 0x0e 0x0a
read:  0e 0a 00 12 80 00

Got message seqno 10 (command_sequence == 10)
response: 12 80 00 
Reported device ID: 0x9530
Looking for device: atmega3208
Configured for device ID: 0x9552 atmega3208 -- FORCED with atmega3208

command "set parameter" [0x12, 0x01]
0E 00 0B 00 12 01 00 02 00 08 00 40 80 40 00 10 80 0F 
Received 0x81 0x11 0x00 0x06 0x0e 0x0b
read:  0e 0b 00 12 80 00

Got message seqno 11 (command_sequence == 11)
response: 12 80 00 
JTAG config complete.
Preparing the target device for On Chip Debugging.

command "set parameter" [0x12, 0x01]
0E 00 0C 00 12 01 00 03 00 01 00 
Received 0x81 0x11 0x00 0x06 0x0e 0x0c
read:  0e 0c 00 12 80 00

Got message seqno 12 (command_sequence == 12)
response: 12 80 00 

command "reset" [0x12, 0x30]
0E 00 0D 00 12 30 00 01 
Received 0x81 0x11 0x00 0x06 0x0e 0x0d
read:  0e 0d 00 12 80 00

Got message seqno 13 (command_sequence == 13)
response: 12 80 00 
read:  0e 00 11 00 12 40 00 00 00 00 01 84 00 31
Event serial 0x0011
caching PC: 0x0000
Waiting for connection on port 5000.
Connection opened by host 127.0.0.1, port 59608.
GDB: <qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;memory-tagging+>
->GDB: PacketSize=40;qXfer:memory-map:read+
GDB: <vMustReplyEmpty>
->GDB: 
GDB: <Hg0>
->GDB: 
GDB: <qTStatus>
->GDB: 
GDB: <?>
->GDB: S05
GDB: <qfThreadInfo>
->GDB: 
GDB: <qL1020000000000000000>
->GDB: 
GDB: <Hc-1>
->GDB: 
GDB: <qC>
->GDB: 
GDB: <qAttached>
->GDB: 
GDB: <qOffsets>
->GDB: 
GDB: <g>

GDB: (Registers)Read 32 bytes from 0x800000
jtagRead 
command "read memory" [0x12, 0x21]
0E 00 0E 00 12 21 00 20 00 00 00 00 20 00 00 00 
Received 0x81 0x11 0x00 0x27 0x0e 0x0e
read:  0e 0e 00 12 84 00 00 00 0b 00 00 00 00 00 00 00 03 00 00 00 ce 00 00 00 00 00 00 00 0c 00 00 00 00 00 00 00 00 00 00

Got message seqno 14 (command_sequence == 14)
response: 12 84 00 00 00 0B 00 00 00 00 00 00 00 03 00 00 00 CE 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 
jtagRead 
command "read memory" [0x12, 0x21]
0E 00 0F 00 12 21 00 20 5D 00 00 00 03 00 00 00 
Received 0x81 0x11 0x00 0x0a 0x0e 0x0f
read:  0e 0f 00 12 84 00 00 00 00 00

Got message seqno 15 (command_sequence == 15)
response: 12 84 00 00 00 00 00 

command "read PC" [0x12, 0x35]
0E 00 10 00 12 35 00 
Received 0x81 0x11 0x00 0x0a 0x0e 0x10
read:  0e 10 00 12 83 00 00 00 00 00

Got message seqno 16 (command_sequence == 16)
response: 12 83 00 00 00 00 00 
PC = 0
->GDB: 00000b0000000000000003000000ce000000000000000c00000000000000000000000000000000
GDB: <qL1020000000000000000>
->GDB: 
GDB: <qSymbol::>
->GDB: 
GDB: <qRcmd,72657365742068616c74>

GDB: (monitor) rese

command "reset" [0x12, 0x30]
0E 00 11 00 12 30 00 01 
Received 0x81 0x11 0x00 0x06 0x0e 0x11
read:  0e 11 00 12 80 00

Got message seqno 17 (command_sequence == 17)
response: 12 80 00 
read:  0e 00 12 00 12 40 00 00 00 00 01 84 00 00
Event serial 0x0012
caching PC: 0x0000
->GDB: 526573657474696e67204d43552e2e2e0a
GDB: <qXfer:memory-map:read::0,3b>
->GDB: l<memory-map>
  <memory type="ram" start="0x800000" length="0x20000" />
  <memory type="flash" start="0" length="0x8000">
     <property name="blocksize">0x80</property>
  </memory>
</memory-map>

GDB: <X1400,0:>
->GDB: 
GDB: <M1400,19:0c94480a0c94650a0c94650a0c94650a0c94650a0c94650a0c>

GDB: Write 25 bytes to 0x1400
jtagWrite 
command "write memory" [0x12, 0x23]
0E 00 12 00 12 23 00 C0 00 14 00 00 18 00 00 00 00 0C 94 48 0A 0C 94 65 0A 0C 94 65 0A 0C 94 65 0A 0C 94 65 0A 0C 94 65 0A 00 
Received 0x81 0x11 0x00 0x07 0x0e 0x12
read:  0e 12 00 12 a0 00 35

Got message seqno 18 (command_sequence == 18)
response: 12 A0 00 35 
Failed to write target memory space: wrong length for memory access
->GDB: E01

gdb client avr-gdb

GNU gdb (GDB) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file /tmp/test.elf 
Reading symbols from /tmp/test.elf...
(gdb) target remote localhost:5000
Remote debugging using localhost:5000
0x00000000 in ?? ()
(gdb) monitor reset halt
Resetting MCU...
(gdb) load
Received too much data from the target.
(gdb) load
Loading section .text, size 0x174c lma 0x1400
Laden fehlgeschlagen
(gdb) 
Florin-Popescu commented 7 months ago

Hello!

Looks like it's trying to write code at: Linker section .text size 0x174c lma 0x1400 (last few lines in your gdb log, + sequence no. 17)

But address 0x1400 is the start of the EEPROM for the atmega 3208. After the 256 bytes at that area there's a reserved section followed by SRAM. You definitely don't want to write .text (code) to those addresses.

Check your linker settings, is it really trying to link .text to that address? If so, you have to adjust your linker settings to use the proper addresses. Judging by the bytes it's trying to write to that address, they do look a bit like interrupt vectors, which should belong to code starting at 0x0000 or 0x4000 - again, see datasheet.

Or am I wrong and you're actually trying to write EEPROM data?

dani9 commented 7 months ago

My elf File contains additionally EEPROM data. I will try to remove this section and update you soon. Thanks for your answer.