-
Notifications
You must be signed in to change notification settings - Fork 2
/
SConscript.target.freertos-stm32
158 lines (144 loc) · 6.12 KB
/
SConscript.target.freertos-stm32
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Copyright (c) Open Connectivity Foundation (OCF), AllJoyn Open Source
# Project (AJOSP) Contributors and others.
#
# SPDX-License-Identifier: Apache-2.0
#
# All rights reserved. This program and the accompanying materials are
# made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Copyright (c) Open Connectivity Foundation and Contributors to AllSeen
# Alliance. All rights reserved.
#
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
import os
Import('env')
# Target specific SCons command line variables
vars = Variables()
vars.Add(BoolVariable('AJWSL', 'Compile driver for the QCA4004 for a specific platform', os.environ.get('AJ_AJWSL', True)))
vars.Add(PathVariable('STM_SRC_DIR', 'Path to the source code for the STM32 microcontroller', os.environ.get('AJ_STM_SRC_DIR'), PathVariable.PathIsDir))
vars.Add(PathVariable('ARM_TOOLCHAIN_DIR', 'Path to the ARM Toolchain', os.environ.get('AJ_ARM_TOOLCHAIN_DIR'), PathVariable.PathIsDir))
vars.Add(PathVariable('FREE_RTOS_DIR', 'Directory to FreeRTOS source code', os.environ.get('AJ_FREE_RTOS_DIR'), PathVariable.PathIsDir))
vars.Update(env)
Help(vars.GenerateHelpText(env))
# Disable building unit tests
env['build_unit_tests'] = False
# Update environment
if env.has_key('ARM_TOOLCHAIN_DIR'):
env['ENV']['PATH'] = ';'.join([ env['ENV']['PATH'], env['ARM_TOOLCHAIN_DIR'] ])
# Cross compile setup
cross_prefix = 'arm-none-eabi-'
env.Replace(CC = cross_prefix + 'gcc')
env.Replace(CXX = cross_prefix + 'g++')
env.Replace(LINK = cross_prefix + 'gcc')
env.Replace(AR = cross_prefix + 'ar')
env.Replace(RANLIB = cross_prefix + 'ranlib')
env.Replace(CCCOM = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES')
env.Replace(CPPDEFPREFIX = '-D')
env.Replace(OBJSUFFIX = '.o')
env.Replace(INCPREFIX = '-I')
env.Replace(LIBDIRPREFIX = '-L')
env.Replace(LIBPREFIX = 'lib')
env.Replace(LIBSUFFIX = '.a')
env.Replace(PROGPREFIX = '')
env.Replace(PROGSUFFIX = '.elf')
env.Replace(LIBDIRSUFFIX = '')
env.Replace(LIBLINKPREFIX = '-l')
env.Replace(LIBLINKSUFFIX = '')
env.Replace(LINKCOM = '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS')
env.Replace(LINKFLAGS = '')
env.Replace(CCFLAGS = '')
env.Replace(ARFLAGS = 'rc')
env.Replace(ARCOM = '$AR $ARFLAGS $TARGET $SOURCES')
env.Replace(ASCOM = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES')
# This was done because scons creates a link file to feed into the linker
# and arm-none-eabi removes '\' when interpreting a linker file. This
# prevents scons from creating a link file and just feeding the command line
# options directly to the compiler/linker
env['MAXLINELENGTH'] = 10000
# Compiler flags
env.Append(CFLAGS = [
'-std=gnu99',
'-pipe',
'-mcpu=cortex-m3',
'-mthumb',
'-mlong-calls',
'-fdata-sections',
'-ffunction-sections',
'-fno-strict-aliasing',
'-Wall',
'-Waggregate-return',
'-Wbad-function-cast',
'-Wcast-align',
'-Wfloat-equal',
'-Wformat=2',
'-Wno-deprecated-declarations',
'-Wno-unknown-pragmas',
'-Wpacked',
'-Wpointer-arith',
'-Wshadow',
'-Wundef',
'-Wformat-security',
'-Werror=format-security',
'-Wwrite-strings'
])
env.Append(CPPDEFINES = {
'STM32F407xx' : None,
'USE_STDPERIPH_DRIVER' : None,
'HAL_UART_MODULE_ENABLED' : None,
'HAL_RCC_MODULE_ENABLED' : None,
'HAL_GPIO_MODULE_ENABLED' : None,
'HAL_USART_MODULE_ENABLED': None,
'HAL_FLASH_MODULE_ENABLED': None,
'_FORTIFY_SOURCE': '1'
})
# Linker flags
env.Append(LINKFLAGS = [
'-mthumb',
'-Wl,--start-group',
'-lm',
'-lc',
'-Wl,--end-group',
'-Wl,--gc-sections',
'-Wl,-Map,${TARGET.base}.map',
'-mcpu=cortex-m3',
'-T' + env['STM_SRC_DIR'] + 'Project/Peripheral_Examples/SysTick/TrueSTUDIO/SysTick/stm32_flash.ld',
'-Wl,--entry=Reset_Handler'
])
# Add in extra non standard include files
env.Install('#dist/include/ajtcl', Glob('src/wsl/*.h'))
env.Install('#dist/include/ajtcl', Glob('src/target/freertos-stm32/*.h'))
env.Install('#dist/include/ajtcl', Glob('src/freertos/*.h'))
env.Install('#dist/include/ajtcl', Glob('src/bsp/*.h'))
# The STM32 software pack requires that you provide "stm32f4xx_conf.h" as a
# configurable header file. Install that file to '#dist/include' where it will
# be found via the normal -I flags test SCons files use.
env.Install('#dist/include', Glob('src/target/freertos-stm32/stm32/*.h'))
env.Append(CPPPATH = Dir(['src/bsp']))
env.Append(CPPPATH = Dir([env['FREE_RTOS_DIR'] + '/Source/include',
env['FREE_RTOS_DIR'] + '/Source/portable/GCC/ARM_CM3',
env['STM_SRC_DIR'] + 'Utilities/STM32F4-Discovery',
env['STM_SRC_DIR'] + 'Libraries/CMSIS/ST/STM32F4xx/Include',
env['STM_SRC_DIR'] + 'Libraries/CMSIS/Include',
env['STM_SRC_DIR'] + 'Libraries/STM32F4xx_StdPeriph_Driver/inc']))
# Debug/Release Variants
if env['VARIANT'] == 'debug':
env.Append(CFLAGS = '-g3')
else:
env.Append(CFLAGS = '-Os')
env.Append(LINKFLAGS = '-s')
env['build_shared'] = False
#env['connectivity_options'] = [ 'tcp', 'ardp' ]