Various fixes and improvements (#515)
* Optional internal pull-ups for SD/MMC pins in DTS * Selectable on‑chip LDO channel for SD/MMC power (can be disabled) * Added several sensor/driver modules to generic ESP32 device configurations so that they become part of the SDKs * SD card mount now prints card information for clearer diagnostics * Fix for bug DTS boolean parsing. Improved tests to catch these issues. * Expanded SDK integration test to include new modules and headers * Modularized packaging to generate per‑module build files and include driver assets
This commit is contained in:
committed by
GitHub
parent
be2cdc0b90
commit
4170b86137
@@ -64,7 +64,10 @@ def property_to_string(property: DeviceProperty, devices: list[Device]) -> str:
|
||||
if type == "value" or type == "int":
|
||||
return property.value
|
||||
elif type == "boolean" or type == "bool":
|
||||
return "true"
|
||||
if property.value is None or not property.value:
|
||||
return "false"
|
||||
else:
|
||||
return "true"
|
||||
elif type == "text":
|
||||
return f"\"{property.value}\""
|
||||
elif type == "values":
|
||||
@@ -120,6 +123,7 @@ def resolve_parameters_from_bindings(device: Device, bindings: list[Binding], de
|
||||
result = [0] * len(binding_properties)
|
||||
for index, binding_property in enumerate(binding_properties):
|
||||
device_property = find_device_property(device, binding_property.name)
|
||||
# No property specified in DTS, use binding defaults
|
||||
if device_property is None:
|
||||
if binding_property.default is not None:
|
||||
temp_prop = DeviceProperty(
|
||||
@@ -130,8 +134,11 @@ def resolve_parameters_from_bindings(device: Device, bindings: list[Binding], de
|
||||
result[index] = property_to_string(temp_prop, devices)
|
||||
elif binding_property.required:
|
||||
raise DevicetreeException(f"device {device.node_name} doesn't have property '{binding_property.name}'")
|
||||
elif binding_property.type == "bool":
|
||||
result[index] = "false"
|
||||
elif binding_property.type == "bool" or binding_property.type == "boolean":
|
||||
if binding_property.default == "true" or binding_property.default == None:
|
||||
result[index] = "true"
|
||||
else: # Explicit or implied false
|
||||
result[index] = "false"
|
||||
else:
|
||||
raise DevicetreeException(f"Device {device.node_name} doesn't have property '{binding_property.name}' and no default value is set")
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
description: Boolean test device binding
|
||||
compatible: "test,bool-device"
|
||||
properties:
|
||||
binding-default-true-setting-implied:
|
||||
type: boolean
|
||||
default: true
|
||||
binding-default-false-setting-implied:
|
||||
type: boolean
|
||||
default: false
|
||||
binding-default-false-setting-direct:
|
||||
type: boolean
|
||||
default: false
|
||||
binding-implied-true-setting-direct:
|
||||
type: boolean
|
||||
binding-implied-true-setting-implied:
|
||||
type: boolean
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
description: Test device binding
|
||||
compatible: "test,device"
|
||||
description: Generic test device binding
|
||||
compatible: "test,generic-device"
|
||||
properties:
|
||||
reg:
|
||||
type: int
|
||||
required: true
|
||||
boolean-prop:
|
||||
type: boolean
|
||||
int-prop:
|
||||
type: int
|
||||
string-prop:
|
||||
@@ -0,0 +1,57 @@
|
||||
// Default headers
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/dts.h>
|
||||
#include <tactility/module.h>
|
||||
// DTS headers
|
||||
#include <test_include.h>
|
||||
|
||||
static const root_config_dt root_config = {
|
||||
"Test Model"
|
||||
};
|
||||
|
||||
static struct Device root = {
|
||||
.name = "/",
|
||||
.config = &root_config,
|
||||
.parent = NULL,
|
||||
.internal = NULL
|
||||
};
|
||||
|
||||
static const generic_device_config_dt test_device@0_config = {
|
||||
0,
|
||||
42,
|
||||
"hello"
|
||||
};
|
||||
|
||||
static struct Device test_device@0 = {
|
||||
.name = "test-device@0",
|
||||
.config = &test_device@0_config,
|
||||
.parent = &root,
|
||||
.internal = NULL
|
||||
};
|
||||
|
||||
static const bool_device_config_dt bool_test_device_config = {
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
};
|
||||
|
||||
static struct Device bool_test_device = {
|
||||
.name = "bool-test-device",
|
||||
.config = &bool_test_device_config,
|
||||
.parent = &root,
|
||||
.internal = NULL
|
||||
};
|
||||
|
||||
struct DtsDevice dts_devices[] = {
|
||||
{ &root, "test,root", DTS_DEVICE_STATUS_OKAY },
|
||||
{ &test_device@0, "test,generic-device", DTS_DEVICE_STATUS_OKAY },
|
||||
{ &bool_test_device, "test,bool-device", DTS_DEVICE_STATUS_OKAY },
|
||||
DTS_DEVICE_TERMINATOR
|
||||
};
|
||||
|
||||
|
||||
struct Module* dts_modules[] = {
|
||||
NULL
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/dts.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
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
|
||||
@@ -7,11 +7,16 @@
|
||||
model = "Test Model";
|
||||
|
||||
test_device1: test-device@0 {
|
||||
compatible = "test,device";
|
||||
compatible = "test,generic-device";
|
||||
reg = <0>;
|
||||
status = "okay";
|
||||
boolean-prop;
|
||||
int-prop = <42>;
|
||||
string-prop = "hello";
|
||||
};
|
||||
|
||||
bool-test-device {
|
||||
compatible = "test,bool-device";
|
||||
binding-default-false-setting-direct;
|
||||
binding-implied-true-setting-direct;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -30,13 +30,23 @@ def test_compile_success():
|
||||
print(f"FAILED: Compilation failed: {result.stderr} {result.stdout}")
|
||||
return False
|
||||
|
||||
if not os.path.exists(os.path.join(output_dir, "devicetree.c")):
|
||||
print("FAILED: devicetree.c not generated")
|
||||
return False
|
||||
for filename in ["devicetree.c", "devicetree.h"]:
|
||||
generated_path = os.path.join(output_dir, filename)
|
||||
expected_path = os.path.join(TEST_DATA_DIR, f"expected_{filename}")
|
||||
|
||||
if not os.path.exists(os.path.join(output_dir, "devicetree.h")):
|
||||
print("FAILED: devicetree.h not generated")
|
||||
return False
|
||||
if not os.path.exists(generated_path):
|
||||
print(f"FAILED: {filename} not generated")
|
||||
return False
|
||||
|
||||
if not os.path.exists(expected_path):
|
||||
print(f"FAILED: {os.path.basename(expected_path)} not found in test data")
|
||||
return False
|
||||
|
||||
diff_result = subprocess.run(["diff", "-u", expected_path, generated_path], capture_output=True, text=True)
|
||||
if diff_result.returncode != 0:
|
||||
print(f"FAILED: {filename} does not match expected_{filename}")
|
||||
print(diff_result.stdout)
|
||||
return False
|
||||
|
||||
print("PASSED")
|
||||
return True
|
||||
|
||||
@@ -2,18 +2,15 @@ idf_component_register(
|
||||
INCLUDE_DIRS
|
||||
"Libraries/TactilityC/include"
|
||||
"Libraries/TactilityKernel/include"
|
||||
"Libraries/TactilityFreeRtos/include"
|
||||
"Libraries/lvgl/include"
|
||||
"Libraries/lvgl-module/include"
|
||||
REQUIRES esp_timer
|
||||
)
|
||||
|
||||
# Regular and core features
|
||||
add_prebuilt_library(TactilityC Libraries/TactilityC/binary/libTactilityC.a)
|
||||
add_prebuilt_library(TactilityKernel Libraries/TactilityKernel/binary/libTactilityKernel.a)
|
||||
add_prebuilt_library(lvgl Libraries/lvgl/binary/liblvgl.a)
|
||||
add_prebuilt_library(lvgl-module Libraries/lvgl-module/binary/liblvgl-module.a)
|
||||
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityC)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityKernel)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE lvgl)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE lvgl-module)
|
||||
|
||||
@@ -14,4 +14,22 @@ macro(tactility_project project_name)
|
||||
if (NOT "$ENV{ESP_IDF_VERSION}" STREQUAL "${TACTILITY_SDK_IDF_VERSION}")
|
||||
message(FATAL_ERROR "ESP-IDF version of Tactility SDK (${TACTILITY_SDK_IDF_VERSION}) does not match current ESP-IDF version ($ENV{ESP_IDF_VERSION})")
|
||||
endif()
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"Libraries/TactilityFreeRtos"
|
||||
"Modules"
|
||||
"Drivers"
|
||||
)
|
||||
|
||||
set(COMPONENTS
|
||||
TactilityFreeRtos
|
||||
bm8563-module
|
||||
bm8563-module
|
||||
bmi270-module
|
||||
mpu6886-module
|
||||
pi4ioe5v6408-module
|
||||
qmi8658-module
|
||||
rx8130ce-module
|
||||
)
|
||||
|
||||
endmacro()
|
||||
|
||||
@@ -5,6 +5,7 @@ import shutil
|
||||
import glob
|
||||
import subprocess
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
def map_copy(mappings, target_base):
|
||||
"""
|
||||
@@ -59,6 +60,45 @@ def map_copy(mappings, target_base):
|
||||
|
||||
os.makedirs(os.path.dirname(final_dst), exist_ok=True)
|
||||
shutil.copy2(src, final_dst)
|
||||
|
||||
def get_driver_mappings(driver_name):
|
||||
return [
|
||||
{'src': f'Drivers/{driver_name}/include/**', 'dst': f'Drivers/{driver_name}/include/'},
|
||||
{'src': f'Drivers/{driver_name}/*.md', 'dst': f'Drivers/{driver_name}/'},
|
||||
{'src': f'build/esp-idf/{driver_name}/lib{driver_name}.a', 'dst': f'Drivers/{driver_name}/binary/lib{driver_name}.a'},
|
||||
]
|
||||
|
||||
def get_module_mappings(module_name):
|
||||
return [
|
||||
{'src': f'Modules/{module_name}/include/**', 'dst': f'Modules/{module_name}/include/'},
|
||||
{'src': f'Modules/{module_name}/*.md', 'dst': f'Modules/{module_name}/'},
|
||||
{'src': f'build/esp-idf/{module_name}/lib{module_name}.a', 'dst': f'Modules/{module_name}/binary/lib{module_name}.a'},
|
||||
]
|
||||
|
||||
def create_module_cmakelists(module_name):
|
||||
return dedent(f'''
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
idf_component_register(
|
||||
INCLUDE_DIRS "include"
|
||||
)
|
||||
add_prebuilt_library({module_name} "binary/lib{module_name}.a")
|
||||
'''.format(module_name=module_name))
|
||||
|
||||
def write_module_cmakelists(path, content):
|
||||
with open(path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
def add_driver(target_path, driver_name):
|
||||
mappings = get_driver_mappings(driver_name)
|
||||
map_copy(mappings, target_path)
|
||||
cmakelists_content = create_module_cmakelists(driver_name)
|
||||
write_module_cmakelists(os.path.join(target_path, f"Drivers/{driver_name}/CMakeLists.txt"), cmakelists_content)
|
||||
|
||||
def add_module(target_path, module_name):
|
||||
mappings = get_module_mappings(module_name)
|
||||
map_copy(mappings, target_path)
|
||||
cmakelists_content = create_module_cmakelists(module_name)
|
||||
write_module_cmakelists(os.path.join(target_path, f"Modules/{module_name}/CMakeLists.txt"), cmakelists_content)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
@@ -85,12 +125,7 @@ def main():
|
||||
{'src': 'build/esp-idf/TactilityKernel/libTactilityKernel.a', 'dst': 'Libraries/TactilityKernel/binary/'},
|
||||
{'src': 'TactilityKernel/include/**', 'dst': 'Libraries/TactilityKernel/include/'},
|
||||
{'src': 'TactilityKernel/CMakeLists.txt', 'dst': 'Libraries/TactilityKernel/'},
|
||||
{'src': 'TactilityKernel/LICENSE*.*', 'dst': 'Libraries/TactilityKernel/'},
|
||||
# lvgl-module
|
||||
{'src': 'build/esp-idf/lvgl-module/liblvgl-module.a', 'dst': 'Libraries/lvgl-module/binary/'},
|
||||
{'src': 'Modules/lvgl-module/include/**', 'dst': 'Libraries/lvgl-module/include/'},
|
||||
{'src': 'Modules/lvgl-module/CMakeLists.txt', 'dst': 'Libraries/lvgl-module/'},
|
||||
{'src': 'Modules/lvgl-module/LICENSE*.*', 'dst': 'Libraries/lvgl-module/'},
|
||||
{'src': 'TactilityKernel/*.md', 'dst': 'Libraries/TactilityKernel/'},
|
||||
# lvgl (basics)
|
||||
{'src': 'build/esp-idf/lvgl__lvgl/liblvgl__lvgl.a', 'dst': 'Libraries/lvgl/binary/liblvgl.a'},
|
||||
{'src': 'Libraries/lvgl/lvgl.h', 'dst': 'Libraries/lvgl/include/'},
|
||||
@@ -108,6 +143,17 @@ def main():
|
||||
|
||||
map_copy(mappings, target_path)
|
||||
|
||||
# Modules
|
||||
add_module(target_path, "lvgl-module")
|
||||
|
||||
# Drivers
|
||||
add_driver(target_path, "bm8563-module")
|
||||
add_driver(target_path, "bmi270-module")
|
||||
add_driver(target_path, "mpu6886-module")
|
||||
add_driver(target_path, "pi4ioe5v6408-module")
|
||||
add_driver(target_path, "qmi8658-module")
|
||||
add_driver(target_path, "rx8130ce-module")
|
||||
|
||||
# Output ESP-IDF SDK version to file
|
||||
esp_idf_version = os.environ.get("ESP_IDF_VERSION", "")
|
||||
with open(os.path.join(target_path, "idf-version.txt"), "a") as f:
|
||||
|
||||
Reference in New Issue
Block a user