Skip to content

Commit

Permalink
SCUM-30. add scum into scons build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
changtengfei committed Aug 19, 2018
1 parent 64b673b commit 23c3c49
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 2 deletions.
41 changes: 40 additions & 1 deletion SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ elif env['toolchain']=='iar-proj':

elif env['toolchain']=='armgcc':

if env['board'] not in ['silabs-ezr32wg','openmote-cc2538','openmote-b','iot-lab_M3','iot-lab_A8-M3','openmotestm', 'samr21_xpro']:
if env['board'] not in ['silabs-ezr32wg','openmote-cc2538','openmote-b','iot-lab_M3','iot-lab_A8-M3','openmotestm', 'samr21_xpro', 'scum']:
raise SystemError('toolchain {0} can not be used for board {1}'.format(env['toolchain'],env['board']))

if env['board'] in ['openmote-cc2538','openmote-b']:
Expand Down Expand Up @@ -393,6 +393,45 @@ elif env['toolchain']=='armgcc':
env.Replace(NM = 'arm-none-eabi-nm')
env.Replace(SIZE = 'arm-none-eabi-size')

elif env['board']=='scum':

# compiler (C)
env.Replace(CC = 'arm-none-eabi-gcc')
env.Append(CCFLAGS = '-O0')
env.Append(CCFLAGS = '-Wall')
env.Append(CCFLAGS = '-c')
env.Append(CCFLAGS = '-fmessage-length=0')
env.Append(CCFLAGS = '-mcpu=cortex-m0')
env.Append(CCFLAGS = '-mthumb')
env.Append(CCFLAGS = '-mthumb-interwork')
env.Append(CCFLAGS = '-g3')
env.Append(CCFLAGS = '-Wstrict-prototypes')
env.Append(CCFLAGS = '-Ibsp/boards/scum')
env.Append(CCFLAGS = '-std=c99')
env.Append(CCFLAGS = '-nostartfiles')
# assembler
env.Replace(AS = 'arm-none-eabi-as')
env.Append(ASFLAGS = '-ggdb -g3 -mcpu=cortex-m0 -mlittle-endian -mapcs-32')
# linker
env.Append(LINKFLAGS = '-Tbsp/boards/scum/scum_linker.ld')
#env.Append(LINKFLAGS = '-nostartfiles')
env.Append(LINKFLAGS = '-mcpu=cortex-m0')
env.Append(LINKFLAGS = '-mthumb')
env.Append(LINKFLAGS = '-specs=nosys.specs')
env.Append(LINKFLAGS = '-g3')
# object manipulation
env.Replace(OBJCOPY = 'arm-none-eabi-objcopy')
env.Replace(OBJDUMP = 'arm-none-eabi-objdump')
# archiver
env.Replace(AR = 'arm-none-eabi-ar')
env.Append(ARFLAGS = '')
env.Replace(RANLIB = 'arm-none-eabi-ranlib')
env.Append(RANLIBFLAGS = '')
# misc
env.Replace(NM = 'arm-none-eabi-nm')
env.Replace(SIZE = 'arm-none-eabi-size')


else:
raise SystemError('unexpected board={0}'.format(env['board']))

Expand Down
4 changes: 3 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ command_line_options = {
'z1',
# Cortex-M3
'openmote-cc2538',
'openmote-b',
'openmote-b',
'silabs-ezr32wg',
'openmotestm',
'iot-lab_M3',
'iot-lab_A8-M3',
'agilefox',
'samr21_xpro',
# Cortex-M0
'scum',
# misc.
'python',
],
Expand Down
29 changes: 29 additions & 0 deletions bsp/boards/scum/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os

Import('env')

localEnv = env.Clone()

# scons doesn't let us look to parent directories for source, so the
# bsp/chips/at86rf231/radio.c is off limits from this file. To keep things
# simple, each SConscript file in bsp/chips/* will return a list of objects
# which can be appended to the source list. Don't forget to specify a variant_dir,
# or else the build will occur directly in the chips directory.

source = [
'board.c',
'scum_startup.s',
'cryptoengine.c',
'debugpins.c',
'eui64.c',
'leds.c',
'radio.c',
'scm3_hardware_interface.c',
'sctimer.c',
'uart.c',
'interrupts.c'
]

board = localEnv.Object(source=source)

Return('board')
15 changes: 15 additions & 0 deletions bsp/boards/scum/interrupts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "uart.h"
#include "sctimer.h"
#include "radio.h"

