From 93b6b755bdc1566920ed7b16b255c10382988b25 Mon Sep 17 00:00:00 2001 From: "Kyle.Hu.GZ@gmail.com" Date: Mon, 4 Jul 2011 10:22:15 +0000 Subject: [PATCH] Added scons scripts. Rename and updated libcpu/avr32/uc3/exception.x (with .irp macro) to exception_gcc.S (without .irp macro) for better compatibility. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1613 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/avr32uc3b0/SConscript | 11 +++ bsp/avr32uc3b0/SConstruct | 31 ++++++++ bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript | 30 +++++++ bsp/avr32uc3b0/rtconfig.py | 42 ++++++++++ .../uc3/{context_gcc.x => context_gcc.S} | 0 .../uc3/{exception.x => exception_gcc.S} | 79 +++++++++++++++++-- 6 files changed, 186 insertions(+), 7 deletions(-) create mode 100644 bsp/avr32uc3b0/SConscript create mode 100644 bsp/avr32uc3b0/SConstruct create mode 100644 bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript create mode 100644 bsp/avr32uc3b0/rtconfig.py rename libcpu/avr32/uc3/{context_gcc.x => context_gcc.S} (100%) rename libcpu/avr32/uc3/{exception.x => exception_gcc.S} (70%) diff --git a/bsp/avr32uc3b0/SConscript b/bsp/avr32uc3b0/SConscript new file mode 100644 index 000000000..f228cf13c --- /dev/null +++ b/bsp/avr32uc3b0/SConscript @@ -0,0 +1,11 @@ +import rtconfig +Import('RTT_ROOT') +from building import * + +src_bsp = ['application.c', 'startup.c', 'board.c'] + +src = File(src_bsp) +CPPPATH = [RTT_ROOT + '/bsp/avr32uc3b0'] +group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/avr32uc3b0/SConstruct b/bsp/avr32uc3b0/SConstruct new file mode 100644 index 000000000..209b762de --- /dev/null +++ b/bsp/avr32uc3b0/SConstruct @@ -0,0 +1,31 @@ +import os +import sys +import rtconfig + +RTT_ROOT = os.path.normpath(os.getcwd() + '/../..') +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +from building import * + +TARGET = 'rtthread-' + rtconfig.ARCH + '.' + rtconfig.TARGET_EXT + +env = Environment(tools = ['mingw'], + AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, + CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, + AR = rtconfig.AR, ARFLAGS = '-rc', + LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) + +Export('RTT_ROOT') +Export('rtconfig') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT) + +# AVR32 software framework building script +objs = objs + SConscript(RTT_ROOT + '/bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript', variant_dir='bsp/SOFTWARE_FRAMEWORK', duplicate=0) + +# build program +env.Program(TARGET, objs) + +# end building +EndBuilding(TARGET) \ No newline at end of file diff --git a/bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript b/bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript new file mode 100644 index 000000000..774c0237d --- /dev/null +++ b/bsp/avr32uc3b0/SOFTWARE_FRAMEWORK/SConscript @@ -0,0 +1,30 @@ +import rtconfig +Import('RTT_ROOT') +from building import * + +cwd = GetCurrentDir() + +src = Split(""" +DRIVERS/FLASHC/flashc.c +DRIVERS/GPIO/gpio.c +DRIVERS/INTC/intc.c +DRIVERS/PM/pm.c +DRIVERS/PM/pm_conf_clocks.c +DRIVERS/PM/power_clocks_lib.c +DRIVERS/USART/usart.c +""") + +CPPPATH = [ + cwd + '/BOARDS', + cwd + '/UTILS', + cwd + '/UTILS/PREPROCESSOR', + cwd + '/DRIVERS/FLASHC', + cwd + '/DRIVERS/GPIO', + cwd + '/DRIVERS/INTC', + cwd + '/DRIVERS/PM', + cwd + '/DRIVERS/USART', +] + +group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/avr32uc3b0/rtconfig.py b/bsp/avr32uc3b0/rtconfig.py new file mode 100644 index 000000000..09292421c --- /dev/null +++ b/bsp/avr32uc3b0/rtconfig.py @@ -0,0 +1,42 @@ + +# toolchains options +ARCH = 'avr32' +CPU = 'uc3' +PART = 'uc3b0256' +BOARD = 'USERBOARD' + +CROSS_TOOL = 'gcc' + +if CROSS_TOOL == 'gcc': + PLATFORM = 'gcc' + EXEC_PATH = 'C:/Program Files/Atmel/AVR Tools/AVR Toolchain/bin' +#BUILD = 'debug' +BUILD = 'release' + +if PLATFORM == 'gcc': + # toolchains + PREFIX = 'avr32-' + CC = PREFIX + 'gcc' + AS = PREFIX + 'gcc' + AR = PREFIX + 'ar' + LINK = PREFIX + 'gcc' + TARGET_EXT = 'elf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' -mpart=' + PART + CFLAGS = DEVICE + ' -DBOARD=' + BOARD + ' -fmessage-length=0 -ffunction-sections -masm-addr-pseudos' + AFLAGS = ' -c -x assembler-with-cpp' + DEVICE + LFLAGS = DEVICE + ' -Wl,--gc-sections --rodata-writable -Wl,--direct-data -LSOFTWARE_FRAMEWORK/UTILS/LIBS/NEWLIB_ADDONS -T avr32elf_uc3b0256.lds' + + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -g3 -Wall' + AFLAGS += ' -g3' + else: + CFLAGS += ' -O2 -Wall' + + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' diff --git a/libcpu/avr32/uc3/context_gcc.x b/libcpu/avr32/uc3/context_gcc.S similarity index 100% rename from libcpu/avr32/uc3/context_gcc.x rename to libcpu/avr32/uc3/context_gcc.S diff --git a/libcpu/avr32/uc3/exception.x b/libcpu/avr32/uc3/exception_gcc.S similarity index 70% rename from libcpu/avr32/uc3/exception.x rename to libcpu/avr32/uc3/exception_gcc.S index 813bf454e..1a36606f3 100644 --- a/libcpu/avr32/uc3/exception.x +++ b/libcpu/avr32/uc3/exception_gcc.S @@ -193,12 +193,11 @@ _handle_Supervisor_Call: .balign 4 - .irp priority, 0, 1, 2, 3 -_int\priority: - mov r12, \priority // Pass the int_level parameter to the _get_interrupt_handler function. +_int0: + mov r12, 0 // Pass the int_level parameter to the _get_interrupt_handler function. call _get_interrupt_handler cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function. - breq _spint\priority // If this was not a spurious interrupt (R12 != NULL), jump to the handler. + breq _spint0 // If this was not a spurious interrupt (R12 != NULL), jump to the handler. call rt_interrupt_enter icall r12 call rt_interrupt_leave @@ -206,15 +205,81 @@ _int\priority: lda.w r12, rt_interrupt_nest /* Is nested interrupt? */ ld.w r11, r12[0] cp.w r11, 0 - brne _spint\priority + brne _spint0 lda.w r12, rt_thread_switch_interrupt_flag /* Is thread switch required? */ ld.w r11, r12[0] cp.w r11, 1 breq rt_hw_context_switch_interrupt_do -_spint\priority: +_spint0: csrf AVR32_SR_GM_OFFSET /* Enable global interrupt */ rete // If this was a spurious interrupt (R12 == NULL), return from event handler. - .endr + + +_int1: + mov r12, 1 // Pass the int_level parameter to the _get_interrupt_handler function. + call _get_interrupt_handler + cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function. + breq _spint1 // If this was not a spurious interrupt (R12 != NULL), jump to the handler. + call rt_interrupt_enter + icall r12 + call rt_interrupt_leave + ssrf AVR32_SR_GM_OFFSET /* Disable global interrupt */ + lda.w r12, rt_interrupt_nest /* Is nested interrupt? */ + ld.w r11, r12[0] + cp.w r11, 0 + brne _spint1 + lda.w r12, rt_thread_switch_interrupt_flag /* Is thread switch required? */ + ld.w r11, r12[0] + cp.w r11, 1 + breq rt_hw_context_switch_interrupt_do +_spint1: + csrf AVR32_SR_GM_OFFSET /* Enable global interrupt */ + rete // If this was a spurious interrupt (R12 == NULL), return from event handler. + + +_int2: + mov r12, 2 // Pass the int_level parameter to the _get_interrupt_handler function. + call _get_interrupt_handler + cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function. + breq _spint2 // If this was not a spurious interrupt (R12 != NULL), jump to the handler. + call rt_interrupt_enter + icall r12 + call rt_interrupt_leave + ssrf AVR32_SR_GM_OFFSET /* Disable global interrupt */ + lda.w r12, rt_interrupt_nest /* Is nested interrupt? */ + ld.w r11, r12[0] + cp.w r11, 0 + brne _spint2 + lda.w r12, rt_thread_switch_interrupt_flag /* Is thread switch required? */ + ld.w r11, r12[0] + cp.w r11, 1 + breq rt_hw_context_switch_interrupt_do +_spint2: + csrf AVR32_SR_GM_OFFSET /* Enable global interrupt */ + rete // If this was a spurious interrupt (R12 == NULL), return from event handler. + + +_int3: + mov r12, 3 // Pass the int_level parameter to the _get_interrupt_handler function. + call _get_interrupt_handler + cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function. + breq _spint3 // If this was not a spurious interrupt (R12 != NULL), jump to the handler. + call rt_interrupt_enter + icall r12 + call rt_interrupt_leave + ssrf AVR32_SR_GM_OFFSET /* Disable global interrupt */ + lda.w r12, rt_interrupt_nest /* Is nested interrupt? */ + ld.w r11, r12[0] + cp.w r11, 0 + brne _spint3 + lda.w r12, rt_thread_switch_interrupt_flag /* Is thread switch required? */ + ld.w r11, r12[0] + cp.w r11, 1 + breq rt_hw_context_switch_interrupt_do +_spint3: + csrf AVR32_SR_GM_OFFSET /* Enable global interrupt */ + rete // If this was a spurious interrupt (R12 == NULL), return from event handler. + rt_hw_context_switch_interrupt_do: mov r11, 0 -- GitLab