Missing eeprom functions in Mac release

The API for the AVR eeprom function at http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html shows these functions:

[edit]uint8_t eeprom_read_byte (const uint8_t *p) uint16_t eeprom_read_word (const uint16_t *p) uint32_t eeprom_read_dword (const uint32_t *p) float eeprom_read_float (const float *p) void eeprom_read_block (void *dst, const void *src, size_t __n)

void eeprom_write_byte (uint8_t *p, uint8_t __value) void eeprom_write_word (uint16_t *p, uint16_t value) void eeprom_write_dword (uint32_t *p, uint32_t value) void eeprom_write_float (float *p, float value) void eeprom_write_block (const void *src, void *__dst, size_t __n)

void eeprom_update_byte (uint8_t *p, uint8_t __value) void eeprom_update_word (uint16_t *p, uint16_t value) void eeprom_update_dword (uint32_t *p, uint32_t value) void eeprom_update_float (float *p, float value) void eeprom_update_block (const void *src, void *__dst, size_t __n)[/edit] The eeprom.h header in the Macintosh Arduino 0021 release shows these functions:

[edit]uint8_t eeprom_read_byte (const uint8_t *p) uint16_t eeprom_read_word (const uint16_t *p) uint32_t eeprom_read_dword (const uint32_t *p) void eeprom_read_block (void *dst, const void *__src, size_t __n)

void eeprom_write_byte ((uint8_t )p, x.byte.byte0); void eeprom_write_word (uint16_t *p, uint16_t value) void eeprom_write_dword (uint32_t *p, uint32_t value) void eeprom_write_block (const void *src, void *__dst, size_t __n)[/edit] **What happened to:*

[edit]float eeprom_read_float (const float p) void eeprom_write_float (float *p, float __value) [/edit] **and:*

[edit]void eeprom_update_byte (uint8_t *p, uint8_t __value) void eeprom_update_word (uint16_t *p, uint16_t value) void eeprom_update_dword (uint32_t *p, uint32_t value) void eeprom_update_float (float *p, float value) void eeprom_update_block (const void *src, void *__dst, size_t __n)[/edit]

Looks like the Mac version doesn't ship with the latest AVR-LIBC version 1.7.0. Here's the changelog that shows what was added (including the eeprom functions you mention):

http://www.nongnu.org/avr-libc/NEWS.txt

-- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Looks like the Mac version doesn't ship with the latest AVR-LIBC version 1.7.0.

Is it possible/practical(/easy) to upgrade the libraries in the Mac Arduino build?

Generally I'm wary of upgrading a library without the compiler as there are usually some strong dependencies there. But the EEPROM functions on a microcontroller target are pretty standalone things. I think it would be worthwhile to investigate downloading the 1.7.0 AVR-LIBC release and transplanting the EEPROM code into the Arduino tools tree.

-- The Quick Shield: breakout all 28 pins to quick-connect terminals

…I think it would be worthwhile to investigate…

I downloaded the avr-libc-1.7.0 package but I’m too cowardly to proceed much further.

There’s a general structural similarity to the directory layout in avr-libc-1.7.0 and in the Mac Arduino avr directories, but also plenty of differences. Plus, the eeprom.h files I found on the Mac have lots of what look like implementation code to me:

/** \ingroup avr_eeprom
    Read one byte from EEPROM address \a __p.
 */
__ATTR_PURE__ static __inline__ uint8_t eeprom_read_byte (const uint8_t *__p)
{
    do {} while (!eeprom_is_ready ());
#if E2END <= 0xFF
    EEARL = (uint8_t)__p;
#else
    EEAR = (uint16_t)__p;
#endif
    /* Use inline assembly below as some AVRs have problems with accessing
    EECR with STS instructions. For example, see errata for ATmega64. 
    The code below also assumes that EECR and EEDR are in the I/O space.
    */
    uint8_t __result;
    __asm__ __volatile__
    (
        "/* START EEPROM READ CRITICAL SECTION */ \n\t"
        "sbi %1, %2 \n\t"
        "in %0, %3 \n\t"
        "/* END EEPROM READ CRITICAL SECTION */ \n\t"
        : "=r" (__result)
        : "i" (_SFR_IO_ADDR(EECR)),
          "i" (EERE),
          "i" (_SFR_IO_ADDR(EEDR))
    );
    return __result;
}

The eeprom.h file from avr-libc-1.7.0 looks limited to simple declarations:

/** \ingroup avr_eeprom
    Read one byte from EEPROM address \a __p.
 */
uint8_t eeprom_read_byte (const uint8_t *__p) __ATTR_PURE__;

I’m willing to wait for Arduino 0022, but is there someone I can bug to make sure that all the eeprom functions make it into the next Arduino release? I have reason to believe that the Windows build is missing these functions too.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287154524/9#9

The Arduino IDE "ships" with a particular version of the compiler and associated avr-libc, and doesn't necessarily change versions just because the "most recent" version released by the avr-gcc people has changed. This tends to be needed so that you can keep track of which compiler bugs you have to deal with...

In general, I tend to go with the latest version of CrossPack for the Mac releases: http://www.obdev.at/products/crosspack/index.html

Dave is correct, the current release of Avr tool chain is from Crosspack. They have stated that they do not have time to update it.

Rick and I are working on updating the tool chain to 4.5.1 and are including in our test suite. There is still a bug in 4.5.1 regarding C++ objects so we have not released it. This is a bug we can duplicate.

4.5.1 has avrlib 1.7.0 which will have the new definitions.

Mark

Rick and I are working on updating the tool chain to 4.5.1 ... 4.5.1 has avrlib 1.7.0 which will have the new definitions.

Thank you Mark and Rick. I haven't been working with Arduino for long but it's been a great pleasure to find that everything Just Works (tm.) Waiting is minor inconvenience compared to the benefits that come from a well-managed development environment.