{"id":1056,"date":"2019-12-09T13:53:28","date_gmt":"2019-12-09T22:53:28","guid":{"rendered":"\/blog\/?p=1056"},"modified":"2023-09-21T09:26:45","modified_gmt":"2023-09-21T00:26:45","slug":"uimage-header","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=1056","title":{"rendered":"uImage Header"},"content":{"rendered":"<a href=\"https:\/\/github.com\/EmcraftSystems\/u-boot\/blob\/master\/include\/image.h\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/EmcraftSystems\/u-boot\/blob\/master\/include\/image.h<\/a><br \/>\n<br \/>\n&nbsp;\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\n\/*\n * (C) Copyright 2008 Semihalf\n *\n * (C) Copyright 2000-2005\n * Wolfgang Denk, DENX Software Engineering, wd@denx.de.\n *\n * See file CREDITS for list of people who contributed to this\n * project.\n *\n * This program is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU General Public License as\n * published by the Free Software Foundation; either version 2 of\n * the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n ********************************************************************\n * NOTE: This header file defines an interface to U-Boot. Including\n * this (unmodified) header file in another file is considered normal\n * use of U-Boot, and does *not* fall under the heading of &quot;derived\n * work&quot;.\n ********************************************************************\n *\/\n\n#ifndef __IMAGE_H__\n#define __IMAGE_H__\n\n#include &quot;compiler.h&quot;\n\n#ifdef USE_HOSTCC\n\n\/* new uImage format support enabled on host *\/\n#define CONFIG_FIT              1\n#define CONFIG_OF_LIBFDT        1\n#define CONFIG_FIT_VERBOSE      1 \/* enable fit_format_{error,warning}() *\/\n\n#else\n\n#include <lmb.h>\n#include <asm u-boot.h=\"\">\n#include <command.h>\n\n#endif \/* USE_HOSTCC *\/\n\n#if defined(CONFIG_FIT)\n#include <fdt.h>\n#include <libfdt.h>\n#include <fdt_support.h>\n#define CONFIG_MD5              \/* FIT images need MD5 support *\/\n#define CONFIG_SHA1             \/* and SHA1 *\/\n#endif\n\n\/*\n * Operating System Codes\n *\/\n#define IH_OS_INVALID           0       \/* Invalid OS   *\/\n#define IH_OS_OPENBSD           1       \/* OpenBSD      *\/\n#define IH_OS_NETBSD            2       \/* NetBSD       *\/\n#define IH_OS_FREEBSD           3       \/* FreeBSD      *\/\n#define IH_OS_4_4BSD            4       \/* 4.4BSD       *\/\n#define IH_OS_LINUX             5       \/* Linux        *\/\n#define IH_OS_SVR4              6       \/* SVR4         *\/\n#define IH_OS_ESIX              7       \/* Esix         *\/\n#define IH_OS_SOLARIS           8       \/* Solaris      *\/\n#define IH_OS_IRIX              9       \/* Irix         *\/\n#define IH_OS_SCO               10      \/* SCO          *\/\n#define IH_OS_DELL              11      \/* Dell         *\/\n#define IH_OS_NCR               12      \/* NCR          *\/\n#define IH_OS_LYNXOS            13      \/* LynxOS       *\/\n#define IH_OS_VXWORKS           14      \/* VxWorks      *\/\n#define IH_OS_PSOS              15      \/* pSOS         *\/\n#define IH_OS_QNX               16      \/* QNX          *\/\n#define IH_OS_U_BOOT            17      \/* Firmware     *\/\n#define IH_OS_RTEMS             18      \/* RTEMS        *\/\n#define IH_OS_ARTOS             19      \/* ARTOS        *\/\n#define IH_OS_UNITY             20      \/* Unity OS     *\/\n#define IH_OS_INTEGRITY         21      \/* INTEGRITY    *\/\n\n\/*\n * CPU Architecture Codes (supported by Linux)\n *\/\n#define IH_ARCH_INVALID         0       \/* Invalid CPU  *\/\n#define IH_ARCH_ALPHA           1       \/* Alpha        *\/\n#define IH_ARCH_ARM             2       \/* ARM          *\/\n#define IH_ARCH_I386            3       \/* Intel x86    *\/\n#define IH_ARCH_IA64            4       \/* IA64         *\/\n#define IH_ARCH_MIPS            5       \/* MIPS         *\/\n#define IH_ARCH_MIPS64          6       \/* MIPS  64 Bit *\/\n#define IH_ARCH_PPC             7       \/* PowerPC      *\/\n#define IH_ARCH_S390            8       \/* IBM S390     *\/\n#define IH_ARCH_SH              9       \/* SuperH       *\/\n#define IH_ARCH_SPARC           10      \/* Sparc        *\/\n#define IH_ARCH_SPARC64         11      \/* Sparc 64 Bit *\/\n#define IH_ARCH_M68K            12      \/* M68K         *\/\n#define IH_ARCH_NIOS            13      \/* Nios-32      *\/\n#define IH_ARCH_MICROBLAZE      14      \/* MicroBlaze   *\/\n#define IH_ARCH_NIOS2           15      \/* Nios-II      *\/\n#define IH_ARCH_BLACKFIN        16      \/* Blackfin     *\/\n#define IH_ARCH_AVR32           17      \/* AVR32        *\/\n#define IH_ARCH_ST200           18      \/* STMicroelectronics ST200  *\/\n\n\/*\n * Image Types\n *\n * &quot;Standalone Programs&quot; are directly runnable in the environment\n *      provided by U-Boot; it is expected that (if they behave\n *      well) you can continue to work in U-Boot after return from\n *      the Standalone Program.\n * &quot;OS Kernel Images&quot; are usually images of some Embedded OS which\n *      will take over control completely. Usually these programs\n *      will install their own set of exception handlers, device\n *      drivers, set up the MMU, etc. - this means, that you cannot\n *      expect to re-enter U-Boot except by resetting the CPU.\n * &quot;RAMDisk Images&quot; are more or less just data blocks, and their\n *      parameters (address, size) are passed to an OS kernel that is\n *      being started.\n * &quot;Multi-File Images&quot; contain several images, typically an OS\n *      (Linux) kernel image and one or more data images like\n *      RAMDisks. This construct is useful for instance when you want\n *      to boot over the network using BOOTP etc., where the boot\n *      server provides just a single image file, but you want to get\n *      for instance an OS kernel and a RAMDisk image.\n *\n *      &quot;Multi-File Images&quot; start with a list of image sizes, each\n *      image size (in bytes) specified by an &quot;uint32_t&quot; in network\n *      byte order. This list is terminated by an &quot;(uint32_t)0&quot;.\n *      Immediately after the terminating 0 follow the images, one by\n *      one, all aligned on &quot;uint32_t&quot; boundaries (size rounded up to\n *      a multiple of 4 bytes - except for the last file).\n *\n * &quot;Firmware Images&quot; are binary images containing firmware (like\n *      U-Boot or FPGA images) which usually will be programmed to\n *      flash memory.\n *\n * &quot;Script files&quot; are command sequences that will be executed by\n *      U-Boot&#39;s command interpreter; this feature is especially\n *      useful when you configure U-Boot to use a real shell (hush)\n *      as command interpreter (=&gt; Shell Scripts).\n *\/\n\n#define IH_TYPE_INVALID         0       \/* Invalid Image                *\/\n#define IH_TYPE_STANDALONE      1       \/* Standalone Program           *\/\n#define IH_TYPE_KERNEL          2       \/* OS Kernel Image              *\/\n#define IH_TYPE_RAMDISK         3       \/* RAMDisk Image                *\/\n#define IH_TYPE_MULTI           4       \/* Multi-File Image             *\/\n#define IH_TYPE_FIRMWARE        5       \/* Firmware Image               *\/\n#define IH_TYPE_SCRIPT          6       \/* Script file                  *\/\n#define IH_TYPE_FILESYSTEM      7       \/* Filesystem Image (any type)  *\/\n#define IH_TYPE_FLATDT          8       \/* Binary Flat Device Tree Blob *\/\n#define IH_TYPE_KWBIMAGE        9       \/* Kirkwood Boot Image          *\/\n#define IH_TYPE_IMXIMAGE        10      \/* Freescale IMXBoot Image      *\/\n\n\/*\n * Compression Types\n *\/\n#define IH_COMP_NONE            0       \/*  No   Compression Used       *\/\n#define IH_COMP_GZIP            1       \/* gzip  Compression Used       *\/\n#define IH_COMP_BZIP2           2       \/* bzip2 Compression Used       *\/\n#define IH_COMP_LZMA            3       \/* lzma  Compression Used       *\/\n#define IH_COMP_LZO             4       \/* lzo   Compression Used       *\/\n\n#define IH_MAGIC        0x27051956      \/* Image Magic Number           *\/\n#define IH_NMLEN                32      \/* Image Name Length            *\/\n\n\/*\n * Legacy format image header,\n * all data in network byte order (aka natural aka bigendian).\n *\/\ntypedef struct image_header {\n        uint32_t        ih_magic;       \/* Image Header Magic Number    *\/\n        uint32_t        ih_hcrc;        \/* Image Header CRC Checksum    *\/\n        uint32_t        ih_time;        \/* Image Creation Timestamp     *\/\n        uint32_t        ih_size;        \/* Image Data Size              *\/\n        uint32_t        ih_load;        \/* Data  Load  Address          *\/\n        uint32_t        ih_ep;          \/* Entry Point Address          *\/\n        uint32_t        ih_dcrc;        \/* Image Data CRC Checksum      *\/\n        uint8_t         ih_os;          \/* Operating System             *\/\n        uint8_t         ih_arch;        \/* CPU architecture             *\/\n        uint8_t         ih_type;        \/* Image Type                   *\/\n        uint8_t         ih_comp;        \/* Compression Type             *\/\n        uint8_t         ih_name[IH_NMLEN];      \/* Image Name           *\/\n} image_header_t;\n\ntypedef struct image_info {\n        ulong           start, end;             \/* start\/end of blob *\/\n        ulong           image_start, image_len; \/* start of image within blob, len of image *\/\n        ulong           load;                   \/* load addr for the image *\/\n        uint8_t         comp, type, os;         \/* compression, type of image, os type *\/\n} image_info_t;\n\n\/*\n * Legacy and FIT format headers used by do_bootm() and do_bootm_<os>()\n * routines.\n *\/\ntypedef struct bootm_headers {\n        \/*\n         * Legacy os image header, if it is a multi component image\n         * then boot_get_ramdisk() and get_fdt() will attempt to get\n         * data from second and third component accordingly.\n         *\/\n        image_header_t  *legacy_hdr_os;         \/* image header pointer *\/\n        image_header_t  legacy_hdr_os_copy;     \/* header copy *\/\n        ulong           legacy_hdr_valid;\n\n#if defined(CONFIG_FIT)\n        const char      *fit_uname_cfg; \/* configuration node unit name *\/\n\n        void            *fit_hdr_os;    \/* os FIT image header *\/\n        const char      *fit_uname_os;  \/* os subimage node unit name *\/\n        int             fit_noffset_os; \/* os subimage node offset *\/\n\n        void            *fit_hdr_rd;    \/* init ramdisk FIT image header *\/\n        const char      *fit_uname_rd;  \/* init ramdisk subimage node unit name *\/\n        int             fit_noffset_rd; \/* init ramdisk subimage node offset *\/\n\n        void            *fit_hdr_fdt;   \/* FDT blob FIT image header *\/\n        const char      *fit_uname_fdt; \/* FDT blob subimage node unit name *\/\n        int             fit_noffset_fdt;\/* FDT blob subimage node offset *\/\n#endif\n\n#ifndef USE_HOSTCC\n        image_info_t    os;             \/* os image info *\/\n        ulong           ep;             \/* entry point of OS *\/\n\n        ulong           rd_start, rd_end;\/* ramdisk start\/end *\/\n\n#ifdef CONFIG_OF_LIBFDT\n        char            *ft_addr;       \/* flat dev tree address *\/\n#endif\n        ulong           ft_len;         \/* length of flat device tree *\/\n\n        ulong           initrd_start;\n        ulong           initrd_end;\n        ulong           cmdline_start;\n        ulong           cmdline_end;\n        bd_t            *kbd;\n#endif\n\n        int             verify;         \/* getenv(&quot;verify&quot;)[0] != &#39;n&#39; *\/\n\n#define BOOTM_STATE_START       (0x00000001)\n#define BOOTM_STATE_LOADOS      (0x00000002)\n#define BOOTM_STATE_RAMDISK     (0x00000004)\n#define BOOTM_STATE_FDT         (0x00000008)\n#define BOOTM_STATE_OS_CMDLINE  (0x00000010)\n#define BOOTM_STATE_OS_BD_T     (0x00000020)\n#define BOOTM_STATE_OS_PREP     (0x00000040)\n#define BOOTM_STATE_OS_GO       (0x00000080)\n        int             state;\n\n#ifdef CONFIG_LMB\n        struct lmb      lmb;            \/* for memory mgmt *\/\n#endif\n} bootm_headers_t;\n\n\/*\n * Some systems (for example LWMON) have very short watchdog periods;\n * we must make sure to split long operations like memmove() or\n * checksum calculations into reasonable chunks.\n *\/\n#ifndef CHUNKSZ\n#define CHUNKSZ (64 * 1024)\n#endif\n\n#ifndef CHUNKSZ_CRC32\n#define CHUNKSZ_CRC32 (64 * 1024)\n#endif\n\n#ifndef CHUNKSZ_MD5\n#define CHUNKSZ_MD5 (64 * 1024)\n#endif\n\n#ifndef CHUNKSZ_SHA1\n#define CHUNKSZ_SHA1 (64 * 1024)\n#endif\n\n#define uimage_to_cpu(x)                be32_to_cpu(x)\n#define cpu_to_uimage(x)                cpu_to_be32(x)\n\n\/*\n * Translation table for entries of a specific type; used by\n * get_table_entry_id() and get_table_entry_name().\n *\/\ntypedef struct table_entry {\n        int     id;\n        char    *sname;         \/* short (input) name to find table entry *\/\n        char    *lname;         \/* long (output) name to print for messages *\/\n} table_entry_t;\n\n\/*\n * get_table_entry_id() scans the translation table trying to find an\n * entry that matches the given short name. If a matching entry is\n * found, it&#39;s id is returned to the caller.\n *\/\nint get_table_entry_id (table_entry_t *table,\n                const char *table_name, const char *name);\n\/*\n * get_table_entry_name() scans the translation table trying to find\n * an entry that matches the given id. If a matching entry is found,\n * its long name is returned to the caller.\n *\/\nchar *get_table_entry_name (table_entry_t *table, char *msg, int id);\n\nconst char *genimg_get_os_name (uint8_t os);\nconst char *genimg_get_arch_name (uint8_t arch);\nconst char *genimg_get_type_name (uint8_t type);\nconst char *genimg_get_comp_name (uint8_t comp);\nint genimg_get_os_id (const char *name);\nint genimg_get_arch_id (const char *name);\nint genimg_get_type_id (const char *name);\nint genimg_get_comp_id (const char *name);\nvoid genimg_print_size (uint32_t size);\n\n#ifndef USE_HOSTCC\n\/* Image format types, returned by _get_format() routine *\/\n#define IMAGE_FORMAT_INVALID    0x00\n#define IMAGE_FORMAT_LEGACY     0x01    \/* legacy image_header based format *\/\n#define IMAGE_FORMAT_FIT        0x02    \/* new, libfdt based format *\/\n\nint genimg_get_format (void *img_addr);\nint genimg_has_config (bootm_headers_t *images);\nulong genimg_get_image (ulong img_addr);\n\nint boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,\n                uint8_t arch, ulong *rd_start, ulong *rd_end);\n\n\n#ifdef CONFIG_OF_LIBFDT\nint boot_get_fdt (int flag, int argc, char *argv[], bootm_headers_t *images,\n                char **of_flat_tree, ulong *of_size);\nint boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base,\n                char **of_flat_tree, ulong *of_size);\n#endif\n\n#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH\nint boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,\n                  ulong *initrd_start, ulong *initrd_end);\n#endif \/* CONFIG_SYS_BOOT_RAMDISK_HIGH *\/\n#ifdef CONFIG_SYS_BOOT_GET_CMDLINE\nint boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,\n                        ulong bootmap_base);\n#endif \/* CONFIG_SYS_BOOT_GET_CMDLINE *\/\n#ifdef CONFIG_SYS_BOOT_GET_KBD\nint boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base);\n#endif \/* CONFIG_SYS_BOOT_GET_KBD *\/\n#endif \/* !USE_HOSTCC *\/\n\n\/*******************************************************************\/\n\/* Legacy format specific code (prefixed with image_) *\/\n\/*******************************************************************\/\nstatic inline uint32_t image_get_header_size (void)\n{\n        return (sizeof (image_header_t));\n}\n\n#define image_get_hdr_l(f) \\\n        static inline uint32_t image_get_##f(const image_header_t *hdr) \\\n        { \\\n                return uimage_to_cpu (hdr-&gt;ih_##f); \\\n        }\nimage_get_hdr_l (magic);        \/* image_get_magic *\/\nimage_get_hdr_l (hcrc);         \/* image_get_hcrc *\/\nimage_get_hdr_l (time);         \/* image_get_time *\/\nimage_get_hdr_l (size);         \/* image_get_size *\/\nimage_get_hdr_l (load);         \/* image_get_load *\/\nimage_get_hdr_l (ep);           \/* image_get_ep *\/\nimage_get_hdr_l (dcrc);         \/* image_get_dcrc *\/\n\n#define image_get_hdr_b(f) \\\n        static inline uint8_t image_get_##f(const image_header_t *hdr) \\\n        { \\\n                return hdr-&gt;ih_##f; \\\n        }\nimage_get_hdr_b (os);           \/* image_get_os *\/\nimage_get_hdr_b (arch);         \/* image_get_arch *\/\nimage_get_hdr_b (type);         \/* image_get_type *\/\nimage_get_hdr_b (comp);         \/* image_get_comp *\/\n\nstatic inline char *image_get_name (const image_header_t *hdr)\n{\n        return (char *)hdr-&gt;ih_name;\n}\n\nstatic inline uint32_t image_get_data_size (const image_header_t *hdr)\n{\n        return image_get_size (hdr);\n}\n\n\/**\n * image_get_data - get image payload start address\n * @hdr: image header\n *\n * image_get_data() returns address of the image payload. For single\n * component images it is image data start. For multi component\n * images it points to the null terminated table of sub-images sizes.\n *\n * returns:\n *     image payload data start address\n *\/\nstatic inline ulong image_get_data (const image_header_t *hdr)\n{\n        return ((ulong)hdr + image_get_header_size ());\n}\n\nstatic inline uint32_t image_get_image_size (const image_header_t *hdr)\n{\n        return (image_get_size (hdr) + image_get_header_size ());\n}\nstatic inline ulong image_get_image_end (const image_header_t *hdr)\n{\n        return ((ulong)hdr + image_get_image_size (hdr));\n}\n\n#define image_set_hdr_l(f) \\\n        static inline void image_set_##f(image_header_t *hdr, uint32_t val) \\\n        { \\\n                hdr-&gt;ih_##f = cpu_to_uimage (val); \\\n        }\nimage_set_hdr_l (magic);        \/* image_set_magic *\/\nimage_set_hdr_l (hcrc);         \/* image_set_hcrc *\/\nimage_set_hdr_l (time);         \/* image_set_time *\/\nimage_set_hdr_l (size);         \/* image_set_size *\/\nimage_set_hdr_l (load);         \/* image_set_load *\/\nimage_set_hdr_l (ep);           \/* image_set_ep *\/\nimage_set_hdr_l (dcrc);         \/* image_set_dcrc *\/\n\n#define image_set_hdr_b(f) \\\n        static inline void image_set_##f(image_header_t *hdr, uint8_t val) \\\n        { \\\n                hdr-&gt;ih_##f = val; \\\n        }\nimage_set_hdr_b (os);           \/* image_set_os *\/\nimage_set_hdr_b (arch);         \/* image_set_arch *\/\nimage_set_hdr_b (type);         \/* image_set_type *\/\nimage_set_hdr_b (comp);         \/* image_set_comp *\/\n\nstatic inline void image_set_name (image_header_t *hdr, const char *name)\n{\n        strncpy (image_get_name (hdr), name, IH_NMLEN);\n}\n\nint image_check_hcrc (const image_header_t *hdr);\nint image_check_dcrc (const image_header_t *hdr);\n#ifndef USE_HOSTCC\nint getenv_yesno (char *var);\nulong getenv_bootm_low(void);\nphys_size_t getenv_bootm_size(void);\nvoid memmove_wd (void *to, void *from, size_t len, ulong chunksz);\n#endif\n\nstatic inline int image_check_magic (const image_header_t *hdr)\n{\n        return (image_get_magic (hdr) == IH_MAGIC);\n}\nstatic inline int image_check_type (const image_header_t *hdr, uint8_t type)\n{\n        return (image_get_type (hdr) == type);\n}\nstatic inline int image_check_arch (const image_header_t *hdr, uint8_t arch)\n{\n        return (image_get_arch (hdr) == arch);\n}\nstatic inline int image_check_os (const image_header_t *hdr, uint8_t os)\n{\n        return (image_get_os (hdr) == os);\n}\n\nulong image_multi_count (const image_header_t *hdr);\nvoid image_multi_getimg (const image_header_t *hdr, ulong idx,\n                        ulong *data, ulong *len);\n\nvoid image_print_contents (const void *hdr);\n\n#ifndef USE_HOSTCC\nstatic inline int image_check_target_arch (const image_header_t *hdr)\n{\n#if defined(__ARM__)\n        if (!image_check_arch (hdr, IH_ARCH_ARM))\n#elif defined(__avr32__)\n        if (!image_check_arch (hdr, IH_ARCH_AVR32))\n#elif defined(__bfin__)\n        if (!image_check_arch (hdr, IH_ARCH_BLACKFIN))\n#elif defined(__I386__)\n        if (!image_check_arch (hdr, IH_ARCH_I386))\n#elif defined(__M68K__)\n        if (!image_check_arch (hdr, IH_ARCH_M68K))\n#elif defined(__microblaze__)\n        if (!image_check_arch (hdr, IH_ARCH_MICROBLAZE))\n#elif defined(__mips__)\n        if (!image_check_arch (hdr, IH_ARCH_MIPS))\n#elif defined(__nios__)\n        if (!image_check_arch (hdr, IH_ARCH_NIOS))\n#elif defined(__nios2__)\n        if (!image_check_arch (hdr, IH_ARCH_NIOS2))\n#elif defined(__PPC__)\n        if (!image_check_arch (hdr, IH_ARCH_PPC))\n#elif defined(__sh__)\n        if (!image_check_arch (hdr, IH_ARCH_SH))\n#elif defined(__sparc__)\n        if (!image_check_arch (hdr, IH_ARCH_SPARC))\n#else\n# error Unknown CPU type\n#endif\n                return 0;\n\n        return 1;\n}\n#endif \/* USE_HOSTCC *\/\n\n\/*******************************************************************\/\n\/* New uImage format specific code (prefixed with fit_) *\/\n\/*******************************************************************\/\n#if defined(CONFIG_FIT)\n\n#define FIT_IMAGES_PATH         &quot;\/images&quot;\n#define FIT_CONFS_PATH          &quot;\/configurations&quot;\n\n\/* hash node *\/\n#define FIT_HASH_NODENAME       &quot;hash&quot;\n#define FIT_ALGO_PROP           &quot;algo&quot;\n#define FIT_VALUE_PROP          &quot;value&quot;\n\n\/* image node *\/\n#define FIT_DATA_PROP           &quot;data&quot;\n#define FIT_TIMESTAMP_PROP      &quot;timestamp&quot;\n#define FIT_DESC_PROP           &quot;description&quot;\n#define FIT_ARCH_PROP           &quot;arch&quot;\n#define FIT_TYPE_PROP           &quot;type&quot;\n#define FIT_OS_PROP             &quot;os&quot;\n#define FIT_COMP_PROP           &quot;compression&quot;\n#define FIT_ENTRY_PROP          &quot;entry&quot;\n#define FIT_LOAD_PROP           &quot;load&quot;\n\n\/* configuration node *\/\n#define FIT_KERNEL_PROP         &quot;kernel&quot;\n#define FIT_RAMDISK_PROP        &quot;ramdisk&quot;\n#define FIT_FDT_PROP            &quot;fdt&quot;\n#define FIT_DEFAULT_PROP        &quot;default&quot;\n\n#define FIT_MAX_HASH_LEN        20      \/* max(crc32_len(4), sha1_len(20)) *\/\n\n\/* cmdline argument format parsing *\/\ninline int fit_parse_conf (const char *spec, ulong addr_curr,\n                ulong *addr, const char **conf_name);\ninline int fit_parse_subimage (const char *spec, ulong addr_curr,\n                ulong *addr, const char **image_name);\n\nvoid fit_print_contents (const void *fit);\nvoid fit_image_print (const void *fit, int noffset, const char *p);\nvoid fit_image_print_hash (const void *fit, int noffset, const char *p);\n\n\/**\n * fit_get_end - get FIT image size\n * @fit: pointer to the FIT format image header\n *\n * returns:\n *     size of the FIT image (blob) in memory\n *\/\nstatic inline ulong fit_get_size (const void *fit)\n{\n        return fdt_totalsize (fit);\n}\n\n\/**\n * fit_get_end - get FIT image end\n * @fit: pointer to the FIT format image header\n *\n * returns:\n *     end address of the FIT image (blob) in memory\n *\/\nstatic inline ulong fit_get_end (const void *fit)\n{\n        return (ulong)fit + fdt_totalsize (fit);\n}\n\n\/**\n * fit_get_name - get FIT node name\n * @fit: pointer to the FIT format image header\n *\n * returns:\n *     NULL, on error\n *     pointer to node name, on success\n *\/\nstatic inline const char *fit_get_name (const void *fit_hdr,\n                int noffset, int *len)\n{\n        return fdt_get_name (fit_hdr, noffset, len);\n}\n\nint fit_get_desc (const void *fit, int noffset, char **desc);\nint fit_get_timestamp (const void *fit, int noffset, time_t *timestamp);\n\nint fit_image_get_node (const void *fit, const char *image_uname);\nint fit_image_get_os (const void *fit, int noffset, uint8_t *os);\nint fit_image_get_arch (const void *fit, int noffset, uint8_t *arch);\nint fit_image_get_type (const void *fit, int noffset, uint8_t *type);\nint fit_image_get_comp (const void *fit, int noffset, uint8_t *comp);\nint fit_image_get_load (const void *fit, int noffset, ulong *load);\nint fit_image_get_entry (const void *fit, int noffset, ulong *entry);\nint fit_image_get_data (const void *fit, int noffset,\n                                const void **data, size_t *size);\n\nint fit_image_hash_get_algo (const void *fit, int noffset, char **algo);\nint fit_image_hash_get_value (const void *fit, int noffset, uint8_t **value,\n                                int *value_len);\n\nint fit_set_timestamp (void *fit, int noffset, time_t timestamp);\nint fit_set_hashes (void *fit);\nint fit_image_set_hashes (void *fit, int image_noffset);\nint fit_image_hash_set_value (void *fit, int noffset, uint8_t *value,\n                                int value_len);\n\nint fit_image_check_hashes (const void *fit, int noffset);\nint fit_all_image_check_hashes (const void *fit);\nint fit_image_check_os (const void *fit, int noffset, uint8_t os);\nint fit_image_check_arch (const void *fit, int noffset, uint8_t arch);\nint fit_image_check_type (const void *fit, int noffset, uint8_t type);\nint fit_image_check_comp (const void *fit, int noffset, uint8_t comp);\nint fit_check_format (const void *fit);\n\nint fit_conf_get_node (const void *fit, const char *conf_uname);\nint fit_conf_get_kernel_node (const void *fit, int noffset);\nint fit_conf_get_ramdisk_node (const void *fit, int noffset);\nint fit_conf_get_fdt_node (const void *fit, int noffset);\n\nvoid fit_conf_print (const void *fit, int noffset, const char *p);\n\n#ifndef USE_HOSTCC\nstatic inline int fit_image_check_target_arch (const void *fdt, int node)\n{\n#if defined(__ARM__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_ARM))\n#elif defined(__avr32__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_AVR32))\n#elif defined(__bfin__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_BLACKFIN))\n#elif defined(__I386__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_I386))\n#elif defined(__M68K__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_M68K))\n#elif defined(__microblaze__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_MICROBLAZE))\n#elif defined(__mips__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_MIPS))\n#elif defined(__nios__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_NIOS))\n#elif defined(__nios2__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_NIOS2))\n#elif defined(__PPC__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_PPC))\n#elif defined(__sh__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_SH))\n#elif defined(__sparc__)\n        if (!fit_image_check_arch (fdt, node, IH_ARCH_SPARC))\n#else\n# error Unknown CPU type\n#endif\n                return 0;\n\n        return 1;\n}\n#endif \/* USE_HOSTCC *\/\n\n#ifdef CONFIG_FIT_VERBOSE\n#define fit_unsupported(msg)    printf (&quot;! %s:%d &quot; \\\n                                &quot;FIT images not supported for &#39;%s&#39;\\n&quot;, \\\n                                __FILE__, __LINE__, (msg))\n\n#define fit_unsupported_reset(msg)      printf (&quot;! %s:%d &quot; \\\n                                &quot;FIT images not supported for &#39;%s&#39; &quot; \\\n                                &quot;- must reset board to recover!\\n&quot;, \\\n                                __FILE__, __LINE__, (msg))\n#else\n#define fit_unsupported(msg)\n#define fit_unsupported_reset(msg)\n#endif \/* CONFIG_FIT_VERBOSE *\/\n#endif \/* CONFIG_FIT *\/\n\n#endif  \/* __IMAGE_H__ *\/\n<\/os><\/fdt_support.h><\/libfdt.h><\/fdt.h><\/command.h><\/asm><\/lmb.h><\/pre>\n\n<!-- \/wp:post-content -->\n<!-- \/wp:syntaxhighlighter\/code -->\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/EmcraftSystems\/u-boot\/blob\/master\/include\/image.h &nbsp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[21],"tags":[],"class_list":["post-1056","post","type-post","status-publish","format-standard","hentry","category-development_openwrt"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1056"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1056\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}