From: Bartlomiej Sieka <tur@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 05/20] [new uImage] Add new uImage format support for ramdisk handling
Date: Wed, 12 Mar 2008 21:10:56 +0100 [thread overview]
Message-ID: <20080312201056.6444.41624.stgit@pollux.denx.de> (raw)
In-Reply-To: <20080312201023.6444.52806.stgit@pollux.denx.de>
From: Marian Balakowicz <m8@semihalf.com>
This patch updates boot_get_ramdisk() routine adding format
verification and handling for new (FIT) uImages.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/image.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 108 insertions(+), 16 deletions(-)
diff --git a/common/image.c b/common/image.c
index 9278ea9..3b15853 100644
--- a/common/image.c
+++ b/common/image.c
@@ -47,11 +47,17 @@
#include <image.h>
-#if defined(CONFIG_FIT)
+#if defined(CONFIG_FIT) || defined (CONFIG_OF_LIBFDT)
#include <fdt.h>
#include <libfdt.h>
#include <fdt_support.h>
+#endif
+
+#if defined(CONFIG_FIT)
#include <sha1.h>
+
+static int fit_check_ramdisk (const void *fit, int os_noffset,
+ uint8_t arch, int verify);
#endif
#ifdef CONFIG_CMD_BDI
@@ -774,8 +780,15 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
const char *fit_uname_config = NULL;
const char *fit_uname_ramdisk = NULL;
ulong default_addr;
+ int rd_noffset;
+ int conf_noffset;
+ const void *data;
+ size_t size;
#endif
+ *rd_start = 0;
+ *rd_end = 0;
+
/*
* Look for a '-' which indicates to ignore the
* ramdisk argument
@@ -812,8 +825,6 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
/* copy from dataflash if needed */
- printf ("## Loading init Ramdisk Image at %08lx ...\n",
- rd_addr);
rd_addr = genimg_get_image (rd_addr);
/*
@@ -823,17 +834,14 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
switch (genimg_get_format ((void *)rd_addr)) {
case IMAGE_FORMAT_LEGACY:
-
- debug ("* ramdisk: legacy format image\n");
+ printf ("## Loading init Ramdisk from Legacy "
+ "Image at %08lx ...\n", rd_addr);
rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
rd_addr, arch, images->verify);
- if (rd_hdr == NULL) {
- *rd_start = 0;
- *rd_end = 0;
+ if (rd_hdr == NULL)
return 1;
- }
rd_data = image_get_data (rd_hdr);
rd_len = image_get_data_size (rd_hdr);
@@ -842,14 +850,60 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
fit_hdr = (void *)rd_addr;
- debug ("* ramdisk: FIT format image\n");
- fit_unsupported_reset ("ramdisk");
- return 1;
+ printf ("## Loading init Ramdisk from FIT "
+ "Image at %08lx ...\n", rd_addr);
+
+ if (!fit_check_format (fit_hdr)) {
+ puts ("Bad FIT ramdisk image format!\n");
+ return 0;
+ }
+
+ if (!fit_uname_ramdisk) {
+ /*
+ * no ramdisk image node unit name, try to get config
+ * node first. If config unit node name is NULL
+ * fit_conf_get_node() will try to find default config node
+ */
+ conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+ if (conf_noffset < 0)
+ return 0;
+
+ rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, conf_noffset);
+ fit_uname_ramdisk = fit_get_name (fit_hdr, rd_noffset, NULL);
+ } else {
+ /* get ramdisk component image node offset */
+ rd_noffset = fit_image_get_node (fit_hdr, fit_uname_ramdisk);
+ }
+ if (rd_noffset < 0)
+ return 0;
+
+ printf (" Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
+
+ if (!fit_check_ramdisk (fit_hdr, rd_noffset, arch, images->verify))
+ return 0;
+
+ /* get ramdisk image data address and length */
+ if (fit_image_get_data (fit_hdr, rd_noffset, &data, &size)) {
+ puts ("Could not find ramdisk subimage data!\n");
+ return 0;
+ }
+
+ rd_data = (ulong)data;
+ rd_len = size;
+
+ if (fit_image_get_load (fit_hdr, rd_noffset, &rd_load)) {
+ puts ("Can't get ramdisk subimage load address!\n");
+ return 0;
+ }
+
+ images->fit_hdr_rd = fit_hdr;
+ images->fit_uname_rd = fit_uname_ramdisk;
+ break;
#endif
default:
printf ("Wrong Image Format for %s command\n",
cmdtp->name);
- rd_data = rd_len = 0;
+ rd_data = rd_len = rd_load = 0;
}
#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
@@ -870,7 +924,7 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
show_boot_progress (13);
printf ("## Loading init Ramdisk from multi component "
- "Image at %08lx ...\n",
+ "Legacy Image at %08lx ...\n",
(ulong)images->legacy_hdr_os);
image_multi_getimg (images->legacy_hdr_os, 1, &rd_data, &rd_len);
@@ -884,8 +938,6 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (!rd_data) {
debug ("## No init Ramdisk\n");
- *rd_start = 0;
- *rd_end = 0;
} else {
*rd_start = rd_data;
*rd_end = rd_data + rd_len;
@@ -2376,4 +2428,44 @@ void fit_conf_print (const void *fit, int noffset, const char *p)
if (uname)
printf ("%s FDT: %s\n", p, uname);
}
+
+/**
+ * fit_check_ramdisk - verify FIT format ramdisk subimage
+ * @fit_hdr: pointer to the FIT ramdisk header
+ * @rd_noffset: ramdisk subimage node offset within FIT image
+ * @arch: requested ramdisk image architecture type
+ * @verify: data CRC verification flag
+ *
+ * fit_check_ramdisk() verifies integrity of the ramdisk subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ * 1, on success
+ * 0, on failure
+ */
+#ifndef USE_HOSTCC
+static int fit_check_ramdisk (const void *fit, int rd_noffset, uint8_t arch, int verify)
+{
+ fit_image_print (fit, rd_noffset, " ");
+
+ if (verify) {
+ puts (" Verifying Hash Integrity ... ");
+ if (!fit_image_check_hashes (fit, rd_noffset)) {
+ puts ("Bad Data Hash\n");
+ return 0;
+ }
+ puts ("OK\n");
+ }
+
+ if (!fit_image_check_os (fit, rd_noffset, IH_OS_LINUX) ||
+ !fit_image_check_arch (fit, rd_noffset, arch) ||
+ !fit_image_check_type (fit, rd_noffset, IH_TYPE_RAMDISK)) {
+ printf ("No Linux %s Ramdisk Image\n",
+ genimg_get_arch_name(arch));
+ return 0;
+ }
+
+ return 1;
+}
+#endif /* USE_HOSTCC */
#endif /* CONFIG_FIT */
next prev parent reply other threads:[~2008-03-12 20:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 01/20] [new uImage] Make node unit names const in struct bootm_headers Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 02/20] [new uImage] Add support for new uImage format to mkimage tool Bartlomiej Sieka
2008-03-14 14:54 ` Luigi 'Comio' Mantellini
2008-03-14 16:19 ` Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 03/20] [new uImage] Add new uImage format support for imls and iminfo commands Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 04/20] [new uImage] Add new uImage format support for kernel booting Bartlomiej Sieka
2008-03-12 20:10 ` Bartlomiej Sieka [this message]
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 06/20] [new uImage] Remove unnecessary arguments passed to ramdisk routines Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 07/20] [new uImage] Re-enable interrupts for non automatic booting Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 08/20] [new uImage] ppc: Add new uImage format support to FDT handling routines Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 09/20] [new uImage] Add node offsets for FIT images listed in struct bootm_headers Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 10/20] [new uImage] Add new uImage format support to arch specific do_bootm_linux() routines Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 11/20] [new uImage] Add new uImage format support to autoscript routine Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 12/20] [new uImage] Add new uImage format support to imgextract command Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 13/20] [new uImage] Add new uImage format handling to other bootm related commands Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 14/20] [new uImage] Add new uImage fromat support to fpga command Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 15/20] [new uImage] Use show_boot_progress() for new uImage format Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 16/20] [new uImage] More verbose kernel image uncompress error message Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 17/20] [new uImage] Add proper ramdisk/FDT handling when FIT configuration is used Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 18/20] [new uImage] Fix build problems on trab board Bartlomiej Sieka
2008-03-12 20:55 ` Wolfgang Denk
2008-03-19 9:01 ` Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 19/20] [new uImage] Fix definition of common bootm_headers_t fields Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 20/20] [new uImage] Add new uImage format documentation and examples Bartlomiej Sieka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080312201056.6444.41624.stgit@pollux.denx.de \
--to=tur@semihalf.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox