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