You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
stm32-better-blink/Makefile_analysis

71 lines
2.4 KiB
Plaintext

9 years ago
BINARY=něco (cokoliv)
9 years ago
LDSCRIPT=../stm32vl-discovery.ld
?? LDSCRIPT=./lib-ex/ex/stm32/f1/stvldisco/stm32vl-discovery.ld
LIBNAME= opencm3-stm32f1
DEFS = -DSTM32F1
FP_FLAGS = -msoft-float
ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
=> ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd
STLINK_PORT = 4242
### Makefile.rules
PREFIX = arm-none-eabi
CC = $(PREFIX)-gcc
=> CC = arm-none-eabi-gcc
LD = $(PREFIX)-gcc
=> LD = arm-none-eabi-gcc
AS = $(PREFIX)-as
=> AS = arm-none-eabi-as
OBJCOPY = $(PREFIX)-objcopy
=> OBJCOPY = arm-none-eabi-objcopy
OBJS = $(BINARY).o
=> OBJS = fancyblink.o
LIBPATH = ./libopencm3 ?? Prostě cesta k libopencm3
OPENCM3_DIR = magic!! ?? složka, kde je libopencm3
INCLUDE_DIR = $(OPENCM3_DIR)/include
=> INCLUDE_DIR ??= ~/Dev/STM/libocm3/libocm3/include
LIB_DIR = $(OPENCM3_DIR)/lib
=> LIB_DIR ??= ~/Dev/STM/libocm3/libocm3/lib
SCRIPT_DIR = $(OPENCM3_DIR)/scripts
=> SCRIPT_DIR ??= ~/Dev/STM/libocm3/libocm3/scripts
CFLAGS = -Os -g -Wextra -Wshadow -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -fno-common -ffunction-sections -fdata-sections
?? Většina zbytečných (-W...)
CPPFLAGS = -MD -Wall -Wundef -I$(INCLUDE_DIR) $(DEFS)
=> CPPFLAGS = -MD -Wall -Wundef -I~/Dev/ST/locm3/locm3/include -DSTM32F1
LDFLAGS = --static -nostartfiles -L$(LIB_DIR) -T$(LDSCRIPT) -Wl,-Map=$(*).map -Wl,--gc-sections
?? $(*).map prostě najít .map soubor
=> LDFLAGS = --static -nostartfiles -L.../libocm3/lib -Tněkde/stm32vl-discovery.ld -Wl,-Map=$(*).map -Wl,--gc-sections
LDLIBS = -l$(LIBNAME) -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
=> LDLIBS = -lopencm3-stm32f1 -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
>>> LET US COMPILE
--------------------------------------------------
To make the .o:
===============
$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o něco.o -c něco.c
=> arm-none-eabi-gcc {Flagy na všechno} -c něco.c -o něco.o
>>> Hotovo!!
To make the elf:
================
$(LD) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o něco.elf
-> vyžaduje $(OBJS), existenci $(LDSCRIPT) a $(LIB_DIR)/lib$(LIBNAME).a
=> arm-none-eabi-gcc {hromada zbytečných LDFLAGS, ARCH_FLAGS} něco.o {LDLIBS} -o něco.elf
-> vyžaduje vytvoření něco.o (zbytek už je v libopencm3, SNAD)
>>> Hotovo!!
To make the bin:
================
$(OBJCOPY) -Obinary něco.elf něco.bin
=> arm-none-eabi-objcopy -Obinary něco.elf něco.bin
>>> Hotovo!!