From 8f9e311dc23c691982289cf9933a2f31548ce693 Mon Sep 17 00:00:00 2001 From: richaravoil Date: Tue, 9 Apr 2024 12:33:47 +0200 Subject: [PATCH] Tools : add a script to make an OEM setup --- Tools/scripts/create_OEM_board.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 Tools/scripts/create_OEM_board.py diff --git a/Tools/scripts/create_OEM_board.py b/Tools/scripts/create_OEM_board.py new file mode 100755 index 0000000000000..6ba5b0fc530bf --- /dev/null +++ b/Tools/scripts/create_OEM_board.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +""" +script to automatically create a copy of a board for an OEM setup +usage example : ./Tools/scripts/create_OEM_board.py mRoPixracerPro mRoPixracerPro-MyCompany +""" + +import sys +import os +import subprocess + +board_name = sys.argv[1] +oem_board_name = sys.argv[2] + + +# directory creation +if not os.path.exists("libraries/AP_HAL_ChibiOS/hwdef/%s" % oem_board_name): + subprocess.run(["mkdir", "libraries/AP_HAL_ChibiOS/hwdef/%s" % oem_board_name]) + # create files and add reference to originals + f=open("libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat" % oem_board_name, "x") + f.write("include ../%s/hwdef.dat" % board_name) + f.close() + f=open("libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat" % oem_board_name, "x") + f.write("include ../%s/hwdef-bl.dat" % board_name) + f.close() + if os.path.exists("libraries/AP_HAL_ChibiOS/hwdef/%s/defaults.parm" % board_name): + subprocess.run(["cp", "libraries/AP_HAL_ChibiOS/hwdef/%s/defaults.parm" % board_name, "libraries/AP_HAL_ChibiOS/hwdef/%s/defaults.parm" % oem_board_name]) + +