2018-06-22 23:02:05 -03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
script to build all of our bootloaders using AP_Bootloader and put the resulting binaries in Tools/bootloaders
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2018-07-04 08:21:09 -03:00
|
|
|
import fnmatch
|
|
|
|
|
|
|
|
board_pattern = '*'
|
|
|
|
|
|
|
|
# allow argument for pattern of boards to build
|
|
|
|
if len(sys.argv)>1:
|
|
|
|
board_pattern = sys.argv[1]
|
2018-06-22 23:02:05 -03:00
|
|
|
|
|
|
|
os.environ['PYTHONUNBUFFERED'] = '1'
|
|
|
|
|
2020-03-10 18:29:24 -03:00
|
|
|
failed_boards = set()
|
|
|
|
|
2018-06-22 23:02:05 -03:00
|
|
|
def get_board_list():
|
|
|
|
'''add boards based on existance of hwdef-bl.dat in subdirectories for ChibiOS'''
|
|
|
|
board_list = []
|
|
|
|
dirname, dirlist, filenames = next(os.walk('libraries/AP_HAL_ChibiOS/hwdef'))
|
|
|
|
for d in dirlist:
|
|
|
|
hwdef = os.path.join(dirname, d, 'hwdef-bl.dat')
|
|
|
|
if os.path.exists(hwdef):
|
|
|
|
board_list.append(d)
|
|
|
|
return board_list
|
|
|
|
|
|
|
|
def run_program(cmd_list):
|
|
|
|
print("Running (%s)" % " ".join(cmd_list))
|
|
|
|
retcode = subprocess.call(cmd_list)
|
|
|
|
if retcode != 0:
|
|
|
|
print("Build failed: %s" % ' '.join(cmd_list))
|
2020-03-10 18:29:24 -03:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def build_board(board):
|
2020-04-24 05:08:03 -03:00
|
|
|
if not run_program(["./waf", "configure", "--board", board, "--bootloader", "--no-submodule-update", "--Werror"]):
|
2020-03-10 18:29:24 -03:00
|
|
|
return False
|
|
|
|
if not run_program(["./waf", "clean"]):
|
|
|
|
return False
|
|
|
|
if not run_program(["./waf", "bootloader"]):
|
|
|
|
return False
|
|
|
|
return True
|
2018-06-22 23:02:05 -03:00
|
|
|
|
|
|
|
for board in get_board_list():
|
2018-07-04 08:21:09 -03:00
|
|
|
if not fnmatch.fnmatch(board, board_pattern):
|
|
|
|
continue
|
2018-06-22 23:02:05 -03:00
|
|
|
print("Building for %s" % board)
|
2020-03-10 18:29:24 -03:00
|
|
|
if not build_board(board):
|
|
|
|
failed_boards.add(board)
|
|
|
|
continue
|
2018-06-23 01:53:20 -03:00
|
|
|
shutil.copy('build/%s/bin/AP_Bootloader.bin' % board, 'Tools/bootloaders/%s_bl.bin' % board)
|
2020-03-10 18:29:24 -03:00
|
|
|
if not run_program(["Tools/scripts/bin2hex.py", "--offset", "0x08000000", 'Tools/bootloaders/%s_bl.bin' % board, 'Tools/bootloaders/%s_bl.hex' % board]):
|
|
|
|
failed_boards.add(board)
|
|
|
|
continue
|
2018-06-22 23:02:05 -03:00
|
|
|
shutil.copy('build/%s/bootloader/AP_Bootloader' % board, 'Tools/bootloaders/%s_bl.elf' % board)
|
2020-03-10 18:29:24 -03:00
|
|
|
|
|
|
|
if len(failed_boards):
|
|
|
|
print("Failed boards: %s" % list(failed_boards))
|