I dont get the_sbrk error when I remove the const in the below function, but then I get a different error
const char* convMonth(byte value) { // converts 1-12 to the correstponding month
switch (value) {
case 1: return "January";
case 2: return "February";
case 3: return "March";
case 4: return "April";
case 5: return "May";
case 6: return "June";
case 7: return "July";
case 8: return "August";
case 9: return "September";
case 10: return "October";
case 11: return "November";
case 12: return "December";
}
}
Wow, that is amazing piece of code! I was expecting something simpler, where would be easier to try disabling parts of code until a culpri can be foundt. But it seems @bko discovered something! I can’t really help much when some internal working is involved as I am - let’s say - too scared to dive into the firmware code. Sorry
Folks, it turns out that _sbrk() is called by functions in the Time class which are calling malloc_r instead of malloc. When @mdma gets back, he should be able to fix this quickly. This only affects the develop branch.
I am currently on hold for doing any local compiling as my code has to have time functions. Do you know what files I would have to edit in the develop branch to change mallocr to malloc? Just so I can start testing my code?
@peekay123, Do you know what files I would have to edit in the develop branch to change mallocr to malloc? Just so I can start testing my code I cant really wait a week or 2.
here are @mdma’s instructions for tracking down your linker problem:
Here’s how to find out which function is causing the problem:
add a function extern “C” void* _sbrk() { return NULL; } to your
program. This is only temporary and will fill in the missing function so
the code links.open the user-part.lst file that is produced alongside your compiled application codesearch for sbrk to find which function is calling that. (It’s usually _mallocr)then search for mallocr and see which function is calling that. That will tell you which function is trying to allocate memory directly via mallocr rather than via malloc()
"
@wesner0019, the _sbrk source is well known to be in the Time class. The Time functions call malloc_r() instead of malloc(). If you don’t use any Time functions then you won’t get the error. In my case, I am using Time so I will want Mat to fix this correctly.
Just git pulled today on the latest branch and found that the sbrk bug now afflicting the latest branch today as well, but only for photon, not core. Strange.