Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Buildscripts/DevicetreeCompiler/dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys
import os

from source.printing import print_error
from source.config import parse_config

def print_help():
print("Usage: python dependencies.py [path]\n")
print("\t[in_file] the path where the root devicetree.yaml file is")

if __name__ == "__main__":
if "--help" in sys.argv:
print_help()
sys.exit()
args = [a for a in sys.argv[1:] if not a.startswith("--")]
if len(args) < 1:
print_error("Missing argument")
print_help()
sys.exit(1)

yaml_directory = args[0]

if not os.path.exists(yaml_directory):
print_error(f"Path not found: {yaml_directory}")
sys.exit(1)

config = parse_config(yaml_directory, os.getcwd())

# Device module is added first because it's started first:
# It creates the root device, so it must exist before its children.
device_dependency = os.path.basename(os.path.normpath(yaml_directory))
print(device_dependency)
for dependency in config.dependencies:
dependency_name = os.path.basename(os.path.normpath(dependency))
print(dependency_name)
30 changes: 27 additions & 3 deletions Buildscripts/DevicetreeCompiler/source/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def gather_devices(device: Device, output: list[Device]):
for child_device in device.devices:
gather_devices(child_device, output)

def generate_devicetree_c(filename: str, items: list[object], bindings: list[Binding], verbose: bool):
def generate_devicetree_c(filename: str, items: list[object], bindings: list[Binding], config, verbose: bool):
# Create a cache for looking up device names and aliases easily
# We still want to traverse it as a tree during code generation because of parent-setting
devices = list()
Expand All @@ -225,6 +225,7 @@ def generate_devicetree_c(filename: str, items: list[object], bindings: list[Bin
// Default headers
#include <tactility/device.h>
#include <tactility/dts.h>
#include <tactility/module.h>
// DTS headers
'''))

Expand All @@ -246,6 +247,25 @@ def generate_devicetree_c(filename: str, items: list[object], bindings: list[Bin
write_device_list_entry(file, item, bindings, verbose)
file.write("\tDTS_DEVICE_TERMINATOR\n")
file.write("};\n")
# Gather module symbols
module_symbol_names = []
for dependency in config.dependencies:
dependency_name = os.path.basename(os.path.normpath(dependency))
module_symbol_name = f"{dependency_name.replace('-', '_')}"
if not module_symbol_name.endswith("_module"):
module_symbol_name += "_module"
module_symbol_names.append(module_symbol_name)
file.write("\n")
# Forward declaration of symbol variables
for symbol in module_symbol_names:
file.write(f"extern struct Module {symbol};\n")
file.write("\n")
# Create array of symbol variables
file.write("struct Module* dts_modules[] = {\n")
for symbol in module_symbol_names:
file.write(f"\t&{symbol},\n")
file.write("\tNULL\n")
file.write("};\n")

def generate_devicetree_h(filename: str):
with open(filename, "w") as file:
Expand All @@ -258,17 +278,21 @@ def generate_devicetree_h(filename: str):
extern "C" {
#endif

// Array of device tree modules terminated with DTS_MODULE_TERMINATOR
extern struct DtsDevice dts_devices[];

// Array of module symbols terminated with NULL
extern struct Module* dts_modules[];

#ifdef __cplusplus
}
#endif
'''))

def generate(output_path: str, items: list[object], bindings: list[Binding], verbose: bool):
def generate(output_path: str, items: list[object], bindings: list[Binding], config, verbose: bool):
if not os.path.exists(output_path):
os.makedirs(output_path)
devicetree_c_filename = os.path.join(output_path, "devicetree.c")
generate_devicetree_c(devicetree_c_filename, items, bindings, verbose)
generate_devicetree_c(devicetree_c_filename, items, bindings, config, verbose)
devicetree_h_filename = os.path.join(output_path, "devicetree.h")
generate_devicetree_h(devicetree_h_filename)
2 changes: 1 addition & 1 deletion Buildscripts/DevicetreeCompiler/source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main(config_path: str, output_path: str, verbose: bool) -> int:
if verbose:
for binding in bindings:
pprint(binding)
generate(output_path, transformed, bindings, verbose)
generate(output_path, transformed, bindings, config, verbose)
return 0
except DevicetreeException as caught:
print("\033[31mError: ", caught, "\033[0m")
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
set(FREERTOS_PORT GCC_POSIX CACHE STRING "")
add_subdirectory(Libraries/FreeRTOS-Kernel)
target_compile_definitions(freertos_kernel PUBLIC "projCOVERAGE_TEST=0")
target_include_directories(freertos_kernel
PUBLIC Devices/Simulator/Source # for FreeRTOSConfig.h
)

