mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Fix self-tests bug.
* This is an edge case which happens if a file is written to the flash storage immediately after the first boot and before a reset causing the host to corrupt the selftests.py script. * The selftests.py is now executed before USB MSC is enabled to avoid corrupting the filesystem when selftests.py is removed. * If the selftests.py fails, the USB MSC is enabled to allow the host to read the error log.
This commit is contained in:
parent
b2270ff85e
commit
0a8cc4f838
@ -213,9 +213,12 @@ void NORETURN __fatal_error(const char *msg) {
|
|||||||
const char *hdr = "FATAL ERROR:\n";
|
const char *hdr = "FATAL ERROR:\n";
|
||||||
f_write(&fp, hdr, strlen(hdr), &bytes);
|
f_write(&fp, hdr, strlen(hdr), &bytes);
|
||||||
f_write(&fp, msg, strlen(msg), &bytes);
|
f_write(&fp, msg, strlen(msg), &bytes);
|
||||||
|
f_close(&fp);
|
||||||
|
storage_flush();
|
||||||
|
// Initialize the USB device if it's not already initialize to allow
|
||||||
|
// the host to mount the filesystem and access the error log.
|
||||||
|
pyb_usb_dev_init(pyb_usb_dev_detect(), USBD_VID, USBD_PID_CDC_MSC, USBD_MODE_CDC_MSC, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
f_close(&fp);
|
|
||||||
storage_flush();
|
|
||||||
|
|
||||||
for (uint i = 0;;) {
|
for (uint i = 0;;) {
|
||||||
led_toggle(((i++) & 3));
|
led_toggle(((i++) & 3));
|
||||||
@ -568,9 +571,12 @@ soft_reset:
|
|||||||
|
|
||||||
// Run boot script(s)
|
// Run boot script(s)
|
||||||
if (first_soft_reset) {
|
if (first_soft_reset) {
|
||||||
// Execute the boot.py script before initializing the USB dev
|
// Execute the boot.py script before initializing the USB dev to
|
||||||
// to override the USB mode if required, otherwise VCP+MSC is used.
|
// override the USB mode if required, otherwise VCP+MSC is used.
|
||||||
exec_boot_script("/boot.py", false, false);
|
exec_boot_script("/boot.py", false, false);
|
||||||
|
// Execute the selftests.py script before the filesystem is mounted
|
||||||
|
// to avoid corrupting the filesystem when selftests.py is removed.
|
||||||
|
exec_boot_script("/selftest.py", true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init USB device to default setting if it was not already configured
|
// Init USB device to default setting if it was not already configured
|
||||||
@ -610,9 +616,8 @@ soft_reset:
|
|||||||
timer_tim5_init(100);
|
timer_tim5_init(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run boot script(s)
|
// Run main script if it exists.
|
||||||
if (first_soft_reset) {
|
if (first_soft_reset) {
|
||||||
exec_boot_script("/selftest.py", true, false);
|
|
||||||
exec_boot_script("/main.py", false, true);
|
exec_boot_script("/main.py", false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user