Hmm, that’s weird. We just released the ram optimization firmware improvements to the build farm yesterday, so it should have at least 4K of ram during startup / handshake, and about 12k of available dynamic ram while connected to the cloud. Any chance you can post your code?
The code is online in a library. To get it, please add the flashee-eeprom library to a app, and copy the integration-test.cpp example to your app. Because of the preprocessor issues I was having, most of the code currently lives in the header integration-tests.h in the library.
I’m afraid it’s not trivial code, and I’m not sure how to water it down or even debug it since the sources aren’t local once I’ve built in the cloud.
What’s strange is that the flash library uses dynamic memory allocation and it’s not even invoked. Yet, the Spark flashes red immediately on startup (before wifi connect etc…)
The library does have a static initializer - see Devices::userFlash, which allocates an object to manage the user accessible flash region, but it’s only a handful of bytes in size.
I have compiled identical code in the IDE and locally and can confirm the local code compiles and runs.
Hi @dave - any news? @stevespark is also getting the same problem. It it’s something I’ve done wrong with the library I’d love to know so I can fix it, but it’s working fine locally. (I should also try the CLI to see if that helps, but I have no time to try that until tomorrow.)
Okay, I’ve been looking into this a bit, I haven’t found any obvious issues on the server end, but I did fix a few small bugs. I’m having trouble compiling the library locally:
In file included from ../src/flashee-eeprom/flashee-eeprom.h:154:0,
from ../src/application.cpp:5:
../src/flashee-eeprom/flashee-eeprom-impl.h: In member function 'virtual bool Flashee::SparkExternalFlashDevice::writePage(const void*, Flashee::flash_addr_t, Flashee::page_size_t)':
../src/flashee-eeprom/flashee-eeprom-impl.h:1309:66: error: invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
In file included from ../../core-common-lib/SPARK_Firmware_Driver/inc/hw_config.h:34:0,
from ../inc/main.h:37,
from ../inc/spark_utilities.h:30,
from ../inc/spark_wiring.h:34,
from ../inc/application.h:29,
from ../src/application.cpp:3:
../../core-common-lib/SPARK_Firmware_Driver/inc/sst25vf_spi.h:65:6: error: initializing argument 1 of 'void sFLASH_WriteBuffer(uint8_t*, uint32_t, uint32_t)' [-fpermissive]
The compile error is because the library is expecting sFLASH_Write to take a const pointer - I made a pull request to change that in the firmware but it’s not been applied yet. I forgot I had this applied locally.
I’ve republished flashee to work with the existing non-const pointer. Only flashee-eeprom-impl.h changed - if you copy that to inc/flashee folder it should now compile for you.
Alas, I’m still getting the SOS in the online IDE with this change in place.
Sorry to dig up an old thread, but I think I finally found the cause of this.
It’s a result of the order that constructors are called on module-scope static instances. The only guarantee is that constructors within the same module are called in the order of declaration, but constructors that depend on other instances in other modules cannot be sure the other instance has in fact been initialized.
The workaround is to put module static instances in an accessor functions, then when the function is called, the constructor is guaranteed to be executed.
I have done this for the static instances in flashee and this fixed the problem.
The crazy thing is that the actual initialization order is based on linker order, and that may vary between builds since it’s based on loosely defined aspects such as the order the filesystem returns the list of files in a directory. This is what makes the problem intermittent.