summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-08-18 17:15:07 +0700
committerhathach <[email protected]>2024-08-18 17:15:07 +0700
commite345380723051ac3342a724660e877d7b2dad2fb (patch)
treee6e4e5a860db8249a1960c79ccf191b09cc288ae
parent76eb2f506642968b2b0079326483905e79d20d2f (diff)
add flash_openocd_adi() for use with max32
add feather max32666 to the hil pool
-rw-r--r--hw/bsp/family_support.cmake19
-rw-r--r--hw/bsp/max32650/family.cmake2
-rw-r--r--hw/bsp/max32666/family.cmake16
-rw-r--r--test/hil/hil_test.py12
-rw-r--r--test/hil/rpi.json7
5 files changed, 41 insertions, 15 deletions
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index 4a31f6218..1df8a6f53 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -480,6 +480,25 @@ function(family_flash_openocd_wch TARGET)
endfunction()
+# Add flash openocd adi (Analog Devices) target
+# included with msdk or compiled from release branch of https://github.com/analogdevicesinc/openocd
+function(family_flash_openocd_adi TARGET)
+ if (DEFINED $ENV{MAXIM_PATH})
+ # use openocd from msdk
+ set(OPENOCD ENV{MAXIM_PATH}/Tools/OpenOCD/openocd)
+ set(OPENOCD_OPTION2 "-s ENV{MAXIM_PATH}/Tools/OpenOCD/scripts")
+ else()
+ # compiled from source
+ if (NOT DEFINED OPENOCD_ADI_PATH)
+ set(OPENOCD_ADI_PATH $ENV{HOME}/app/openocd_adi)
+ endif ()
+ set(OPENOCD ${OPENOCD_ADI_PATH}/src/openocd)
+ set(OPENOCD_OPTION2 "-s ${OPENOCD_ADI_PATH}/tcl")
+ endif ()
+
+ family_flash_openocd(${TARGET})
+endfunction()
+
# Add flash with https://github.com/ch32-rs/wlink
function(family_flash_wlink_rs TARGET)
if (NOT DEFINED WLINK_RS)
diff --git a/hw/bsp/max32650/family.cmake b/hw/bsp/max32650/family.cmake
index 8c4f286a2..e05bd7652 100644
--- a/hw/bsp/max32650/family.cmake
+++ b/hw/bsp/max32650/family.cmake
@@ -14,6 +14,7 @@ set(LD_FILE_Clang ${LD_FILE_GNU})
set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
set(JLINK_DEVICE max32650)
+set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/max32650.cfg")
set(FAMILY_MCUS MAX32650 CACHE INTERNAL "")
@@ -150,6 +151,7 @@ function(family_configure_example TARGET RTOS)
# Add the optional MSDK OpenOCD flashing
family_flash_msdk(${TARGET})
+ family_flash_openocd_adi(${TARGET})
endfunction()
function(family_flash_msdk TARGET)
diff --git a/hw/bsp/max32666/family.cmake b/hw/bsp/max32666/family.cmake
index 4a3f1a428..fb8c32295 100644
--- a/hw/bsp/max32666/family.cmake
+++ b/hw/bsp/max32666/family.cmake
@@ -15,6 +15,7 @@ set(LD_FILE_Clang ${LD_FILE_GNU})
set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
set(JLINK_DEVICE max32666)
+set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/max32665.cfg")
set(FAMILY_MCUS MAX32666 CACHE INTERNAL "")
@@ -142,18 +143,5 @@ function(family_configure_example TARGET RTOS)
# Flashing
family_flash_jlink(${TARGET})
- family_flash_msdk(${TARGET})
-endfunction()
-
-# Add flash msdk target
-function(family_flash_msdk TARGET)
- set(MAXIM_PATH "$ENV{MAXIM_PATH}")
-
- add_custom_target(${TARGET}-msdk
- DEPENDS ${TARGET}
- COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts
- -f interface/cmsis-dap.cfg -f target/max32665.cfg
- -c "program $<TARGET_FILE:${TARGET}> verify; init; reset; exit"
- VERBATIM
- )
+ family_flash_openocd_adi(${TARGET})
endfunction()
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index 1d5f98e5c..e5900c616 100644
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -173,10 +173,20 @@ echo "Ready for Remote Connections"
with open(f_wch, 'w') as file:
file.write(cfg_content)
- ret = run_cmd(f'openocd_wch -c "adapter serial {board["flasher_sn"]}" -f {f_wch} -c "program {firmware}.elf reset exit"')
+ ret = run_cmd(f'openocd_wch -c "adapter serial {board["flasher_sn"]}" -f {f_wch} '
+ f'-c "program {firmware}.elf reset exit"')
return ret
+def flash_openocd_adi(board, firmware):
+ openocd_adi_script_path = f'{os.getenv("HOME")}/app/openocd_adi/tcl'
+ if not os.path.exists(openocd_adi_script_path):
+ openocd_adi_script_path = '/home/pi/openocd_adi/tcl'
+
+ ret = run_cmd(f'openocd_adi -c "adapter serial {board["flasher_sn"]}" -s {openocd_adi_script_path} '
+ f'{board["flasher_args"]} -c "program {firmware}.elf reset exit"')
+ return ret
+
def flash_wlink_rs(board, firmware):
# wlink use index for probe selection and lacking usb serial support
ret = run_cmd(f'wlink flash {firmware}.elf')
diff --git a/test/hil/rpi.json b/test/hil/rpi.json
index b7d36c543..a10fa76bd 100644
--- a/test/hil/rpi.json
+++ b/test/hil/rpi.json
@@ -15,6 +15,13 @@
"flasher_args": "-f interface/cmsis-dap.cfg -f target/atsame5x.cfg -c \"adapter speed 5000\""
},
{
+ "name": "max32666fthr",
+ "uid": "0C81464124010B20FF0A08CC2C",
+ "flasher": "openocd_adi",
+ "flasher_sn": "040917023bffc88100000000000000000000000097969906",
+ "flasher_args": "-f interface/cmsis-dap.cfg -f target/max32665.cfg"
+ },
+ {
"name": "lpcxpresso11u37",
"uid": "17121919",
"flasher": "jlink",