hinata46243 / mega-isp

Automatically exported from code.google.com/p/mega-isp
0 stars 0 forks source link

EEPROM write & read BUG #26

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write & read flash on a ATMega64 that have 2Kb of eeprom 

What is the expected output? What do you see instead?
Can you read& write all of the eeprom memory

Please provide any additional information below.

The bug is the start in the write_eeprom & read_eeprom subs
here was multiply for 2!!!

int start = here; // * 2; // BUG!!!

Original issue reported on code.google.com by occhiobe...@gmail.com on 8 Nov 2011 at 11:34

GoogleCodeExporter commented 8 years ago
Now I can use ArduinoISP to program my new radio Turnigy 9X with ER9X firmware 
and EEPE program!!!

Original comment by occhiobe...@gmail.com on 8 Nov 2011 at 11:35

GoogleCodeExporter commented 8 years ago
This is the corrected full version base on 04

Original comment by occhiobe...@gmail.com on 8 Nov 2011 at 11:46

Attachments:

GoogleCodeExporter commented 8 years ago
Can someone test this on a Mega368 chip? The Tiny2313 chip uses the universal 
command to write EEPROM, so it never runs the code in question.

Original comment by rsb...@gmail.com on 17 Nov 2011 at 1:06

GoogleCodeExporter commented 8 years ago
Why do you have changed the status to fixed without changing main code?

Original comment by occhiobe...@gmail.com on 17 Nov 2011 at 1:12

GoogleCodeExporter commented 8 years ago
Please try the following:

In terminal mode: 
w eeprom 0x10 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17
r eeprom 0 0x40

Now read the eeprom to a file:
-U eeprom:r:ee00.hex:i

ee00.hex should look like this:
:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1011121314151617FFFFFFFFFFFFFFFF5C
:20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0

When I use ArduinoISP05.pde with the atmega328 I get this instead:
:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1011DD
:200020001011121312131415141516171617FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBB

If you're getting something different with your mega64 please let me know. 
Also, which version of avrdude are you using?

Original comment by rsb...@gmail.com on 19 Nov 2011 at 9:30

GoogleCodeExporter commented 8 years ago
avrdude> w eeprom 0x10 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17
>>> w eeprom 0x10 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 

avrdude> r eeprom 0 0x40
>>> r eeprom 0 0x40 
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  10 11 12 13 14 15 16 17  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> 

Original comment by occhiobe...@gmail.com on 19 Nov 2011 at 1:48

GoogleCodeExporter commented 8 years ago
avrdude version 5.8cvs, URL: <http://savannah.nongnu.org/projects/avrdude/>

Work perfectly with 05.

Original comment by occhiobe...@gmail.com on 19 Nov 2011 at 1:49

GoogleCodeExporter commented 8 years ago
avrdude: writing output file "ee00.hex"

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Ettore:~ ciskje$ less ee00.hex 

:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1011121314151617FFFFFFFFFFFFFFFF5C
:20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0

Original comment by occhiobe...@gmail.com on 19 Nov 2011 at 1:50

GoogleCodeExporter commented 8 years ago
avrdude come from WinAVR crosspack.
Ettore:~ ciskje$ avrdude -P /dev/tty.usbmodem12341 -c avrisp -p m328p -t

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.12s

avrdude: Device signature = 0x1e950f
avrdude> w eeprom 0x10 0x10 0x11 0x12 0x13 0x14 0x15 0x16
>>> w eeprom 0x10 0x10 0x11 0x12 0x13 0x14 0x15 0x16 

avrdude> r eeprom 0 0x40
>>> r eeprom 0 0x40 
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  10 11 12 13 14 15 16 ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> 

Original comment by occhiobe...@gmail.com on 19 Nov 2011 at 2:00

GoogleCodeExporter commented 8 years ago
This is a piece of code taken from usbasp (world leader in AVR programming 3 
dollars!) :)
uchar ispReadEEPROM(unsigned int address) {
    ispTransmit(0xA0);
    ispTransmit(address >> 8);
    ispTransmit(address);
    return ispTransmit(0);
}

uchar ispWriteEEPROM(unsigned int address, uchar data) {

    ispTransmit(0xC0);
    ispTransmit(address >> 8);
    ispTransmit(address);
    ispTransmit(data);

    clockWait(30); // wait 9,6 ms

    return 0;
}

As you can see eeprom address is byte oriented.

Original comment by occhiobe...@gmail.com on 20 Nov 2011 at 10:16

GoogleCodeExporter commented 8 years ago
Found small differences between avrdude reading eeprom: 
m64
                        Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    20    64    0 no       2048    8      0  9000  9000 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

avrdude: Send: U [55] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [00] . [08] E [45]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] 
avrdude: Recv: . [10] 
avrdude: Send: U [55] . [08] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [00] . [08] E [45]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] . [11] . [12] . [13] . [14] . [15] . [16] . [ff] 
avrdude: Recv: . [10] 
avrdude: Send: U [55] . [10] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [00] . [08] E [45]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] 
avrdude: Recv: . [10] 

as you can see avrdude read 8 step of 8 byte so address is clearly byte 
oriented but:

328p
                       Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

avrdude: Send: U [55] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [00] . [04] E [45]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] 
avrdude: Recv: . [10] 
avrdude: Send: U [55] . [02] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [00] . [04] E [45]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] 
avrdude: Recv: . [10] 
avrdude: Send: U [55] . [04] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [00] . [04] E [45]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] 
avrdude: Recv: . [10] 

read with 2 step and 4 byte buffer, so clearly is a word based address.
It was usefull?

Original comment by occhiobe...@gmail.com on 20 Nov 2011 at 5:30

GoogleCodeExporter commented 8 years ago
Yes, very useful. We need to figure out how to tell if avrdude is sending word 
or by addresses. I know why it does it: if the chip definition in avrdude.conf 
has an eeprom>loadpage_lo entry it uses word addresses (see m328p). If not 
(m64) it sends by addresses. Question is, does it send the information to 
ArduinoISP?

Original comment by rsb...@gmail.com on 21 Nov 2011 at 1:49