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:
Chen Wang 2025-04-10 18:27:28 +08:00 committed by Rbb666
parent 90e81cf4b6
commit 2a00bd4ecb
5 changed files with 31 additions and 10 deletions

1
bsp/k230/.gitignore vendored
View File

@ -4,6 +4,7 @@ packages/
install/
rtthread.*
link.lds.generated
__pycache__
.config.old

View File

@ -1,10 +1,36 @@
import os
import sys
import rtconfig
import platform
import subprocess
from rtconfig import RTT_ROOT
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')]
from building import *
@ -26,12 +52,7 @@ Export('rtconfig')
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
stack_size = 4096
stack_lds = open('link_stacksize.lds', 'w')
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
stack_lds.close()
generate_ldscript('link.lds', 'link.lds.generated')
# make a building
DoBuilding(TARGET, objs)

View File

@ -8,7 +8,7 @@
* 2020/12/12 bernard The first version
*/
INCLUDE "link_stacksize.lds"
#include "rtconfig.h"
OUTPUT_ARCH( "riscv" )
@ -22,7 +22,7 @@ OUTPUT_ARCH( "riscv" )
MEMORY
{
SRAM : ORIGIN = 0xffffffc000020000, LENGTH = 262012K
SRAM : ORIGIN = KERNEL_VADDR_START, LENGTH = 262012K
}
ENTRY(_start)

View File

@ -1 +0,0 @@
__STACKSIZE__ = 65536;

View File

@ -44,7 +44,7 @@ if PLATFORM == 'gcc':
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 '
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 = ''
LPATH = ''