void UART_Handler(void){
uart_rx_isr();
}

void RF_Handler(void){
radio_isr();
}

void RFTIMER_Handler(void){
sctimer_isr();
}
3 changes: 3 additions & 0 deletions bsp/boards/scum/interrupts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void UART_Handler(void);
void RF_Handler(void);
void RFTIMER_Handler(void);
89 changes: 89 additions & 0 deletions bsp/boards/scum/scum_linker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

ENTRY(Reset_Handler)

MEMORY
{
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 64K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}

stack_size = 2048;
heap_size = 1024;

_stack_start = ORIGIN(RAM)+LENGTH(RAM);
_stack_end = _stack_start - stack_size;

SECTIONS
{
/* The startup code goes first into ROM */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >ROM

/* The program code and other data goes into ROM */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >ROM

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ROM
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >ROM

/* used by the startup to initialize data */
_sidata = .;

/* Initialized data sections goes into RAM, load LMA copy after code */
.data : AT ( _sidata )
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM

/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* Used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM

. = ALIGN(4);
.heap :
{
_heap_start = .;
. = . + heap_size;
_heap_end = .;
end = _heap_start;
_end = end;
} > RAM

.ARM.attributes 0 : { *(.ARM.attributes) }
}
152 changes: 152 additions & 0 deletions bsp/boards/scum/scum_startup.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/* File: startup_ARMCM0.S
* Purpose: startup file for Cortex-M0 devices. Should use with
* GCC for ARM Embedded Processors
* Version: V2.01
* Date: 12 June 2014
*
*/
/* Copyright (c) 2011 - 2014 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/


.syntax unified
.arch armv6-m

.section .stack
.align 4
#ifdef __STACK_SIZE
.equ Stack_Size, __STACK_SIZE
#else
.equ Stack_Size, 0x00000800
#endif
.globl __StackTop
.globl __StackLimit
__StackLimit:
.space Stack_Size
.size __StackLimit, . - __StackLimit
__StackTop:
.size __StackTop, . - __StackTop

.section .heap
.align 4
#ifdef __HEAP_SIZE
.equ Heap_Size, __HEAP_SIZE
#else
.equ Heap_Size, 0x00000400
#endif
.globl __HeapBase
.globl __HeapLimit
__HeapBase:
.if Heap_Size
.space Heap_Size
.endif
.size __HeapBase, . - __HeapBase
__HeapLimit:
.size __HeapLimit, . - __HeapLimit

.section .vectors
.align 2
.globl __Vectors
__Vectors:
.long __StackTop /* Top of Stack */
.long Reset_Handler /* Reset Handler */
.long 0 /* Reserved*/
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved*/
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved*/
.long 0 /* Reserved */

/* External interrupts */
.long UART_Handler /* 0: UART_ */
.long 0 /* 1: Reserved */
.long 0 /* 2: Reserved */
.long 0 /* 3: Reserved */
.long 0 /* 4: Reserved */
.long 0 /* 5: Reserved */
.long RF_Handler /* 6: RF */
.long RFTIMER_Handler /* 7: RFTimer */
.long 0 /* 8: Reserved */
.long 0 /* 9: Reserved */
.long 0 /* 10: Reserved */
.long 0 /* 11: Reserved */
.long 0 /* 12: Reserved */
.long 0 /* 13: Reserved */
.long 0 /* 14: Reserved */
.long 0 /* 15: Reserved */

.size __Vectors, . - __Vectors

.text
.thumb
.thumb_func
.align 1
.globl Reset_Handler
.type Reset_Handler, %function
Reset_Handler:

#Interrupt Set Enable Register
ldr r1, =0xe000e100
#<- REMEMBER TO ENABLE THE INTERRUPTS!!
ldr r0, =0xc1
str r0, [r1]

.global main
b main

.pool
.size Reset_Handler, . - Reset_Handler

.align 1
.thumb_func
.weak Default_Handler
.type Default_Handler, %function
Default_Handler:
b .
.size Default_Handler, . - Default_Handler

/* Macro to define default handlers. Default handler
* will be weak symbol and just dead loops. They can be
* overwritten by other handlers */
.macro def_irq_handler handler_name
.weak \handler_name
.set \handler_name, Default_Handler
.endm

def_irq_handler UART_Handler
def_irq_handler RF_Handler
def_irq_handler RFTIMER_Handler

.end

0 comments on commit 23c3c49

Please sign in to comment.