-
Notifications
You must be signed in to change notification settings - Fork 62
Description
With the micro:bit V2.2 boards when DAPLink is erasing a flash page if the CPU tries to access flash (e.g. to fetch an instruction) it will be blocked until the erase operation is done.
This affects the processing of serial data from the target to the interface, as DAPLink can be unresponsive for the 87.5ms it takes to erase a page.
So, when using data logging in a programme like this one, with serial mirroring enabled, whenever a page erase is triggered (after logging 4096 bytes) we lose some of the serial mirrored data.
This is also replicable with smaller strings, but then things like I2C "nops" and "null transactions" (which are enabled/disabled depending on multiple factors) can somewhat mitigate this, so this longer string is easier to replicate.
#include "MicroBit.h"
MicroBit uBit;
int main() {
uBit.init();
uBit.serial.setTxBufferSize(250);
uBit.log.setSerialMirroring(true);
uBit.log.setTimeStamp(TimeStampFormat::None);
while (true) {
uBit.log.beginRow();
uBit.log.logData("I", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
uBit.log.endRow();
uBit.sleep(20);
}
}
And in a serial console we'll see and output similar to this extract:
...
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
...
Our current theory is that when writing to a new page MicrobitLog
sends the serial data to the DMA or peripheral and then it sends the "erase page" command to DAPLink before all the serial data had time to be sent out of the target.
So once DAPLink starts erasing flash any UART from the target is dropped and that's when we see those issues in the serial output.
One simple solution could be to send the serial data after the DAPLink commands are processed.
Alternatively if there was a wait for CODAL to wait until all the data is out of the target that could work as well.