LoadStoreErrorCause help

smbgaiden
Posts: 5
Joined: Wed Oct 18, 2017 8:09 am

LoadStoreErrorCause help

Postby smbgaiden » Thu Oct 19, 2017 5:06 am

Hi All,

I've written some strings into spi flash and then try to access using the virtual memory addressing and have a weird behavior that I can't figure out how to cope with.

Flashed my equal sized strings with esptool.py to 0x80000. Verified they're there via two ways:
A.
char* p = (char *)0x40280000;
os_printf("%c%c%c%c\n", p[0], p[1], p[2], p[3]);

B.
spi_flash_read(0x80000, temp, sizeof(temp));
os_printf("SPI Read: 0x%X 0x%X 0x%X 0x%X\n", temp[0], temp[1], temp[2], tem$

Compared the hex vs. the chars vs. the bin I wrote there and everything was fine.

Now if I do:
char * p =(char *)0x40280064; // this is a valid string address starting point and is smaller than the bin file written into 0x80000

os_printf(p); // This is good! See my string printed over serial.
// But if I do this:
os_printf("This is my string: %s", p); // this throws me out the following before reset:

This is my string: Fatal exception 3(LoadStoreErrorCause):
epc1=0x4000228b, epc2=0x00000000, epc3=0x00000000, excvaddr=0x40280064, depc=0x0

Closest address to 0x4000228b seems to be:
40001f00 g *ABS* 00000000 ets_vprintf
; which makes sense for os_printf to call.

Does anyone know why I can directly use a pointer to virtual indexed memory with os_printf and have a good result vs. having the printf code look it up via a va_list causes the LoadStoreErrorCause?

smbgaiden
Posts: 5
Joined: Wed Oct 18, 2017 8:09 am

Re: LoadStoreErrorCause help

Postby smbgaiden » Thu Oct 19, 2017 6:31 am

Oh correction... the p[0] was actually int pointers. Seems you can't use l8 functions with SPI Flash addresses. When I recast the int * to char * and try to printf with %c p[0] and etc it will crash.

sedlacek.david
Posts: 10
Joined: Thu Jul 12, 2018 2:06 pm

Re: LoadStoreErrorCause help

Postby sedlacek.david » Sun Aug 05, 2018 10:21 pm

I'm probably facing the same problem. Have 4MBytes of flash. I can declare a variable like

Code: Select all

const char * p = 0x40280000
and read it like

Code: Select all

int x = *p
. This works.
But when I have a pointer like this:

Code: Select all

UINT32 addr = 0x40280000;
const char * p = (const char *)addr;


it will crash:

Code: Select all

Fatal exception 3(LoadStoreErrorCause):
                                       
epc1=0x402430ec, epc2=0x00000000, epc3=0x00000000, excvaddr=0x40280000, depc=0x0
0000000


Don't understand...

sedlacek.david
Posts: 10
Joined: Thu Jul 12, 2018 2:06 pm

Re: LoadStoreErrorCause help

Postby sedlacek.david » Wed Aug 15, 2018 1:15 am

Can someone help?

blubb
Posts: 107
Joined: Mon Jun 22, 2015 5:35 am

Re: LoadStoreErrorCause help

Postby blubb » Wed Aug 15, 2018 8:11 am

You have to read 4 bytes at once always. If you try to read only 1 or 2, a crash is normal behavior.

sedlacek.david
Posts: 10
Joined: Thu Jul 12, 2018 2:06 pm

Re: LoadStoreErrorCause help

Postby sedlacek.david » Wed Aug 15, 2018 3:32 pm

Thank you for your reply.

So there is nothing wrong with it. What I have to do now is refactor some of my C structures mapping some UINT8 stuff stored in the FLASH.

Who is online

Users browsing this forum: No registered users and 8 guests