1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00

Thanks to the people@elua-dev list, I finally understood what's ARM EABI, so I thought I make good use of it :), so I enabled it for ALL ARM and Cortex targets alike. Now you can specify the toolchain to use like this:

$ scons board=... toolchain=arm-gcc|arm-gcc-eabi
(the default is still arm-gcc, but this can be changed by editing SConstruct).

This is a Very Good thing for us, because users won't need to build their own toolchains anymore, they can just download the one from CS and use it. Thanks again for this.
Actually, the whole build system was changed to support arbitrary toolchains (although there's much work to be done in this area).
Also, changed a few things in the STM32 port (the linker script file, the stack definitions).
And other (very minor) changes (mostly to fix some compiler warnings).
This commit is contained in:
Bogdan Marinescu 2009-02-23 13:56:21 +00:00
parent 9ac734be3c
commit a2b915dd2f
21 changed files with 546 additions and 620 deletions

View File

@ -3,18 +3,53 @@ target = ARGUMENTS.get( 'target', 'lua' ).lower()
cputype = ARGUMENTS.get( 'cpu', '' ).upper()
allocator = ARGUMENTS.get( 'allocator', '' ).lower()
boardname = ARGUMENTS.get( 'board' , '').upper()
cprefix = ARGUMENTS.get( 'cprefix', '')
toolchain = ARGUMENTS.get( 'toolchain', '')
optram = int( ARGUMENTS.get( 'optram', '1' ) )
# List of platform/CPU combinations
cpu_list = { 'at91sam7x' : [ 'AT91SAM7X256', 'AT91SAM7X512' ],
'lm3s' : [ 'LM3S8962', 'LM3S6965' ],
'str9' : [ 'STR912FW44' ],
'i386' : [ 'I386' ],
'lpc288x' : [ 'LPC2888' ],
'str7' : [ 'STR711FR2' ],
'stm32' : [ 'STM32F103ZE' ],
'avr32' : [ 'AT32UC3A0512' ]
# List of toolchains
toolchain_list = {
'arm-gcc' : {
'compile' : 'arm-elf-gcc',
'link' : 'arm-elf-ld',
'asm' : 'arm-elf-as',
'bin' : 'arm-elf-objcopy',
'size' : 'arm-elf-size'
},
'arm-gcc-eabi' : {
'compile' : 'arm-none-eabi-gcc',
'link' : 'arm-none-eabi-ld',
'asm' : 'arm-none-eabi-as',
'bin' : 'arm-none-eabi-objcopy',
'size' : 'arm-none-eabi-size'
},
'avr32-gcc' : {
'compile' : 'avr32-gcc',
'link' : 'avr32-ld',
'asm' : 'avr32-as',
'bin' : 'avr32-objcopy',
'size' : 'avr32-size'
},
'i686-gcc' : {
'compile' : 'i686-elf-gcc',
'link' : 'i686-elf-ld',
'asm' : 'nasm',
'bin' : 'i686-elf-objcopy',
'size' : 'i686-elf-size'
}
}
# List of platform/CPU/toolchains combinations
# The first toolchain in the toolchains list is the default one
# (the one that will be used if none is specified)
platform_list = {
'at91sam7x' : { 'cpus' : [ 'AT91SAM7X256', 'AT91SAM7X512' ], 'toolchains' : [ 'arm-gcc', 'arm-gcc-eabi' ] },
'lm3s' : { 'cpus' : [ 'LM3S8962', 'LM3S6965' ], 'toolchains' : [ 'arm-gcc', 'arm-gcc-eabi' ] },
'str9' : { 'cpus' : [ 'STR912FW44' ], 'toolchains' : [ 'arm-gcc', 'arm-gcc-eabi' ] },
'i386' : { 'cpus' : [ 'I386' ], 'toolchains' : [ 'i686-gcc' ] },
'lpc288x' : { 'cpus' : [ 'LPC2888' ], 'toolchains' : [ 'arm-gcc', 'arm-gcc-eabi' ] },
'str7' : { 'cpus' : [ 'STR711FR2' ], 'toolchains' : [ 'arm-gcc', 'arm-gcc-eabi' ] },
'stm32' : { 'cpus' : [ 'STM32F103ZE', 'STM32F103RE' ], 'toolchains' : [ 'arm-gcc', 'arm-gcc-eabi' ] },
'avr32' : { 'cpus' : [ 'AT32UC3A0512' ], 'toolchains' : [ 'avr32-gcc' ] }
}
# List of board/CPU combinations
@ -26,7 +61,8 @@ board_list = { 'SAM7-EX256' : [ 'AT91SAM7X256', 'AT91SAM7X512' ],
'LPC-H2888' : [ 'LPC2888' ],
'MOD711' : [ 'STR711FR2' ],
'STM3210E-EVAL' : [ 'STM32F103ZE' ],
'ATEVK1100' : [ 'AT32UC3A0512' ]
'ATEVK1100' : [ 'AT32UC3A0512' ],
'ET-STM32' : [ 'STM32F103RE' ]
}
# ROMFS file list "groups"
@ -57,7 +93,8 @@ file_list = { 'SAM7-EX256' : [ 'bisect', 'hangman' , 'led', 'piano', 'hello', 'i
'LPC-H2888' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
'MOD711' : [ 'bisect', 'hangman', 'led', 'hello', 'info', 'dualpwm' ],
'STM3210E-EVAL' : [ 'bisect', 'hello', 'info' ],
'ATEVK1100' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ]
'ATEVK1100' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
'ET-STM32' : [ 'hello', 'info', 'bisect' ]
}
# Variants: board = <boardname>
@ -93,22 +130,31 @@ else:
print "CPU %s not found" % cputype
sys.exit( -1 )
platform = None
# Look for the given CPU in the list of platforms
for p, v in cpu_list.items():
if cputype in v:
platform = None
for p, v in platform_list.items():
if cputype in v[ 'cpus' ]:
platform = p
break
else:
print "Unknown CPU %s" % cputype
print "List of accepted CPUs: "
for p, v in cpu_list.items():
for p, v in platform_list.items():
print " ", p, "-->",
for cpu in v:
for cpu in v[ 'cpus' ]:
print cpu,
print
sys.exit( -1 )
# Check the toolchain
if toolchain != '':
if not toolchain in platform_list[ platform ][ 'toolchains' ]:
print "Invalid toolchain '%s' for CPU '%s'" % ( toolchain, cputype )
sys.exit( -1 )
else:
toolchain = platform_list[ platform ][ 'toolchains' ][ 0 ]
toolset = toolchain_list[ toolchain ]
# CPU/allocator mapping (if allocator not specified)
if allocator == '':
if boardname == 'LPC-H2888' or boardname == 'ATEVK1100':
@ -130,7 +176,8 @@ if not GetOption( 'clean' ):
print "Board: ", boardname
print "Platform: ", platform
print "Allocator: ", allocator
print "Target: ", target
print "Target: ", target == 'lua' and 'fplua' or 'target'
print "Toolchain: ", toolchain
print "*********************************"
print

View File

@ -30,15 +30,16 @@ ldscript = "src/platform/%s/%s" % ( platform, ldscript )
# Toolset data
tools[ 'at91sam7x' ] = {}
tools[ 'at91sam7x' ][ 'cccom' ] = "arm-elf-gcc -mcpu=arm7tdmi %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( modeflag, opt, local_include, cdefs )
tools[ 'at91sam7x' ][ 'linkcom' ] = "arm-elf-gcc -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,entry -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( modeflag, ldscript, local_libs )
tools[ 'at91sam7x' ][ 'ascom' ] = "arm-elf-gcc -x assembler-with-cpp %s -mcpu=arm7tdmi %s %s -D__ASSEMBLY__ -Wall -c $SOURCE -o $TARGET" % ( local_include, modeflag, cdefs )
tools[ 'at91sam7x' ][ 'cccom' ] = "%s -mcpu=arm7tdmi %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], modeflag, opt, local_include, cdefs )
tools[ 'at91sam7x' ][ 'linkcom' ] = "%s -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,entry -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( toolset[ 'compile' ], modeflag, ldscript, local_libs )
tools[ 'at91sam7x' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mcpu=arm7tdmi %s %s -D__ASSEMBLY__ -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, modeflag, cdefs )
# Programming function for LPC2888
def progfunc_at91sam7x( target, source, env ):
outname = output + ".elf"
os.system( "arm-elf-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( "arm-elf-objcopy -O binary %s %s.bin" % ( outname, output ) )
os.system( "%s -O binary %s %s.bin" % ( toolset[ 'bin' ], outname, output ) )
tools[ 'at91sam7x' ][ 'progfunc' ] = progfunc_at91sam7x

View File

@ -64,6 +64,8 @@ SECTIONS
. = ALIGN(4);
_efixed = .;
PROVIDE(etext = .);
_fini = .;
*(.fini)
} >flash
.relocate : AT (_efixed)
@ -77,6 +79,18 @@ SECTIONS
_erelocate = .;
} >sram
.ARM.extab :
{
*(.ARM.extab*)
} >sram
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx*)
} >sram
__exidx_end = .;
.bss (NOLOAD) : {
_szero = .;
*(.bss .bss.*)

View File

@ -64,6 +64,8 @@ SECTIONS
. = ALIGN(4);
_efixed = .;
PROVIDE(etext = .);
_fini = .;
*(.fini)
} >flash
.relocate : AT (_efixed)
@ -77,6 +79,18 @@ SECTIONS
_erelocate = .;
} >sram
.ARM.extab :
{
*(.ARM.extab*)
} >sram
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx*)
} >sram
__exidx_end = .;
.bss (NOLOAD) : {
_szero = .;
*(.bss .bss.*)

View File

@ -168,7 +168,7 @@ pio_type platform_pio_op( unsigned port, pio_type pinmask, int op )
case PLATFORM_IO_PORT_GET_VALUE:
pin->mask = 0x7FFFFFFF;
pin->type = pinmask == PLATFORM_IO_READ_IN_MASK ? : PIO_INPUT : PIO_OUTPUT_0;
pin->type = pinmask == PLATFORM_IO_READ_IN_MASK ? PIO_INPUT : PIO_OUTPUT_0;
retval = PIO_Get( pin );
break;

View File

@ -11,16 +11,17 @@ ldscript = "src/platform/%s/%s" % ( platform, ldscript )
# Toolset data
tools[ 'avr32' ] = {}
tools[ 'avr32' ][ 'cccom' ] = "avr32-gcc -mpart=uc3a0512 %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( opt, local_include, cdefs )
tools[ 'avr32' ][ 'linkcom' ] = "avr32-gcc -nostartfiles -nostdlib -T %s -Wl,--gc-sections -Wl,-e,crt0 -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( ldscript, local_libs )
tools[ 'avr32' ][ 'ascom' ] = "avr32-gcc -x assembler-with-cpp %s -mpart=uc3a0512 %s -Wall -c $SOURCE -o $TARGET" % ( local_include, cdefs )
tools[ 'avr32' ][ 'cccom' ] = "%s -mpart=uc3a0512 %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], opt, local_include, cdefs )
tools[ 'avr32' ][ 'linkcom' ] = "%s -nostartfiles -nostdlib -T %s -Wl,--gc-sections -Wl,-e,crt0 -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( toolset[ 'compile' ], ldscript, local_libs )
tools[ 'avr32' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mpart=uc3a0512 %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, cdefs )
# Programming function
def progfunc_avr32( target, source, env ):
outname = output + ".elf"
os.system( "avr32-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( "avr32-objcopy -O ihex %s %s.hex" % ( outname, output ) )
os.system( "%s -O ihex %s %s.hex" % ( toolset[ 'bin' ], outname, output ) )
# print "Programming..."
# os.system( "batchisp3.sh -hardware usb -device at32uc3a0512 -operation erase f memory flash blankcheck loadbuffer %s program verify start reset 0" % ( output + ".hex" ) )

View File

@ -9,14 +9,14 @@ ldscript = "src/platform/%s/%s" % ( platform, ldscript )
# Toolset data
tools[ 'i386' ] = {}
tools[ 'i386' ][ 'cccom' ] = "i686-elf-gcc %s %s -march=i386 -mfpmath=387 -m32 -ffunction-sections -fdata-sections -fno-builtin -fno-stack-protector %s -Wall -c $SOURCE -o $TARGET" % ( opt, local_include, cdefs )
tools[ 'i386' ][ 'linkcom' ] = "i686-elf-gcc -nostartfiles -nostdlib -march=i386 -mfpmath=387 -m32 -T %s -Wl,--gc-sections -Wl,-e,start -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( ldscript, local_libs )
tools[ 'i386' ][ 'ascom' ] = "nasm -felf $SOURCE"
tools[ 'i386' ][ 'cccom' ] = "%s %s %s -march=i386 -mfpmath=387 -m32 -ffunction-sections -fdata-sections -fno-builtin -fno-stack-protector %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], opt, local_include, cdefs )
tools[ 'i386' ][ 'linkcom' ] = "%s -nostartfiles -nostdlib -march=i386 -mfpmath=387 -m32 -T %s -Wl,--gc-sections -Wl,-e,start -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( toolset[ 'compile' ], ldscript, local_libs )
tools[ 'i386' ][ 'ascom' ] = "%s -felf $SOURCE" % toolset[ 'asm' ]
# Programming function for i386 (not needed, empty function)
def progfunc_i386( target, source, env ):
outname = output + ".elf"
os.system( "i686-elf-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Visit http://www.eluaproject.net for instructions on how to use your eLua ELF file"
tools[ 'i386' ][ 'progfunc' ] = progfunc_i386

View File

@ -7,12 +7,6 @@ if boardname == 'EK-LM3S6965' or boardname == 'EK-LM3S8962':
ldscript = "lm3s.ld"
# Use default toolchain prefix if one isn't provided
if cprefix == '':
cprefix= "arm-elf-"
else:
cprefix = cprefix + '-'
# Prepend with path
specific_files = " ".join( [ "src/platform/%s/%s" % ( platform, f ) for f in specific_files.split() ] )
ldscript = "src/platform/%s/%s" % ( platform, ldscript )
@ -21,20 +15,15 @@ cdefs = cdefs + " -DFOR" + cputype + " -Dgcc"
# Toolset data
tools[ 'lm3s' ] = {}
tools[ 'lm3s' ][ 'cccom' ] = cprefix + "gcc -mcpu=cortex-m3 -mthumb %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( opt, local_include, cdefs )
if cprefix == 'arm-elf-':
tools[ 'lm3s' ][ 'linkcom' ] = cprefix + "gcc -nostartfiles -nostdlib -T %s -Wl,--gc-sections -Wl,-e,ResetISR -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( ldscript, local_libs )
else:
tools[ 'lm3s' ][ 'linkcom' ] = cprefix + "gcc -mthumb -mcpu=cortex-m3 -nostartfiles -T %s -Wl,--gc-sections -Wl,-e,ResetISR -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lm %s" % ( ldscript, local_libs )
tools[ 'lm3s' ][ 'ascom' ] = cprefix + "gcc -x assembler-with-cpp %s -mcpu=cortex-m3 -mthumb %s -Wall -c $SOURCE -o $TARGET" % ( local_include, cdefs )
tools[ 'lm3s' ][ 'cccom' ] = "%s -mcpu=cortex-m3 -mthumb %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], opt, local_include, cdefs )
tools[ 'lm3s' ][ 'linkcom' ] = "%s -mthumb -mcpu=cortex-m3 -nostartfiles -T %s -Wl,--gc-sections -Wl,-e,ResetISR -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lm %s" % ( toolset[ 'compile' ], ldscript, local_libs )
tools[ 'lm3s' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mcpu=cortex-m3 -mthumb %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, cdefs )
# Programming function
def progfunc_lm3s( target, source, env ):
outname = output + ".elf"
os.system( cprefix + "size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( cprefix + "objcopy -O binary %s %s.bin" % ( outname, output ) )
os.system( "%s -O binary %s %s.bin" % ( toolset[ 'bin' ], outname, output ) )
tools[ 'lm3s' ][ 'progfunc' ] = progfunc_lm3s

View File

@ -31,15 +31,15 @@ ldscript = "src/platform/%s/%s" % ( platform, ldscript )
# Toolset data
tools[ 'lpc288x' ] = {}
tools[ 'lpc288x' ][ 'cccom' ] = "arm-elf-gcc -mcpu=arm7tdmi %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( opt, local_include, modeflag, cdefs )
tools[ 'lpc288x' ][ 'linkcom' ] = "arm-elf-gcc -mcpu=arm7tdmi -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,HardReset -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( modeflag, ldscript, local_libs )
tools[ 'lpc288x' ][ 'ascom' ] = "arm-elf-gcc -x assembler-with-cpp %s -mcpu=arm7tdmi %s %s -Wall -c $SOURCE -o $TARGET" % ( local_include, modeflag, cdefs )
tools[ 'lpc288x' ][ 'cccom' ] = "%s -mcpu=arm7tdmi %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], opt, local_include, modeflag, cdefs )
tools[ 'lpc288x' ][ 'linkcom' ] = "%s -mcpu=arm7tdmi -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,HardReset -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( toolset[ 'compile' ], modeflag, ldscript, local_libs )
tools[ 'lpc288x' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mcpu=arm7tdmi %s %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, modeflag, cdefs )
# Programming function for LPC2888
def progfunc_lpc288x( target, source, env ):
outname = output + ".elf"
os.system( "arm-elf-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( "arm-elf-objcopy -O binary %s %s.bin" % ( outname, output ) )
os.system( "%s -O binary %s %s.bin" % ( toolset[ 'bin' ], outname, output ) )
tools[ 'lpc288x' ][ 'progfunc' ] = progfunc_lpc288x

View File

@ -25,6 +25,8 @@ SECTIONS
. = ALIGN(4);
_efixed = .;
PROVIDE(etext = .);
_fini = .;
*(.fini)
} >flash
.relocate : AT (_efixed)
@ -37,6 +39,18 @@ SECTIONS
_erelocate = .;
} >sram
.ARM.extab :
{
*(.ARM.extab*)
} >sram
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx*)
} >sram
__exidx_end = .;
.bss (NOLOAD) : {
_szero = .;
*(.bss .bss.*)

View File

@ -23,17 +23,17 @@ cdefs = cdefs + " -Dgcc"
# Toolset data
tools[ 'stm32' ] = {}
tools[ 'stm32' ][ 'cccom' ] = "arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mlittle-endian %s %s -ffunction-sections -fdata-sections -fno-strict-aliasing %s -Wall -c $SOURCE -o $TARGET" % ( opt, local_include, cdefs )
#tools[ 'stm32' ][ 'linkcom' ] = "arm-none-eabi-gcc -nostartfiles -nostdlib -T %s -Wl,--gc-sections -Wl,-e,ResetISR -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( ldscript, local_libs )
tools[ 'stm32' ][ 'linkcom' ] = "arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker %s -u _start -Wl,-e,Reset_Handler -Wl,-static -Wl,--gc-sections -nostartfiles -nostdlib -Wl,-Map -Xlinker project.map -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( ldscript, local_libs )
tools[ 'stm32' ][ 'ascom' ] = "arm-none-eabi-gcc -x assembler-with-cpp %s -mcpu=cortex-m3 -mthumb %s -Wall -c $SOURCE -o $TARGET" % ( local_include, cdefs )
tools[ 'stm32' ][ 'cccom' ] = "%s -mcpu=cortex-m3 -mthumb -mlittle-endian %s %s -ffunction-sections -fdata-sections -fno-strict-aliasing %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], opt, local_include, cdefs )
tools[ 'stm32' ][ 'linkcom' ] = "%s -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker %s -u _start -Wl,-e,Reset_Handler -Wl,-static -Wl,--gc-sections -nostartfiles -nostdlib -Wl,-Map -Xlinker project.map -Wl,--allow-multiple-definition -o $TARGET $SOURCES -lc -lgcc -lm %s" % ( toolset[ 'compile' ], ldscript, local_libs )
tools[ 'stm32' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mcpu=cortex-m3 -mthumb %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, cdefs )
# Programming function
def progfunc_stm32( target, source, env ):
outname = output + ".elf"
os.system( "arm-none-eabi-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( "arm-none-eabi-objcopy -O binary %s %s.bin" % ( outname, output ) )
os.system( "arm-none-eabi-objcopy -O ihex %s %s.hex" % ( outname, output ) )
os.system( "%s -O binary %s %s.bin" % ( toolset[ 'bin' ], outname, output ) )
os.system( "%s -O ihex %s %s.hex" % ( toolset[ 'bin' ], outname, output ) )
tools[ 'stm32' ][ 'progfunc' ] = progfunc_stm32

View File

@ -5,6 +5,7 @@
#include "auxmods.h"
#include "type.h"
#include "stacks.h"
// *****************************************************************************
// Define here what components you want for this platform
@ -18,7 +19,6 @@
//#define BUILD_DNS
#define BUILD_CON_GENERIC
//#define BUILD_CON_TCP
#define EXTENDED_PLATFORM_DATA
// *****************************************************************************
// UART/Timer IDs configuration data (used in main.c)
@ -34,24 +34,14 @@
// *****************************************************************************
// Auxiliary libraries that will be compiled for this platform
#ifdef FORSTM3210E_EVAL
#define AUXLIB_LCD "stm3210lcd"
LUALIB_API int ( luaopen_lcd )( lua_State* L );
#if 0
#define LUA_PLATFORM_LIBS\
{ AUXLIB_PIO, luaopen_pio },\
{ AUXLIB_SPI, luaopen_spi },\
{ AUXLIB_TMR, luaopen_tmr },\
{ AUXLIB_PD, luaopen_pd },\
{ AUXLIB_UART, luaopen_uart },\
{ AUXLIB_TERM, luaopen_term },\
{ AUXLIB_PWM, luaopen_pwm },\
{ AUXLIB_PACK, luaopen_pack },\
{ AUXLIB_BIT, luaopen_bit },\
{ AUXLIB_NET, luaopen_net },\
{ AUXLIB_CPU, luaopen_cpu },\
{ LUA_MATHLIBNAME, luaopen_math }
#define LCDLINE _ROM( AUXLIB_LCD, luaopen_lcd, lcd_map )
#else
#define LCDLINE
#endif
#define LUA_PLATFORM_LIBS_ROM\
_ROM( AUXLIB_PIO, luaopen_pio, pio_map )\
_ROM( AUXLIB_PD, luaopen_pd, pd_map )\
@ -60,9 +50,8 @@ LUALIB_API int ( luaopen_lcd )( lua_State* L );
_ROM( AUXLIB_PACK, luaopen_pack, pack_map )\
_ROM( AUXLIB_BIT, luaopen_bit, bit_map )\
_ROM( AUXLIB_CPU, luaopen_cpu, cpu_map )\
_ROM( AUXLIB_LCD, luaopen_lcd, lcd_map )\
LCDLINE\
_ROM( LUA_MATHLIBNAME, luaopen_math, math_map )
#endif
// *****************************************************************************
// Configuration data
@ -117,10 +106,9 @@ u32 platform_s_cpu_get_frequency();
// Allocator data: define your free memory zones here in two arrays
// (start address and end address)
#define STACK_SIZE 256
#define SRAM_SIZE ( 64 * 1024 )
#define MEM_START_ADDRESS { ( void* )end }
#define MEM_END_ADDRESS { ( void* )( SRAM_BASE + SRAM_SIZE - STACK_SIZE - 1 ) }
#define MEM_END_ADDRESS { ( void* )( SRAM_BASE + SRAM_SIZE - STACK_SIZE_TOTAL - 1 ) }
// *****************************************************************************
// CPU constants that should be exposed to the eLua "cpu" module

View File

@ -0,0 +1,9 @@
// Stack size definitions
#ifndef __STACKS_H__
#define __STACKS_H__
#define STACK_SIZE 2048
#define STACK_SIZE_TOTAL ( STACK_SIZE )
#endif

View File

@ -1,244 +1,66 @@
/*
Default linker script for STM32F10x_512K_64K
Copyright RAISONANCE S.A.S. 2008
*/
/* include the common STM32F10x sub-script */
/* Common part of the linker scripts for STM32 devices*/
/* default stack sizes.
These are used by the startup in order to allocate stacks for the different modes.
*/
__Stack_Size = 2048 ;
PROVIDE ( _Stack_Size = __Stack_Size ) ;
__Stack_Init = _estack - __Stack_Size ;
/*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
PROVIDE ( _Stack_Init = __Stack_Init ) ;
/*
There will be a link error if there is not this amount of RAM free at the end.
*/
_Minimum_Stack_Size = 0x100 ;
/* include the memory spaces definitions sub-script */
/*
Linker subscript for STM32F10x definitions with 512K Flash and 64K RAM */
/* Memory Spaces Definitions */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
EXTSRAM (xrw) : ORIGIN = 0x68000000, LENGTH = 8192K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 64k
flash (RX) : ORIGIN = 0x08000000, LENGTH = 512k
}
/* higher address of the user mode stack */
_estack = 0x20010000;
/* include the sections management sub-script for FLASH mode */
/* Sections Definitions */
SECTIONS
{
/* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */
.flashtext :
{
. = ALIGN(4);
*(.flashtext) /* Startup code */
. = ALIGN(4);
} >FLASH
/* the program code is stored in the .text section, which goes to Flash */
.text :
{
. = ALIGN(4);
_text = .;
PROVIDE(stext = .);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
KEEP(*(.isr_vector))
KEEP(*(.init))
*(.text .text.*)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
. = ALIGN(4);
_etext = .;
PROVIDE(etext = .);
/* This is used by the startup in order to initialize the .data secion */
_sidata = _etext;
} >FLASH
_fini = . ;
*(.fini)
} >flash
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data : AT ( _sidata )
.data : AT (_etext)
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;
*(.data)
*(.data.*)
_data = .;
*(.ramfunc .ramfunc.* .fastrun .fastrun.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_edata = .;
} >RAM
} >sram
/* This is the uninitialized data section */
.bss :
.ARM.extab :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .;
*(.ARM.extab*)
} >sram
*(.bss)
*(.bss.*)
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx*)
} >sram
__exidx_end = .;
.bss (NOLOAD) : {
_bss = .;
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = .;
} >RAM
} >sram
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
/* This is the user stack section
This is just to check that there is enough RAM left for the User mode stack
It should generate an error if it's full.
*/
._usrstack :
{
. = ALIGN(4);
_susrstack = . ;
. = . + _Minimum_Stack_Size ;
. = ALIGN(4);
_eusrstack = . ;
} >RAM
/* this is the FLASH Bank1 */
/* the C or assembly source must explicitly place the code or data there
using the "section" attribute */
.b1text :
{
*(.b1text) /* remaining code */
*(.b1rodata) /* read-only data (constants) */
*(.b1rodata*)
} >FLASHB1
/* this is the EXTMEM */
/* the C or assembly source must explicitly place the code or data there
using the "section" attribute */
/* EXTMEM Bank0 */
.eb0text :
{
*(.eb0text) /* remaining code */
*(.eb0rodata) /* read-only data (constants) */
*(.eb0rodata*)
} >EXTMEMB0
/* EXTMEM Bank1 */
.eb1text :
{
*(.eb1text) /* remaining code */
*(.eb1rodata) /* read-only data (constants) */
*(.eb1rodata*)
} >EXTMEMB1
/* EXTMEM Bank2 */
.eb2text :
{
*(.eb2text) /* remaining code */
*(.eb2rodata) /* read-only data (constants) */
*(.eb2rodata*)
} >EXTMEMB2
/* EXTMEM Bank0 */
.eb3text :
{
*(.eb3text) /* remaining code */
*(.eb3rodata) /* read-only data (constants) */
*(.eb3rodata*)
} >EXTMEMB3
/* after that it's only debugging information. */
/* remove the debugging information from the standard libraries */
DISCARD :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
end = .;
PROVIDE( _estack = 0x20010000 );
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}

