melexis_io_fw in this repo as your working project folder. It already contains the project configuration files (.ioc and .extSettings) and all generated and patched source files.Next: Use STM32CubeIDE · Build on Windows (MSYS2 MinGW64) · Build on Linux
.ioc file, but the folder name must match the .ioc filename (without the extension). For example, if you rename it to MyProj.ioc, the folder must be MyProj/.
.ioc file in STM32CubeMX.
Application/src inside the generated project and copy the file
melexis_io_fw/Application/src/heap_useNewlib_ST.c
there (so it becomes Application/src/heap_useNewlib_ST.c in your project tree).
Core/Src/sysmem.c in the generated project and change the _sbrk signature to be weak by adding the attribute:
__attribute__((weak)) void *_sbrk(ptrdiff_t incr)
CMakeLists.txt and add heap_useNewlib_ST.c to the executable sources:
# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
# Add user sources here
Application/src/heap_useNewlib_ST.c
)
CMakeLists.txt so they are available as compile-time macros:
# Add project symbols (macros)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined symbols
USB_FS_VID=0x1111
USB_FS_PID=0x2222
)
.hex file from the built ELF by adding this to CMakeLists.txt:
# Generate HEX file from ELF
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O ihex $<TARGET_FILE:${CMAKE_PROJECT_NAME}> ${CMAKE_PROJECT_NAME}.hex
COMMENT "Generating HEX file"
)
${CMAKE_OBJCOPY} isn’t defined by your toolchain file, replace it with arm-none-eabi-objcopy.STM32F446xx_FLASH.ld) to preserve Flash sectors 1–3 for EEPROM emulation. Keep the vector table in sector 0 and start the application at 0x08010000:
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* Vector table (Sector 0) */
/* EEPROM (rwx): ORIGIN = 0x08004000, LENGTH = 3 * 16K */ /* Sectors 1, 2 and 3 for EEPROM emulation */
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K-16K-48K /* Use remaining for code */
}
/* Place vector table in dedicated ISR region */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >ISR
arm-none-eabi-gcc --version).build/), run CMake configure and build..elf/.hex.If you prefer STM32CubeIDE instead, you can import the generated project there and build/flash from the IDE.
CMakeLists.txt)STM32F446MEYx
.elf, ensure the ST-LINK debugger is selected, then Apply and Run.
pacman -S --needed mingw-w64-x86_64-arm-none-eabi-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
arm-none-eabi-gcc --version. If you prefer Makefiles instead of Ninja, install mingw-w64-x86_64-make and adjust the generator accordingly.cd /c/Projects/<your-path-to-generated-project>
mkdir build
cd build
cmake -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc-arm-none-eabi.cmake
cmake --build .
cmake -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc-arm-none-eabi.cmake.arm-none-eabi-gcc, cmake, ninja-build.
sudo apt install gcc-arm-none-eabi cmake ninja-build. Package names may vary by distro.cd ~/Documents/projects/<your-path-to-generated-project>
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc-arm-none-eabi.cmake
cmake --build .
/c/Projects/..., e.g., /home/<user>/Projects/.... If needed, specify a generator explicitly: cmake -G Ninja ...