From a9f99fc21741d3a97c8094d4afb296bfd0bd21e1 Mon Sep 17 00:00:00 2001 From: Matthew Mets Date: Fri, 10 Feb 2023 01:02:14 +0000 Subject: [PATCH] Add test routine for erasing CH552 --- hw/production_test/binaries/blank.bin | Bin 0 -> 8000 bytes hw/production_test/production_test.py | 27 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 hw/production_test/binaries/blank.bin diff --git a/hw/production_test/binaries/blank.bin b/hw/production_test/binaries/blank.bin new file mode 100644 index 0000000000000000000000000000000000000000..975a03d03fdcdbfdb325e9dc0c1e44b152cd6305 GIT binary patch literal 8000 zcmeIufdBvi0Dz$VsTV1P3IhfV7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkoOG CKmY*% literal 0 HcmV?d00001 diff --git a/hw/production_test/production_test.py b/hw/production_test/production_test.py index df4f556..04a21df 100755 --- a/hw/production_test/production_test.py +++ b/hw/production_test/production_test.py @@ -17,6 +17,7 @@ file_locations = { 'chprog':'chprog', 'app_gateware':'binaries/top.bin', 'ch552_firmware':'binaries/usb_device_cdc.bin', + 'ch552_firmware_blank':'binaries/blank.bin', 'ch552_firmware_injected':'/tmp/ch552_fw_injected.bin', 'pico_bootloader_source':'binaries/main.uf2', 'pico_bootloader_target_dir':'/media/lab/RPI-RP2/' @@ -203,6 +204,17 @@ def flash_ch552(serial): print(result) return (result.returncode == 0) +def erase_ch552(): + """Erase an attached CH552 device""" + + # Program the CH552 using CHPROG + result = run([ + file_locations['chprog'], + file_locations['ch552_firmware_blank'] + ]) + print(result) + return (result.returncode == 0) + def find_serial_device(desc): """Look for a serial device that has the given attributes""" @@ -253,6 +265,18 @@ def ch552_program(): return True +def ch552_erase(): + """Erase the firmware from a previously programmed CH552""" + if not test_found_bootloader(): + print('Error finding CH552!') + return False + + if not erase_ch552(): + print('Error erasing CH552!') + return False + + return True + def test_txrx_touchpad(): """Test UART communication, RGB LED, and touchpad by asking the operator to interact with the touch pad""" description = { @@ -334,6 +358,7 @@ manual_tests = [ flash_check, test_extra_io, ch552_program, + ch552_erase, test_txrx_touchpad, enable_power, disable_power @@ -482,6 +507,8 @@ if __name__ == '__main__': pass except OSError as e: pass + except ValueError as e: + pass else: print(ANSI['bg_green'] + pass_msg + ANSI['reset'])