| 16 | |
| 17 | # replace 'bl main' to 'bl entry' |
| 18 | def 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 |
| 47 | def stm32update_heap2zero(path): |