Blame view
tools/rksd.c
1.59 KB
83d290c56 SPDX: Convert all... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
f9a3c278b rockchip: Add sup... |
2 3 4 5 |
/* * (C) Copyright 2015 Google, Inc * Written by Simon Glass <sjg@chromium.org> * |
f9a3c278b rockchip: Add sup... |
6 7 8 9 10 11 12 13 |
* See README.rockchip for details of the rksd format */ #include "imagetool.h" #include <image.h> #include <rc4.h> #include "mkimage.h" #include "rkcommon.h" |
f9a3c278b rockchip: Add sup... |
14 |
static void rksd_set_header(void *buf, struct stat *sbuf, int ifd, |
2fb371ff6 rockchip: mkimage... |
15 |
struct image_tool_params *params) |
f9a3c278b rockchip: Add sup... |
16 17 18 |
{ unsigned int size; int ret; |
366aad4d9 rockchip: mkimage... |
19 20 21 |
/* * We need to calculate this using 'RK_SPL_HDR_START' and not using * 'tparams->header_size', as the additional byte inserted when |
2fb371ff6 rockchip: mkimage... |
22 23 |
* 'is_boot0' is true counts towards the payload (and not towards the * header). |
366aad4d9 rockchip: mkimage... |
24 |
*/ |
7bf274b9c rockchip: mkimage... |
25 26 |
size = params->file_size - RK_SPL_HDR_START; ret = rkcommon_set_header(buf, size, params); |
f9a3c278b rockchip: Add sup... |
27 28 |
if (ret) { /* TODO(sjg@chromium.org): This method should return an error */ |
366aad4d9 rockchip: mkimage... |
29 30 31 |
printf("Warning: SPL image is too large (size %#x) and will " "not boot ", size); |
f9a3c278b rockchip: Add sup... |
32 |
} |
f9a3c278b rockchip: Add sup... |
33 |
} |
f9a3c278b rockchip: Add sup... |
34 35 36 37 38 39 40 |
static int rksd_check_image_type(uint8_t type) { if (type == IH_TYPE_RKSD) return EXIT_SUCCESS; else return EXIT_FAILURE; } |
f9a3c278b rockchip: Add sup... |
41 42 43 |
static int rksd_vrec_header(struct image_tool_params *params, struct image_type_params *tparams) { |
c25b8c3af rockchip: mkimage... |
44 |
/* |
ad972ac3d rockchip: mkimage... |
45 46 |
* Pad to a 2KB alignment, as required for init_size by the ROM * (see https://lists.denx.de/pipermail/u-boot/2017-May/293268.html) |
c25b8c3af rockchip: mkimage... |
47 |
*/ |
ad972ac3d rockchip: mkimage... |
48 |
return rkcommon_vrec_header(params, tparams, RK_INIT_SIZE_ALIGN); |
f9a3c278b rockchip: Add sup... |
49 50 51 52 53 54 55 56 |
} /* * rk_sd parameters */ U_BOOT_IMAGE_TYPE( rksd, "Rockchip SD Boot Image support", |
111bcc4fb rockchip: mkimage... |
57 58 |
0, NULL, |
7bf274b9c rockchip: mkimage... |
59 |
rkcommon_check_params, |
2fb371ff6 rockchip: mkimage... |
60 61 |
rkcommon_verify_header, rkcommon_print_header, |
f9a3c278b rockchip: Add sup... |
62 |
rksd_set_header, |
2fb371ff6 rockchip: mkimage... |
63 |
NULL, |
f9a3c278b rockchip: Add sup... |
64 65 66 67 |
rksd_check_image_type, NULL, rksd_vrec_header ); |