Esempio n. 1
0
def main():
    cc = AvrGcc()
    print '--------------'
    print 'avr-gcc'
    print '--------------'

    print 'compiler version:', cc.version()
    cc.optimize_for_size()
    print
    for mcu in cc.targets:
        print mcu
Esempio n. 2
0
def main():
    cc = AvrGcc()
    print '--------------'
    print 'avr-gcc'
    print '--------------'

    print 'compiler version:', cc.version()
    cc.optimize_for_size()
    print 'compiler options:', ' '.join(cc.options_generated())
    print 'code:', cc.minprog
    print
    for mcu in cc.targets:
        test(cc, mcu)
Esempio n. 3
0
def main():
    cc = AvrGcc()
    print '--------------'
    print 'avr-gcc'
    print '--------------'

    print 'compiler version:', cc.version()
    cc.optimize_for_size()
    print 'compiler options:', ' '.join(cc.options_generated())
    print 'code:', cc.minprog
    print
    for mcu in cc.targets:
        test(cc, mcu)
Esempio n. 4
0
from entrypoint2 import entrypoint
from pyavrutils.avrgcc import AvrGcc, AvrGccCompileError

templ = '''
#include <avr/io.h>
#include <util/delay.h>
int main()
{
    %s;
    return 0;
}
'''

cc = AvrGcc()
cc.optimize_no()
print  'compiler version:', cc.version()
print


def test(snippet, option=''):
    print  snippet.ljust(33),
    cc.options_extra = option.split()
    print  'compiler option:', option, '\t',
    try:
        cc.build([templ % snippet])
        size = cc.size()
        print 'program, data =', str(size.program_bytes).rjust(8), ',', str(size.data_bytes).rjust(8)
    except AvrGccCompileError:
        print  'compile error'

Esempio n. 5
0
from entrypoint2 import entrypoint
from pyavrutils.avrgcc import AvrGcc, AvrGccCompileError

templ = '''
#include <avr/io.h>
#include <util/delay.h>
int main()
{
    %s;
    return 0;
}
'''

cc = AvrGcc()
cc.optimize_no()
print 'compiler version:', cc.version()
print


def test(snippet, option=''):
    print snippet.ljust(33),
    cc.options_extra = option.split()
    print 'compiler option:', option, '\t',
    try:
        cc.build([templ % snippet])
        size = cc.size()
        print 'program, data =', str(size.program_bytes).rjust(8), ',', str(
            size.data_bytes).rjust(8)
    except AvrGccCompileError:
        print 'compile error'
Esempio n. 6
0
from pyavrutils.avrgcc import AvrGcc
from entrypoint2 import entrypoint

cc = AvrGcc()


def test_option(sources, optimization, gc_sections=0, ffunction_sections=0):
    print 'optimization =', optimization,
    print 'gc_sections =', gc_sections,
    print 'ffunction_sections =', ffunction_sections,
    print

    cc.optimization = optimization
    cc.gc_sections = gc_sections
    cc.ffunction_sections = ffunction_sections
    try:
        cc.build(sources)
        size = cc.size()
        print 'program, data =', str(size.program_bytes).rjust(8), ',', str(size.data_bytes).rjust(8)
    except:
        print  'compile error'


def test(sources):
    print 'sources:', sources
    test_option(sources, 0)
    test_option(sources, 's', 0)
    test_option(sources, 's', 1)
    test_option(sources, 's', 1, 1)

Esempio n. 7
0
from pyavrutils.avrgcc import AvrGcc
from entrypoint2 import entrypoint

templ = '''
#include <avr/io.h>
#include <avr/pgmspace.h>
int main()
{
    %s;
    return 0;
}
'''

cc = AvrGcc()
cc.optimization = 0
print  'compiler version:', cc.version()
print  'compiler options:', ' '.join(cc.options_generated())
print


def test(snippet):
    print  snippet, '\t\t',
    try:
        cc.build([templ % snippet])
        size = cc.size()
        print 'program, data =', str(size.program_bytes).rjust(8), ',', str(size.data_bytes).rjust(8)
    except:
        print  'compile error'


def test_comb(s):
Esempio n. 8
0
from pyavrutils.avrgcc import AvrGcc
from entrypoint2 import entrypoint

templ = '''
#include <avr/io.h>
#include <avr/pgmspace.h>
int main()
{
    %s;
    return 0;
}
'''

cc = AvrGcc()
cc.optimization = 0
print 'compiler version:', cc.version()
print 'compiler options:', ' '.join(cc.options_generated())
print


def test(snippet):
    print snippet, '\t\t',
    try:
        cc.build([templ % snippet])
        size = cc.size()
        print 'program, data =', str(size.program_bytes).rjust(8), ',', str(
            size.data_bytes).rjust(8)
    except:
        print 'compile error'

Esempio n. 9
0
from entrypoint2 import entrypoint
from pyavrutils.avrgcc import AvrGcc, AvrGccCompileError
from pysimavr.sim import ArduinoSim
import time
import glob

# define controller and clockspeed
mcu='atmega328'
f_cpu=8000000

# sourcefolder
sources = glob.glob('./source/*.c')
headerlocation = './header'

# compile the project
cc = AvrGcc(mcu = mcu)
cc.f_cpu = f_cpu
cc.options_extra = ['-I%s'%headerlocation,
                    '-uvfprintf',
                    '-lprintf_flt', '-lm', '-DF_CPU=%d'%f_cpu]

print '-------------------------------------------------------------------'
print  'compiler version:', cc.version()
print '-------------------------------------------------------------------'
print 'Project targets'
for source in sources:
    print '  '+source
print '-------------------------------------------------------------------'
print cc.command_list(sources)
error = False
try: