mirror of https://github.com/RT-Thread/rt-thread
bsp: k230: use rtconfig.h for linkscript
For linker script, use constant macro defined from rtconfig.h, not immediate value. Also cleanup the link_statksize.lds, it is also not needed when using new mechanism. Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
parent
90e81cf4b6
commit
2a00bd4ecb
|
@ -4,6 +4,7 @@ packages/
|
||||||
install/
|
install/
|
||||||
|
|
||||||
rtthread.*
|
rtthread.*
|
||||||
|
link.lds.generated
|
||||||
|
|
||||||
__pycache__
|
__pycache__
|
||||||
.config.old
|
.config.old
|
||||||
|
|
|
@ -1,10 +1,36 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import rtconfig
|
import rtconfig
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from rtconfig import RTT_ROOT
|
from rtconfig import RTT_ROOT
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
def generate_ldscript(input, output):
|
||||||
|
|
||||||
|
if not os.path.exists(input):
|
||||||
|
print('Error: file', input, 'not found')
|
||||||
|
return
|
||||||
|
|
||||||
|
if os.path.exists(output):
|
||||||
|
os.remove(output)
|
||||||
|
|
||||||
|
if rtconfig.PLATFORM == 'gcc':
|
||||||
|
|
||||||
|
gcc_cmd = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
|
||||||
|
|
||||||
|
# gcc -E -P -x c $input -o $output
|
||||||
|
if (platform.system() == 'Windows'):
|
||||||
|
child = subprocess.Popen([gcc_cmd, '-E', '-P', '-x', 'c', input, '-o', output], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||||
|
else:
|
||||||
|
child = subprocess.Popen(gcc_cmd + f' -E -P -x c {input} -o {output}', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||||
|
|
||||||
|
child.communicate()
|
||||||
|
|
||||||
|
print(output, 'is generated from', input)
|
||||||
|
|
||||||
|
|
||||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||||
from building import *
|
from building import *
|
||||||
|
|
||||||
|
@ -26,12 +52,7 @@ Export('rtconfig')
|
||||||
# prepare building environment
|
# prepare building environment
|
||||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
||||||
|
|
||||||
stack_size = 4096
|
generate_ldscript('link.lds', 'link.lds.generated')
|
||||||
|
|
||||||
stack_lds = open('link_stacksize.lds', 'w')
|
|
||||||
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
|
|
||||||
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
|
|
||||||
stack_lds.close()
|
|
||||||
|
|
||||||
# make a building
|
# make a building
|
||||||
DoBuilding(TARGET, objs)
|
DoBuilding(TARGET, objs)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* 2020/12/12 bernard The first version
|
* 2020/12/12 bernard The first version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INCLUDE "link_stacksize.lds"
|
#include "rtconfig.h"
|
||||||
|
|
||||||
OUTPUT_ARCH( "riscv" )
|
OUTPUT_ARCH( "riscv" )
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ OUTPUT_ARCH( "riscv" )
|
||||||
|
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
SRAM : ORIGIN = 0xffffffc000020000, LENGTH = 262012K
|
SRAM : ORIGIN = KERNEL_VADDR_START, LENGTH = 262012K
|
||||||
}
|
}
|
||||||
|
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
__STACKSIZE__ = 65536;
|
|
|
@ -44,7 +44,7 @@ if PLATFORM == 'gcc':
|
||||||
DEVICE = ' -mcmodel=medany -march=rv64imafdcv -mabi=lp64d'
|
DEVICE = ' -mcmodel=medany -march=rv64imafdcv -mabi=lp64d'
|
||||||
CFLAGS = DEVICE + ' -Wno-cpp -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -D_POSIX_SOURCE '
|
CFLAGS = DEVICE + ' -Wno-cpp -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -D_POSIX_SOURCE '
|
||||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
|
||||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + ' -lsupc++ -lgcc -static'
|
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds.generated' + ' -lsupc++ -lgcc -static'
|
||||||
CPATH = ''
|
CPATH = ''
|
||||||
LPATH = ''
|
LPATH = ''
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue