So I’m having some difficulties saving/reading from the flash memory, as mentioned above.
I found recently, after reflashing my core, I was unable to send/receive data from the core in any fashion until I do a factory reset.
The code in my firmware that seems to cause the problem consists of reading/writing to flash.
If I comment out the related code shown below, the problem doesn’t occur, and I am able to use other functions normally, sending/receiving/reflashing/etc.
The problem isn’t consistent either.
Without executing the save_color_to_mem function, I can occasionally get the core to execute other commands before it freezes up, and doesn’t seem to recognize any other cloud input.
If I execute the save_color_to_mem function, it stops accepting commands typically, and if I reset it, it doesn’t read from memory. I originally tried just reading/writing the 3 bytes that I needed, since based on information from here, I found that I could write odd bytes, and it shouldn’t be a problem (using the code found in the link seemed to work without issue).
Any suggestions? If you need any additional information, let me know.
#define DESIRED_LED_FLASH_ADDRESS 0x80000
...
int global_r, global_g, global_b;
...
void setup() {
...
uint8_t temp_rgb[4];
sFLASH_ReadBuffer(temp_rgb, DESIRED_LED_FLASH_ADDRESS, 4);
global_r = temp_rgb[0];
global_g = temp_rgb[1];
global_b = temp_rgb[2];
...
}
...
int save_color_to_mem(){
sFLASH_EraseSector(DESIRED_LED_FLASH_ADDRESS);
uint8_t values_led[4] = { (uint8_t)global_r, (uint8_t)global_g,
(uint8_t)global_b, 0 };
sFLASH_WriteBuffer(values_led, DESIRED_LED_FLASH_ADDRESS, 4);
return 1;
}