Programming AVR128DB128 from another chip #298
Replies: 3 comments 9 replies
-
The flash is word addressed not byte addressed. So you have 64k words not
64k bytes max with v1. There was some line in avrdude.conf that was needed
to make it do that correctly, but shouldn't be a problem for optiboot. That
said, i would definitely meditate on why I wasn't using updi directly
…____________
Spence Konde
Azzy’S Electronics
New products! Check them out at tindie.com/stores/DrAzzy
GitHub: github.com/SpenceKonde
ATTinyCore: Arduino support for almost every ATTiny microcontroller
Contact: ***@***.***
On Thu, Jul 14, 2022, 14:03 dpetican ***@***.***> wrote:
I've previously decoded the STK500v2 protocol and programmed an ESP8266 to
program an ATMEGA2560 via bootloader over serial. The v2 message format is
complex compared to v1. I now want to do the same for an AVR128DB128 from
an ESP32. I've looked at the Optiboot source code and figure I can do this
fairly easily. For the ATMEGA extended addressing was required because 256K.
I'm probably just not remembering something because its been almost 4
years since I touched the previous code. The v1 protocol uses only 2 bytes
for addresses whereas the v2 protocol uses 4. But I also remember that the
ATMEGA1280 used the v1 protocol. Reading the source code for Optiboot leads
me to believe that I don't need extended addressing for 128K. But that
doesn't seem correct 16bits != 128K of addresses.
If I can figure that out I could probably do this without decoding the
serial stream as I upload from Arduino. That was a nightmare. Even though
the memory layout of the 128K parts is more complex than an ATMEGA I'm
assuming I would just send the bytes as if the address space was fully
mapped along with the correct starting address of each 256 byte page
(extended if required) and the bootloader would figure out the rest? Thanks.
—
Reply to this email directly, view it on GitHub
<#298>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTXEWYHMKWLXABRD2RLBTDVUBI7TANCNFSM53TCV73Q>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I have a working system updating an avr64db32 from optiboot on an esp32. LMK if you want my optiboot client library. No ESP dependency in particular although I am lazy and have a buffer that holds the full target flash in SRAM. I spent several days trying to get UPDI to work (I agree it is cleaner. It also saves two pins on the avr) but the Adafruit AVRPRog UPDI library gave me nothing but a wide variety of physical interface errors when running either on an esp32 or a avr64db. |
Beta Was this translation helpful? Give feedback.
-
Thanks @ObviousInRetrospect I was able to use your code as a guide to modify my ESP32 program to flash the AVR128DB28... sometimes. A small 3K program (read that this is less than 64K) flashed via ESP32 okay. However, a larger 65K program did not. [deleted all previous comments] I think I see the problem. I captured the serial output (directly not through ESP32) while uploading the 65K program and noticed this: LOAD_ADDRESS: 55 00 FE 20 I read the comments in the Optiboot source code and thought I read extended addressing is not required for 128K parts. My binary is 130 pages of 512 bytes = 66560 and I saw that 2 pages were programmed after the extended address command. However, shouldn't that be 3 pages after since the bootloader takes up the first page? I counted several times and saw only 129 pages being programmed, But it is late now so... I just need to format the debug output from my ESP32 to look a little bit more like the serial capture and do some more debugging after implementing the extended addressing. That should get me further along. In summary it seems only 64K can be programmed without loading an extended address. In the V2 protocol with a page size of 128 extended addressing is needed for > 128K while with the V1 protocol its needed for > 64K with page size of 512. BTW I noticed an interesting thing while getting to this point. Trying to explain my process in writing actually helped with the debugging. This was a 2+ hour editing session. Oy! |
Beta Was this translation helpful? Give feedback.
-
I've previously decoded the STK500v2 protocol and programmed an ESP8266 to program an ATMEGA2560 via bootloader over serial. The v2 message format is complex compared to v1. I now want to do the same for an AVR128DB128 from an ESP32. I've looked at the Optiboot source code and figure I can do this fairly easily. For the ATMEGA extended addressing was required because 256K.
I'm probably just not remembering something because its been almost 4 years since I touched the previous code. The v1 protocol uses only 2 bytes for addresses whereas the v2 protocol uses 4. But I also remember that the ATMEGA1280 used the v1 protocol. Reading the source code for Optiboot leads me to believe that I don't need extended addressing for 128K. But that doesn't seem correct 16bits != 128K of addresses.
If I can figure that out I could probably do this without decoding the serial stream as I upload from Arduino. That was a nightmare. Even though the memory layout of the 128K parts is more complex than an ATMEGA I'm assuming I would just send the bytes as if the address space was fully mapped along with the correct starting address of each 256 byte page (extended if required) and the bootloader would figure out the rest? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions