]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
f9a3c278 SG |
2 | /* |
3 | * (C) Copyright 2015 Google, Inc | |
4 | * Written by Simon Glass <[email protected]> | |
5 | * | |
f9a3c278 SG |
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 | ||
f9a3c278 | 15 | static void rksd_set_header(void *buf, struct stat *sbuf, int ifd, |
2fb371ff | 16 | struct image_tool_params *params) |
f9a3c278 SG |
17 | { |
18 | unsigned int size; | |
19 | int ret; | |
20 | ||
366aad4d PT |
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 | |
2fb371ff PT |
24 | * 'is_boot0' is true counts towards the payload (and not towards the |
25 | * header). | |
366aad4d | 26 | */ |
7bf274b9 JC |
27 | size = params->file_size - RK_SPL_HDR_START; |
28 | ret = rkcommon_set_header(buf, size, params); | |
f9a3c278 SG |
29 | if (ret) { |
30 | /* TODO([email protected]): This method should return an error */ | |
366aad4d PT |
31 | printf("Warning: SPL image is too large (size %#x) and will " |
32 | "not boot\n", size); | |
f9a3c278 | 33 | } |
f9a3c278 SG |
34 | } |
35 | ||
f9a3c278 SG |
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 | ||
f9a3c278 SG |
44 | static int rksd_vrec_header(struct image_tool_params *params, |
45 | struct image_type_params *tparams) | |
46 | { | |
c25b8c3a | 47 | /* |
ad972ac3 PT |
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) | |
c25b8c3a | 50 | */ |
ad972ac3 | 51 | return rkcommon_vrec_header(params, tparams, RK_INIT_SIZE_ALIGN); |
f9a3c278 SG |
52 | } |
53 | ||
54 | /* | |
55 | * rk_sd parameters | |
56 | */ | |
57 | U_BOOT_IMAGE_TYPE( | |
58 | rksd, | |
59 | "Rockchip SD Boot Image support", | |
111bcc4f PT |
60 | 0, |
61 | NULL, | |
7bf274b9 | 62 | rkcommon_check_params, |
2fb371ff PT |
63 | rkcommon_verify_header, |
64 | rkcommon_print_header, | |
f9a3c278 | 65 | rksd_set_header, |
2fb371ff | 66 | NULL, |
f9a3c278 SG |
67 | rksd_check_image_type, |
68 | NULL, | |
69 | rksd_vrec_header | |
70 | ); |