Compare commits

...

7 Commits

Author SHA1 Message Date
Kwabena W Agyeman
83e2e8c506
Merge 14112734e7 into 8759db0b6a 2025-11-01 19:50:24 +01:00
Ibrahim Abdelkader
8759db0b6a
Merge pull request #2907 from openmv/fix_stm32_mpu_region
Some checks failed
🔎 Check Code Formatting / formatting-check (push) Has been cancelled
🔥 Firmware Build / build-firmware (false, 0, false, DOCKER) (push) Has been cancelled
🔥 Firmware Build / build-firmware (false, 0, true, MPS2_AN500) (push) Has been cancelled
🔥 Firmware Build / build-firmware (false, 0, true, MPS3_AN547) (push) Has been cancelled
🔥 Firmware Build / build-firmware (false, 1, false, OPENMV_N6) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, ARDUINO_GIGA) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, ARDUINO_NANO_33_BLE_SENSE) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, ARDUINO_NANO_RP2040_CONNECT) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, ARDUINO_NICLA_VISION) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, ARDUINO_PORTENTA_H7) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV2) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV3) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV4) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV4P) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMVPT) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV_AE3) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV_N6) (push) Has been cancelled
🔥 Firmware Build / build-firmware (true, 0, false, OPENMV_RT1060) (push) Has been cancelled
🔥 Firmware Build / code-size-report (push) Has been cancelled
🔥 Firmware Build / stable-release (push) Has been cancelled
🔥 Firmware Build / development-release (push) Has been cancelled
ports/stm32: Remove unused MPU_REGION_NUMBER_MAX.
2025-11-01 11:03:20 +02:00
Ibrahim Abdelkader
3770b314bc
Merge pull request #2906 from openmv/add_crc_test
scripts/unittests: Add crc test.
2025-11-01 11:02:59 +02:00
iabdalkader
70c9ce2c66 ports/stm32: Remove unused MPU_REGION_NUMBER_MAX.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-11-01 09:53:24 +01:00
iabdalkader
627dc0b1f6 scripts/unittest: Add CRC module unit test.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-11-01 09:52:30 +01:00
iabdalkader
c3b0676470 scripts/unittest: Add total test execution time to summary.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
igned-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-11-01 09:52:27 +01:00
iabdalkader
b997cc2b69 boards/MPS: Enable CRC module.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-11-01 09:40:39 +01:00
5 changed files with 123 additions and 9 deletions

View File

@ -8,6 +8,7 @@ OMV_BOARD_CFLAGS= -DQEMU_SOC_MPS2 \
-DCPU_FREQ_HZ=25000000
MICROPY_PY_CSI = 1
MICROPY_PY_CSI_NG = 1
MICROPY_PY_CRC = 1
MICROPY_PY_FIR = 0
MICROPY_PY_ULAB = 1
MICROPY_PY_WINC1500 = 0

View File

@ -9,6 +9,7 @@ OMV_BOARD_CFLAGS= -mcmse \
-DCPU_FREQ_HZ=32000000
MICROPY_PY_CSI = 1
MICROPY_PY_CSI_NG = 1
MICROPY_PY_CRC = 1
MICROPY_PY_FIR = 0
MICROPY_PY_ULAB = 1
MICROPY_PY_WINC1500 = 0

View File

@ -34,12 +34,6 @@
#include "omv_gpio.h"
#include "stm_dma.h"
#if defined(MPU_REGION_NUMBER15)
#define MPU_REGION_NUMBER_MAX (MPU_REGION_NUMBER15)
#else
#define MPU_REGION_NUMBER_MAX (MPU_REGION_NUMBER7)
#endif
#define MEMATTR_NORMAL_NCACHE 0
#define MEMATTR_NORMAL_WB_RA_WA 1

View File

