MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / stm32update_main2entry

Function stm32update_main2entry

tools/release/stm32_update.py:18–44  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

16
17# replace 'bl main' to 'bl entry'
18def stm32update_main2entry(path):
19 oldline = ''
20 newline = ''
21
22 for root, dirs, files in os.walk(path):
23 for file in files:
24 if os.path.splitext(file)[1] == '.s': # find .s files (Keil MDK)
25 file_path = os.path.join(root,file)
26 flag_need_replace = False
27 with open(file_path,'r+',) as f:
28 while True:
29 line = f.readline()
30 if line == '':
31 break
32 elif ('bl' in line) and ('main' in line): # find 'bl main'
33 oldline = line # bl main
34 newline = line.replace('main', 'entry') # use 'entry' to replace 'main'
35 flag_need_replace = True # mark that need to be replaced
36 break
37
38 if (flag_need_replace == True): # use 'entry' to replace 'main'
39 f.seek(0)
40 content = f.read()
41 f.seek(0)
42 f.truncate()
43 newcontent = content.replace(oldline, newline)
44 f.write(newcontent)
45
46#reduce the heap size as 0x000
47def stm32update_heap2zero(path):

Callers 1

stm32_updateFunction · 0.85

Calls 5

walkMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected