Created
September 10, 2019 10:49
-
-
Save ladislas/a9c2f035ca03745bcea8d4e0d639345b to your computer and use it in GitHub Desktop.
avr-gcc-unused-code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define F_CPU 8000000UL | |
#include <avr/io.h> | |
#include <util/delay.h> | |
#include <stdio.h> | |
void blink(void) { | |
DDRB |= (1 << PB0); | |
while(1) { | |
PORTB ^= (1 << PB0); | |
_delay_ms(500); | |
} | |
} | |
void blink1(void) { | |
DDRB |= (1 << PB1); | |
while(1) { | |
PORTB ^= (1 << PB1); | |
_delay_ms(1000); | |
} | |
} | |
int main (void) { | |
blink(); | |
return 0; | |
} | |
// int main (void) { | |
// DDRB |= _BV(DDB0); | |
// while(1) { | |
// PORTB ^= _BV(PB0); | |
// _delay_ms(500); | |
// } | |
// return 0; | |
// } | |
// #include <avr/io.h> | |
// #include <util/delay.h> | |
// void init_io(void) | |
// { | |
// // 1 = output, 0 = input | |
// DDRB = 0b11111111; // All outputs | |
// DDRC = 0b11111111; // All outputs | |
// DDRD = 0b11111110; // PORTD (RX on PD0). Just for demo | |
// } | |
// int main(void) | |
// { | |
// init_io(); | |
// while (1) | |
// { | |
// PORTC = 0xFF; | |
// PORTB = 0xFF; | |
// PORTD = 0xFF; | |
// _delay_ms(500); | |
// PORTC = 0x00; | |
// PORTB = 0x00; | |
// PORTD = 0x00; | |
// _delay_ms(500); | |
// } | |
// return 0; | |
// } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: direct elf size | |
1: clean direct elf nm size | |
2: clean stepped elf nm size | |
3: clean steppedimproved elf nm size | |
direct: | |
avr-gcc -mmcu=atmega328p -Wall -flto -g -Os -c main.c -o main.c.elf --verbose | |
stepped: | |
avr-gcc -mmcu=atmega328p -Wall -g -Os -c main.c -o main.c.o --verbose | |
avr-gcc -flto main.c.o -o main.c.elf --verbose | |
steppedimproved: | |
avr-gcc -mmcu=atmega328p -Wall -g -Os -fdata-sections -ffunction-sections -c main.c -o main.c.o --verbose | |
avr-gcc -Wl,--gc-sections -Wl,--print-gc-sections main.c.o -o main.c.elf --verbose | |
hex: | |
avr-objcopy -O ihex -j .text -j .data -R .eeprom main.c.elf main.c.hex | |
dump: | |
avr-objdump -x main.c.o | |
elf: | |
avr-objdump -xsh main.c.elf | |
size: | |
avr-size --mcu=atmega328p -C --format=avr main.c.elf | |
nm: | |
avr-nm -S main.c.elf | |
lss: | |
avr-objdump -h -S -z main.c.elf | |
clean: | |
rm -rf *.c.* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment