From fdf64f92941020ed2183bbe25036ad4c64770cfe Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 22 Sep 2020 22:42:49 +0200 Subject: [PATCH] Make self-test configurable. --- src/omv/boards/OPENMV2/omv_boardconfig.h | 3 +++ src/omv/boards/OPENMV3/omv_boardconfig.h | 3 +++ src/omv/boards/OPENMV4/omv_boardconfig.h | 3 +++ src/omv/boards/OPENMV4P/omv_boardconfig.h | 3 +++ src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h | 3 +++ src/omv/boards/PORTENTA/omv_boardconfig.h | 3 +++ src/omv/main.c | 8 +++++--- 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/omv/boards/OPENMV2/omv_boardconfig.h b/src/omv/boards/OPENMV2/omv_boardconfig.h index 46b2c53e1..10dc48ca4 100644 --- a/src/omv/boards/OPENMV2/omv_boardconfig.h +++ b/src/omv/boards/OPENMV2/omv_boardconfig.h @@ -52,6 +52,9 @@ #define OMV_ENABLE_LEPTON (0) #define OMV_ENABLE_HM01B0 (0) +// Enable self-tests on first boot +#define OMV_ENABLE_SELFTEST (1) + // If buffer size is bigger than this threshold, the quality is reduced. // This is only used for JPEG images sent to the IDE not normal compression. #define JPEG_QUALITY_THRESH (160*120*2) diff --git a/src/omv/boards/OPENMV3/omv_boardconfig.h b/src/omv/boards/OPENMV3/omv_boardconfig.h index ac856f745..272d74f71 100644 --- a/src/omv/boards/OPENMV3/omv_boardconfig.h +++ b/src/omv/boards/OPENMV3/omv_boardconfig.h @@ -52,6 +52,9 @@ #define OMV_ENABLE_LEPTON (0) #define OMV_ENABLE_HM01B0 (0) +// Enable self-tests on first boot +#define OMV_ENABLE_SELFTEST (1) + // If buffer size is bigger than this threshold, the quality is reduced. // This is only used for JPEG images sent to the IDE not normal compression. #define JPEG_QUALITY_THRESH (160*120*2) diff --git a/src/omv/boards/OPENMV4/omv_boardconfig.h b/src/omv/boards/OPENMV4/omv_boardconfig.h index 002023f6b..ef7419799 100644 --- a/src/omv/boards/OPENMV4/omv_boardconfig.h +++ b/src/omv/boards/OPENMV4/omv_boardconfig.h @@ -58,6 +58,9 @@ // Enable WiFi debug #define OMV_ENABLE_WIFIDBG (1) +// Enable self-tests on first boot +#define OMV_ENABLE_SELFTEST (1) + // If buffer size is bigger than this threshold, the quality is reduced. // This is only used for JPEG images sent to the IDE not normal compression. #define JPEG_QUALITY_THRESH (320*240*2) diff --git a/src/omv/boards/OPENMV4P/omv_boardconfig.h b/src/omv/boards/OPENMV4P/omv_boardconfig.h index 7e5c1ad81..459a6ee2d 100644 --- a/src/omv/boards/OPENMV4P/omv_boardconfig.h +++ b/src/omv/boards/OPENMV4P/omv_boardconfig.h @@ -62,6 +62,9 @@ // Enable WiFi debug #define OMV_ENABLE_WIFIDBG (1) +// Enable self-tests on first boot +#define OMV_ENABLE_SELFTEST (1) + // If buffer size is bigger than this threshold, the quality is reduced. // This is only used for JPEG images sent to the IDE not normal compression. #define JPEG_QUALITY_THRESH (1920*1080*2) diff --git a/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h b/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h index b945e00b7..a02d8847f 100644 --- a/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h +++ b/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h @@ -62,6 +62,9 @@ // Enable WiFi debug #define OMV_ENABLE_WIFIDBG (1) +// Enable self-tests on first boot +#define OMV_ENABLE_SELFTEST (0) + // If buffer size is bigger than this threshold, the quality is reduced. // This is only used for JPEG images sent to the IDE not normal compression. #define JPEG_QUALITY_THRESH (1920*1080*2) diff --git a/src/omv/boards/PORTENTA/omv_boardconfig.h b/src/omv/boards/PORTENTA/omv_boardconfig.h index 80a7cf9b6..2f3fa9878 100644 --- a/src/omv/boards/PORTENTA/omv_boardconfig.h +++ b/src/omv/boards/PORTENTA/omv_boardconfig.h @@ -59,6 +59,9 @@ // Enable WiFi debug #define OMV_ENABLE_WIFIDBG (0) +// Enable self-tests on first boot +#define OMV_ENABLE_SELFTEST (0) + // If buffer size is bigger than this threshold, the quality is reduced. // This is only used for JPEG images sent to the IDE not normal compression. #define JPEG_QUALITY_THRESH (320*240*2) diff --git a/src/omv/main.c b/src/omv/main.c index 9ac2bb05b..007352381 100644 --- a/src/omv/main.c +++ b/src/omv/main.c @@ -113,9 +113,7 @@ static const char fresh_readme_txt[] = "https://github.com/openmv/openmv\r\n" ; -#ifdef OPENMV1 -static const char fresh_selftest_py[] =""; -#else +#if (OMV_ENABLE_SELFTEST == 1) static const char fresh_selftest_py[] = "import sensor, time, pyb\n" "\n" @@ -275,10 +273,12 @@ void make_flash_fs() f_write(&fp, fresh_readme_txt, sizeof(fresh_readme_txt) - 1 /* don't count null terminator */, &n); f_close(&fp); + #if (OMV_ENABLE_SELFTEST == 1) // Create default selftest.py f_open(&vfs_fat->fatfs, &fp, "/selftest.py", FA_WRITE | FA_CREATE_ALWAYS); f_write(&fp, fresh_selftest_py, sizeof(fresh_selftest_py) - 1 /* don't count null terminator */, &n); f_close(&fp); + #endif led_state(LED_RED, 0); } @@ -596,9 +596,11 @@ soft_reset: // Execute the boot.py script before initializing the USB dev to // override the USB mode if required, otherwise VCP+MSC is used. exec_boot_script("/boot.py", false, false); + #if (OMV_ENABLE_SELFTEST == 1) // 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); + #endif } // Init USB device to default setting if it was not already configured