chipKIT® Development Platform

Inspired by Arduino™

EEPROM problem

Created Wed, 21 May 2014 12:30:00 +0000 by kaaasap


kaaasap

Wed, 21 May 2014 12:30:00 +0000

When using the provided EEPROM read/write/clear examples, EEPROM works. When I try to use EEPROM.read/clear I have no problems, but when I use EEPROM.write in sketch I get the following errors:

C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0008300 of Ametek_Display_Rev1_5.cpp.elf section .stack' is not within region kseg1_data_mem' C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0008800 of Ametek_Display_Rev1_5.cpp.elf section .ramfunc' is not within region kseg1_data_mem' C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: Ametek_Display_Rev1_5.cpp.elf section .mdebug.abi32' will not fit in region kseg1_data_mem' C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: Not enough space to allocate both stack and heap. Reduce heap and/or stack size. C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0008300 of Ametek_Display_Rev1_5.cpp.elf section .stack' is not within region kseg1_data_mem' C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0008800 of Ametek_Display_Rev1_5.cpp.elf section .ramfunc' is not within region kseg1_data_mem' C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: Not enough space to allocate both stack and heap. Reduce heap and/or stack size. C:/Users/melton/Desktop/mpide-0023-windows-20130715/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: region `kseg1_data_mem' overflowed by 2048 bytes collect2: ld returned 1 exit status

I have tried to find any reference to this and coming up short (story of my life).


kaaasap

Wed, 21 May 2014 13:37:49 +0000

I have checked stack, heap, data and bss size, as found here:

http://www.chipkit.net/forum/viewtopic.php?f=6&t=2577&p=10048&hilit=Reduce+heap+and%2For+stack+size.#p10048

and I am not over. Please help.


kaaasap

Wed, 21 May 2014 15:23:14 +0000

Let me just say, Majenko and UECIDE rock. Just installed UECIDE and no problem. I am testing what I just uploaded to my uC32 and no problems yet. All this even though MPIDE gave the above errors. Majenko, if I ever visit the UK or you come here, there will be much liquor handed over to you.


EmbeddedMan

Wed, 21 May 2014 15:27:46 +0000

I've done a bunch of testing on the EEPROM and have never come across the errors you posted. What board were you building for? I'd like to see if I can reproduce and fix the issue.

*Brian


kaaasap

Wed, 21 May 2014 16:22:02 +0000

The uC32 with PIC32MX340F512H.


EmbeddedMan

Wed, 21 May 2014 16:23:44 +0000

OK thanks. What's the simplest sketch you can come up with that demonstrates the problem?

*Brian


kaaasap

Wed, 21 May 2014 16:36:44 +0000

The following loads and runs just fine.

#include <EEPROM.h>

int addr0 = 0; int addr1 = 1; int addr2 = 2; int addr3 = 3; int addr4 = 4; int addr5 = 5; int addr6 = 6; int addr7 = 7; int addr8 = 8; int addr9 = 9; int addr10 = 10; int addr11 = 11; int addr12 = 12; int addr13 = 13; int addr14 = 14;

int val0 = 5; int val1 = 6; int val2 = 2; int val3 = 1; int val4 = 10; int val5 = 3; int val6 = 3; int val7 = 3; int val8 = 3; int val9 = 3; int val10 = 2; int val11 = 2; int val12 = 2; int val13 = 2; int val14 = 2;

void setup() { Serial.begin(115200); delay(1500);

EEPROM.write(addr0, val0); delay(100); EEPROM.write(addr1, val1); delay(100); EEPROM.write(addr2, val2); delay(100); EEPROM.write(addr3, val3); delay(100); EEPROM.write(addr4, val4); delay(100);

EEPROM.write(addr5, val5); delay(100); EEPROM.write(addr6, val6); delay(100); EEPROM.write(addr7, val7); delay(100); EEPROM.write(addr8, val8); delay(100); EEPROM.write(addr9, val9); delay(100);

EEPROM.write(addr10, val10); delay(100); EEPROM.write(addr11, val11); delay(100); EEPROM.write(addr12, val12); delay(100); EEPROM.write(addr13, val13); delay(100); EEPROM.write(addr14, val14); delay(100);

}

void loop() { reader = (EEPROM.read(0)); Serial.println(reader); delay(1000); reader = (EEPROM.read(1)); Serial.println(reader); delay(1000); reader = (EEPROM.read(2)); Serial.println(reader); delay(1000); reader = (EEPROM.read(3)); Serial.println(reader); delay(1000); reader = (EEPROM.read(4)); Serial.println(reader); delay(1000); reader = (EEPROM.read(5)); Serial.println(reader); delay(1000); reader = (EEPROM.read(6)); Serial.println(reader); delay(1000); reader = (EEPROM.read(7)); Serial.println(reader); delay(1000); reader = (EEPROM.read(8)); Serial.println(reader); delay(1000); reader = (EEPROM.read(9)); Serial.println(reader); delay(1000); reader = (EEPROM.read(10)); Serial.println(reader); delay(1000); reader = (EEPROM.read(11)); Serial.println(reader); delay(1000); reader = (EEPROM.read(12)); Serial.println(reader); delay(1000); reader = (EEPROM.read(13)); Serial.println(reader); delay(1000); reader = (EEPROM.read(14)); Serial.println(reader); delay(1000);

}

however, in my sketch I have

EEPROM.write(pwn0, spwn0); delay(100); EEPROM.write(pwn1, spwn1); delay(100); EEPROM.write(pwn2, spwn2); delay(100); EEPROM.write(pwn3, spwn3); delay(100); EEPROM.write(pwn4, spwn4); delay(100);

pwnX and spwnX are both ints zero to ten and when I have them in my sketch I get the errors.


EmbeddedMan

Wed, 21 May 2014 17:56:13 +0000

Can you copy/paste the exact sketch that demonstrates the problem? (I'm looking specifically for how you define pwnX and spwnX)

*Brian


kaaasap

Wed, 21 May 2014 19:26:04 +0000

Really can't paste the code as it is something for work...but here is how I am defining them: int pwn0 = 4; int spwn0 = 5; int pwn1 = 4; int spwn1 =5; etc. etc. etc.


majenko

Wed, 21 May 2014 20:27:25 +0000

The error you are seeing is usually due to having too many (or too large) variables - basically it's saying you're running out of RAM.

Note that the PIC32 doesn't have EEPROM, so it emulates it with Flash pages. As a result large amounts of RAM are needed for buffering the data while writing (it has to read a page into RAM, modify it, erase the page, then write the data back).

static uint8_t tempBuffer[MAX_ADDRESS_DEFAULT];

and MAX_ADDRESS_DEFAULT is:

#define MAX_ADDRESS_DEFAULT     512

So that's 512 bytes lost to your sketch just from that. Confirmed here:

a0000140 l     O .bss	00000200 tempBuffer

0x200 is 512 decimal.

The uC32 has 32K of RAM, and I don't know what else you're using, but it is most likely that you are overflowing the RAM somewhere.

How big is the BSS without the EEPROM code included?


EmbeddedMan

Thu, 22 May 2014 13:39:48 +0000

OK, so I've got my uC32, and I'm using MPIDE 20130715, and I'm trying to reproduce the problem you're having.

Unfortunately, the sketch that you say works fine doesn't compile.

And you haven't yet provided a sketch that we can use that will show the problem.

With those, all I can do is guess what the issue is, and for that, I completely agree with Majenko.

I understand your sketch is for work and you can't share the whole thing. But if it starts working when you cut it down in size to post here, then you know it's something about the variables and their size that's giving you the errors.

*Brian


kaaasap

Mon, 02 Jun 2014 13:45:26 +0000

Interesting it doesn't compile for you. I just re-compiled it and got a screen capture of it.

I have my full program running no prob and compiling on UECIDE.

Now I am running into a problem with the Serial1.read() buffer not clearing/flushing/emptying for me. If I Serial1.read() for a while, stop, then do it again, the first read always equals the previous sets last read. Example:

for (i = 0, i <= 55, i++)

The first reading of the second or third or fourth...etc. time through equals the last reading of the previous time.

I tried a Serail1.flush(), but am not sure this is correct. Any suggestions?


Jacob Christ

Mon, 02 Jun 2014 21:13:32 +0000

Really can't paste the code as it is something for work...but here is how I am defining them: int pwn0 = 4; int spwn0 = 5; int pwn1 = 4; int spwn1 =5; etc. etc. etc.

You don't need to send your work code, but if you upload a sketch that fails then its easier for those looking to reproduce the problem. However, if you create a simplified sketch and it doesn't fail, then it maybe suggestive of a different issue (such as Majenko suggested).

Jacob


kaaasap

Tue, 03 Jun 2014 18:16:53 +0000

I agree, normally I would question my code. But if UECIDE compiles it, shows I am not over RAM and mpide doesn't, I would think something funny (like a cannibal eating a clown) is happening within mpide. I am close to the 32k limit, I will admit that, but I am not over.


majenko

Tue, 03 Jun 2014 18:18:43 +0000

It could be that you are using a newer core in MPIDE than in UECIDE, or the other way around, and one uses more RAM than the other...?


kaaasap

Tue, 03 Jun 2014 18:25:53 +0000

mpide 0023-windows-20130715 vs. uecide v0.8.5e

recently had a flash screen freezing problem with uecide. fixed it by deleting the roaming uecide file and re-installing the uecide-master (renamed) from github.

checking cores to see if different.


majenko

Tue, 03 Jun 2014 18:35:14 +0000

That MPIDE is an order of magnitude behind UECIDE. I believe there have been some changes made to the EEPROM system since that ancient release to do with making it work better on the MX1/MX2 chips (i.e., actually work at all). What chip / board are you using again?


kaaasap

Thu, 05 Jun 2014 12:24:23 +0000

uC32 with PIC32MX340F512H

will download newest mpide and check


kaaasap

Thu, 05 Jun 2014 12:37:32 +0000

Just ran verify on the same sketch in mpide 20140316 (newest version on chipkit.net) and received the same errors.


kaaasap

Thu, 12 Jun 2014 00:53:24 +0000

got a little curious and created a bunch of fluff to max out ram on uC32 with UECIDE. RAM tops out at 36752!

Compile the same thing for MAX32 and get 37896 RAM


kaaasap

Thu, 12 Jun 2014 00:54:09 +0000

Anyway, the project has expanded and has moved to the MAX32....