Discussion:
[avr-libc-dev] [bug #47113] XMegaE series won't write eeprom
Scott Price
2016-02-10 21:53:55 UTC
Permalink
URL:
<http://savannah.nongnu.org/bugs/?47113>

Summary: XMegaE series won't write eeprom
Project: AVR C Runtime Library
Submitted by: scottprice
Submitted on: Wed 10 Feb 2016 03:53:54 PM CST
Category: Library
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: libc code
Status: None
Percent Complete: 0%
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: Any
Fixed Release: None

_______________________________________________________

Details:

This bug is in 2.0.0.

None of the eeprom write or update functions work on the XMega32E5. It seems
to be a problem stemming from this block of code starting at line 119 in
libc/misc/eewr_byte.S:

#if defined (NVM_EEMAPEN_bm)
std Z + NVM_DATA0 - NVM_BASE, r18
#else
movw XL, addr_lo
subi XL, lo8(-MAPPED_EEPROM_START)
sbci XH, hi8(-MAPPED_EEPROM_START)
st X, r18
#endif

In the XMegaE series the memory mapping can't be turned off (it doesn't have
NVM_EEMAPEN_bm) so it uses the code in the #else. However, this code seems to
do nothing. If the code is changed so that it uses the line under the if
statement, it writes the eeprom properly. I tested it using the patch
attached, but I don't know enough about the other XMega processors to know if
it will break anything else.

As I dig into this more I am confused, though. NVM_EEMAPEN_bm is not defined
for the E5 series, in the ioxXe5 header files. Yet if the code, before this
patch, seems to be building like it has that defined. The patch was just
removing the #if statement, only leaving what is in the #else block. That
should have been what was built for the E5.





_______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 10 Feb 2016 03:53:54 PM CST Name: libc.patch Size: 539B By:
scottprice

<http://savannah.nongnu.org/bugs/download.php?file_id=36306>

_______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Scott Price
2016-02-10 22:03:38 UTC
Permalink
Follow-up Comment #1, bug #47113 (project avr-libc):

Sorry, I was writing the bug as I was debugging. The paragraph that starts
out "In the XMegaE series" is confusing and conflicting.

The problem is this:

For the XMegaE5, the #if defined() statement is making the wrong choice. It
*should* be compiling in the #else block, but it is not. If only the #else
block is left in the code (that is what the attached patch does) then it
works.

_______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Joerg Wunsch
2016-02-10 23:02:07 UTC
Permalink
Update of bug #47113 (project avr-libc):

Release: Any => 2.0.0


_______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Scott Price
2016-02-15 14:50:38 UTC
Permalink
Additional Item Attachment, bug #47113 (project avr-libc):

File name: libc.correct.patch Size:0 KB


_______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Scott Price
2016-02-19 23:24:43 UTC
Permalink
Follow-up Comment #2, bug #47113 (project avr-libc):

I am also having problems with the Mega16/32 series. I can't read or write
eeprom in those.

As soon as I can get to the git repository, I am going to see if I can find
the first checkin that caused the problem.

_______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Scott Price
2016-03-07 21:16:45 UTC
Permalink
Follow-up Comment #3, bug #47113 (project avr-libc):

This must have been something in my environment. I rebuilt everything from
scratch, using gcc 5.3.0, binutils 2.26 and avr-libc 2.0.0, and now it works.

Could you please close this bug as invalid?

_______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Joerg Wunsch
2016-03-07 21:26:48 UTC
Permalink
Update of bug #47113 (project avr-libc):

Status: None => Invalid
Open/Closed: Open => Closed

_______________________________________________________

Follow-up Comment #4:

OK, I'm glad it works for you now, and thanks for telling us!

_______________________________________________________

Reply to this item at:

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

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

Loading...