#!/usr/bin/env python3 # encoding=utf-8 # Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys import struct sys.path.append(os.path.dirname(__file__)) from conf_parser import BuildConfParser, ParserError from utils.build_utils import fn_str_to_int ## ## Params Area Stucture ## ## Image_ID: 4B ## Struct_Version: 4B ## Version: 4B ## Item_Offset: 2B ## Item_Count: 1B ## ItemID_List: Item_Count ## Padding_Area: Item_Offset - 15 - Item_Count ## Item_List: (4B + 4B) * Item_Count ## def param_area(dst_file, image_id, stru_ver, version, param_info) -> None: item_num = len(param_info) item_offset = 15 + item_num item_offset = int((item_offset + 3) / 4) * 4 ## image_id, stru_ver, version, item_offset, item_num bin_size = 1024 binary = struct.pack("