View File

@ -40,16 +40,15 @@ typedef union { intfunc __fun; void * __ptr; } intvec_elem;
extern unsigned long _etext;
/* start address for the initialization values of the .data section.
defined in linker script */
extern unsigned long _sidata;
/* start address for the .data section. defined in linker script */
extern unsigned long _sdata;
extern unsigned long _data;
/* end address for the .data section. defined in linker script */
extern unsigned long _edata;
/* start address for the .bss section. defined in linker script */
extern unsigned long _sbss;
extern unsigned long _bss;
/* end address for the .bss section. defined in linker script */
extern unsigned long _ebss;
@ -194,13 +193,13 @@ unsigned long *pulSrc, *pulDest;
/* Copy the data segment initializers from flash to SRAM */
pulSrc = &_sidata;
for(pulDest = &_sdata; pulDest < &_edata; )
pulSrc = &_etext;
for(pulDest = &_data; pulDest < &_edata; )
{
*(pulDest++) = *(pulSrc++);
}
/* Zero fill the bss segment. */
for(pulDest = &_sbss; pulDest < &_ebss; )
for(pulDest = &_bss; pulDest < &_ebss; )
{
*(pulDest++) = 0;
}

View File

@ -33,7 +33,7 @@ void SysTick_Config(void)
*******************************************************************************/
void Delay(u32 nCount)
{
printf("Delay(%d)\n", nCount);
printf("Delay(%u)\n", (unsigned)nCount);
TimingDelay = nCount;
/* Enable the SysTick Counter */

View File

@ -24,15 +24,15 @@ ldscript = "src/platform/%s/%s" % ( platform, ldscript )
# Toolset data
tools[ 'str7' ] = {}
tools[ 'str7' ][ 'cccom' ] = "arm-elf-gcc -mcpu=arm7tdmi %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( modeflag, opt, local_include, cdefs )
tools[ 'str7' ][ 'linkcom' ] = "arm-elf-gcc -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,entry -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( modeflag, ldscript, local_libs )
tools[ 'str7' ][ 'ascom' ] = "arm-elf-gcc -x assembler-with-cpp %s -mcpu=arm7tdmi %s %s -Wall -c $SOURCE -o $TARGET" % ( local_include, modeflag, cdefs )
tools[ 'str7' ][ 'cccom' ] = "%s -mcpu=arm7tdmi %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], modeflag, opt, local_include, cdefs )
tools[ 'str7' ][ 'linkcom' ] = "%s -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,entry -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( toolset[ 'compile' ], modeflag, ldscript, local_libs )
tools[ 'str7' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mcpu=arm7tdmi %s %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, modeflag, cdefs )
# Programming function for LPC2888
def progfunc_str7( target, source, env ):
outname = output + ".elf"
os.system( "arm-elf-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( "arm-elf-objcopy -O binary %s %s.bin" % ( outname, output ) )
os.system( "%s -O binary %s %s.bin" % ( toolset[ 'bin' ], outname, output ) )
tools[ 'str7' ][ 'progfunc' ] = progfunc_str7

View File

@ -27,6 +27,8 @@ SECTIONS
. = ALIGN(4);
_efixed = .;
PROVIDE(etext = .);
_fini = .;
*(.fini)
} >flash
.relocate : AT (_efixed)
@ -40,6 +42,18 @@ SECTIONS
_erelocate = .;
} >sram
.ARM.extab :
{
*(.ARM.extab*)
} >sram
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx*)
} >sram
__exidx_end = .;
.bss (NOLOAD) : {
_szero = .;
*(.bss .bss.*)

View File

@ -26,15 +26,15 @@ ldscript = "src/platform/%s/%s" % ( platform, ldscript )
# Toolset data
tools[ 'str9' ] = {}
tools[ 'str9' ][ 'cccom' ] = "arm-elf-gcc -mcpu=arm966e-s -mfpu=fpa %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( opt, local_include, modeflag, cdefs )
tools[ 'str9' ][ 'linkcom' ] = "arm-elf-gcc -mcpu=arm966e-s -mfpu=fpa -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,_startup -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( modeflag, ldscript, local_libs )
tools[ 'str9' ][ 'ascom' ] = "arm-elf-gcc -x assembler-with-cpp %s -mcpu=arm966e-s -mfpu=fpa %s %s -Wall -c $SOURCE -o $TARGET" % ( local_include, modeflag, cdefs )
tools[ 'str9' ][ 'cccom' ] = "%s -mcpu=arm966e-s -mfpu=fpa %s %s %s -ffunction-sections -fdata-sections %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile'], opt, local_include, modeflag, cdefs )
tools[ 'str9' ][ 'linkcom' ] = "%s -mcpu=arm966e-s -mfpu=fpa -nostartfiles -nostdlib %s -T %s -Wl,--gc-sections -Wl,-e,_startup -Wl,--allow-multiple-definition -o $TARGET $SOURCES %s -lc -lgcc -lm" % ( toolset[ 'compile' ], modeflag, ldscript, local_libs )
tools[ 'str9' ][ 'ascom' ] = "%s -x assembler-with-cpp %s -mcpu=arm966e-s -mfpu=fpa %s %s -Wall -c $SOURCE -o $TARGET" % ( toolset[ 'compile' ], local_include, modeflag, cdefs )
# Programming function for LPC2888
def progfunc_str9( target, source, env ):
outname = output + ".elf"
os.system( "arm-elf-size %s" % outname )
os.system( "%s %s" % ( toolset[ 'size' ], outname ) )
print "Generating binary image..."
os.system( "arm-elf-objcopy -O binary %s %s.bin" % ( outname, output ) )
os.system( "%s -O binary %s %s.bin" % ( toolset[ 'bin' ], outname, output ) )
tools[ 'str9' ][ 'progfunc' ] = progfunc_str9

View File

@ -25,6 +25,8 @@ SECTIONS
. = ALIGN(4);
_efixed = .;
PROVIDE(etext = .);
_fini = .;
*(.fini)
} >flash
.relocate : AT (_efixed)
@ -37,6 +39,18 @@ SECTIONS
_erelocate = .;
} >sram
.ARM.extab :
{
*(.ARM.extab*)
} >sram
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx*)
} >sram
__exidx_end = .;
.bss (NOLOAD) : {
_szero = .;
*(.bss .bss.*)

View File

@ -136,7 +136,7 @@ static void shell_recv( char* args )
while( *p == '\x1A' )
p --;
p ++;
printf( "done, got %ld bytes\n", p - shell_prog );
printf( "done, got %u bytes\n", ( unsigned )( p - shell_prog ) );
// Execute
if( ( L = lua_open() ) == NULL )