# EmbedTLS
set(ENABLE_TESTING OFF)
Expand Down
3 changes: 1 addition & 2 deletions Devices/btt-panda-touch/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module btt_panda_touch_module = {
.name = "btt-panda-touch",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-2432s024c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_2432s024c_module = {
.name = "cyd-2432s024c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-2432s028r/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_2432s028r_module = {
.name = "cyd-2432s028r",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-2432s028rv3/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_2432s028rv3_module = {
.name = "cyd-2432s028rv3",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-2432s032c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_2432s032c_module = {
.name = "cyd-2432s032c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-4848s040c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_4848s040c_module = {
.name = "cyd-4848s040c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-8048s043c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_8048s043c_module = {
.name = "cyd-8048s043c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-e32r28t/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_e32r28t_module = {
.name = "cyd-e32r28t",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/cyd-e32r32p/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module cyd_e32r32p_module = {
.name = "cyd-e32r32p",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/elecrow-crowpanel-advance-28/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module elecrow_crowpanel_advance_28_module = {
.name = "elecrow-crowpanel-advance-28",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/elecrow-crowpanel-advance-35/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module elecrow_crowpanel_advance_35_module = {
.name = "elecrow-crowpanel-advance-35",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/elecrow-crowpanel-advance-50/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module elecrow_crowpanel_advance_50_module = {
.name = "elecrow-crowpanel-advance-50",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/elecrow-crowpanel-basic-28/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module elecrow_crowpanel_basic_28_module = {
.name = "elecrow-crowpanel-basic-28",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/elecrow-crowpanel-basic-35/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module elecrow_crowpanel_basic_35_module = {
.name = "elecrow-crowpanel-basic-35",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/elecrow-crowpanel-basic-50/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module elecrow_crowpanel_basic_50_module = {
.name = "elecrow-crowpanel-basic-50",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/generic-esp32/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module generic_esp32_module = {
.name = "generic-esp32",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/generic-esp32c6/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module generic_esp32c6_module = {
.name = "generic-esp32c6",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/generic-esp32p4/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module generic_esp32p4_module = {
.name = "generic-esp32p4",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/generic-esp32s3/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module generic_esp32s3_module = {
.name = "generic-esp32s3",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/guition-jc1060p470ciwy/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module guition_jc1060p470ciwy_module = {
.name = "guition-jc1060p470ciwy",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/guition-jc2432w328c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module guition_jc2432w328c_module = {
.name = "guition-jc2432w328c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/guition-jc3248w535c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module guition_jc3248w535c_module = {
.name = "guition-jc3248w535c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/guition-jc8048w550c/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module guition_jc8048w550c_module = {
.name = "guition-jc8048w550c",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/heltec-wifi-lora-32-v3/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module heltec_wifi_lora_32_v3_module = {
.name = "heltec-wifi-lora-32-v3",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/lilygo-tdeck/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module lilygo_tdeck_module = {
.name = "lilygo-tdeck",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/lilygo-tdisplay-s3/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module lilygo_tdisplay_s3_module = {
.name = "lilygo-tdisplay-s3",
.start = start,
.stop = stop,
Expand Down
3 changes: 1 addition & 2 deletions Devices/lilygo-tdisplay/Source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static error_t stop() {
return ERROR_NONE;
}

/** @warning The variable name must be exactly "device_module" */
struct Module device_module = {
struct Module lilygo_tdisplay_module = {
.name = "lilygo-tdisplay",
.start = start,
.stop = stop,
Expand Down
Loading