-
Notifications
You must be signed in to change notification settings - Fork 6
/
ProgramBootblock_Secure.py
42 lines (30 loc) · 1.34 KB
/
ProgramBootblock_Secure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# SPDX-License-Identifier: GPL-2.0
#
# Nuvoton IGPS: Image Generation And Programming Scripts For Poleg BMC
#
# Copyright (C) 2019 Nuvoton Technologies, All Rights Reserved
#-------------------------------------------------------------------------
import os
from shutil import copyfile
import ImageGeneration.BinaryGenerator
import ImageProgramming.Program
Programming_inputs_dir = os.path.join("ImageProgramming", "inputs")
Intermediate_dir = os.path.join("ImageGeneration", "intermediate")
FW_and_Header_bin = os.path.join("ImageGeneration", "output_binaries", "Secure", "BootBlockAndHeader.bin")
FW_Programming_xml = os.path.join(Programming_inputs_dir, "BootBlockProgramming.xml")
FW_Programming_bin = os.path.join(Intermediate_dir, "BootBlockProgramming.bin")
FW_bin_intermediate = os.path.join(Intermediate_dir, "BootBlockAndHeader.bin")
try:
currpath = os.getcwd()
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if not os.path.isdir(Intermediate_dir):
os.mkdir(Intermediate_dir)
copyfile(FW_and_Header_bin, FW_bin_intermediate)
ImageGeneration.BinaryGenerator.generate_binary( os.path.abspath(FW_Programming_xml), \
os.path.abspath(FW_Programming_bin))
ImageProgramming.Program.run( os.path.abspath(FW_and_Header_bin), \
os.path.abspath(FW_Programming_bin))
except Exception as e:
print(e)
finally:
os.chdir(currpath)