| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef INCLUDED_BUILDIMAGE_H |
| 25 |
#define INCLUDED_BUILDIMAGE_H |
| 26 |
|
| 27 |
#include <sys/types.h> |
| 28 |
#include <stdio.h> |
| 29 |
#include <stdlib.h> |
| 30 |
#include <assert.h> |
| 31 |
#include <errno.h> |
| 32 |
#include <math.h> |
| 33 |
#include <stdint.h> |
| 34 |
|
| 35 |
#define NVBOOT_AES_BLOCK_SIZE_LOG2 4 |
| 36 |
#define MAX_BUFFER 200 |
| 37 |
#define MAX_STR_LEN 20 |
| 38 |
#define MAX_BOOTLOADER_SIZE (16 * 1024 * 1024) |
| 39 |
#define NVBOOT_BOOTDATA_VERSION(a, b) ((((a)&0xffff) << 16) | ((b)&0xffff)) |
| 40 |
#define NVBOOT_BAD_BLOCK_TABLE_SIZE 4096 |
| 41 |
#define NV_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
| 42 |
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 43 |
|
| 44 |
#define BOOTDATA_VERSION_T20 NVBOOT_BOOTDATA_VERSION(0x2, 0x1) |
| 45 |
#define BOOTDATA_VERSION_T30 NVBOOT_BOOTDATA_VERSION(0x3, 0x1) |
| 46 |
#define BOOTDATA_VERSION_T114 NVBOOT_BOOTDATA_VERSION(0x35, 0x1) |
| 47 |
#define BOOTDATA_VERSION_T124 NVBOOT_BOOTDATA_VERSION(0x40, 0x1) |
| 48 |
#define BOOTDATA_VERSION_T132 NVBOOT_BOOTDATA_VERSION(0x13, 0x1) |
| 49 |
#define BOOTDATA_VERSION_T210 NVBOOT_BOOTDATA_VERSION(0x21, 0x1) |
| 50 |
|
| 51 |
#define MAX_MTS_SIZE (4 * 1024 * 1024) |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#define NVBOOT_CONFIG_TABLE_SIZE_MIN 4080 |
| 67 |
#define NVBOOT_CONFIG_TABLE_SIZE_MAX (10 * 1024) |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
typedef enum |
| 74 |
{ |
| 75 |
file_type_bl = 0, |
| 76 |
file_type_bct, |
| 77 |
file_type_mts, |
| 78 |
file_type_bin, |
| 79 |
} file_type; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
typedef struct build_image_context_rec |
| 85 |
{ |
| 86 |
FILE *config_file; |
| 87 |
char *output_image_filename; |
| 88 |
char *input_image_filename; |
| 89 |
FILE *raw_file; |
| 90 |
uint32_t block_size; |
| 91 |
uint32_t block_size_log2; |
| 92 |
uint32_t page_size; |
| 93 |
uint32_t page_size_log2; |
| 94 |
uint32_t pages_per_blk; |
| 95 |
uint32_t partition_size; |
| 96 |
uint32_t redundancy; |
| 97 |
uint32_t version; |
| 98 |
uint32_t bct_copy; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
uint32_t pre_bct_pad_blocks; |
| 106 |
|
| 107 |
struct blk_data_rec *memory; |
| 108 |
|
| 109 |
uint32_t next_bct_blk; |
| 110 |
|
| 111 |
char *newbl_filename; |
| 112 |
uint32_t newbl_load_addr; |
| 113 |
uint32_t newbl_entry_point; |
| 114 |
uint32_t newbl_attr; |
| 115 |
uint8_t generate_bct; |
| 116 |
uint8_t *bct; |
| 117 |
|
| 118 |
char *mts_filename; |
| 119 |
uint32_t mts_load_addr; |
| 120 |
uint32_t mts_entry_point; |
| 121 |
uint32_t mts_attr; |
| 122 |
|
| 123 |
char *bct_filename; |
| 124 |
uint32_t last_blk; |
| 125 |
uint32_t bct_size; |
| 126 |
uint32_t boot_data_version; |
| 127 |
uint8_t bct_init; |
| 128 |
uint32_t odm_data; |
| 129 |
uint8_t unique_chip_id[16]; |
| 130 |
uint8_t secure_jtag_control; |
| 131 |
uint32_t secure_debug_control; |
| 132 |
uint8_t update_image; |
| 133 |
} build_image_context; |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
int write_image_file(build_image_context *context); |
| 138 |
|
| 139 |
|
| 140 |
extern int enable_debug; |
| 141 |
|
| 142 |
#endif |