Hi, thanks for the input. Yes I meant the second iteration through the loop. Here are some more points:
1. For writing calibration parameters (only 256 bytes), I open flashx:code and flashx:swap0, use SEEK_END to see how large the “file” size is, and compare total sizes to make sure I have enough space after the end of the image to write my 256 bytes. I write my 256 bytes at the end of flashx:swap0, which so far has always been much larger than flashx:code. Incidentally, I have also tried flax:swap1 and I still get the failure, so it doesn’t appear to be clobbering or overwriting its own image.
2. I have about 30k Bytes available in RAM, based on seeing how large lwmemalloc can go, so I’m not running out of memory.
3. According to the IAR introspection tool, I’m not overflowing the stacks in any tasks, and all the tasks appear to be healthy before and after a failed write attempt.
4. I have a test function (as opposed to the real API function which is buried a few layers deep) which attempts to write 256 bytes to the end of flashx:swap0 and I have put this at various points through the startup process. In all cases, it works initially, then after starting up some tasks, it eventually fails. In some of these cases, I don’t actually need to start RTCS_create(). It will fail after starting up one of the other subtasks. So this appears to be an issue between MQX tasks and the flashx driver; it appears it doesn’t actually have to be RTCS_create(). However, if I don’t link in the RTCS library, I don’t have the issue. So it kind of smells like it has to do with total size of the image, or maybe where the linker decides to put things.