mirror of https://github.com/ArduPilot/ardupilot
waf: moved to generated loader script
This commit is contained in:
parent
6e4ef32628
commit
2978649cd4
|
@ -253,6 +253,8 @@ class chibios(Board):
|
|||
def configure_env(self, cfg, env):
|
||||
super(chibios, self).configure_env(cfg, env)
|
||||
|
||||
env.BOARD = self.name
|
||||
|
||||
env.DEFINES.update(
|
||||
CONFIG_HAL_BOARD = 'HAL_BOARD_CHIBIOS',
|
||||
HAVE_OCLOEXEC = 0,
|
||||
|
@ -314,6 +316,9 @@ class chibios(Board):
|
|||
'-mfloat-abi=hard'
|
||||
]
|
||||
|
||||
bldnode = cfg.bldnode.make_node(self.name)
|
||||
env.BUILDROOT = bldnode.make_node('').abspath()
|
||||
|
||||
env.LINKFLAGS = [
|
||||
'-mcpu=cortex-m4',
|
||||
'-Os',
|
||||
|
@ -336,6 +341,9 @@ class chibios(Board):
|
|||
'-mfpu=fpv4-sp-d16',
|
||||
'-mno-thumb-interwork',
|
||||
'-mthumb',
|
||||
'-L%s' % cfg.srcnode.make_node('modules/ChibiOS/os/common/startup/ARMCMx/compilers/GCC/ld/').abspath(),
|
||||
'-L%s' % cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/common/').abspath(),
|
||||
'-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=%s/ldscript.ld,--defsym=__process_stack_size__=0x400,--defsym=__main_stack_size__=0x400' % env.BUILDROOT,
|
||||
]
|
||||
|
||||
env.LIB += ['gcc', 'm']
|
||||
|
@ -355,13 +363,6 @@ class skyviper_f412(chibios):
|
|||
env.DEFINES.update(
|
||||
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_CHIBIOS_SKYVIPER_F412',
|
||||
)
|
||||
env.BOARD = 'skyviper-f412'
|
||||
env.LINKFLAGS += [
|
||||
'-L%s'\
|
||||
% cfg.srcnode.make_node('modules/ChibiOS/os/common/startup/ARMCMx/compilers/GCC/ld/').abspath(),
|
||||
'-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=%s,--defsym=__process_stack_size__=0x400,--defsym=__main_stack_size__=0x400'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/%s/ldscript.ld' % env.BOARD).abspath(),
|
||||
]
|
||||
|
||||
class fmuv3(chibios):
|
||||
name = 'fmuv3'
|
||||
|
@ -370,13 +371,6 @@ class fmuv3(chibios):
|
|||
env.DEFINES.update(
|
||||
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_CHIBIOS_FMUV3',
|
||||
)
|
||||
env.BOARD = 'fmuv3'
|
||||
env.LINKFLAGS += [
|
||||
'-L%s'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/').abspath(),
|
||||
'-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=%s,--defsym=__process_stack_size__=0x400,--defsym=__main_stack_size__=0x400'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/%s/ldscript.ld' % env.BOARD).abspath(),
|
||||
]
|
||||
|
||||
class fmuv4(chibios):
|
||||
name = 'fmuv4'
|
||||
|
@ -385,13 +379,6 @@ class fmuv4(chibios):
|
|||
env.DEFINES.update(
|
||||
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_CHIBIOS_FMUV4',
|
||||
)
|
||||
env.BOARD = 'fmuv4'
|
||||
env.LINKFLAGS += [
|
||||
'-L%s'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/').abspath(),
|
||||
'-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=%s,--defsym=__process_stack_size__=0x400,--defsym=__main_stack_size__=0x400'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/%s/ldscript.ld' % env.BOARD).abspath(),
|
||||
]
|
||||
|
||||
class mindpx_v2(chibios):
|
||||
name = 'mindpx-v2'
|
||||
|
@ -400,13 +387,6 @@ class mindpx_v2(chibios):
|
|||
env.DEFINES.update(
|
||||
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_CHIBIOS_MINDPXV2',
|
||||
)
|
||||
env.BOARD = 'mindpx-v2'
|
||||
env.LINKFLAGS += [
|
||||
'-L%s'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/').abspath(),
|
||||
'-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=%s,--defsym=__process_stack_size__=0x400,--defsym=__main_stack_size__=0x400'\
|
||||
% cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/%s/ldscript.ld' % env.BOARD).abspath(),
|
||||
]
|
||||
|
||||
class linux(Board):
|
||||
def configure_env(self, cfg, env):
|
||||
|
|
|
@ -127,23 +127,25 @@ def configure(cfg):
|
|||
env.BOARD_MK = mk_custom
|
||||
else:
|
||||
env.BOARD_MK = mk_common
|
||||
print("BOARD_MK=%s" % env.BOARD_MK)
|
||||
|
||||
if cfg.options.default_parameters:
|
||||
cfg.msg('Default parameters', cfg.options.default_parameters, color='YELLOW')
|
||||
env.DEFAULT_PARAMETERS = srcpath(cfg.options.default_parameters)
|
||||
|
||||
|
||||
import subprocess
|
||||
|
||||
hwdef = srcpath('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % env.BOARD)
|
||||
hwdef_script = srcpath('libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py')
|
||||
hwdef_out = env.BUILDROOT
|
||||
if not os.path.exists(hwdef_out):
|
||||
os.mkdir(hwdef_out)
|
||||
try:
|
||||
cmd = 'python %s -D %s %s' % (hwdef_script, hwdef_out, hwdef)
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
except Exception:
|
||||
print("Failed to generate hwdef.h")
|
||||
|
||||
def build(bld):
|
||||
bld(
|
||||
# build hwdef.h and apj.prototype from hwdef.dat
|
||||
source='libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % bld.env.get_flat('BOARD'),
|
||||
rule='python ${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py -D ${BUILDROOT} ${AP_HAL_ROOT}/hwdef/${BOARD}/hwdef.dat',
|
||||
group='dynamic_sources',
|
||||
target=['hwdef.h', 'apj.prototype']
|
||||
)
|
||||
|
||||
bld(
|
||||
# create the file modules/ChibiOS/include_dirs
|
||||
rule='touch Makefile && BUILDDIR=${BUILDDIR} CHIBIOS=${CH_ROOT} AP_HAL=${AP_HAL_ROOT} ${MAKE} pass -f ${BOARD_MK}',
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
this file is included by the board specific ldscript.ld which is
|
||||
generated from hwdef.dat
|
||||
*/
|
||||
|
||||
/* RAM region to be used for Main stack. This stack accommodates the processing
|
||||
of all exceptions and interrupts*/
|
||||
REGION_ALIAS("MAIN_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the process stack. This is the stack used by
|
||||
the main() function.*/
|
||||
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for data segment.*/
|
||||
REGION_ALIAS("DATA_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for BSS segment.*/
|
||||
REGION_ALIAS("BSS_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the default heap.*/
|
||||
REGION_ALIAS("HEAP_RAM", ram0);
|
||||
|
||||
__ram0_start__ = ORIGIN(ram0);
|
||||
__ram0_size__ = LENGTH(ram0);
|
||||
__ram0_end__ = __ram0_start__ + __ram0_size__;
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
_text = .;
|
||||
|
||||
startup : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
KEEP(*(.vectors))
|
||||
} > flash
|
||||
|
||||
constructors : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
__init_array_start = .;
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
__init_array_end = .;
|
||||
} > flash
|
||||
|
||||
destructors : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
__fini_array_start = .;
|
||||
KEEP(*(.fini_array))
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
__fini_array_end = .;
|
||||
} > flash
|
||||
|
||||
.text : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.glue_7t)
|
||||
*(.glue_7)
|
||||
*(.gcc*)
|
||||
} > flash
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > flash
|
||||
|
||||
.ARM.exidx : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} > flash
|
||||
|
||||
.eh_frame_hdr :
|
||||
{
|
||||
*(.eh_frame_hdr)
|
||||
} > flash
|
||||
|
||||
.eh_frame : ONLY_IF_RO
|
||||
{
|
||||
*(.eh_frame)
|
||||
} > flash
|
||||
|
||||
.textalign : ONLY_IF_RO
|
||||
{
|
||||
. = ALIGN(8);
|
||||
} > flash
|
||||
|
||||
/* Legacy symbol, not used anywhere.*/
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_etext = .);
|
||||
|
||||
/* Special section for exceptions stack.*/
|
||||
.mstack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__main_stack_base__ = .;
|
||||
. += __main_stack_size__;
|
||||
. = ALIGN(8);
|
||||
__main_stack_end__ = .;
|
||||
} > MAIN_STACK_RAM
|
||||
|
||||
/* Special section for process stack.*/
|
||||
.pstack :
|
||||
{
|
||||
__process_stack_base__ = .;
|
||||
__main_thread_stack_base__ = .;
|
||||
. += __process_stack_size__;
|
||||
. = ALIGN(8);
|
||||
__process_stack_end__ = .;
|
||||
__main_thread_stack_end__ = .;
|
||||
} > PROCESS_STACK_RAM
|
||||
|
||||
.data : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_textdata = LOADADDR(.data));
|
||||
PROVIDE(_data = .);
|
||||
_textdata_start = LOADADDR(.data);
|
||||
_data_start = .;
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.ramtext)
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_edata = .);
|
||||
_data_end = .;
|
||||
} > DATA_RAM AT > flash
|
||||
|
||||
.bss (NOLOAD) : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_bss_start = .;
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_bss_end = .;
|
||||
PROVIDE(end = .);
|
||||
} > BSS_RAM
|
||||
|
||||
.ram0_init : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram0_init_text__ = LOADADDR(.ram0_init);
|
||||
__ram0_init__ = .;
|
||||
*(.ram0_init)
|
||||
*(.ram0_init.*)
|
||||
. = ALIGN(4);
|
||||
} > ram0 AT > flash
|
||||
|
||||
.ram0 (NOLOAD) : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__ram0_clear__ = .;
|
||||
*(.ram0_clear)
|
||||
*(.ram0_clear.*)
|
||||
. = ALIGN(4);
|
||||
__ram0_noinit__ = .;
|
||||
*(.ram0)
|
||||
*(.ram0.*)
|
||||
. = ALIGN(4);
|
||||
__ram0_free__ = .;
|
||||
} > ram0
|
||||
|
||||
/* The default heap uses the (statically) unused part of a RAM section.*/
|
||||
.heap (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__heap_base__ = .;
|
||||
. = ORIGIN(HEAP_RAM) + LENGTH(HEAP_RAM);
|
||||
__heap_end__ = .;
|
||||
} > HEAP_RAM
|
||||
}
|
Loading…
Reference in New Issue