These are chat archives for esp8266/Arduino

10th
Aug 2016
@mkeyno
Aug 10 2016 08:43

hi All , I'm trying to copy read file to buffer in my sketch by I've got LoadProhibitedCause exception , following is the code that used in sketch
in pre setup
uint8_t * BUFFER;
in setup
BUFFER = (uint8_t *)malloc(1024);
in loop
ESP.flashRead(_address,(uint32_t *)& BUFFER, sizeof(BUFFER));

memcpy_P(_Destination,BUFFER, sizeof(BUFFER));

either memcpy and memcpy_P throw the issue as following
Fatal exception 28(LoadProhibitedCause):

Exception (28):

ctx: cont
sp: 3fff0d70 end: 3fff0f50 offset: 01a0

0x402071bb: loop at read_raw_data.ino line 465
0x4020e908: loop_wrapper at core_esp8266_main.cpp line 56
0x40100718: cont_norm at cont.S line 109
any clue is really appreciated
@mkeyno
Aug 10 2016 09:04
I've also check with memmove() function, but same result , hope could have @me-no-dev and @igrr comments on this issue
Ivan Grokhotkov
@igrr
Aug 10 2016 09:37
@mkeyno what code is at line 465 of read_raw_data.ino ?
@mkeyno
Aug 10 2016 09:38
memcpy_P(_Destination,BUFFER, sizeof(BUFFER));
without this line I have no problem , but when I try to copy read file in define buffer the exception come out
Ivan Grokhotkov
@igrr
Aug 10 2016 09:39
could you please add the following line before this one and run the sketch again
Serial.printf("memcpy: %08x %08x %d\r\n", (uint32_t) _Destination, (uint32_t) BUFFER, sizeof(BUFFER));
@mkeyno
Aug 10 2016 09:39
ok , hold on
@mkeyno
Aug 10 2016 09:45
memcpy: 00000000 3f0201e9 4
memcpy: 000001b0 f91061e2 4
memcpy: 00000360 00c0ff3b 4

Exception (28):

ctx: cont
sp: 3fff0d80 end: 3fff0f70 offset: 01a0
Ivan Grokhotkov
@igrr
Aug 10 2016 09:46
Okay, cool, your _Destination variable is zero :)
Now remove the ampersand before BUFFER in your ESP.flashRead line and try again
@mkeyno
Aug 10 2016 09:48
you mean this address 00000000 3f0201e9 is void
Ivan Grokhotkov
@igrr
Aug 10 2016 09:48
also, sizeof(BUFFER) is 4
are you sure you want to copy 4 bytes?
@mkeyno
Aug 10 2016 09:49
no in fact 144*3 byte
Ivan Grokhotkov
@igrr
Aug 10 2016 09:49
then fix your error in flashRead line and then fix the size you are memcpy'ing
i.e. change sizeof(BUFFER) to 144*3
@mkeyno
Aug 10 2016 09:50
thanks my man , its work now
one more question , I'm tying to get free space address in flash and then copy file to raw flash but it seems the address is not correct
this is my function to find the free start address
bool ini_custom_SPIFF(void)
{
uint32_t current_SPIFF_size = (uint32_t)(&_SPIFFS_end) - (uint32_t)(&_SPIFFS_start);
free_Space_location_start=(ESP.getSketchSize() + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
uint32_t avialable_room=ESP.getFreeSketchSpace();
uint32_t page   = (uint32_t) &_SPIFFS_page;
uint32_t  block  = (uint32_t) &_SPIFFS_block;
//Serial.printf("current SPIFF start %x -> end %x in  size of %uKB  free space=%uKB\n",(uint32_t)(&_SPIFFS_start),(uint32_t)(&_SPIFFS_end),current_SPIFF_size/1024,free_Space_location_start/1024);
if (avialable_room > current_SPIFF_size)
{
Serial.println("Set New SPIFFS");
SPIFFS.end(); // free current FS implementation
SPIFFS = FS(fs::FSImplPtr(new SPIFFSImpl(free_Space_location_start, avialable_room, page, block, 2)));
return true;
}
return false;
}
and then use this function to copy file from SPIFF to raw flash
void copy_file_from_SPIFF_to_Raw_Flash(String path, byte file_num){
uint32_t startTime = millis();
File f = SPIFFS.open(path, "r");
if(!f) { Serial.println("Could not open file for reading"); return; }
size_t i = f.size();
Serial.printf("File size is %u Bytes\n", i);
while(i > SPI_FLASH_SEC_SIZE){
optimistic_yield(10000);
ESP.flashWrite(current_raw_location,(uint32_t *)& BUFFER, SPI_FLASH_SEC_SIZE);
Serial.print("."); i -= SPI_FLASH_SEC_SIZE;
current_raw_location+=SPI_FLASH_SEC_SIZE;
}
optimistic_yield(10000);
ESP.flashWrite(current_raw_location,(uint32_t *)& BUFFER, i);
current_raw_location+=i;
f.close();
Serial.printf("copy took %u ms, memory end address=%u\n",  millis() - startTime,current_raw_location);
}
@mkeyno
Aug 10 2016 09:57
this function gave me start address in 49000 whereas second function gave me file start location address like 385408
I mean 49000 if far close to address like 385408
what did I miss?
SteveToulouse
@SteveToulouse
Aug 10 2016 10:10
The printf in the second function is after the copy, so it's telling you the next free address, not the start address ?
@mkeyno
Aug 10 2016 10:11
I know , and I know the file size but it seems still far away from each other
it must follow the this rule , start address + filesize = start next address, but it doesn't
somehow start free location address gave me wrong information
@mkeyno
Aug 10 2016 10:18
@SteveToulouse can you spare time and run my sketch by yourself
SteveToulouse
@SteveToulouse
Aug 10 2016 10:19
How are _SPIFFS_start and _SPIFFS_end declared?
I'm on mobile right now and it doesn't have an ESP inside ;-)
@mkeyno
Aug 10 2016 10:20
extern "C" uint32_t _SPIFFS_start;
extern "C" uint32_t _SPIFFS_end;
extern "C" uint32_t _SPIFFS_page;
extern "C" uint32_t _SPIFFS_block;
ok , can you let me know whenever got proper time and tools to test it
SteveToulouse
@SteveToulouse
Aug 10 2016 10:23
In your first function, you calculate spiffs size by subtracting the addresses of _SPIFFS_start and _end. What value does it give?
@mkeyno
Aug 10 2016 10:24
the exact value that set in flash size setting
@mkeyno
Aug 10 2016 10:32
@igrr is there any program or python script , like windows hex viewer which can show graphically , what's happening on flash
SteveToulouse
@SteveToulouse
Aug 10 2016 10:33
I'm not sure but it seems your call to SPIFFSImpl is giving addresses (&) in the page and block PARAMETERS, instead of values, no?
Ivan Grokhotkov
@igrr
Aug 10 2016 10:35
you can use esptool.py to download the contents of flash into a file and then use any hex viewer with that
@mkeyno
Aug 10 2016 10:42
SPIFFSImpl just work when free space greater than SPIFF
thanks @igrr , can you remind me what is download syntax ,
Ivan Grokhotkov
@igrr
Aug 10 2016 10:48
usage: esptool.py read_flash [-h] [--no-progress] address size filename
@mkeyno
Aug 10 2016 10:50
is this clone whole flash memory of ESP?
Ivan Grokhotkov
@igrr
Aug 10 2016 10:50
read size bytes starting from address
into filename
@mkeyno
Aug 10 2016 10:51
so where can I introduce the COM port number to read from it
SteveToulouse
@SteveToulouse
Aug 10 2016 10:53
The -p COMx option
I think
@mkeyno
Aug 10 2016 10:56

such as esptool.py read_flash -p com19 -h --no-progress 0 4095 image.bin

argument address: invalid arg_auto_int value: 'com19'

