Skip to content

Instantly share code, notes, and snippets.

@TravMurav
Last active July 13, 2019 18:00
Show Gist options
  • Save TravMurav/e2778bb0e5f5fbe02432d2a580359d8f to your computer and use it in GitHub Desktop.
Save TravMurav/e2778bb0e5f5fbe02432d2a580359d8f to your computer and use it in GitHub Desktop.
Generate all variants of IDs for DTS
// SPDX-License-Identifier: GPL-2.0-only
/dts-v1/;
// ...
/ {
model = "Wileyfox Swift";
compatible = "wileyfox,crackling", "qcom,msm8916";
qcom,msm-id = %%MSM_ID%%;
qcom,board-id = %%BOARD_ID%%;
aliases {
serial0 = &blsp1_uart2;
};
chosen {
stdout-path = "serial0";
bootargs = "earlycon=msm_serial_dm,0x78b0000 console=ttyMSM0,115200,n8 firmware_class.path=/lib/firmware/wileyfox-crackling PMOS_NO_OUTPUT_REDIRECT CRACKLING_%%NUM%%_VARIANT";
};
// ...
};
#!/usr/bin/env python3
FILE_TEMPLATE = "msm8916-wileyfox-crackling.dts"
MSM_ID = ["<206 0>", "<248 0>", "<249 0>", "<250 0>"]
BOARD_ID = ["<0x1000b 9>", "<0x1010b 9>", "<0x3010b 9>"]
OUT_PREFIX = "delme_crackling_v_"
OUT_SUFFIX = ".dts"
variant_num = 0
with open(FILE_TEMPLATE) as template:
template_data = template.read()
for msm in MSM_ID:
for board in BOARD_ID:
filename = OUT_PREFIX + str(variant_num) + OUT_SUFFIX
print(filename)
with open(filename, "w") as output:
replaced_out = template_data
replaced_out = replaced_out.replace("%%MSM_ID%%", msm)
replaced_out = replaced_out.replace("%%BOARD_ID%%", board)
replaced_out = replaced_out.replace("%%NUM%%", str(variant_num))
output.write(replaced_out)
output.close()
variant_num +=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment