mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
sysupgrade: Add sysupgrade support for signed images.
Change-Id: I2b4a5aeaa311e08ec59f70c3a9e3a88e11dc10f1 Signed-off-by: Sachin Sundar <ssundar@codeaurora.org>
This commit is contained in:
parent
ac91142257
commit
1ed5f5b1a2
4 changed files with 1298 additions and 1 deletions
|
|
@ -15,6 +15,9 @@ CONFIG_NETCONSOLE = y
|
|||
CONFIG_SHA1_CHECK_UB_IMG = y
|
||||
endif
|
||||
|
||||
ifneq ($(TARGETCC),)
|
||||
HOSTCC = $(TARGETCC)
|
||||
endif
|
||||
subdir-$(HOST_TOOLS_ALL) += easylogo
|
||||
subdir-$(HOST_TOOLS_ALL) += gdb
|
||||
|
||||
|
|
@ -94,6 +97,7 @@ dumpimage-mkimage-objs := aisimage.o \
|
|||
pbl_crc32.o \
|
||||
$(ROCKCHIP_OBS) \
|
||||
socfpgaimage.o \
|
||||
sysupgrade.o \
|
||||
lib/sha1.o \
|
||||
lib/sha256.o \
|
||||
common/hash.o \
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "dumpimage.h"
|
||||
#include <image.h>
|
||||
#include <version.h>
|
||||
#include "sysupgrade.h"
|
||||
|
||||
static void usage(void);
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ int main(int argc, char **argv)
|
|||
|
||||
params.cmdname = *argv;
|
||||
|
||||
while ((opt = getopt(argc, argv, "li:o:T:p:V")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "c:li:o:T:p:V")) != -1) {
|
||||
switch (opt) {
|
||||
case 'l':
|
||||
params.lflag = 1;
|
||||
|
|
@ -96,6 +97,8 @@ int main(int argc, char **argv)
|
|||
case 'V':
|
||||
printf("dumpimage version %s\n", PLAIN_VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'c':
|
||||
return do_board_upgrade_check(optarg);
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
|
|
@ -206,6 +209,10 @@ static void usage(void)
|
|||
fprintf(stderr,
|
||||
" %s -V ==> print version information and exit\n",
|
||||
params.cmdname);
|
||||
fprintf(stderr,
|
||||
" %s -c image\n"
|
||||
" -c ==> do board upgrade check\n",
|
||||
params.cmdname);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
1184
tools/sysupgrade.c
Normal file
1184
tools/sysupgrade.c
Normal file
File diff suppressed because it is too large
Load diff
102
tools/sysupgrade.h
Normal file
102
tools/sysupgrade.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <dumpimage.h>
|
||||
#include <elf.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <mtd/mtd-user.h>
|
||||
#include <limits.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
typedef enum {HLOS_TYPE, UBOOT_TYPE, SBL_TYPE, TZ_TYPE, RPM_TYPE}type;
|
||||
|
||||
struct image_section {
|
||||
type section_type;
|
||||
int max_version;
|
||||
char file[256];
|
||||
char *type;
|
||||
char tmp_file[256];
|
||||
int img_version;
|
||||
int local_version;
|
||||
char *version_file;
|
||||
int is_present;
|
||||
int (*pre_op)(struct image_section *);
|
||||
int (*get_sw_id)(struct image_section *);
|
||||
int (*split_components)(struct image_section *, char **, char**, char**);
|
||||
};
|
||||
|
||||
typedef struct mbn_header {
|
||||
uint16_t image_id;
|
||||
uint32_t ver_num;
|
||||
uint32_t image_src;
|
||||
uint8_t *image_dest_ptr;
|
||||
uint32_t image_size;
|
||||
uint32_t code_size;
|
||||
uint8_t *sig_ptr;
|
||||
uint32_t sig_sz;
|
||||
uint8_t *cert_ptr;
|
||||
uint32_t cert_sz;
|
||||
}Mbn_Hdr;
|
||||
|
||||
struct ubi_ec_hdr {
|
||||
__be32 magic;
|
||||
__u8 version;
|
||||
__u8 padding1[3];
|
||||
__be64 ec; /* Warning: the current limit is 31-bit anyway! */
|
||||
__be32 vid_hdr_offset;
|
||||
__be32 data_offset;
|
||||
__be32 image_seq;
|
||||
__u8 padding2[32];
|
||||
__be32 hdr_crc;
|
||||
};
|
||||
|
||||
struct ubi_vid_hdr {
|
||||
__be32 magic;
|
||||
__u8 version;
|
||||
__u8 vol_type;
|
||||
__u8 copy_flag;
|
||||
__u8 compat;
|
||||
__be32 vol_id;
|
||||
__be32 lnum;
|
||||
__u8 padding1[4];
|
||||
__be32 data_size;
|
||||
__be32 used_ebs;
|
||||
__be32 data_pad;
|
||||
__be32 data_crc;
|
||||
__u8 padding2[4];
|
||||
__be64 sqnum;
|
||||
__u8 padding3[12];
|
||||
__be32 hdr_crc;
|
||||
};
|
||||
|
||||
int get_sections(void);
|
||||
int is_authentication_check_enabled(void);
|
||||
int get_local_image_version(struct image_section *);
|
||||
int set_local_image_version(struct image_section *);
|
||||
int is_version_check_enabled(void);
|
||||
int get_sw_id_from_component_bin(struct image_section *);
|
||||
int get_sw_id_from_component_bin_elf(struct image_section *);
|
||||
int extract_kernel_binary(struct image_section *);
|
||||
int is_image_version_higher(void);
|
||||
int update_version(void);
|
||||
int check_image_version(void);
|
||||
int split_code_signature_cert_from_component_bin(struct image_section *, char **, char **, char **);
|
||||
int split_code_signature_cert_from_component_bin_elf(struct image_section *, char **, char **, char **);
|
||||
void generate_swid_ipad(char *, unsigned long long *);
|
||||
void generate_hwid_opad(char *, char *, char *, unsigned long long *);
|
||||
int generate_hash(char *, char *, char *);
|
||||
int is_component_authenticated(char *, char *, char *);
|
||||
int is_image_authenticated(void);
|
||||
int do_board_upgrade_check(char *);
|
||||
Loading…
Add table
Reference in a new issue