Arduino Touchshield Slide EEPROM help

Hi,

i jus gotten a touchshield slide and when i tried to use the EEPROM function i get this bunch of error below, i'm using an arduino0018-antipasto0043 downloaded from liquidware

previously when i used this on my touch shield stealth it works perfect, even now when i used the stealth it compiles and uploads OK but when i switch the board to slide, the error runs up.. Anyone with any thoughts of how i may resolve this?

Settings\Administrator\Desktop\Antipasto\hardware\arduino\cores\touchshield\src\components\libraries\EEPROM\EEPROM.cpp:24:
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'void eeprom_read_block(void*, const void*, size_t)':
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: ISO C++ forbids incrementing a pointer of type 'void*'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: ISO C++ forbids incrementing a pointer of type 'const void*'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: invalid conversion from 'const void*' to 'const uint8_t*'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: initializing argument 1 of 'uint8_t eeprom_read_byte(const uint8_t*)'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'void eeprom_write_block(const void*, void*, size_t)':
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: ISO C++ forbids incrementing a pointer of type 'void*'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: ISO C++ forbids incrementing a pointer of type 'const void*'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: invalid conversion from 'void*' to 'uint8_t*'
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: initializing argument 1 of 'void eeprom_write_byte(uint8_t*, uint8_t)'

Thanks in advance

Jonathan

i think eeprom.h is not good for the current c++ compiler...

some had success with changing that file:

http://old.nabble.com/eeprom.h-error:-cast-from-'const-uint8_t*'-to-'uint8_t'-loses-precision-in-c%2B%2B-td20900465.html

can u post those 2 lines that contain errors?

can u upgrade that code somehow?

-arne

from line 290 onwards.

static inline void
eeprom_read_block (void *__dst, const void __src, size_t __n)
{
#if (! (defined(AVR_ATmega2560) || defined(AVR_ATmega2561)) )
__eerd_block (__dst, __src, __n, eeprom_read_byte);
#else
/
If ATmega256x device, do not call function. */
while (__n--)
{
*(char *)__dst++ = eeprom_read_byte(__src++);
}
#endif
}

from line 398 onwards.

static inline void
eeprom_write_block (const void *__src, void __dst, size_t __n)
{
#if (! (defined(AVR_ATmega2560) || defined(AVR_ATmega2561)) )
__eewr_block (__dst, __src, __n, eeprom_write_byte);
#else
/
If ATmega256x device, do not call function. */
while (__n--)
eeprom_write_byte (__dst++, *(uint8_t *)__src++);
#endif
}

these 2 block of codes are giving the abv error anyone can provide any insights on how i may tweak this code?

Thanks in advance

Jonathan

this line
*(char *)__dst++ = eeprom_read_byte(__src++);
should look like this:
*(((char *)__dst)++) = eeprom_read_byte(((const char *)__src)++);

this line
eeprom_write_byte (__dst++, *(uint8_t *)__src++);
should look like this:
eeprom_write_byte (((char *)__dst)++, *(((const uint8_t *)__src)++));

-arne

Hi, have tried the new codes, but still the same results

compile(), new thread run about to sketch.compile()
[echo] Building TouchShield Slide libraries...
[apply] In file included from C:\Documents and Settings\Administrator\Desktop\Antipasto\hardware\arduino\cores\touchshield\src\components\libraries\EEPROM\EEPROM.cpp:24:
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'void eeprom_read_block(void*, const void*, size_t)':
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:292: error: lvalue required as increment operand
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:292: error: lvalue required as increment operand
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'void eeprom_write_block(const void*, void*, size_t)':
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:402: error: lvalue required as increment operand
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:402: error: lvalue required as increment operand

=(

did u try this:

static __inline__ void
eeprom_write_block (const void *__src, void *__dst, size_t __n)
{
#if (! (defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)) )
   __eewr_block (__dst, __src, __n, eeprom_write_byte);
#else
   const uint8_t *S = (const uint8_t *)__src;
   uint8_t *D = (uint8_t *)__dst;
   while (__n--) {
       eeprom_write_byte (D, *S);
       D++; S++;
   }
#endif
}

?

what does it say then?

-arne

Settings\Administrator\Desktop\Antipasto\hardware\arduino\cores\touchshield\src\components\libraries\EEPROM\EEPROM.cpp:24:
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'int eeprom_write_block(const void*, void*, size_t)':
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:403: error: 'D' was not declared in this scope
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:403: error: 'S' was not declared in this scope
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:404: error: 'D' was not declared in this scope
[apply] c:/documents and settings/administrator/desktop/antipasto/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:404: error: 'S' was not declared in this scope

Humm whats D and S supposed to be? i think it has to be declared.. heeh..

btw do help me check this code out, i did this changes and my compiler didn't complain.

eeprom_read_block (int *__dst, const uint8_t *__src, size_t __n)
eeprom_write_block (const int *__src, uint8_t *__dst, size_t __n)

Do you think its alright? instead of void i changed to int and cont uint8_t whereever applicable.. previously when i compiled anything, even the ellipseAtTouch example the compiler screams at me, but after changing from void to int, it kept quiet, but i don't know if when i use the EEPROM in future will it be ok.

Haven't tried it yet.. would you help me check it out?

Thanks alot dude =)

