Skip to content

Commit dd7da0f

Browse files
CYFS3Rbb666
authored andcommitted
bsp: support env shared package paths
1 parent f12485a commit dd7da0f

24 files changed

Lines changed: 391 additions & 101 deletions

File tree

bsp/ESP/ESP32_C3/SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import sys
3-
import rtconfig
43
from esptool.bin_image import ELFFile, ImageSegment, LoadFirmwareImage
54
from esptool.targets import CHIP_DEFS, CHIP_LIST, ROM_LIST
65

@@ -40,6 +39,7 @@ else:
4039
RTT_ROOT = os.path.join(os.getcwd(), '..', '..', '..')
4140

4241
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
42+
import rtconfig
4343
from building import *
4444

4545
TARGET = 'rtthread.' + rtconfig.TARGET_EXT

bsp/ESP/ESP32_C3/rtconfig.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import os
2+
import sys
3+
4+
BSP_ROOT = os.path.dirname(os.path.abspath(__file__))
5+
RTT_ROOT = os.getenv('RTT_ROOT') or os.path.normpath(os.path.join(BSP_ROOT, '..', '..', '..'))
6+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
7+
from env_package import find_package_path
28

39
# toolchains options
410
ARCH ='risc-v'
@@ -8,7 +14,7 @@
814
if os.getenv('RTT_CC'):
915
CROSS_TOOL = os.getenv('RTT_CC')
1016

11-
if CROSS_TOOL == 'gcc':
17+
if CROSS_TOOL == 'gcc':
1218
PLATFORM = 'gcc'
1319
EXEC_PATH = r'~/.espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin'
1420
else:
@@ -38,8 +44,9 @@
3844
DEVICE = ' -nostartfiles -march=rv32imc --specs=nosys.specs -fasynchronous-unwind-tables '
3945
CFLAGS = DEVICE + '-include ../../components/libc/compilers/common/include/sys/ioctl.h -gdwarf-4 -ggdb -Og '
4046
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
41-
LFLAGS = DEVICE + ' -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32C3=0 -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T idf_port/ld/memory.ld -T idf_port/ld/sections.ld -T packages/ESP-IDF-latest/components/esp_rom/esp32c3/ld/esp32c3.rom.ld -T packages/ESP-IDF-latest/components/esp_rom/esp32c3/ld/esp32c3.rom.api.ld -T packages/ESP-IDF-latest/components/esp_rom/esp32c3/ld/esp32c3.rom.libgcc.ld -T packages/ESP-IDF-latest/components/esp_rom/esp32c3/ld/esp32c3.rom.newlib.ld -T packages/ESP-IDF-latest/components/esp_rom/esp32c3/ld/esp32c3.rom.version.ld -T packages/ESP-IDF-latest/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld -T packages/ESP-IDF-latest/components/soc/esp32c3/ld/esp32c3.peripherals.ld -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_table -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__deregister_frame_info -Wl,--wrap=_Unwind_Find_FDE -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=__cxa_call_unexpected -Wl,--eh-frame-hdr -Wl,--wrap=__gxx_personality_v0 -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32C3=0'
42-
CXXFLAGS = CFLAGS
47+
idf_path = find_package_path(BSP_ROOT, 'ESP-IDF-latest', relative_to=BSP_ROOT, pathsep='/')
48+
LFLAGS = DEVICE + ' -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32C3=0 -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T idf_port/ld/memory.ld -T idf_port/ld/sections.ld -T ' + idf_path + '/components/esp_rom/esp32c3/ld/esp32c3.rom.ld -T ' + idf_path + '/components/esp_rom/esp32c3/ld/esp32c3.rom.api.ld -T ' + idf_path + '/components/esp_rom/esp32c3/ld/esp32c3.rom.libgcc.ld -T ' + idf_path + '/components/esp_rom/esp32c3/ld/esp32c3.rom.newlib.ld -T ' + idf_path + '/components/esp_rom/esp32c3/ld/esp32c3.rom.version.ld -T ' + idf_path + '/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld -T ' + idf_path + '/components/soc/esp32c3/ld/esp32c3.peripherals.ld -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_table -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__deregister_frame_info -Wl,--wrap=_Unwind_Find_FDE -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=__cxa_call_unexpected -Wl,--eh-frame-hdr -Wl,--wrap=__gxx_personality_v0 -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32C3=0'
49+
CXXFLAGS = CFLAGS
4350

4451
POST_ACTION = OBJCPY + ' -Oihex $TARGET rtthread.hex\n' + SIZE + ' $TARGET \n'
4552

bsp/Infineon/libraries/templates/XMC7200D/SConstruct

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,10 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
if os.path.exists(SDK_ROOT + '/packages'):
40-
libraries_path_prefix = SDK_ROOT + '/packages'
41-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4242
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4344

4445
SDK_LIB = libraries_path_prefix
4546
Export('SDK_LIB')

bsp/Infineon/psoc6-cy8ckit-062-BLE/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

bsp/Infineon/psoc6-cy8ckit-062-WIFI-BT/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

bsp/Infineon/psoc6-cy8ckit-062S2-43012/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

bsp/Infineon/psoc6-cy8ckit-062s4/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

bsp/Infineon/psoc6-cy8cproto-062S3-4343W/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

bsp/Infineon/psoc6-evaluationkit-062S2/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

bsp/Infineon/xmc7100d-f144k4160aa/SConstruct

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else:
1010
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
1111
try:
1212
from building import *
13+
from env_package import find_package_root
1314
except:
1415
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
1516
print(RTT_ROOT)
@@ -36,12 +37,10 @@ Export('rtconfig')
3637

3738
SDK_ROOT = os.path.abspath('./')
3839

39-
libraries_path_prefix = SDK_ROOT
40-
41-
if os.path.exists(SDK_ROOT + '/packages'):
42-
libraries_path_prefix = SDK_ROOT + '/packages'
43-
else:
40+
libraries_path_prefix = find_package_root(SDK_ROOT, package_prefix='Infineon_mtb-pdl-cat1')
41+
if not libraries_path_prefix:
4442
print("Error: Packages for HAL_Driver does not exist, pull it in ENV using `pkg --update`.")
43+
libraries_path_prefix = os.path.join(SDK_ROOT, 'packages')
4544

4645
SDK_LIB = libraries_path_prefix
4746
Export('SDK_LIB')

0 commit comments

Comments
 (0)