Skip to content
Open
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
31 changes: 30 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,35 @@ jobs:
build/dmboot.map
retention-days: 30

test-selector:
name: Selector tests (host, sanitizers)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build and run the tests of the selector
run: |
cmake -S selector -B build-selector -DDMSEL_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug
cmake --build build-selector
ctest --test-dir build-selector --output-on-failure

- name: Install the ARM toolchain
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gcc-arm-none-eabi libnewlib-arm-none-eabi binutils-arm-none-eabi

- name: Build the selector for the STM32F7 (it has to fit 32 kB; the linker checks)
run: |
cmake -S selector/fw -B build-selector-fw
cmake --build build-selector-fw
ls -l build-selector-fw/dmsel.bin

- name: Build the test images of the banks
run: selector/fw/testbank/build.sh build-selector-banks 1 2

test-renode:
name: Test Renode Simulation
runs-on: ubuntu-latest
Expand Down Expand Up @@ -190,7 +219,7 @@ jobs:
build-all:
name: All builds completed
runs-on: ubuntu-latest
needs: [build-cmake, test-renode]
needs: [build-cmake, test-renode, test-selector]

permissions:
contents: read
Expand Down
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ project(dmboot
DESCRIPTION "DMOD Bootloader"
LANGUAGES C CXX ASM)

# Release is -O2, not CMake's -O3: 23 kB less of the firmware (stm32f746g-disco: 369 kB instead of
# 392 kB) - at -O3 it no longer fits into a bank of the selector (384 kB). The modules are built
# by their own projects and do not change.
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")

# ======================================================================
# For VS Code
# ======================================================================
Expand Down Expand Up @@ -276,8 +282,34 @@ target_compile_definitions(${MODULE_NAME}.elf
DMBOOT_MAIN_HEAP_TAGS_STRING="${DMBOOT_MAIN_HEAP_TAGS}"
)

# The image can be linked for a bank of the flash, to be started by the selector (selector/): the ROM is the bank without the
# 512 bytes of the header; the whole flash otherwise
set(DMBOOT_BANK "" CACHE STRING "Bank (A or B) that the image is linked for, started by the selector; empty: the whole flash, no selector")
set(DMBOOT_ROM_ORIGIN 0x08000000)
set(DMBOOT_ROM_LENGTH 0x100000)
if(DMBOOT_BANK)
if(NOT DEFINED DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN)
message(FATAL_ERROR "DMBOOT_BANK=${DMBOOT_BANK}: the board does not define the bank (DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN)")
endif()
math(EXPR DMBOOT_ROM_ORIGIN "${DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN} + 512" OUTPUT_FORMAT HEXADECIMAL)
math(EXPR DMBOOT_ROM_LENGTH "${DMBOOT_BANK_${DMBOOT_BANK}_SIZE} - 512" OUTPUT_FORMAT HEXADECIMAL)
message(STATUS "Linked for the bank ${DMBOOT_BANK}: vectors at ${DMBOOT_ROM_ORIGIN}, ${DMBOOT_ROM_LENGTH} bytes")

# Dmod_Firmware*, Dmod_*Persistency over the table of the selector (an object library: the weak defaults of the SAL
# would otherwise be enough for the linker and the archive member would not be taken)
string(FIND "ABCD" "${DMBOOT_BANK}" DMBOOT_BANK_INDEX)
add_library(dmboot_firmware OBJECT src/firmware/dmboot_firmware.c)
dmod_set_current_allocator(dmboot_firmware)
target_compile_definitions(dmboot_firmware PRIVATE DMBOOT_BANK_INDEX=${DMBOOT_BANK_INDEX})
target_include_directories(dmboot_firmware PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/selector/include)
target_link_libraries(dmboot_firmware PRIVATE dmod)
target_link_libraries(${MODULE_NAME}.elf PRIVATE dmboot_firmware)
endif()

target_link_options(${MODULE_NAME}.elf
PRIVATE
-Wl,--defsym=DMBOOT_ROM_ORIGIN=${DMBOOT_ROM_ORIGIN}
-Wl,--defsym=DMBOOT_ROM_LENGTH=${DMBOOT_ROM_LENGTH}
-L${DMOD_DIR}/scripts
-T${CMAKE_CURRENT_SOURCE_DIR}/configs/arch/${DMBOOT_ARCH}/arch.ld
-T${CMAKE_CURRENT_SOURCE_DIR}/configs/mcu/${DMBOOT_MCU_SERIES}/${DMBOOT_MCU_NAME}/mcu.ld
Expand Down
16 changes: 16 additions & 0 deletions configs/board/stm32f746g-disco/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,21 @@ set(DMBOOT_DMSECRETS_PATH "/ext/secrets.vault" CACHE STRING "Path of the default
# The display driver is on /ext: the splash logo (60 kB of raw pixels) is too, and shows as soon as /ext is mounted.
set(DMBOOT_SPLASH_LOGO_PATH "/ext/views/splash_logo.dmvir" CACHE STRING "Path of the splash logo (.dmvir) on the target")

# Dual bank layout of the internal flash (selector/): S0 the selector, S1 its store (the state of the banks, the persistent
# items), S2 and S3 the file systems of the banks, A = S4+S5, B = S6+S7 (384 kB each; the header of the image takes the first
# 512 bytes of a bank, the vectors follow). The firmware is linked for the bank A by default (and installed with the
# selector); -DDMBOOT_BANK=B links it for the other one, -DDMBOOT_BANK= for the whole flash without the selector. The
# emulation (Renode) loads the plain image.
if(NOT DMBOOT_EMULATION)
set(DMBOOT_BANK "A" CACHE STRING "Bank (A or B) that the image is linked for, started by the selector; empty: the whole flash, no selector")
endif()
set(DMBOOT_BANK_A_ORIGIN 0x08020000)
set(DMBOOT_BANK_A_SIZE 0x00060000)
set(DMBOOT_BANK_B_ORIGIN 0x08080000)
set(DMBOOT_BANK_B_SIZE 0x00060000)
set(DMBOOT_SELECTOR_ORIGIN 0x08000000)
set(DMBOOT_SELECTOR_STORE 0x08008000)
set(DMBOOT_SELECTOR_STORE_SECTOR 1)

# QUADSPI bank 1 + N25Q128A, DMA2 stream 7/channel 3, IRQ 92 (RM0385).
set(DMBOOT_RENODE_QSPI_MODEL "${CMAKE_SOURCE_DIR}/configs/renode/STM32F7_QUADSPI.cs")
8 changes: 6 additions & 2 deletions configs/board/stm32f746g-disco/ext.dmd
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ dmwm8994 driver=board/stm32f746g-disco/codec-with-touch.ini
#
# The audio service: dmaudio.rules starts a dmaudio@<name> for every audio
# device dmdevfs reports - here /dev/wm8994 -, mixing what the applications
# play (libdmaudio) into it.
# play (libdmaudio) into it. Through the speaker (JP3; speaker=mono in the
# codec's configuration mixes both channels into it) - service=dmaudio@.ini
# for the headphone jack. audioctl output headphone|speaker switches it while
# it plays.
#
dmaudio service=dmaudio@.ini
dmaudio service=speaker/dmaudio@.ini
dmaudio rules=dmaudio.rules
audioctl
#
# The display service: dmview.rules starts a dmview@<name> for the LCD
# (/dev/dmlcdtft0), which shows what the applications claim for it - with
Expand Down
3 changes: 2 additions & 1 deletion configs/mcu/stm32f7/stm32f746xg/mcu.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
/* The whole flash, or a bank of it (DMBOOT_BANK, see CMakeLists.txt): the origin and the length come from --defsym */
rom (rx) : ORIGIN = DMBOOT_ROM_ORIGIN, LENGTH = DMBOOT_ROM_LENGTH
ram (rwx) : ORIGIN = 0x20010000, LENGTH = 256K
ext (rwx) : ORIGIN = 0x60000000, LENGTH = 2047M
dma (rwx) : ORIGIN = 0x20000000, LENGTH = 64k
Expand Down
2 changes: 1 addition & 1 deletion docs/external-flash.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cmake --build build --target upload-ext
```

sends `build/ext` over the console (YMODEM) to `/ext`, so the modules land in **`/ext/bin`**, on the module search path.
`install-all` also downloads and sends these files, after installing the firmware and uploading the SD card files.
`install-all` also downloads and sends these files, after installing the firmware and before the SD card files (the SD card driver is on `/ext`), then restarts the device to start them.
It uses `DMBOOT_UPLOAD_WAIT` while waiting for the console and requires the external flash to be formatted and mounted;
it never runs `format-ext` automatically.

Expand Down
1 change: 1 addition & 0 deletions linker/common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SECTIONS
PROVIDE(__text_start__ = __text_start__);

. = ALIGN(4);
. = ALIGN(512); /* VTOR wants the table aligned to its size rounded up to a power of 2 (114 entries: 512) */
KEEP(*(.vectors)) /* Startup code */

. = ALIGN(4);
Expand Down
59 changes: 55 additions & 4 deletions scripts/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,56 @@ else()
set(CONNECT_COMMENT "Connecting to ${TARGET} with OpenOCD...")
endif()

# Linked for a bank: the image gets the header of the selector, and the board is programmed with the selector as well
if(DMBOOT_BANK AND NOT DMBOOT_EMULATION)
set(DMBOOT_BANK_IMAGE ${CMAKE_BINARY_DIR}/${MODULE_NAME}_bank_${DMBOOT_BANK}.bin)
set(DMBOOT_SELECTOR_BUILD_DIR ${CMAKE_BINARY_DIR}/selector)
set(DMBOOT_SELECTOR_BIN ${DMBOOT_SELECTOR_BUILD_DIR}/dmsel.bin)
set(DMBOOT_BANK_VERSION "auto" CACHE STRING "Version in the header of the image: a number, or auto - the time of the build (the bigger the newer)")

add_custom_command(TARGET ${MODULE_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O binary ${MODULE_NAME}.elf ${MODULE_NAME}.code.bin
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/selector/tools/dmsel_mkimage.py
${MODULE_NAME}.code.bin ${DMBOOT_BANK_IMAGE} --version ${DMBOOT_BANK_VERSION}
--capacity ${DMBOOT_BANK_${DMBOOT_BANK}_SIZE}
COMMENT "Image of the bank ${DMBOOT_BANK}: ${DMBOOT_BANK_IMAGE}"
VERBATIM)

add_custom_target(selector
COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/selector/fw -B ${DMBOOT_SELECTOR_BUILD_DIR}
COMMAND ${CMAKE_COMMAND} --build ${DMBOOT_SELECTOR_BUILD_DIR}
BYPRODUCTS ${DMBOOT_SELECTOR_BIN}
COMMENT "Building the selector...")

# The whole flash: the selector, the store erased (the state is rebuilt from the banks: the newest good image
# starts), the image of the bank. The file systems of the banks (S2, S3) are not touched.
set(INSTALL_FIRMWARE_COMMAND ${OPENOCD} -f ${OPENOCD_INTERFACE} -f ${OPENOCD_TARGET}
-c "init" -c "reset halt"
-c "flash write_image erase ${DMBOOT_SELECTOR_BIN} ${DMBOOT_SELECTOR_ORIGIN} bin"
-c "flash erase_sector 0 ${DMBOOT_SELECTOR_STORE_SECTOR} ${DMBOOT_SELECTOR_STORE_SECTOR}"
-c "flash write_image erase ${DMBOOT_BANK_IMAGE} ${DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN} bin"
-c "verify_image ${DMBOOT_BANK_IMAGE} ${DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN} bin"
-c "reset run" -c "shutdown")
set(INSTALL_FIRMWARE_COMMENT "Installing the selector and the bank ${DMBOOT_BANK} on ${TARGET}...")
add_custom_target(install-bank
COMMAND ${OPENOCD} -f ${OPENOCD_INTERFACE} -f ${OPENOCD_TARGET}
-c "init" -c "reset halt"
-c "flash write_image erase ${DMBOOT_BANK_IMAGE} ${DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN} bin"
-c "verify_image ${DMBOOT_BANK_IMAGE} ${DMBOOT_BANK_${DMBOOT_BANK}_ORIGIN} bin"
-c "reset run" -c "shutdown"
DEPENDS ${MODULE_NAME}.elf
COMMENT "Writing the bank ${DMBOOT_BANK} only (the selector and its store stay)...")
endif()

# Define install-firmware target
add_custom_target(install-firmware
COMMAND ${INSTALL_FIRMWARE_COMMAND}
DEPENDS ${MODULE_NAME}.elf
COMMENT ${INSTALL_FIRMWARE_COMMENT}
)
if(DMBOOT_BANK AND NOT DMBOOT_EMULATION)
add_dependencies(install-firmware selector)
endif()

# Define connect target
add_custom_target(connect
Expand Down Expand Up @@ -209,11 +253,12 @@ if(Python3_Interpreter_FOUND)
USES_TERMINAL
COMMENT "Uploading files to ${DMBOOT_UPLOAD_WHERE} over ${DMBOOT_UPLOAD_PORT} (YMODEM)..."
)
# The SD card driver and its file system are on /ext when the board has one (docs/external-flash.md): there the files
# of /ext go first, the device restarts to start them, and only then the card is looked for (POST_BUILD steps, in order).
add_custom_target(install-all
COMMAND ${DMBOOT_UPLOAD_COMMAND} --wait ${DMBOOT_UPLOAD_WAIT} ${DMBOOT_UPLOAD_SOURCES}
COMMAND ${CMAKE_COMMAND} -E echo "Firmware installed, uploading the files..."
DEPENDS install-firmware download_sdcard_modules
USES_TERMINAL
COMMENT "Uploading files to ${DMBOOT_UPLOAD_WHERE} once ${TARGET} has started..."
)

# The external flash (DMBOOT_EXT_DEVICE, set by the board): the console runs the commands, YMODEM sends build/ext.
Expand All @@ -225,7 +270,7 @@ if(Python3_Interpreter_FOUND)
--port ${DMBOOT_UPLOAD_PORT} --baud ${DMBOOT_UPLOAD_BAUD} --block ${DMBOOT_UPLOAD_BLOCK})
add_custom_target(format-ext
COMMAND ${DMBOOT_EXT_CONSOLE_COMMAND} --wait 5
--run "-umount ${DMBOOT_EXT_MOUNT}"
"--run=-umount ${DMBOOT_EXT_MOUNT}"
--run "${DMBOOT_EXT_MKFS} ${DMBOOT_EXT_DEVICE}"
--run "mount -t ${DMBOOT_EXT_FS} -o device=${DMBOOT_EXT_DEVICE} ${DMBOOT_EXT_MOUNT}"
--ensure-dir ${DMBOOT_EXT_MOUNT}
Expand All @@ -244,9 +289,15 @@ if(Python3_Interpreter_FOUND)
add_dependencies(install-all download_ext_modules)
add_custom_command(TARGET install-all POST_BUILD
COMMAND ${DMBOOT_EXT_UPLOAD_COMMAND} --wait ${DMBOOT_UPLOAD_WAIT}
COMMENT "Uploading build/ext to ${DMBOOT_EXT_MOUNT} over ${DMBOOT_UPLOAD_PORT} (YMODEM)..."
COMMAND ${DMBOOT_EXT_CONSOLE_COMMAND} --wait 5 "--run=-reboot"
COMMENT "Uploading build/ext to ${DMBOOT_EXT_MOUNT} over ${DMBOOT_UPLOAD_PORT} (YMODEM), then restarting to start its modules..."
)
endif()

add_custom_command(TARGET install-all POST_BUILD
COMMAND ${DMBOOT_UPLOAD_COMMAND} --wait ${DMBOOT_UPLOAD_WAIT} ${DMBOOT_UPLOAD_SOURCES}
COMMENT "Uploading files to ${DMBOOT_UPLOAD_WHERE} once ${TARGET} has started..."
)
else()
message(STATUS "Python 3 not found - the upload-files, install-all, format-ext and upload-ext targets are not available")
endif()
34 changes: 34 additions & 0 deletions selector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# The selector: portable code (src/), the flash in RAM for its tests (port/host/)
# Standalone: cmake -S selector -B build-selector && cmake --build build-selector && ctest --test-dir build-selector
cmake_minimum_required(VERSION 3.16)
project(dmsel LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
option(DMSEL_SANITIZE "AddressSanitizer + UBSanitizer" OFF)

add_library(dmsel STATIC src/dmsel.c)
target_include_directories(dmsel PUBLIC include)
target_compile_options(dmsel PRIVATE -Wall -Wextra -Wshadow -Wpedantic -Werror)

enable_testing()
add_executable(test_selector tests/test_selector.c port/host/dmsel_port_host.c)
target_include_directories(test_selector PRIVATE port/host)
target_link_libraries(test_selector PRIVATE dmsel)
target_compile_options(test_selector PRIVATE -Wall -Wextra)
if(DMSEL_SANITIZE)
foreach(t dmsel test_selector)
target_compile_options(${t} PRIVATE -fsanitize=address,undefined -fno-sanitize-recover=undefined)
target_link_options(${t} PRIVATE -fsanitize=address,undefined)
endforeach()
endif()
add_test(NAME test_selector COMMAND test_selector)

# The tool that makes the images (python) and the core have to agree on the header and on the CRC
find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND)
file(WRITE ${CMAKE_BINARY_DIR}/code.bin "vectors and code of a test image - 0123456789")
add_test(NAME mkimage COMMAND ${CMAKE_COMMAND}
-DPY=${Python3_EXECUTABLE} -DTOOL=${CMAKE_CURRENT_SOURCE_DIR}/tools/dmsel_mkimage.py
-DIN=${CMAKE_BINARY_DIR}/code.bin -DOUT=${CMAKE_BINARY_DIR}/image.bin -DCHECK=$<TARGET_FILE:test_selector>
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/mkimage.cmake)
endif()
56 changes: 56 additions & 0 deletions selector/fw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# The selector for the STM32F7 (the code of the first sector of the flash)
# cmake -S selector/fw -B build-selector-fw && cmake --build build-selector-fw
# Result: dmsel.elf and dmsel.bin (at most 32 kB: the linker script checks)
cmake_minimum_required(VERSION 3.16)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(dmsel_fw C)

set(DMSEL_WATCHDOG_MS 0 CACHE STRING "Watchdog (ms) armed for an image on trial; the firmware has to feed it, 0: none")
set(DMBOOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../..")

# dmlog.c wants the configuration header of dmod: a bare-metal one, as the firmware has it
set(DMOD_VERSION_STRING "1.0")
foreach(opt STDLIB GETENV ENVIRON STDIO DIRENT ASSERT PTHREAD MMAN ALIGNED_ALLOC ALIGNED_MALLOC_MOCK REALLOC TERMIOS TIME DMCOMP_ENCODER)
set(DMOD_USE_${opt} OFF)
endforeach()
set(DMOD_USE_FASTLZ OFF)
set(DMOD_USE_DMCOMP OFF)
set(DMOD_IMPLEMENT_PRINTF OFF)
set(DMOD_IMPLEMENT_SCANF OFF)
set(DMOD_MAX_MODULES 1)
set(DMOD_MAX_REQUIRED_MODULES 1)
set(DMOD_VFPRINTF_STACK_BUFFER_SIZE 100)
set(DMOD_MODE "DMOD_SYSTEM")
set(DMOD_SYSTEM ON)
set(DMOD_MODULE OFF)
set(DMOD_SYSTEM_VERSION_MAJOR 0)
set(DMOD_SYSTEM_VERSION_MINOR 1)
set(DMOD_REPO_DIR "/")
set(DMOD_REPO_PATHS "/")
set(DMOD_CPU_NAME "stm32f746xg")
set(DMOD_ARRAY_SEP ":")
set(DMOD_PATH_SEP "/")
set(DMOD_BUILTIN_COMPRESSION_API OFF)
set(DMOD_BUILD_DIR "${CMAKE_BINARY_DIR}")
set(dmod_VERSION_MAJOR 1)
set(dmod_VERSION_MINOR 0)
configure_file("${DMBOOT_DIR}/lib/dmod/dmod-config.h.in" "${CMAKE_BINARY_DIR}/gen/dmod-config.h")

add_executable(dmsel.elf
startup.c main.c dmsel_port_f7.c dmod_stubs.c libc_min.c
../src/dmsel.c
${DMBOOT_DIR}/lib/dmlog/src/dmlog.c)
set_source_files_properties(${DMBOOT_DIR}/lib/dmlog/src/dmlog.c PROPERTIES COMPILE_OPTIONS "-w")
target_include_directories(dmsel.elf PRIVATE . ../include ${DMBOOT_DIR}/lib/dmlog/include ${DMBOOT_DIR}/lib/dmod/inc ${CMAKE_BINARY_DIR}/gen)
target_compile_definitions(dmsel.elf PRIVATE DMOD_EXTERNAL_REGISTRATION DMOD_CURRENT_ALLOCATOR="dmsel" DMSEL_WATCHDOG_MS=${DMSEL_WATCHDOG_MS})
target_compile_options(dmsel.elf PRIVATE -mcpu=cortex-m7 -mthumb -Os -ffunction-sections -fdata-sections -ffreestanding
-Wall -Wextra -std=gnu11)
target_link_options(dmsel.elf PRIVATE -mcpu=cortex-m7 -mthumb -nostdlib -nostartfiles -Wl,--gc-sections
-T${CMAKE_CURRENT_LIST_DIR}/dmsel_f7.ld -Wl,-Map=${CMAKE_BINARY_DIR}/dmsel.map -lgcc)
set_target_properties(dmsel.elf PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/dmsel_f7.ld)
add_custom_command(TARGET dmsel.elf POST_BUILD
COMMAND arm-none-eabi-objcopy -O binary dmsel.elf dmsel.bin
COMMAND arm-none-eabi-size dmsel.elf)
28 changes: 28 additions & 0 deletions selector/fw/dmod_stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @file dmod_stubs.c
* @brief What dmlog.c takes from dmod and the selector does not have: nothing runs beside it, there are no files and no heap
*/
#include "dmod.h"

void Dmod_Assert( int Condition, const char* Message, const char* File, int Line, const char* Function )
{
(void)Message; (void)File; (void)Line; (void)Function;
while( !Condition ) {}
}
bool Dmod_CheckLogLevel( Dmod_LogLevel_t LogLevel ) { (void)LogLevel; return false; }
void Dmod_EnterCritical( void ) {}
void Dmod_ExitCritical( void ) {}
int Dmod_FPrintf( void* File, const char* Format, ... ) { (void)File; (void)Format; return 0; }
void Dmod_FileClose( void* File ) { (void)File; }
void* Dmod_FileOpen( const char* Path, const char* Mode ) { (void)Path; (void)Mode; return 0; }
size_t Dmod_FileRead( void* Buffer, size_t Size, size_t Count, void* File ) { (void)Buffer; (void)Size; (void)Count; (void)File; return 0; }
Dmod_FileSize_t Dmod_FileSize( void* File ) { (void)File; return 0; }
size_t Dmod_FileWrite( const void* Buffer, size_t Size, size_t Count, void* File ) { (void)Buffer; (void)Size; (void)Count; (void)File; return 0; }
void Dmod_FreeEx( void* Ptr, bool Concatenate ) { (void)Ptr; (void)Concatenate; }
void* Dmod_GetStreamLogFile( Dmod_LogLevel_t LogLevel ) { (void)LogLevel; return 0; }
int Dmod_Ioctl( void* File, int Command, void* Arg ) { (void)File; (void)Command; (void)Arg; return -1; }
void* Dmod_LockStdio( void* StdHandle ) { (void)StdHandle; return 0; }
void* Dmod_MallocEx( size_t Size, const char* ModuleName ) { (void)Size; (void)ModuleName; return 0; }
void Dmod_ThreadSleep( uint32_t Milliseconds ) { (void)Milliseconds; }
void Dmod_UnlockStdio( void* StdHandle ) { (void)StdHandle; }
const char* strerror( int errnum ) { (void)errnum; return ""; }
Loading
Loading