SteveToulouse
@SteveToulouse
Aug 10 2016 11:07
Upper case COM ?
@mkeyno
Aug 10 2016 11:08
no different
SteveToulouse
@SteveToulouse
Aug 10 2016 11:10
--port COM19 ?
@mkeyno
Aug 10 2016 11:12
esptool.py -p com19 erase_flash easily works for me but it seems new parameter not match the correct syntax
SteveToulouse
@SteveToulouse
Aug 10 2016 11:28
Maybe parameter order. After read_flash you need to put the start_addr and size, not the -p? Soory, just guessing
Hagai Shatz
@hagai-shatz
Aug 10 2016 12:57
Is there a way to generate 16MHz constant clock signal on one of the pins?
@mkeyno
Aug 10 2016 12:58
@igrr I define uint8_t * BUFFER; and initialized by BUFFER = (uint8_t *)malloc(64); , I've tried to print what read by ESP.flashRead(_address,(uint32_t *) BUFFER, sizeof(BUFFER)); function , but it just print one 32bit data with length of 4, do you have any comments for that
Martin Ayotte
@martinayotte
Aug 10 2016 13:00
You did the same mistake as prevously : sizeof(BUFFER) does NOT equal 64, it give the size of the pointer which is 4.
@mkeyno
Aug 10 2016 13:01
thanks @martinayotte , but how can I print what I read
Martin Ayotte
@martinayotte
Aug 10 2016 13:01
@hagai-shatz , No !
@mkeyno , Simply specify the real size directly : ESP.flashRead(_address,(uint32_t *) BUFFER, 64);
Hagai Shatz
@hagai-shatz
Aug 10 2016 13:03
@martinayotte , thanks. I found somewhere that there are special clock functions for some pins, but was unable to find specific details.
Martin Ayotte
@martinayotte
Aug 10 2016 13:03
What do you mean by "special clock" ?
Hagai Shatz
@hagai-shatz
Aug 10 2016 13:04
XTAL, RTC or something.
Martin Ayotte
@martinayotte
Aug 10 2016 13:05
There is CLK_OUT available on GPIO0, but since the xtal is 26Mhz, you can not get a proper divider for makeing it 16Mhz
Hagai Shatz
@hagai-shatz
Aug 10 2016 13:08
What dividers/frequencies can I get?
Martin Ayotte
@martinayotte
Aug 10 2016 13:09
I mean the only divider possible here is a single flipflop, so divide by 2, that means you will get 13Mhz not 16Mhz
What is your needs for that 16Mhz ? why not using another xtal ?
Hagai Shatz
@hagai-shatz
Aug 10 2016 13:13
Thanks, was trying to save a component. Will use another xtal.
@mkeyno
Aug 10 2016 13:14
@martinayotte do you have any suggestion to print out what is read by ESP.flashRead()
Martin Ayotte
@martinayotte
Aug 10 2016 13:16
@mkeyno , a "for" loop printing each bytes ...
@mkeyno
Aug 10 2016 13:17
is there any faster way ?
Martin Ayotte
@martinayotte
Aug 10 2016 13:20
no, the "for" loop isn't the bottleneck here, it is the print over serial that is the bootleneck. you can do the print in a TCP telnet connection to make this faster.
@mkeyno
Aug 10 2016 13:27
ok , thanks @martinayotte I've just wanted to check it , what is suppose to be read
@mkeyno
Aug 10 2016 17:05
@martinayotte what I read by ESP.flashRead()is different from what I read bySPIFF f.read()
Martin Ayotte
@martinayotte
Aug 10 2016 17:27
@mkeyno , in the code mentioned above while reading SPIFFS and write Raw, do you still have this wrong Ampersand ? ESP.flashWrite(current_raw_location,(uint32_t *)& BUFFER, SPI_FLASH_SEC_SIZE); , this would means that you wrote many times the address of the pointer, not the content of the buffer.
@mkeyno
Aug 10 2016 17:29
no I remove it as soon as Ivan mentioned
@mkeyno
Aug 10 2016 17:35
I created a file with known character but when I print what flashWrite did , it is only contain repeated character
Martin Ayotte
@martinayotte
Aug 10 2016 17:41
"repeated characters" means somehow a "pointer of the pointer" ... Make sure all you're ampersands are removed.
@mkeyno
Aug 10 2016 17:49
known character appear but somehow its shattered every where and disorder
Martin Ayotte
@martinayotte
Aug 10 2016 18:01
@mkeyno
Aug 10 2016 18:02
I did, that's why I find out it is not copy in correct way
File f = SPIFFS.open(path, "r");
if(!f) { Serial.println("Could not open file for reading"); return; }
size_t i = f.size();
Serial.printf("File size is %u Bytes\n", i);
while(i > SPI_FLASH_SEC_SIZE){
optimistic_yield(10000);
ESP.flashWrite(current_raw_location,(uint32_t *) BUFFER, SPI_FLASH_SEC_SIZE);
Serial.print("."); i -= SPI_FLASH_SEC_SIZE;
current_raw_location+=SPI_FLASH_SEC_SIZE;
}
optimistic_yield(10000);
ESP.flashWrite(current_raw_location,(uint32_t *) BUFFER, i);
current_raw_location+=i;
f.close();
Martin Ayotte
@martinayotte
Aug 10 2016 18:04
So, is the discripency in the transfer or in the raw read back ?
In the above code, I don't see any print of the buffer content. Maybe add one, and to reduce the test just use smaller files
@mkeyno
Aug 10 2016 18:05
I think its not write correctly , because flashRead has simple function
Martin Ayotte
@martinayotte
Aug 10 2016 18:05
flashWrite() too ...
@mkeyno
Aug 10 2016 18:06
I remove it and paste here
after writing or reading use following code to check buffer content for(int j=0;j<size;j++){Serial.print((char)BUFFER[j]); Serial.print(",");}
Martin Ayotte
@martinayotte
Aug 10 2016 18:13
You means ESP.flashWrite() ? Yes, the core Updater ! Oh, that make me think : are you doing ESP.flashEraseSector() before ESP.flashWrite() ? If not, you should, since maybe the flash have already some zero bits which cannot be re-writen ...
@mkeyno
Aug 10 2016 18:15
what do you mean can not be re written? should I do erase flash before copy data to
Martin Ayotte
@martinayotte
Aug 10 2016 18:17
Like the Updater, one every sectors you try to write, you should do a ESP.flashEraseSector(current_raw_location/FLASH_SECTOR_SIZE); in your transfer loop
@mkeyno
Aug 10 2016 18:20
why in loop()? should I after locate the free flash spot in setup() then run ESP.flashEraseSector()
Martin Ayotte
@martinayotte
Aug 10 2016 18:22
No, simply in your above loop, since this will just erase sectors on the fly before writing them again, accordingly to file size.
@mkeyno
Aug 10 2016 18:26
actually the plan is copy files located in SPIFF to the raw flash and then in loop read from raw flash instead of SPIFF , so do you think is it necessary to do ESP.flashEraseSector() repeatedly
Martin Ayotte
@martinayotte
Aug 10 2016 18:32
I means in the SPIFF-to-RAW loop you've pasted above, sector by sector, just before the flashWrite()
@mkeyno
Aug 10 2016 18:44
thanks @martinayotte it seems character in order now , but some line is missing , I should recheck it again. I'll update my code in repo , after that may I ask spare couple of minutes and run my sketch
John
@9H5G
Aug 10 2016 20:06
Help plse :) I've been compiling stuff for weeks now with 1.6.9 and suddenly tonight with no changes to my .ino, it fails with: C:\Users\john\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++": file does not exist. I uninstalled and then installed 1.6.10 and downgraded (to 2.2) and then upgraded the ESP boards to 2.3 without change. Any thoughts welcome please
John
@9H5G
Aug 10 2016 22:43
It would seem that my antivirus program has decided the file is a trojan! (Bitdefender). Sorry to bother you.