2 * (C) Copyright 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
7 * See README.rockchip for details of the rksd format
10 #include "imagetool.h"
17 RKSD_HEADER0_START = 64 * RK_BLK_SIZE,
18 RKSD_SPL_HDR_START = RKSD_HEADER0_START +
19 RK_CODE1_OFFSET * RK_BLK_SIZE,
20 RKSD_SPL_START = RKSD_SPL_HDR_START + 4,
21 RKSD_HEADER_LEN = RKSD_SPL_START,
24 static char dummy_hdr[RKSD_HEADER_LEN];
26 static int rksd_check_params(struct image_tool_params *params)
31 static int rksd_verify_header(unsigned char *buf, int size,
32 struct image_tool_params *params)
37 static void rksd_print_header(const void *buf)
41 static void rksd_set_header(void *buf, struct stat *sbuf, int ifd,
42 struct image_tool_params *params)
47 /* Zero the whole header. The first 32KB is empty */
48 memset(buf, '\0', RKSD_HEADER0_START);
50 size = params->file_size - RKSD_SPL_HDR_START;
51 ret = rkcommon_set_header(buf + RKSD_HEADER0_START, size);
53 /* TODO(sjg@chromium.org): This method should return an error */
54 printf("Warning: SPL image is too large (size %#x) and will not boot\n",
58 memcpy(buf + RKSD_SPL_HDR_START, "RK32", 4);
61 static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
66 static int rksd_check_image_type(uint8_t type)
68 if (type == IH_TYPE_RKSD)
74 /* We pad the file out to a fixed size - this method returns that size */
75 static int rksd_vrec_header(struct image_tool_params *params,
76 struct image_type_params *tparams)
80 pad_size = RKSD_SPL_HDR_START + RK_MAX_CODE1_SIZE;
81 debug("pad_size %x\n", pad_size);
83 return pad_size - params->file_size;
91 "Rockchip SD Boot Image support",
98 rksd_extract_subimage,
99 rksd_check_image_type,