Jonathan

S and D r like this:
const uint8_t *S = (const uint8_t *)__src;
uint8_t *D = (uint8_t *)__dst;

maybe u forgot them?
if not, then something strange is going on...
ghostbusters... :slight_smile:

ur own solution changes the interface of the function, what i found problematic (that's why i proposed to introduce S and D)...

furthermore ur own solution possibly doesnt work,
because:
int is 8bit longer than uint8_t/char...

-arne

it works! =) i'll wait for the read tweaking codes and compile everything up into a well quick guide for anyone else who has this similar problem in future.. all credits to Riddick aka Arne

ok - good to read that - i was already doubting my C/C++ skills...
because type casting is quite basic...

this should be the C++yfied ...read() thingy:

static __inline__ void
eeprom_read_block (void *__dst, const void *__src, size_t __n)
{
#if (! (defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)) )
   __eerd_block (__dst, __src, __n, eeprom_read_byte);
#else
   const uint8_t *S = (const uint8_t *)__src;
   uint8_t *D = (uint8_t *)__dst;
   while (__n--)
   {
       *D = eeprom_read_byte(S);
       D++; S++;
   }
#endif
}

maybe there r more compact solutions, but obviously i cant find one...
in earlier times there were coding contests "the most complex functionality in just 1024 characters" or so... ;D

-arne

ahh its about the same as the write() humm.. alright let me do the changes, update this entire post so that anyone with the liquidware IDE will probably find this useful.. and THANKS ALOT!! =D i still have no idea what on earth is going on anyway =P

dont' worry about compact solutions.. to me is.. which one works heeh..

whats that lil * thing infront of.. the variables for?

Hi For anyone who uses liquidware Arduino0018-Antipasto0043 who wanna use the EEPROM functionality for touch shield SLIDE but realised copying the EEPROM library from the Arduino side doesn't work well heres the guide.

Strangely enough by simply copying the library from Arduino Core works for Stealth but not Slide, i'm not sure if its a bug or something but heres the solution.

To use EEPROM on Touch Shield
1)Copy EEPROM from your arudino folder(ur path might differ)
desktop/antipasto/hardware/arduino/cores/arduino/src/components/library
2)well COPY folder EEPROM and paste in following path
desktop/antipasto/hardware/arduino/cores/touchshield/src/components/library

If you are running touch shield Stealth u can stop here. EEPROM examples will be available under file tab, Examples.

If you are trying to run Slide, then carry on.

  1. Go to the following path and open the file
    desktop/antipasto/hardware/tools/avr/avr/include/avr/eeprom

  2. make the following changes(suggest you use Ctrl F and search for eeprom_read_block and eeprom_write_block). The fonts in red are the ones to remove, its the original code, remove them or comment them out. The fonts in Green are to be added.

eeprom_read_block (void *__dst, const void __src, size_t __n)
{
#if (! (defined(AVR_ATmega2560) || defined(AVR_ATmega2561)) )
__eerd_block (__dst, __src, __n, eeprom_read_byte);
#else
/
If ATmega256x device, do not call function. */
const uint8_t *S = (const uint8_t *)__src;
uint8_t *D = (uint8_t )__dst;
while (__n--)
{
//
(char *)__dst++ = eeprom_read_byte(__src++);
*D = eeprom_read_byte(S);
D++; S++;
}
#endif
}

static inline int
eeprom_write_block (const void *__src, void __dst, size_t __n)
{
#if (! (defined(AVR_ATmega2560) || defined(AVR_ATmega2561)) )
__eewr_block (__dst, __src, __n, eeprom_write_byte);
#else
/
If ATmega256x device, do not call function. */
const uint8_t *S = (const uint8_t *)__src;
uint8_t *D = (uint8_t *)__dst;
while (__n--){
//eeprom_write_byte (__dst++, *(uint8_t *)__src++);

eeprom_write_byte (D, *S);
D++; S++;
}

#endif
}

Hope this little guide is helpful to anyone who attempts to use EEPROM on Slide.

Special Thanks To Riddick for all the help provided and to make this guide possible.

Regards
Jonathan.

in the ...write() function the curled brackets r missing... :slight_smile:

"*D" means: we want to access the memory that D points at...
if "D" points to address 10... then "*D" is the memory at address 10...

-arne