Skip to content

[Bug] stm32 bsp 里面,hal 的获取,支持的开发板是从远程获取的,template 是从本地获取的,但是本地的hal 新版没有了,所以template 报错 #11516

Description

@ziyouchutuwenwu

RT-Thread Version

5.2.2

Hardware Type/Architectures

stm32f411ceu6

Develop Toolchain

GCC

Describe the bug

我系统是linux, 没有装studio, 我用的是手动复制template的模式来做的

1, 复制 $RTT_SRC/bsp/stm32/stm32f411-atk-nano 为 aaa
2, 复制 $RTT_SRC/bsp/stm32/libraries/templates/stm32f4xx 为 bbb

aaa下

# scons 提示要先 pkgs --update
scons 正常

bbb 下

mmc at manjaro in ~/dev/embedded/rtt/repo/bsp/stm32/bbb (venv)
$ scons
scons: Reading SConscript files ...
/home/mmc/dev/embedded/rtt/repo/bsp/stm32/bbb/rtconfig.py:76: SyntaxWarning: "\l" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\l"? A raw string is also an option.
  LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict'
/home/mmc/dev/embedded/rtt/repo/bsp/stm32/bbb/rtconfig.py:76: SyntaxWarning: "\l" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\l"? A raw string is also an option.
  LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict'
Newlib version: 4.5.0

scons: *** missing SConscript file 'build/libraries/STM32F4xx_HAL/SConscript'
File "/home/mmc/dev/embedded/rtt/repo/bsp/stm32/bbb/SConstruct", line 54, in <module>

mmc at manjaro in ~/dev/embedded/rtt/repo/bsp/stm32/bbb (venv)
$ pkgs --update
Operation completed successfully.

mmc at manjaro in ~/dev/embedded/rtt/repo/bsp/stm32/bbb (venv)
$ scons
scons: Reading SConscript files ...
/home/mmc/dev/embedded/rtt/repo/bsp/stm32/bbb/rtconfig.py:76: SyntaxWarning: "\l" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\l"? A raw string is also an option.
  LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict'
/home/mmc/dev/embedded/rtt/repo/bsp/stm32/bbb/rtconfig.py:76: SyntaxWarning: "\l" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\l"? A raw string is also an option.
  LFLAGS = DEVICE + ' --scatter "board\linker_scripts\link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict'
Newlib version: 4.5.0

scons: *** missing SConscript file 'build/libraries/STM32F4xx_HAL/SConscript'
File "/home/mmc/dev/embedded/rtt/repo/bsp/stm32/bbb/SConstruct", line 54, in <module>

我看了一下 SConstruct,结构不一样的,我尝试把aaa的复制到bbb, 也是很多的错误

mmc at manjaro in ~/dev/embedded/rtt/repo/bsp/stm32/bbb (venv)
$ cat ../aaa/SConstruct
import os
import sys
import rtconfig

if os.getenv('RTT_ROOT'):
    RTT_ROOT = os.getenv('RTT_ROOT')
else:
    RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
    from building import *
except:
    print('Cannot found RT-Thread root directory, please check RTT_ROOT')
    print(RTT_ROOT)
    exit(-1)

def bsp_pkg_check():
    import subprocess

    check_paths = [
        os.path.join("packages", "CMSIS-Core-latest"),
        os.path.join("packages", "stm32f4_cmsis_driver-latest"),
        os.path.join("packages", "stm32f4_hal_driver-latest")
    ]

    need_update = not all(os.path.exists(p) for p in check_paths)

    if need_update:
        print("\n===============================================================================")
        print("Dependency packages missing, please running 'pkgs --update'...")
        print("If no packages are fetched, run 'pkgs --upgrade' first, then 'pkgs --update'...")
        print("===============================================================================")
        exit(1)

RegisterPreBuildingAction(bsp_pkg_check)

TARGET = 'rt-thread.' + rtconfig.TARGET_EXT

DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
    AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
    CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
    AR = rtconfig.AR, ARFLAGS = '-rc',
    CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
    LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)

if rtconfig.PLATFORM in ['iccarm']:
    env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
    env.Replace(ARFLAGS = [''])
    env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map')

Export('env')
Export('RTT_ROOT')
Export('rtconfig')

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

if os.path.exists(SDK_ROOT + '/libraries'):
    libraries_path_prefix = SDK_ROOT + '/libraries'
else:
    libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)

rtconfig.BSP_LIBRARY_TYPE = None

# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'),variant_dir='build/libraries/HAL_Drivers', duplicate=0))



# make a building
DoBuilding(TARGET, objs)

mmc at manjaro in ~/dev/embedded/rtt/repo/bsp/stm32/bbb (venv)
$ cat ./SConstruct
import os
import sys
import rtconfig

if os.getenv('RTT_ROOT'):
    RTT_ROOT = os.getenv('RTT_ROOT')
else:
    RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
    from building import *
except:
    print('Cannot found RT-Thread root directory, please check RTT_ROOT')
    print(RTT_ROOT)
    exit(-1)

TARGET = 'rt-thread.' + rtconfig.TARGET_EXT

DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
    AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
    CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
    AR = rtconfig.AR, ARFLAGS = '-rc',
    CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
    LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)

if rtconfig.PLATFORM in ['iccarm']:
    env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
    env.Replace(ARFLAGS = [''])
    env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map')

Export('RTT_ROOT')
Export('rtconfig')

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

if os.path.exists(SDK_ROOT + '/libraries'):
    libraries_path_prefix = SDK_ROOT + '/libraries'
else:
    libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'

SDK_LIB = libraries_path_prefix
Export('SDK_LIB')

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)

stm32_library = 'STM32F4xx_HAL'
rtconfig.BSP_LIBRARY_TYPE = stm32_library

# include libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'), variant_dir='build/libraries/'+stm32_library, duplicate=0))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'),variant_dir='build/libraries/'+'HAL_Drivers', duplicate=0))

# make a building
DoBuilding(TARGET, objs)

我记得几年前的时候,这样是可以的,看了一下分支,几年前的分支如下

Image Image Image

Other additional context

4.1 的lts里面,有很多的hal, 5.2里面只有一个L1, master里面都拿掉了,bsp/stm32/libraries/templates/ 里面获取hal 还是从本地拿的,新版的开发板里面,hal 是通过pkgs --update 从远程获取的, 这些 template 是不是忘记修改了?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions