Discussion:
[avr-libc-dev] 2.0.0 and XMega32E5 eeprom troubles...
Scott Price
2016-02-09 19:23:59 UTC
Permalink
I am not able to get any of the eeprom_write_* or eeprom_update_*
functions working on an XMega32E5. There are no compile errors or
warnings, the functions just don't do anything. The eeprom read
functions that I am using all work fine.

I had previously been using a version of avr-libc that I lifted from
AVRStudio 6.2 to get support for the E5. The eeprom functions worked
well on that version.

I compiled it using gcc-4.9.3 on Ubuntu Trusty.

Atmel's nvm functions work for me, but add a significant amount of code.
I would rather use the ones from avr-libc, since I use them for all of
my other AVR projects.

Looking through the code and the docs it seems like the functions should
work.

I have done a number of experiments, including writing a fixed value to
a fixed location on boot then reading the eeprom out with avr-dude.
Nothing I have done has produced a successful write.

What more information do you need, or what tests can I run to help debug
this?

Thanks!

Scott =)
--
Scott L. Price, P.E.
Electrical Engineering/IT Manager
Hunt Utilities Group LLC http://www.hugllc.com
Pine River, MN (218) 587-5001
MN Electrical Licenses: Master #AM08525 Power Limited #PL11071
Sivanupandi, Pitchumani
2016-02-10 08:13:07 UTC
Permalink
-----Original Message-----
Sent: 10 February 2016 00:54
Subject: [avr-libc-dev] 2.0.0 and XMega32E5 eeprom troubles...
I am not able to get any of the eeprom_write_* or eeprom_update_* functions
working on an XMega32E5. There are no compile errors or warnings, the
functions just don't do anything. The eeprom read functions that I am using
all work fine.
I had previously been using a version of avr-libc that I lifted from
AVRStudio 6.2 to get support for the E5. The eeprom functions worked well
on that version.
I compiled it using gcc-4.9.3 on Ubuntu Trusty.
Atmel's nvm functions work for me, but add a significant amount of code.
I would rather use the ones from avr-libc, since I use them for all of my
other AVR projects.
Looking through the code and the docs it seems like the functions should
work.
I have done a number of experiments, including writing a fixed value to a
fixed location on boot then reading the eeprom out with avr-dude.
Nothing I have done has produced a successful write.
What more information do you need, or what tests can I run to help debug
this?
Hi Scott,

If you are building avr-libc, could you try below patch?
This is the related difference I could see from Atmel's avr-libc build.

Regards,
Pitchumani

diff --git a/avr-libc/libc/misc/eewr_byte.S b/avr-libc/libc/misc/eewr_byte.S
index 98008c2..30b1595 100644
--- a/avr-libc/libc/misc/eewr_byte.S
+++ b/avr-libc/libc/misc/eewr_byte.S
@@ -61,6 +61,12 @@ ENTRY eeprom_write_r18
# define NVM_CMD_ERASE_EEPROM_BUFFER_gc 0x36
# endif

+#if ! defined (NVM_EEMAPEN_bm)
+ ; Saving X register because it might contain source address of block
+ push XL
+ push XH
+#endif
+
; Prepare base address of NVM.
ldi ZL, lo8(NVM_BASE)
ldi ZH, hi8(NVM_BASE)
@@ -136,6 +142,12 @@ ENTRY eeprom_write_r18
; Increment address.
adiw addr_lo, 1

+#if ! defined (NVM_EEMAPEN_bm)
+ ; Restoring X register
+ pop XH
+ pop XL
+#endif
+
ret

#else /* ---------------------------------------------------- */
Scott Price
2016-02-10 14:34:24 UTC
Permalink
Post by Sivanupandi, Pitchumani
-----Original Message-----
Sent: 10 February 2016 00:54
Subject: [avr-libc-dev] 2.0.0 and XMega32E5 eeprom troubles...
I am not able to get any of the eeprom_write_* or eeprom_update_* functions
working on an XMega32E5. There are no compile errors or warnings, the
functions just don't do anything. The eeprom read functions that I am using
all work fine.
I had previously been using a version of avr-libc that I lifted from
AVRStudio 6.2 to get support for the E5. The eeprom functions worked well
on that version.
I compiled it using gcc-4.9.3 on Ubuntu Trusty.
Atmel's nvm functions work for me, but add a significant amount of code.
I would rather use the ones from avr-libc, since I use them for all of my
other AVR projects.
Looking through the code and the docs it seems like the functions should
work.
I have done a number of experiments, including writing a fixed value to a
fixed location on boot then reading the eeprom out with avr-dude.
Nothing I have done has produced a successful write.
What more information do you need, or what tests can I run to help debug
this?
Hi Scott,
If you are building avr-libc, could you try below patch?
This is the related difference I could see from Atmel's avr-libc build.
Regards,
Pitchumani
diff --git a/avr-libc/libc/misc/eewr_byte.S b/avr-libc/libc/misc/eewr_byte.S
index 98008c2..30b1595 100644
--- a/avr-libc/libc/misc/eewr_byte.S
+++ b/avr-libc/libc/misc/eewr_byte.S
@@ -61,6 +61,12 @@ ENTRY eeprom_write_r18
# define NVM_CMD_ERASE_EEPROM_BUFFER_gc 0x36
# endif
+#if ! defined (NVM_EEMAPEN_bm)
+ ; Saving X register because it might contain source address of block
+ push XL
+ push XH
+#endif
+
; Prepare base address of NVM.
ldi ZL, lo8(NVM_BASE)
ldi ZH, hi8(NVM_BASE)
@@ -136,6 +142,12 @@ ENTRY eeprom_write_r18
; Increment address.
adiw addr_lo, 1
+#if ! defined (NVM_EEMAPEN_bm)
+ ; Restoring X register
+ pop XH
+ pop XL
+#endif
+
ret
#else /* ---------------------------------------------------- */
_______________________________________________
AVR-libc-dev mailing list
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
That gives me the same result. No warnings or errors, it just does
nothing. It is like it is not getting called or compiled in. The map
file from gcc says it is taking up 0x46 bytes of memory in
.text.avr-libc, so it is getting compiled in.

After hacking around some, I found the patch below makes it work for me.
Granted, it is not a good solution, as it probably breaks things for all
other XMegas. ;) I am only using the E5 currently.

Thanks!

Scott =)


--- eewr_byte.S.orig 2016-02-10 08:22:16.373013183 -0600
+++ eewr_byte.S 2016-02-10 08:28:46.638860509 -0600
@@ -116,7 +116,7 @@
std Z + NVM_ADDR0 - NVM_BASE, addr_lo
std Z + NVM_ADDR1 - NVM_BASE, addr_hi
std Z + NVM_ADDR2 - NVM_BASE, __zero_reg__
-#if defined (NVM_EEMAPEN_bm)
+#if !defined (NVM_EEMAPEN_bm)
std Z + NVM_DATA0 - NVM_BASE, r18
#else
movw XL, addr_lo
--
Scott L. Price, P.E.
Electrical Engineering/IT Manager
Hunt Utilities Group LLC http://www.hugllc.com
Pine River, MN (218) 587-5001
MN Electrical Licenses: Master #AM08525 Power Limited #PL11071
Joerg Wunsch
2016-02-10 21:11:36 UTC
Permalink
Post by Scott Price
After hacking around some, I found the patch below makes it work for me.
Granted, it is not a good solution, as it probably breaks things for all
other XMegas. ;) I am only using the E5 currently.
Does that mean it's an XmegaE issue?

Please submit a bug report:

https://savannah.nongnu.org/bugs/?group=avr-libc
--
cheers, Joerg .-.-. --... ...-- -.. . DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
Scott Price
2016-02-10 21:56:43 UTC
Permalink
Post by Joerg Wunsch
Post by Scott Price
After hacking around some, I found the patch below makes it work for me.
Granted, it is not a good solution, as it probably breaks things for all
other XMegas. ;) I am only using the E5 currently.
Does that mean it's an XmegaE issue?
It is filed as bug #47113.

Just a note, I couldn't chose 2.0.0 for the release the bug was in. I
wrote it in the top of the description instead.

Thanks!

Scott =)
--
Scott L. Price, P.E.
Electrical Engineering/IT Manager
Hunt Utilities Group LLC http://www.hugllc.com
Pine River, MN (218) 587-5001
MN Electrical Licenses: Master #AM08525 Power Limited #PL11071
Joerg Wunsch
2016-02-10 23:02:59 UTC
Permalink
Post by Scott Price
Just a note, I couldn't chose 2.0.0 for the release the bug was in. I
wrote it in the top of the description instead.
Thanks for reminding me: I forgot to update the web interface after
the recent release.
--
cheers, Joerg .-.-. --... ...-- -.. . DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)
Loading...