diff --git a/.gitignore b/.gitignore index 5fae1b3..85114f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .direnv/ .ccls-cache/ +build/*.bin diff --git a/Makefile b/Makefile index af22655..00b0202 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,9 @@ OBJ_FILES := $(patsubst $(BUILD_DIR)/%.S,$(BUILD_DIR)/%.o,$(ASM_FILES)) .PHONY: build build: builddir preprocess compile assemble $(BUILD_DIR)/$(TARGET).elf +$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf + arm-none-eabi-objcopy -O binary $< $@ + $(BUILD_DIR)/$(TARGET).elf: $(OBJ_FILES) $(CC) $(LDFLAGS) $^ -o $@ @@ -58,6 +61,10 @@ compile: preprocess $(ASM_FILES) .PHONY: assemble assemble: compile $(OBJ_FILES) +.PHONY: flash +flash: $(BUILD_DIR)/$(TARGET).bin + st-flash --reset write $< 0x8000000 + .PHONY: clean clean: rm -rf $(BUILD_DIR) diff --git a/flake.nix b/flake.nix index ba34c08..0dc66b9 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,7 @@ packages = [ pkgs.gnumake pkgs.gcc-arm-embedded + pkgs.stlink ]; }; }