Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
7b6ecb1b
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7b6ecb1b
编写于
10月 12, 2021
作者:
G
guo
提交者:
GitHub
10月 12, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5137 from mysterywolf/tool
[tools] 增加将汇编启动文件入口函数由main改为entry的自动扫描脚本
上级
2ee81eda
1c90cb36
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
142 addition
and
0 deletion
+142
-0
bsp/stm32/tools/upgrade.py
bsp/stm32/tools/upgrade.py
+142
-0
未找到文件。
bsp/stm32/tools/upgrade.py
0 → 100644
浏览文件 @
7b6ecb1b
#
# File : upgrade.py
# This file is part of RT-Thread RTOS
# COPYRIGHT (C) 2006 - 2021, RT-Thread Development Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Change Logs:
# Date Author Notes
# 2021-10-11 Meco Man First version
#
# 本文件用于在HAL库更新之后
# 1.对gcc的汇编启动文件中main替换为entry函数
# 2.将启动文件heap降为0
#使用方法:运行脚本,将bsp/stm32的绝对路径传给脚本即可,如:C:\Users\92036\Desktop\rt-thread\bsp\stm32
import
os
import
re
#将'bl main' 替换为 'bl entry'
def
main2entry
(
path
):
oldline
=
''
newline
=
''
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
#递归扫描里面的所有文件
for
file
in
files
:
if
os
.
path
.
splitext
(
file
)[
1
]
==
'.s'
:
#找.s文件
file_path
=
os
.
path
.
join
(
root
,
file
)
flag_need_replace
=
False
with
open
(
file_path
,
'r+'
,)
as
f
:
while
True
:
line
=
f
.
readline
()
if
line
==
''
:
break
elif
(
'bl'
in
line
)
and
(
'main'
in
line
):
#发现'bl main'
oldline
=
line
# bl main
newline
=
line
.
replace
(
'main'
,
'entry'
)
#将main替换为entry,形成新的字符串
flag_need_replace
=
True
#标记该文件需要做entry替换
break
if
(
flag_need_replace
==
True
):
#若该文件需要将main替换为entry
f
.
seek
(
0
)
content
=
f
.
read
()
f
.
seek
(
0
)
f
.
truncate
()
newcontent
=
content
.
replace
(
oldline
,
newline
)
f
.
write
(
newcontent
)
#将启动文件的heap降为0
def
heap2zero
(
path
):
oldline
=
''
newline
=
''
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
#递归扫描里面的所有文件
for
file
in
files
:
file_path
=
os
.
path
.
join
(
root
,
file
)
if
os
.
path
.
splitext
(
file
)[
1
]
==
'.s'
:
#找.s文件
with
open
(
file_path
,
'r+'
,)
as
f
:
flag_need_replace
=
False
while
True
:
line
=
f
.
readline
()
if
line
==
''
:
break
re_result
=
re
.
match
(
'\s*Heap_Size\s+EQU\s+0[xX][0-9a-fA-F]+'
,
line
)
#MDK的表示方法
if
re_result
!=
None
:
oldline
=
line
newline
=
re
.
sub
(
'0[xX][0-9a-fA-F]+'
,
'0x00000000'
,
oldline
)
flag_need_replace
=
True
break
if
flag_need_replace
==
True
:
f
.
seek
(
0
)
content
=
f
.
read
()
f
.
seek
(
0
)
f
.
truncate
()
newcontent
=
content
.
replace
(
oldline
,
newline
)
f
.
write
(
newcontent
)
elif
os
.
path
.
splitext
(
file
)[
1
]
==
'.icf'
:
#找.icf文件(IAR)
with
open
(
file_path
,
'r+'
,)
as
f
:
flag_need_replace
=
False
while
True
:
line
=
f
.
readline
()
if
line
==
''
:
break
re_result
=
re
.
match
(
'\s*define\s+symbol\s+__ICFEDIT_size_heap__\s*=\s*0[xX][0-9a-fA-F]+'
,
line
)
#IAR的表示方法
if
re_result
!=
None
:
oldline
=
line
newline
=
re
.
sub
(
'0[xX][0-9a-fA-F]+'
,
'0x000'
,
oldline
)
flag_need_replace
=
True
break
if
flag_need_replace
==
True
:
f
.
seek
(
0
)
content
=
f
.
read
()
f
.
seek
(
0
)
f
.
truncate
()
newcontent
=
content
.
replace
(
oldline
,
newline
)
f
.
write
(
newcontent
)
elif
os
.
path
.
splitext
(
file
)[
1
]
==
'.lds'
:
#找.lds文件(GCC)
with
open
(
file_path
,
'r+'
,)
as
f
:
flag_need_replace
=
False
while
True
:
line
=
f
.
readline
()
if
line
==
''
:
break
re_result
=
re
.
match
(
'\s*_system_stack_size\s*=\s*0[xX][0-9a-fA-F]+'
,
line
)
#GCC的表示方法
if
re_result
!=
None
:
oldline
=
line
newline
=
re
.
sub
(
'0[xX][0-9a-fA-F]+'
,
'0x000'
,
oldline
)
flag_need_replace
=
True
break
if
flag_need_replace
==
True
:
f
.
seek
(
0
)
content
=
f
.
read
()
f
.
seek
(
0
)
f
.
truncate
()
newcontent
=
content
.
replace
(
oldline
,
newline
)
f
.
write
(
newcontent
)
folder_path
=
input
(
'please input path:'
)
main2entry
(
folder_path
)
heap2zero
(
folder_path
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录