[bug #48131] Problem with EEprom address of avrdude for different processors!

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #48131] Problem with EEprom address of avrdude for different processors!

Joerg Wunsch-6
URL:
  <http://savannah.nongnu.org/bugs/?48131>

                 Summary: Problem with EEprom address of avrdude for different
processors!
                 Project: AVR Downloader/UploaDEr
            Submitted by: kh_kuebbbeler
            Submitted on: Sa 04 Jun 2016 18:06:37 GMT
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: kh_kuebbeler
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I have found out, that the address of EEprom load with the stk500v1 protocol
is send as word address for the target ATmega328 and as a byte address for the
target ATmega8.
I have build a bootloader from the optiboot source in assembly language with
additional EEprom support, which match in a 512 byte page.
If I handle the transmitted address different for the ATmega328 and
the ATmega8, all works well. For the ATmega328 I must multiply the
transmitted address by 2.
The problem is already reported at
https://www.mikrocontroller.net/topic/398978 in german language. Joerg Wunsch
has this information already.
I can handle the different address type in my bootloader version,
if I know, which processors use the byte address (mega8, mega16, mega32, ...).
But what is with other transfer programs as avrdude?
The AVR061 from Atmel does not specify the address type of the
Cmnd_STK_LOAD_ADDRESS command.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?48131>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

[bug #48131] Problem with EEprom address of avrdude for different processors!

Joerg Wunsch-6
Update of bug #48131 (project avrdude):

                  Status:                    None => Confirmed              
             Assigned to:                    None => bdean                  

    _______________________________________________________

Follow-up Comment #1:

The problem is apparently that piece of code in stk500.c:


  if ((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO]))
    a_div = 2;
  else
    a_div = 1;


Later on, a_div is used to determine whether the address in
the load command needs to be divided by 2:


    stk500_loadaddr(pgm, m, addr/a_div);


(Similar code exists in both, stk500_paged_write() as well as
stk500_paged_load()).

I think the intention was to divide the load address by 2 when
accessing flash.  Now, the ATmega328 entry (as well as others)
has an AVR_OP_LOADPAGE_LO instruction even in the EEPROM memory
section.  Thus, load addresses are halved for it when accessing
EEPROM.

If the only decision needed is whether flash or EEPROM is going
to be accessed, my suggestion is to combine that with the 'F' and
'E' decision a few lines before:


  if (strcmp(m->desc, "flash") == 0) {
    memtype = 'F';
    a_div = 2;
  }
  else if (strcmp(m->desc, "eeprom") == 0) {
    memtype = 'E';
    a_div = 1;
  }
  else {
    return -2;
  }



    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?48131>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

[bug #48131] Problem with EEprom address of avrdude for different processors!

Joerg Wunsch-6
Follow-up Comment #2, bug #48131 (project avrdude):

Hmm.  Also breaks the ability to read or write EEPROM to ATMEGA8 using the
Arduino as ISP sketch, which is expecting the addresses in the STK500 "Load
Address" command to be word addresses (as it is for the m328.)

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?48131>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev