CeDOS - Commit 66dd8e21

cmake: Build image using genimage Luckily, genimage is very flexible and has support for any feature this project might need. The configuration file makes it clearer how the image is structured and we no longer need sudo for image generation. Signed-off-by: Celina Sophie Kalus <hello@celinakalus.de>
Celina Sophie Kalus
Mon, 02 Jun 2025 23:32:09 +0200
2 files changed, 44 insertions(+), 3 deletions(-)
M CMakeLists.txtCMakeLists.txt

@@ -14,6 +14,9 @@ string(REPLACE ".elf" ".map" target_map ${target_elf})

target_link_options(${target_elf} PRIVATE LINKER:-Map=${CMAKE_BINARY_DIR}/${target_map} ) + add_custom_target(${target_map} ALL + DEPENDS ${target_map} + ) endfunction() function(cedos_print_usage target_elf)

@@ -24,10 +27,9 @@ endfunction()

function(cedos_strip_binary target_elf) string(REPLACE ".elf" ".bin" target_bin ${target_elf}) - add_custom_command( - TARGET ${target_elf} POST_BUILD + add_custom_target(${target_bin} ALL + DEPENDS ${target_elf} COMMAND ${CMAKE_OBJCOPY} -O binary ${target_elf} ${target_bin} - COMMENT "Stripping ${target_elf} into raw binary ${target_bin}" ) endfunction()

@@ -178,3 +180,13 @@ target_link_options(${SHELL_APP} PRIVATE

LINKER:-Map=${CMAKE_BINARY_DIR}/${SHELL_APP}.map ) endforeach() + +# image +add_custom_target( + cedos.img ALL + DEPENDS kernel.bin boot.bin ${SHELL_APPS} + COMMAND mkdir -p ${CMAKE_BINARY_DIR}/root ${CMAKE_BINARY_DIR}/input + COMMAND cp kernel.bin ${SHELL_APPS} ${CMAKE_BINARY_DIR}/root + COMMAND cp boot.bin ${CMAKE_BINARY_DIR}/input + COMMAND genimage --config ${CMAKE_SOURCE_DIR}/image.conf +)
A image.conf

@@ -0,0 +1,29 @@

+# genimage configuration file +image cedos.img { + name = "cedos" + + hdimage { + partition-table-type = "mbr" + } + + partition bootloader { + in-partition-table = false + offset = 0 + image = "boot.bin" + holes = {"(440; 512)"} + } + + partition cedos { + in-partition-table = true + bootable = true + image = "part.img" + } +} + +image part.img { + name = "cedos" + size = 448k + + vfat { } +} +