1#!/usr/bin/env python3
2#
3# Copyright (c) 2021 ASPEED Technology Inc.
4#
5# SPDX-License-Identifier: Apache-2.0
6#
7
8import sys
9
10if __name__ == "__main__":
11    src = sys.argv[1]
12    dst = sys.argv[2]
13
14    with open(src,'rb') as r:
15        src_image = r.read()
16
17    # get src size and round up to 4-byte align
18    src_len = len(src_image)
19    src_len_align = (src_len + 3) & (~3)
20    src_len_byte = src_len_align.to_bytes(4, byteorder='little', signed=False)
21
22    dst_image = src_len_byte + src_image
23
24    with open(dst, 'w+b') as w:
25        w.write(dst_image)
26