forked from elovalo/elovalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.scons
32 lines (24 loc) · 1.05 KB
/
release.scons
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- mode: python; coding: utf-8 -*-
import os
env = Environment(ENV=os.environ)
env['CC'] = 'avr-gcc'
env.Append(CCFLAGS = '-mmcu=atmega328p -DF_CPU=16000000UL -O2 -Wall -std=gnu99 -fpack-struct -flto')
env.Append(LINKFLAGS = '-O2 -mmcu=atmega328p -flto')
if GetOption('use_asm'):
env.Append(CPPDEFINES = 'ASM_ISRS')
Target = 'ledcube'
# Make elf
env.Program(Target+'.elf', [Glob('src/*.c'), Glob('src/effects/lib/*.c'), Glob('src/avr/*.c')], LIBS='m')
# Make hex
env.Command(Target+".hex", Target+".elf", 'avr-objcopy -j .text -j .data -O ihex $SOURCE $TARGET')
# Dump assembly code
env.Command(Target+".lss", Target+".elf", 'avr-objdump -h -S $SOURCE >$TARGET')
# Show memory usage
env.Command(None, Target+".elf", "avr-size -C --mcu=atmega328p $SOURCE")
# Program the thing
if GetOption('program'):
pgm = env.Command('pgm', Target+".hex",
'avrdude -pm328p -cusbasp -y -u -Uflash:w:$SOURCE:a '+
'-Ulfuse:w:0xbf:m -Uhfuse:w:0xdb:m -Uefuse:w:0x5:m '+
'-Ulock:w:0xf:m')
env.AlwaysBuild(pgm)