can i use custom make file to implement plug and p
can i use custom make file to implement plug and p
ifeq ($(ENABLE_DRIVER_X), 1)
C_SOURCES += Drivers/my_driver_x.c
C_INCLUDES += -IDrivers/my_driver_x
CFLAGS += -DDRIVER_X_ENABLED
endif
This approach lets you conditionally include drivers at build time based on configuration
variables [1] [2] .
build_with_driver_A:
$(MAKE) DRIVER_CONFIG=A
build_with_driver_B:
$(MAKE) DRIVER_CONFIG=B
Practical Implementation
For a reusable driver approach:
1. Create a folder structure for your custom drivers (e.g., my_Driver/) [1]
2. Add the driver paths to your makefile:
C_INCLUDES += -Imy_Driver
C_SOURCES += my_Driver/my_Driver.c
Unlike Linux kernel modules [3] [4] , true runtime code loading isn't possible on most STM32
MCUs. However, these techniques provide flexible alternatives for modular, configurable driver
implementations in embedded systems.
⁂
1. https://www.reddit.com/r/stm32/comments/18nwwnu/developing_a_custom_driver_with_stm32_and_vsc
ode/
2. https://github.com/bbrown1867/stm32-makefile
3. https://docs.kernel.org/kbuild/makefiles.html
4. https://fastbitlab.com/building-a-linux-kernel-module/
5. https://stackoverflow.com/questions/76154215/stm32-replace-entry-in-vector-table-at-runtime