Commit 6859b562 authored by Oliver Horst's avatar Oliver Horst
Browse files

[chg] Improved the documentation for the applist target, as well as introduced...

[chg] Improved the documentation for the applist target, as well as introduced stable symbol names within the built binary
parent 0c745a96
......@@ -65,6 +65,11 @@ def get_toki_slave_cores(d):
return " ".join(slave_cores)
def get_toki_num_cores(d):
config = get_toki_deployment_config(d)
return len(config['cores'])
def get_toki_multiconfig_str(d):
enabled_cores = set(get_toki_slave_cores(d).split())
master_core = get_toki_master_core(d)
......
......@@ -14,7 +14,7 @@ DEPENDS += "\
"
do_compile () {
${CC} -DPYTHON_CFFI -E -P ${S}/freertos+/elfloader/app-config.h > ${B}/app-config.preprocessed.h
${CC} -DPYTHON_CFFI -E -P ${S}/freertos+/elfloader/applist.h > ${B}/applist.preprocessed.h
${PYTHON} \
${THISDIR}/python3/app-list-builder.py \
......
......@@ -20,7 +20,19 @@ python __anonymous () {
do_compile () {
cd ${B}
${OBJCOPY} -I binary -O ${ELF_OUTPUT_FORMAT} -B ${TARGET_ARCH} ${RECIPE_SYSROOT_NATIVE}${libdir}/${BIN_NAME} ${LIB_NAME}
export BIN_FILE="${RECIPE_SYSROOT_NATIVE}${libdir}/${BIN_NAME}"
export SYMBOL_BASE=$(echo "${BIN_FILE}" | sed s/[\.\/-]/_/g)
${OBJCOPY} -I binary \
-O ${ELF_OUTPUT_FORMAT} \
-B ${TARGET_ARCH} \
${BIN_FILE} ${LIB_NAME}
${OBJCOPY} --redefine-sym _binary_${SYMBOL_BASE}_start=${APP_LIST_SYMBOL} \
--redefine-sym _binary_${SYMBOL_BASE}_end=${APP_LIST_SYMBOL}_end \
--redefine-sym _binary_${SYMBOL_BASE}_size=${APP_LIST_SYMBOL}_size \
${LIB_NAME}
}
do_install () {
......
BIN_NAME = "applist.bin"
LIB_NAME = "libapplist.a"
APP_LIST_SYMBOL ="__app_list"
......@@ -8,7 +8,8 @@ import sys
# Transfer, i.e., sets all the configuration parameters specified in the given (JSON-based) deployment configuration
# within the 'AppListEntry_t' C structure that is used during loading of the application.
# within the 'AppListEntry_t' C structure that is used during loading of the application. All values from the deployment
# configuration are automatically casted to the targeted C structure element type.
def transferconfig(ffi, cdata, struct, config):
for key in config.keys():
if isinstance(config[key], dict):
......@@ -27,22 +28,22 @@ core = int(sys.argv[5])
apps = config['cores'][core]["apps"]
# Parse and load 'freertos+/elfloader/app-config.h'
# Parse and load 'freertos+/elfloader/applist.h'
ffi = cffi.FFI()
with open("{}/app-config.preprocessed.h".format(build_dir)) as f:
with open("{}/applist.preprocessed.h".format(build_dir)) as f:
ffi.cdef(f.read())
ffi.set_source(
"_app_config",
"#include \"{}/app-config.preprocessed.h\"".format(build_dir)
"_applist_cdata",
"#include \"{}/applist.preprocessed.h\"".format(build_dir)
)
ffi.compile()
sys.path.append(build_dir)
cdata = __import__("_app_config", fromlist=[]).ffi
cdata = __import__("_applist_cdata", fromlist=[]).ffi
# Discover the paths to the app binaries and their sizes
......@@ -76,18 +77,28 @@ block = cdata.new("uint8_t[]", total_size)
# Iterate through all apps, set all given configuration options, and copy their binary code into our app list structure
offset = 0
current_entry = cdata.cast("AppListEntry_t *", block)
for app_name in apps.keys():
current_entry_addr = int(ffi.cast("uintptr_t", block)) + offset
for i, app_name in enumerate(apps.keys()):
if offset != 0:
current_entry.next = cdata.cast("void *", current_entry_addr)
# For all iterations, except for the first one, we set the .next element of the previous iteration's entry here in
# accordance with the calculated offset between the two elements.
if i > 0:
current_entry.next = offset
# Calculating the pointer to the next app list entry
current_entry_addr = int(ffi.cast("uintptr_t", current_entry)) + offset
current_entry = cdata.cast("AppListEntry_t *", current_entry_addr)
# Sets all elements in the C structure to the value given in the matching dictionary entries of the given toki
# deployment config
transferconfig(ffi, cdata, current_entry, apps[app_name])
# Separately sets the name of the app, as the name string has to be truncated and converted to bytes first, before
# it can stored in the char[] name filed of the AppListEntry_t structure.
current_entry.name = bytes(app_name[:127], encoding='UTF-8')
# Copies the actual application binary data
with open(apps_path[app_name], "rb") as app_binary:
cdata.memmove(
current_entry.binary,
......@@ -95,7 +106,8 @@ for app_name in apps.keys():
current_entry.size
)
offset += cdata.sizeof("AppListEntry_t")
# Calculating the offset to the next app list entry
offset = cdata.sizeof("AppListEntry_t")
offset += current_entry.size
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment