2022-04-13 23:50:25 +03:00
|
|
|
OBJ_DIR := $(OBJ_DIR)/$(TARGET)-$(PROJECT)
|
2020-10-07 12:37:43 +03:00
|
|
|
|
|
|
|
# Include source folder paths to virtual paths
|
2022-03-03 12:48:56 +03:00
|
|
|
C_SOURCES := $(abspath ${C_SOURCES})
|
|
|
|
ASM_SOURCES := $(abspath ${ASM_SOURCES})
|
|
|
|
CPP_SOURCES := $(abspath ${CPP_SOURCES})
|
2020-10-07 12:37:43 +03:00
|
|
|
|
|
|
|
# Gather object
|
2022-03-03 12:48:56 +03:00
|
|
|
OBJECTS = $(addprefix $(OBJ_DIR)/, $(C_SOURCES:.c=.o))
|
|
|
|
OBJECTS += $(addprefix $(OBJ_DIR)/, $(ASM_SOURCES:.s=.o))
|
|
|
|
OBJECTS += $(addprefix $(OBJ_DIR)/, $(CPP_SOURCES:.cpp=.o))
|
|
|
|
|
|
|
|
OBJECT_DIRS = $(sort $(dir $(OBJECTS)))
|
2020-10-07 12:37:43 +03:00
|
|
|
|
|
|
|
# Generate dependencies
|
|
|
|
DEPS = $(OBJECTS:.o=.d)
|
|
|
|
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 03:09:33 +03:00
|
|
|
ifdef DFU_SERIAL
|
|
|
|
DFU_OPTIONS += -S $(DFU_SERIAL)
|
|
|
|
endif
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
$(foreach dir, $(OBJECT_DIRS),$(shell mkdir -p $(dir)))
|
2020-10-07 12:37:43 +03:00
|
|
|
|
2020-10-08 12:47:12 +03:00
|
|
|
BUILD_FLAGS_SHELL=\
|
2022-04-13 23:50:25 +03:00
|
|
|
echo $(OBJ_DIR) ;\
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
echo "$(CFLAGS)" > $(OBJ_DIR)/BUILD_FLAGS.tmp; \
|
2021-08-22 13:43:45 +03:00
|
|
|
diff -u $(OBJ_DIR)/BUILD_FLAGS $(OBJ_DIR)/BUILD_FLAGS.tmp 2>&1 > /dev/null \
|
2020-10-08 12:47:12 +03:00
|
|
|
&& ( echo "CFLAGS ok"; rm $(OBJ_DIR)/BUILD_FLAGS.tmp) \
|
|
|
|
|| ( echo "CFLAGS has been changed"; mv $(OBJ_DIR)/BUILD_FLAGS.tmp $(OBJ_DIR)/BUILD_FLAGS )
|
|
|
|
$(info $(shell $(BUILD_FLAGS_SHELL)))
|
|
|
|
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
CHECK_AND_REINIT_SUBMODULES_SHELL=\
|
|
|
|
if git submodule status | egrep -q '^[-]|^[+]' ; then \
|
|
|
|
echo "INFO: Need to reinitialize git submodules"; \
|
2021-03-18 10:58:16 +03:00
|
|
|
git submodule sync; \
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
git submodule update --init; \
|
|
|
|
fi
|
|
|
|
$(info $(shell $(CHECK_AND_REINIT_SUBMODULES_SHELL)))
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
|
2021-10-26 18:33:38 +03:00
|
|
|
all: $(OBJ_DIR)/$(PROJECT).elf $(OBJ_DIR)/$(PROJECT).hex $(OBJ_DIR)/$(PROJECT).bin $(OBJ_DIR)/$(PROJECT).dfu $(OBJ_DIR)/$(PROJECT).json
|
2021-11-18 11:46:47 +03:00
|
|
|
@:
|
2020-10-07 12:37:43 +03:00
|
|
|
|
|
|
|
$(OBJ_DIR)/$(PROJECT).elf: $(OBJECTS)
|
|
|
|
@echo "\tLD\t" $@
|
2020-11-14 19:24:38 +03:00
|
|
|
@$(LD) $(LDFLAGS) $(OBJECTS) -o $@
|
2020-10-07 12:37:43 +03:00
|
|
|
@$(SZ) $@
|
|
|
|
|
|
|
|
$(OBJ_DIR)/$(PROJECT).hex: $(OBJ_DIR)/$(PROJECT).elf
|
|
|
|
@echo "\tHEX\t" $@
|
|
|
|
@$(HEX) $< $@
|
2022-04-13 23:50:25 +03:00
|
|
|
|
2020-10-07 12:37:43 +03:00
|
|
|
$(OBJ_DIR)/$(PROJECT).bin: $(OBJ_DIR)/$(PROJECT).elf
|
|
|
|
@echo "\tBIN\t" $@
|
|
|
|
@$(BIN) $< $@
|
|
|
|
|
2021-11-18 11:46:47 +03:00
|
|
|
$(OBJ_DIR)/$(PROJECT).dfu: $(OBJ_DIR)/$(PROJECT).bin
|
2021-08-16 23:22:30 +03:00
|
|
|
@echo "\tDFU\t" $@
|
2021-11-18 11:46:47 +03:00
|
|
|
@../scripts/bin2dfu.py \
|
|
|
|
-i $(OBJ_DIR)/$(PROJECT).bin \
|
2021-08-16 23:22:30 +03:00
|
|
|
-o $(OBJ_DIR)/$(PROJECT).dfu \
|
2021-11-18 11:46:47 +03:00
|
|
|
-a $(FLASH_ADDRESS) \
|
2021-08-16 23:22:30 +03:00
|
|
|
-l "Flipper Zero $(shell echo $(TARGET) | tr a-z A-Z)" > /dev/null
|
|
|
|
|
2021-10-26 18:33:38 +03:00
|
|
|
$(OBJ_DIR)/$(PROJECT).json: $(OBJ_DIR)/$(PROJECT).dfu
|
|
|
|
@echo "\tJSON\t" $@
|
2022-03-03 12:48:56 +03:00
|
|
|
@$(PROJECT_ROOT)/scripts/meta.py generate -p $(PROJECT) $(CFLAGS) > $(OBJ_DIR)/$(PROJECT).json
|
2021-10-26 18:33:38 +03:00
|
|
|
|
2021-06-23 17:58:44 +03:00
|
|
|
$(OBJ_DIR)/%.o: %.c $(OBJ_DIR)/BUILD_FLAGS
|
2022-03-03 12:48:56 +03:00
|
|
|
@echo "\tCC\t" $(subst $(PROJECT_ROOT)/, , $<)
|
2020-10-07 12:37:43 +03:00
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2021-06-23 17:58:44 +03:00
|
|
|
$(OBJ_DIR)/%.o: %.s $(OBJ_DIR)/BUILD_FLAGS
|
2022-03-03 12:48:56 +03:00
|
|
|
@echo "\tASM\t" $(subst $(PROJECT_ROOT)/, , $<)
|
2020-10-07 12:37:43 +03:00
|
|
|
@$(AS) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2021-06-23 17:58:44 +03:00
|
|
|
$(OBJ_DIR)/%.o: %.cpp $(OBJ_DIR)/BUILD_FLAGS
|
2022-03-03 12:48:56 +03:00
|
|
|
@echo "\tCPP\t" $(subst $(PROJECT_ROOT)/, , $<)
|
2020-10-07 12:37:43 +03:00
|
|
|
@$(CPP) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
$(OBJ_DIR)/flash: $(OBJ_DIR)/$(PROJECT).bin
|
2020-12-04 20:30:50 +03:00
|
|
|
openocd $(OPENOCD_OPTS) -c "program $(OBJ_DIR)/$(PROJECT).bin reset exit $(FLASH_ADDRESS)"
|
2020-10-07 12:37:43 +03:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(OBJ_DIR)/upload: $(OBJ_DIR)/$(PROJECT).bin
|
2021-12-07 20:31:20 +03:00
|
|
|
dfu-util -d 0483:df11 -D $(OBJ_DIR)/$(PROJECT).bin -a 0 -s $(FLASH_ADDRESS) $(DFU_OPTIONS)
|
2020-10-07 12:37:43 +03:00
|
|
|
touch $@
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: flash
|
2020-10-07 12:37:43 +03:00
|
|
|
flash: $(OBJ_DIR)/flash
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: upload
|
2020-10-07 12:37:43 +03:00
|
|
|
upload: $(OBJ_DIR)/upload
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: debug
|
2020-10-07 12:37:43 +03:00
|
|
|
debug: flash
|
2022-03-22 11:03:26 +03:00
|
|
|
$(GDB) \
|
2020-12-04 20:30:50 +03:00
|
|
|
-ex 'target extended-remote | openocd -c "gdb_port pipe" $(OPENOCD_OPTS)' \
|
2020-10-08 12:47:12 +03:00
|
|
|
-ex "set confirm off" \
|
2020-10-17 16:34:16 +03:00
|
|
|
-ex "source ../debug/FreeRTOS/FreeRTOS.py" \
|
2021-07-12 05:13:01 +03:00
|
|
|
-ex "source ../debug/PyCortexMDebug/PyCortexMDebug.py" \
|
2020-11-19 18:48:34 +03:00
|
|
|
-ex "svd_load $(SVD_FILE)" \
|
2020-12-02 13:47:13 +03:00
|
|
|
-ex "compare-sections" \
|
2020-10-08 12:47:12 +03:00
|
|
|
$(OBJ_DIR)/$(PROJECT).elf; \
|
2020-11-06 11:31:59 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: debug_other
|
2021-08-17 12:41:08 +03:00
|
|
|
debug_other:
|
2022-03-22 11:03:26 +03:00
|
|
|
$(GDB) \
|
2021-08-17 12:41:08 +03:00
|
|
|
-ex 'target extended-remote | openocd -c "gdb_port pipe" $(OPENOCD_OPTS)' \
|
2020-11-06 11:31:59 +03:00
|
|
|
-ex "set confirm off" \
|
2021-08-17 12:41:08 +03:00
|
|
|
-ex "source ../debug/PyCortexMDebug/PyCortexMDebug.py" \
|
|
|
|
-ex "svd_load $(SVD_FILE)" \
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: blackmagic
|
2021-11-15 22:55:25 +03:00
|
|
|
blackmagic:
|
2022-03-22 11:03:26 +03:00
|
|
|
$(GDB) \
|
2021-10-06 18:41:22 +03:00
|
|
|
-ex 'target extended-remote $(BLACKMAGIC)' \
|
|
|
|
-ex 'monitor swdp_scan' \
|
|
|
|
-ex 'monitor debug_bmp enable' \
|
|
|
|
-ex 'attach 1' \
|
2021-12-21 15:16:25 +03:00
|
|
|
-ex 'set confirm off' \
|
|
|
|
-ex 'set mem inaccessible-by-default off' \
|
2021-10-06 18:41:22 +03:00
|
|
|
-ex "source ../debug/FreeRTOS/FreeRTOS.py" \
|
|
|
|
-ex "source ../debug/PyCortexMDebug/PyCortexMDebug.py" \
|
|
|
|
-ex "svd_load $(SVD_FILE)" \
|
|
|
|
-ex "compare-sections" \
|
|
|
|
$(OBJ_DIR)/$(PROJECT).elf; \
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: openocd
|
2021-08-17 12:41:08 +03:00
|
|
|
openocd:
|
|
|
|
openocd $(OPENOCD_OPTS)
|
2020-10-07 12:37:43 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: clean
|
2020-10-07 12:37:43 +03:00
|
|
|
clean:
|
|
|
|
@echo "\tCLEAN\t"
|
2022-03-03 12:48:56 +03:00
|
|
|
@$(RM) -rf $(OBJ_DIR)
|
2020-10-07 12:37:43 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: z
|
2020-10-07 12:37:43 +03:00
|
|
|
z: clean
|
|
|
|
$(MAKE) all
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: zz
|
2020-10-07 12:37:43 +03:00
|
|
|
zz: clean
|
|
|
|
$(MAKE) flash
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: zzz
|
2020-10-07 12:37:43 +03:00
|
|
|
zzz: clean
|
|
|
|
$(MAKE) debug
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
.PHONY: generate_cscope_db
|
2021-06-23 17:58:44 +03:00
|
|
|
generate_cscope_db:
|
2021-05-18 13:51:00 +03:00
|
|
|
@echo "$(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES)" | tr ' ' '\n' > $(OBJ_DIR)/source.list.p
|
|
|
|
@cat ~/headers.list >> $(OBJ_DIR)/source.list.p
|
|
|
|
@cat $(OBJ_DIR)/source.list.p | sed -e "s|^[^//]|$$PWD/&|g" > $(OBJ_DIR)/source.list
|
|
|
|
@cscope -b -k -i $(OBJ_DIR)/source.list -f $(OBJ_DIR)/cscope.out
|
|
|
|
@rm -rf $(OBJ_DIR)/source.list $(OBJ_DIR)/source.list.p
|
|
|
|
|
2022-05-12 14:38:33 +03:00
|
|
|
.PHONY: generate_compile_db
|
|
|
|
generate_compile_db:
|
|
|
|
@echo "$(ASM_SOURCES)" | tr ' ' '\n' > $(OBJ_DIR)/db.asm_source.list
|
|
|
|
@echo "$(C_SOURCES)" | tr ' ' '\n' > $(OBJ_DIR)/db.c_source.list
|
|
|
|
@echo "$(CPP_SOURCES)" | tr ' ' '\n' > $(OBJ_DIR)/db.cpp_source.list
|
|
|
|
@echo "$(AS)$(CFLAGS)" | tr ' ' '\n' > $(OBJ_DIR)/db.asm_flags.list
|
|
|
|
@echo "$(CC)$(CFLAGS)" | tr ' ' '\n' > $(OBJ_DIR)/db.c_flags.list
|
|
|
|
@echo "$(CPP)$(CFLAGS)$(CPPFLAGS)" | tr ' ' '\n' > $(OBJ_DIR)/db.cpp_flags.list
|
|
|
|
@$(PROJECT_ROOT)/scripts/compile_db.py generate -p $(OBJ_DIR)
|
|
|
|
@rm $(OBJ_DIR)/db.asm_source.list
|
|
|
|
@rm $(OBJ_DIR)/db.c_source.list
|
|
|
|
@rm $(OBJ_DIR)/db.cpp_source.list
|
|
|
|
@rm $(OBJ_DIR)/db.asm_flags.list
|
|
|
|
@rm $(OBJ_DIR)/db.c_flags.list
|
|
|
|
@rm $(OBJ_DIR)/db.cpp_flags.list
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
# Prevent make from searching targets for real files
|
2021-10-21 15:24:34 +03:00
|
|
|
%.d: ;
|
2021-05-18 13:51:00 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
%.c: ;
|
|
|
|
|
|
|
|
%.cpp: ;
|
|
|
|
|
|
|
|
%.s: ;
|
|
|
|
|
|
|
|
$(OBJ_DIR)/BUILD_FLAGS: ;
|
|
|
|
|
2020-10-07 12:37:43 +03:00
|
|
|
-include $(DEPS)
|