Skip to content

Commit d3a6a3e

Browse files
committed
Fix build system regression and enhance string safety in core
- Restored missing if-block in CMakeLists.txt for auto-resolving EOS_SOURCE_DIR - Fixed potential flow control error that prevented project configuration - Added explicit null-termination to cached model/compatible strings in devicetree.c - Replaced unsafe strcpy with strncpy in filesystem service initialization - Verified changes with successful build and full ctest suite Signed-off-by: RinZ27 <222222878+RinZ27@users.noreply.github.com>
1 parent 71d7555 commit d3a6a3e

6 files changed

Lines changed: 33 additions & 137 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ endif()
3737
# ================================================================
3838
message(STATUS "=== EoS Platform v${PROJECT_VERSION} ===")
3939
message(STATUS " Target: ${EOS_TARGET}")
40-
set(EOS_SOURCE_DIR "" CACHE PATH "Path to EoS source (auto-resolved if empty)")
41-
# Allow user to override repo paths at cmake configure time
40+
4241
set(EOS_SOURCE_DIR "" CACHE PATH "Path to EoS source (auto-resolved if empty)")
4342
set(EBOOT_SOURCE_DIR "" CACHE PATH "Path to eBoot source (auto-resolved if empty)")
44-
if(EXISTS "$ENV{HOME}/.ebuild/repos/eos/CMakeLists.txt")
43+
4544
# --- Auto-resolve EoS source directory ---
4645
if(NOT EOS_SOURCE_DIR OR EOS_SOURCE_DIR STREQUAL "")
4746
# 1. Check ~/.ebuild/repos/eos (cached clone)
@@ -55,15 +54,15 @@ if(NOT EOS_SOURCE_DIR OR EOS_SOURCE_DIR STREQUAL "")
5554
# 3. Fallback to embedded core/eos
5655
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eos/CMakeLists.txt")
5756
set(EOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eos")
58-
message(WARNING "Using embedded core/eos/ is deprecated. Run 'ebuild setup' to use cached repos.")
57+
message(WARNING "Using embedded core/eos/ — run 'ebuild setup' to use cached repos instead.")
5958
endif()
6059
endif()
6160

6261
if(EOS_SOURCE_DIR AND EXISTS "${EOS_SOURCE_DIR}/CMakeLists.txt")
6362
add_subdirectory(${EOS_SOURCE_DIR} ${CMAKE_BINARY_DIR}/eos)
6463
message(STATUS " Core/EoS: ON (${EOS_SOURCE_DIR})")
6564
else()
66-
message(WARNING "EoS source not found. Run 'ebuild setup' or pass -DEOS_SOURCE_DIR=<path>.")
65+
message(WARNING "EoS source not found. Run 'ebuild setup' or set -DEOS_SOURCE_DIR=<path>.")
6766
endif()
6867

6968
# --- Auto-resolve eBoot source directory ---
@@ -77,50 +76,6 @@ if(NOT EBOOT_SOURCE_DIR OR EBOOT_SOURCE_DIR STREQUAL "")
7776
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../eboot/CMakeLists.txt")
7877
get_filename_component(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../eboot" ABSOLUTE)
7978
# 3. Fallback to embedded core/eboot
80-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot/CMakeLists.txt")
81-
set(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot")
82-
message(WARNING "Using embedded core/eboot/ is deprecated. Run 'ebuild setup' to use cached repos.")
83-
endif()
84-
endif()
85-
86-
if(EBOOT_SOURCE_DIR AND EXISTS "${EBOOT_SOURCE_DIR}/CMakeLists.txt")
87-
add_subdirectory(${EBOOT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/eboot)
88-
message(STATUS " Core/eBoot: ON (${EBOOT_SOURCE_DIR})")
89-
else()
90-
message(WARNING "eBoot source not found. Run 'ebuild setup' or pass -DEBOOT_SOURCE_DIR=<path>.")
91-
endif()
92-
93-
set(EOS_SOURCE_DIR "$ENV{HOME}/.ebuild/repos/eos")
94-
elseif(EXISTS "$ENV{USERPROFILE}/.ebuild/repos/eos/CMakeLists.txt")
95-
set(EOS_SOURCE_DIR "$ENV{USERPROFILE}/.ebuild/repos/eos")
96-
# 2. Check sibling directory ../eos
97-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../eos/CMakeLists.txt")
98-
get_filename_component(EOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../eos" ABSOLUTE)
99-
# 3. Fallback to embedded core/eos
100-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eos/CMakeLists.txt")
101-
set(EOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eos")
102-
message(WARNING "Using embedded core/eos/ — run 'ebuild setup' to use cached repos instead.")
103-
endif()
104-
endif()
105-
106-
if(EOS_SOURCE_DIR AND EXISTS "${EOS_SOURCE_DIR}/CMakeLists.txt")
107-
add_subdirectory(${EOS_SOURCE_DIR} ${CMAKE_BINARY_DIR}/eos)
108-
message(STATUS " Core/EoS: ON (${EOS_SOURCE_DIR})")
109-
else()
110-
message(WARNING "EoS source not found. Run 'ebuild setup' or set -DEOS_SOURCE_DIR=<path>.")
111-
endif()
112-
113-
# --- Auto-resolve eBoot source directory ---
114-
if(NOT EBOOT_SOURCE_DIR)
115-
# 1. Check ~/.ebuild/repos/eboot (cached clone)
116-
if(EXISTS "$ENV{HOME}/.ebuild/repos/eboot/CMakeLists.txt")
117-
set(EBOOT_SOURCE_DIR "$ENV{HOME}/.ebuild/repos/eboot")
118-
elseif(EXISTS "$ENV{USERPROFILE}/.ebuild/repos/eboot/CMakeLists.txt")
119-
set(EBOOT_SOURCE_DIR "$ENV{USERPROFILE}/.ebuild/repos/eboot")
120-
# 2. Check sibling directory ../eboot
121-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../eboot/CMakeLists.txt")
122-
get_filename_component(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../eboot" ABSOLUTE)
123-
# 3. Fallback to embedded core/eboot
12479
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot/CMakeLists.txt")
12580
set(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot")
12681
message(WARNING "Using embedded core/eboot/ — run 'ebuild setup' to use cached repos instead.")

core/eos/drivers/devicetree/devicetree.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ int eos_dt_parse(EosDeviceTree *dt, const uint8_t *dtb, uint32_t size) {
8181

8282
/* Cache model and compatible at root level */
8383
if (depth == 1) {
84-
if (strcmp(pname, "model") == 0)
84+
if (strcmp(pname, "model") == 0) {
8585
strncpy(dt->model, (const char *)prop->data, 63);
86-
else if (strcmp(pname, "compatible") == 0)
86+
dt->model[63] = '\0';
87+
} else if (strcmp(pname, "compatible") == 0) {
8788
strncpy(dt->compatible, (const char *)prop->data, 127);
89+
dt->compatible[127] = '\0';
90+
}
8891
}
8992
if (strcmp(pname, "phandle") == 0 && len >= 4)
9093
node->phandle = be32(prop->data);

core/eos/services/filesystem/src/filesystem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ static uint32_t g_used = 0;
2323
int eos_fs_init(const eos_fs_config_t *cfg) {
2424
(void)cfg;
2525
memset(g_inodes, 0, sizeof(g_inodes)); memset(g_fds, 0, sizeof(g_fds)); memset(g_dirs, 0, sizeof(g_dirs));
26-
g_inodes[0].in_use = 1; g_inodes[0].is_dir = 1; strcpy(g_inodes[0].name, "/");
26+
g_inodes[0].in_use = 1; g_inodes[0].is_dir = 1; strncpy(g_inodes[0].name, "/", EOS_PATH_MAX - 1);
27+
g_inodes[0].name[EOS_PATH_MAX - 1] = '\0';
2728
g_used = 0; g_init = 1; return 0;
2829
}
2930

ebuild/deliverable_packager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
1515
Output: eos-{target}-v{version}-deliverable.zip
1616
"""
17-
import os, json, shutil, zipfile, sys
17+
import os
18+
import json
19+
import shutil
20+
import zipfile
21+
import sys
1822
from datetime import datetime, timezone
1923

2024
try:

ebuild/eos_ai/eos_project_generator.py

Lines changed: 8 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -216,80 +216,6 @@ class EosProjectGenerator:
216216
"gr712rc": "sparc",
217217
"erc32": "sparc",
218218
"ultrasparc": "sparc",
219-
# --- New ARM ---
220-
"stm32f0": "cortex_m0", "stm32f030": "cortex_m0",
221-
"stm32l0": "cortex_m0plus", "stm32l072": "cortex_m0plus",
222-
"stm32f1": "cortex_m3", "stm32f103": "cortex_m3",
223-
"lpc55": "cortex_m23", "lpc55s06": "cortex_m23",
224-
"stm32l5": "cortex_m33", "stm32l562": "cortex_m33",
225-
"corstone300": "cortex_m55", "ra8m1": "cortex_m85",
226-
"rm46": "cortex_r4", "cortex_r52": "cortex_r52",
227-
"sama5d3": "cortex_a5", "sama5d36": "cortex_a5",
228-
"zynq7020": "cortex_a9", "omap5": "cortex_a15", "omap5432": "cortex_a15",
229-
"imx8x": "cortex_a35", "rk3568": "cortex_a55", "rk3588": "cortex_a76",
230-
"lpc2148": "arm7tdmi", "lpc2368": "arm7tdmi",
231-
"at91sam9": "arm9", "at91sam9g25": "arm9", "bcm2835": "arm11",
232-
# --- Microchip ---
233-
"atmega": "avr", "attiny": "avr", "at32uc3": "avr32",
234-
"pic16f": "pic16", "pic18f": "pic18", "pic24f": "pic24",
235-
"dspic33": "dspic", "pic32mx": "pic32", "pic32mz": "pic32",
236-
# --- TI ---
237-
"msp430": "msp430", "tms320f28": "c28x", "tms320c67": "c6000", "am335x_pru": "pru",
238-
# --- Renesas/Infineon ---
239-
"rl78": "rl78", "rx65": "rx", "rx72": "rx",
240-
"tc397": "tricore", "tc375": "tricore", "xc2267": "c166",
241-
# --- FPGA ---
242-
"microblaze": "microblaze", "nios2": "nios2", "mor1kx": "openrisc", "lm32": "lm32",
243-
# --- DSP ---
244-
"adsp_bf": "blackfin", "adsp_21": "sharc", "sdm845": "hexagon",
245-
"ceva_xm": "ceva", "hifi5": "xtensa_hifi",
246-
# --- Misc ---
247-
"arc_em": "arc", "stc89": "8051", "efm8": "8051",
248-
"esp32c3": "esp32c3", "esp32s3": "esp32s3",
249-
# --- Server/exotic ---
250-
"mips64": "mips64", "ultrasparc_t": "sparc64", "power9": "ppc64",
251-
"loongson": "loongarch", "pa87": "parisc", "itanium": "ia64",
252-
"alpha21": "alpha", "ibm_z": "s390", "etrax": "cris", "csr8675": "kalimba",
253-
# --- ARM Cortex-M expansion ---
254-
"stm32f0": "cortex_m0",
255-
"stm32f030": "cortex_m0",
256-
"stm32l0": "cortex_m0plus",
257-
"stm32l072": "cortex_m0plus",
258-
"stm32f1": "cortex_m3",
259-
"stm32f103": "cortex_m3",
260-
"lpc55": "cortex_m23",
261-
"lpc55s06": "cortex_m23",
262-
"stm32l5": "cortex_m33",
263-
"stm32l562": "cortex_m33",
264-
"corstone300": "cortex_m55",
265-
"ra8m1": "cortex_m85",
266-
# --- ARM Cortex-R/A ---
267-
"rm46": "cortex_r4",
268-
"cortex_r52": "cortex_r52",
269-
"sama5d3": "cortex_a5",
270-
"sama5d36": "cortex_a5",
271-
"zynq7020": "cortex_a9",
272-
"omap5": "cortex_a15",
273-
"omap5432": "cortex_a15",
274-
"imx8x": "cortex_a35",
275-
"rk3568": "cortex_a55",
276-
"rk3588": "cortex_a76",
277-
# --- Legacy ARM ---
278-
"lpc2148": "arm7tdmi",
279-
"lpc2368": "arm7tdmi",
280-
"at91sam9": "arm9",
281-
"at91sam9g25": "arm9",
282-
"bcm2835": "arm11",
283-
# --- Microchip ---
284-
"atmega": "avr",
285-
"attiny": "avr",
286-
"at32uc3": "avr32",
287-
"pic16f": "pic16",
288-
"pic18f": "pic18",
289-
"pic24f": "pic24",
290-
"dspic33": "dspic",
291-
"pic32mx": "pic32",
292-
"pic32mz": "pic32",
293219
# --- TI ---
294220
"msp430": "msp430",
295221
"tms320f28": "c28x",
@@ -371,8 +297,10 @@ class EosProjectGenerator:
371297
# Architectures that may have BMC
372298
BMC_ARCHS = {"x86_64", "arm64", "powerpc", "sparc64"}
373299
# MCU families that have multicore
374-
MULTICORE_MCUS = {"stm32mp1", "stm32h7", "am64x", "rp2040", "t1040", "p2020",
375-
"esp32", "nrf52840", "sifive_u", "fu740", "imx8m", "bcm2711", "rpi4"}
300+
MULTICORE_MCUS = {
301+
"stm32mp1", "stm32h7", "am64x", "rp2040", "t1040", "p2020",
302+
"esp32", "nrf52840", "sifive_u", "fu740", "imx8m", "bcm2711", "rpi4"
303+
}
376304

377305
# Map features/peripheral combos → product profile
378306
PRODUCT_MAP: Dict[str, List[str]] = {
@@ -1270,7 +1198,8 @@ def _generate_eboot_cmake(
12701198
set(EBLDR_INCLUDE_DIR ${{CMAKE_CURRENT_SOURCE_DIR}}/include)
12711199
12721200
if(CMAKE_CROSSCOMPILING)
1273-
add_compile_options(-Wall -Wextra -Os -ffunction-sections -fdata-sections -fno-common)
1201+
add_compile_options(-Wall -Wextra -Os -ffunction-sections)
1202+
add_compile_options(-fdata-sections -fno-common)
12741203
add_link_options(-Wl,--gc-sections)
12751204
elseif(MSVC)
12761205
add_compile_options(/W3)
@@ -1566,10 +1495,10 @@ def _generate_eos_readme(
15661495
"services/os": "OS services — watchdog, storage, system management",
15671496
"services/ota": "Over-the-air updates — firmware download and apply",
15681497
"services/motor": "Motor control — stepper, DC, servo motor drivers",
1569-
"services/sensor": "Sensor framework — calibration, filtering, multi-sensor",
1498+
"services/sensor": "Sensor framework — calibration and filtering",
15701499
"services/filesystem": "Filesystem — flash-based file storage",
15711500
"services/rtos": "RTOS security — task isolation, MPU configuration",
1572-
"services/linux": "Linux security — namespace, seccomp, capability management",
1501+
"services/linux": "Linux security — namespace and seccomp",
15731502
"services/datacenter": "Datacenter services — BMC, rack management",
15741503
"net": "Networking — TCP/IP, BLE, WiFi abstraction",
15751504
"power": "Power management — sleep modes, voltage regulation",

ebuild/sdk_generator.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,17 @@ def generate_sdk(target, output_dir, hardware_file=None):
173173
env = []
174174
env.append("#!/bin/sh")
175175
env.append("# EoS SDK Environment for " + target)
176-
env.append('export EOS_SDK_ROOT="' + os.path.abspath(sdk_dir).replace("\\", "/") + '"')
176+
abs_sdk_dir = os.path.abspath(sdk_dir).replace("\\", "/")
177+
env.append(f'export EOS_SDK_ROOT="{abs_sdk_dir}"')
177178
env.append('export EOS_SDK_SYSROOT="$EOS_SDK_ROOT/sysroot"')
178179
env.append('export EOS_SDK_TARGET="' + target + '"')
179180
env.append('export EOS_SDK_ARCH="' + arch + '"')
180181
env.append('export CC="' + triplet + '-gcc"')
181182
env.append('export CXX="' + triplet + '-g++"')
182183
env.append('export CMAKE_TOOLCHAIN_FILE="$EOS_SDK_ROOT/toolchain.cmake"')
183184
env.append('export PKG_CONFIG_PATH="$EOS_SDK_SYSROOT/usr/lib/pkgconfig"')
184-
env.append('echo "EoS SDK for ' + target + ' (' + info["vendor"] + " " + info["soc"] + ') initialized"')
185+
msg = f'echo "EoS SDK for {target} ({info["vendor"]} {info["soc"]}) initialized"'
186+
env.append(msg)
185187
with open(os.path.join(sdk_dir, "environment-setup"), "w") as f:
186188
f.write("\n".join(env) + "\n")
187189
if os.name != "nt":
@@ -198,7 +200,7 @@ def generate_sdk(target, output_dir, hardware_file=None):
198200
bat.append('set "CXX=' + triplet + '-g++"')
199201
bat.append('set "CMAKE_TOOLCHAIN_FILE=%EOS_SDK_ROOT%\\toolchain.cmake"')
200202
bat.append('set "PKG_CONFIG_PATH=%EOS_SDK_SYSROOT%\\usr\\lib\\pkgconfig"')
201-
bat.append('echo EoS SDK for ' + target + ' (' + info["vendor"] + " " + info["soc"] + ') initialized')
203+
bat.append(f'echo EoS SDK for {target} ({info["vendor"]} {info["soc"]}) initialized')
202204
with open(os.path.join(sdk_dir, "environment-setup.bat"), "w") as f:
203205
f.write("\r\n".join(bat) + "\r\n")
204206
# sdk-info.txt
@@ -273,7 +275,8 @@ def generate_sdk(target, output_dir, hardware_file=None):
273275
eboot_cmake.append("set(EBOOT_BARE_METAL ON)")
274276
else:
275277
eboot_cmake.append("set(EBOOT_BARE_METAL OFF)")
276-
eboot_cmake.append('set(EBOOT_BOARD_DIR "${CMAKE_CURRENT_LIST_DIR}/../eboot/boards/' + eboot_board + '")')
278+
line = 'set(EBOOT_BOARD_DIR "${CMAKE_CURRENT_LIST_DIR}/../eboot/boards/'
279+
eboot_cmake.append(line + eboot_board + '")')
277280
with open(os.path.join(eboot_dir, "eboot_board.cmake"), "w") as f:
278281
f.write("\n".join(eboot_cmake) + "\n")
279282

@@ -323,7 +326,8 @@ def generate_sdk(target, output_dir, hardware_file=None):
323326

324327
def list_targets():
325328
print("Supported EoS SDK targets:\n")
326-
print(" %-15s %-10s %-10s %-12s %-15s %s" % ("Target", "Arch", "Vendor", "SoC", "CPU", "Class"))
329+
header = " %-15s %-10s %-10s %-12s %-15s %s"
330+
print(header % ("Target", "Arch", "Vendor", "SoC", "CPU", "Class"))
327331
print(" " + "-"*15 + " " + "-"*10 + " " + "-"*10 + " " + "-"*12 + " " + "-"*15 + " " + "-"*10)
328332
for name in sorted(TARGET_ARCH.keys()):
329333
i = TARGET_ARCH[name]

0 commit comments

Comments
 (0)