Makefile target for viewing assembly/symbol table and gitignore

This commit is contained in:
Imbus 2024-04-03 20:19:58 +02:00
parent f5750bee33
commit c659d21f0b
2 changed files with 12 additions and 8 deletions

2
.gitignore vendored
View file

@ -1,6 +1,8 @@
# Compiled object files
*.o
*.hex
*.asm
*.map
# Executables
*.exe

View file

@ -9,7 +9,7 @@ MCU = atmega328p
QEMU_MACHINE_NAME = uno
# Compiler flags
CFLAGS = -std=c99 -Wall -Wno-array-bounds -mmcu=$(MCU) -DF_CPU=16000000UL -Os -g
CFLAGS = -std=c99 -Wall -Wno-array-bounds -mmcu=$(MCU) -DF_CPU=16000000UL -Os -g -ffunction-sections -fdata-sections
# Source files
SRCS = main.c
@ -29,7 +29,7 @@ all: $(TARGET).hex
# Link object files
$(TARGET).elf: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET).elf
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET).elf -Wl,--gc-sections
# Convert ELF to HEX
$(TARGET).hex: $(TARGET).elf
@ -43,22 +43,24 @@ flash: $(TARGET).hex
qemu: $(TARGET).elf
qemu-system-avr -machine $(QEMU_MACHINE_NAME) -bios $(TARGET).elf
# View the generated assembly
asm: $(TARGET).hex
avr-objdump -S $(TARGET).elf
.PHONY: serial
serial:
picocom -b 9600 /dev/ttyUSB0
# Check so that we can talk to the MCU
.PHONY: check
check:
avrdude -p $(MCU) -c $(PROGRAMMER)
# Generate symbol table and assembly
extra: $(TARGET).elf
avr-objdump -t $(TARGET).elf > $(TARGET).map
avr-objdump -S $(TARGET).elf > $(TARGET).asm
# Clean
.PHONY: clean
clean:
rm -f $(OBJS) $(TARGET).elf $(TARGET).hex
rm -f $(OBJS) $(TARGET).elf $(TARGET).hex $(TARGET).map $(TARGET).asm
size: main.hex
avr-size --mcu=atmega328p main.hex
avr-size --mcu=$(MCU) main.hex