@ -44,6 +44,8 @@ def main():
if not "temp" in os.listdir():
os.mkdir("temp") # Make a temp directory
total_start_time = time.ticks_ms()
for test in tests:
result = "PASSED"
path = "/".join((TEST_PATH, test))
@ -72,14 +74,21 @@ def main():
print_result(test, result, time_ms)
gc.collect()
total_time_ms = time.ticks_diff(time.ticks_ms(), total_start_time)
# Print summary
total_tests = passed_count + failed_count + skipped_count
print("\n" + "=" * 60)
stats_line = ("Total: %d | Passed: %d | Failed: %d | Skipped: %d | Time: %dms" %
(total_tests, passed_count, failed_count, skipped_count, total_time_ms))
separator = "=" * len(stats_line)
print("\n" + separator)
print("Total: %d | " % total_tests +
COLOR_GREEN + "Passed: %d" % passed_count + COLOR_RESET + " | " +
COLOR_RED + "Failed: %d" % failed_count + COLOR_RESET + " | " +
COLOR_YELLOW + "Skipped: %d" % skipped_count + COLOR_RESET)
print("=" * 60)
COLOR_YELLOW + "Skipped: %d" % skipped_count + COLOR_RESET + " | " +
"Time: %dms" % total_time_ms)
print(separator)
if failed_count > 0:
print(COLOR_RED + "Some tests FAILED." + COLOR_RESET)

View File

@ -0,0 +1,109 @@
def unittest(data_path, temp_path):
try:
import crc
except ImportError:
raise Exception("crc module unavailable")
# Test data
test_data1 = b"Hello, World!"
test_data2 = b"OpenMV"
test_data3 = b"1234567890"
# Test 1: Basic CRC16 calculation
crc16_result1 = crc.crc16(test_data1)
if not isinstance(crc16_result1, int):
return False
# CRC16 should be 16-bit value (0-65535)
if crc16_result1 < 0 or crc16_result1 > 0xFFFF:
return False
# Test 2: Basic CRC32 calculation
crc32_result1 = crc.crc32(test_data1)
if not isinstance(crc32_result1, int):
return False
# CRC32 should be 32-bit value
if crc32_result1 < 0 or crc32_result1 > 0xFFFFFFFF:
return False
# Test 3: Consistency - same input should give same output
crc16_result1_repeat = crc.crc16(test_data1)
if crc16_result1 != crc16_result1_repeat:
return False
crc32_result1_repeat = crc.crc32(test_data1)
if crc32_result1 != crc32_result1_repeat:
return False
# Test 4: Different inputs should give different outputs
crc16_result2 = crc.crc16(test_data2)
if crc16_result1 == crc16_result2:
return False
crc32_result2 = crc.crc32(test_data2)
if crc32_result1 == crc32_result2:
return False
# Test 5: Incremental CRC16 calculation
# Calculate CRC of concatenated data in one go
combined_data = test_data1 + test_data2
crc16_combined = crc.crc16(combined_data)
# Calculate CRC incrementally
crc16_part1 = crc.crc16(test_data1)
crc16_incremental = crc.crc16(test_data2, value=crc16_part1)
# Both methods should give same result
if crc16_combined != crc16_incremental:
return False
# Test 6: Incremental CRC32 calculation
crc32_combined = crc.crc32(combined_data)
crc32_part1 = crc.crc32(test_data1)
crc32_incremental = crc.crc32(test_data2, value=crc32_part1)
if crc32_combined != crc32_incremental:
return False
# Test 7: Multi-step incremental CRC16
crc16_step1 = crc.crc16(test_data1)
crc16_step2 = crc.crc16(test_data2, value=crc16_step1)
crc16_step3 = crc.crc16(test_data3, value=crc16_step2)
# Should match single calculation
all_data = test_data1 + test_data2 + test_data3
crc16_all = crc.crc16(all_data)
if crc16_step3 != crc16_all:
return False
# Test 8: Multi-step incremental CRC32
crc32_step1 = crc.crc32(test_data1)
crc32_step2 = crc.crc32(test_data2, value=crc32_step1)
crc32_step3 = crc.crc32(test_data3, value=crc32_step2)
crc32_all = crc.crc32(all_data)
if crc32_step3 != crc32_all:
return False
# Test 9: Empty data handling
empty_data = b""
crc16_empty = crc.crc16(empty_data)
crc32_empty = crc.crc32(empty_data)
# Empty data should return valid CRC values
if not isinstance(crc16_empty, int) or not isinstance(crc32_empty, int):
return False
# Test 10: Single byte data
single_byte = b"A"
crc16_single = crc.crc16(single_byte)
crc32_single = crc.crc32(single_byte)
if not isinstance(crc16_single, int) or not isinstance(crc32_single, int):
return False
return True