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