1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Renesas RZ/N1 Package Table format 4 * (C) 2015-2016 Renesas Electronics Europe, LTD 5 * All rights reserved. 6 * 7 * Converted to mkimage plug-in 8 * (C) Copyright 2022 Schneider Electric 9 */ 10 11 #ifndef _SPKGIMAGE_H_ 12 #define _SPKGIMAGE_H_ 13 14 #include <linux/compiler_attributes.h> 15 16 #define SPKG_HEADER_MARKER {'R', 'Z', 'N', '1'} 17 #define SPKG_HEADER_SIZE 24 18 #define SPKG_HEADER_COUNT 8 19 #define SPKG_BLP_SIZE 264 20 #define SPKG_CRC_SIZE 4 21 22 /** 23 * struct spkg_hdr - SPKG header 24 * @marker: magic pattern "RZN1" 25 * @version: header version (currently 1) 26 * @ecc: ECC enable and block size. 27 * @ecc_scheme: ECC algorithm selction 28 * @ecc_bytes: ECC bytes per block 29 * @payload_length: length of the payload (including CRC) 30 * @load_address: address in memory where payload should be loaded 31 * @execution_offset: offset from @load_address where execution starts 32 * @crc: 32-bit CRC of the above header fields 33 * 34 * SPKG header format is defined by Renesas. It is documented in the Reneasas 35 * RZ/N1 User Manual, Chapter 7.4 ("SPKG format"). 36 * 37 * The BootROM searches this header in order to find and validate the boot 38 * payload. It is therefore mandatory to wrap the payload in this header. 39 * 40 * The ECC-related fields @ecc @ecc_scheme @ecc_bytes are used only when 41 * booting from NAND flash, and they are only used while fetching the payload. 42 * These values are used to initialize the ECC controller. To avoid using 43 * non-portable bitfields, struct spkg_hdr uses uint8_t for these fields, so 44 * the user must shift the values into the correct spot. 45 * 46 * The payload will be loaded into memory at @payload_address. 47 * Execution then jumps to @payload_address + @execution_offset. 48 * The LSB of @execution_offset selects between ARM and Thumb mode, 49 * as per the usual ARM interworking convention. 50 */ 51 struct spkg_hdr { 52 uint8_t marker[4]; /* aka magic */ 53 uint8_t version; 54 uint8_t ecc; 55 uint8_t ecc_scheme; 56 uint8_t ecc_bytes; 57 uint32_t payload_length; /* only HIGHER 24 bits */ 58 uint32_t load_address; 59 uint32_t execution_offset; 60 uint32_t crc; /* of this header */ 61 } __packed; 62 63 /** 64 * struct spkg_file - complete SPKG image 65 * 66 * A SPKG image consists of 8 identical copies of struct spkg_hdr, each one 67 * occupying 24 bytes, for a total of 192 bytes. 68 * 69 * This is followed by the payload (the u-boot binary), and a 32-bit CRC. 70 * 71 * Optionally, the payload can be being with security header ("BLp_header"). 72 * This feature is not currently supported in mkimage. 73 * 74 * The payload is typically padded with 0xFF bytes so as to bring the total 75 * image size to a multiple of the flash erase size (often 64kB). 76 */ 77 struct spkg_file { 78 struct spkg_hdr header[SPKG_HEADER_COUNT]; 79 uint8_t payload[0]; 80 /* then the CRC */ 81 } __packed; 82 83 #endif 84