Makefile target for viewing assembly/symbol table and gitignore
This commit is contained in:
		
							parent
							
								
									f5750bee33
								
							
						
					
					
						commit
						c659d21f0b
					
				
					 2 changed files with 12 additions and 8 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1,6 +1,8 @@ | ||||||
| # Compiled object files | # Compiled object files | ||||||
| *.o | *.o | ||||||
| *.hex | *.hex | ||||||
|  | *.asm | ||||||
|  | *.map | ||||||
| 
 | 
 | ||||||
| # Executables | # Executables | ||||||
| *.exe | *.exe | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								makefile
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								makefile
									
										
									
									
									
								
							|  | @ -9,7 +9,7 @@ MCU = atmega328p | ||||||
| QEMU_MACHINE_NAME = uno | QEMU_MACHINE_NAME = uno | ||||||
| 
 | 
 | ||||||
| # Compiler flags
 | # 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
 | # Source files
 | ||||||
| SRCS = main.c | SRCS = main.c | ||||||
|  | @ -29,7 +29,7 @@ all: $(TARGET).hex | ||||||
| 
 | 
 | ||||||
| # Link object files
 | # Link object files
 | ||||||
| $(TARGET).elf: $(OBJS) | $(TARGET).elf: $(OBJS) | ||||||
| 	$(CC) $(CFLAGS) $(OBJS) -o $(TARGET).elf | 	$(CC) $(CFLAGS) $(OBJS) -o $(TARGET).elf -Wl,--gc-sections | ||||||
| 
 | 
 | ||||||
| # Convert ELF to HEX
 | # Convert ELF to HEX
 | ||||||
| $(TARGET).hex: $(TARGET).elf | $(TARGET).hex: $(TARGET).elf | ||||||
|  | @ -43,22 +43,24 @@ flash: $(TARGET).hex | ||||||
| qemu: $(TARGET).elf | qemu: $(TARGET).elf | ||||||
| 	qemu-system-avr -machine $(QEMU_MACHINE_NAME) -bios $(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 | .PHONY: serial | ||||||
| serial: | serial: | ||||||
| 	picocom -b 9600 /dev/ttyUSB0 | 	picocom -b 9600 /dev/ttyUSB0 | ||||||
| 
 | 
 | ||||||
|  | # Check so that we can talk to the MCU
 | ||||||
| .PHONY: check | .PHONY: check | ||||||
| check: | check: | ||||||
| 	avrdude -p $(MCU) -c $(PROGRAMMER) | 	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
 | # Clean
 | ||||||
| .PHONY: clean | .PHONY: clean | ||||||
| clean: | clean: | ||||||
| 	rm -f $(OBJS) $(TARGET).elf $(TARGET).hex | 	rm -f $(OBJS) $(TARGET).elf $(TARGET).hex $(TARGET).map $(TARGET).asm | ||||||
| 
 | 
 | ||||||
| size: main.hex | size: main.hex | ||||||
| 	avr-size --mcu=atmega328p main.hex | 	avr-size --mcu=$(MCU) main.hex | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus