From: Bartlomiej Sieka <tur@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Fix do_bootm_linux() so that multi-file images with FDT blob boot.
Date: Fri, 31 Aug 2007 18:20:10 +0200 [thread overview]
Message-ID: <20070831162010.GA15703@frozen.semihalf.com> (raw)
Fix the following issues in do_bootm_linux() that prevent booting the kernel
from a mulit-file image (kernel + initrd + blob):
- incorrect initrd address and length calculation
- incorrect blob address calculation
Also, make minor updates to the U-Boot's output and to the coding style.
Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
---
Tested on two MPC5200B-based boards, one using CONFIG_OF_FLAT_TREE (still),
the other using CONFIG_OF_LIBFDT. On each board the mulit-file image was
booted from an address in RAM, as well as in Flash.
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index bcb927f..4aca783 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -724,9 +724,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
if (tail) {
data += 4 - tail;
}
-
- len = ntohl(len_ptr[1]);
-
+ len = ntohl (((image_header_t *)data)->ih_size);
+ data = data + sizeof(image_header_t);
} else {
/*
* no initrd image
@@ -817,27 +816,32 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
int i;
/* skip kernel length, initrd length, and terminator */
- of_data = (ulong)(&len_ptr[3]);
+ of_flat_tree = (char *)(&len_ptr[3]);
/* skip any additional image length fields */
for (i=2; len_ptr[i]; ++i)
- of_data += 4;
+ of_flat_tree += 4;
/* add kernel length, and align */
- of_data += ntohl(len_ptr[0]);
+ of_flat_tree += ntohl(len_ptr[0]);
if (tail) {
- of_data += 4 - tail;
+ of_flat_tree += 4 - tail;
}
/* add initrd length, and align */
tail = ntohl(len_ptr[1]) % 4;
- of_data += ntohl(len_ptr[1]);
+ of_flat_tree += ntohl(len_ptr[1]);
if (tail) {
- of_data += 4 - tail;
+ of_flat_tree += 4 - tail;
}
+ /* move the blob if it is in flash (set of_data to !null) */
+ if (addr2info ((ulong)of_flat_tree) != NULL)
+ of_data = (ulong)of_flat_tree;
+
+
#if defined(CONFIG_OF_FLAT_TREE)
- if (*((ulong *)(of_flat_tree + sizeof(image_header_t))) != OF_DT_HEADER) {
+ if (*((ulong *)(of_flat_tree)) != OF_DT_HEADER) {
#else
- if (fdt_check_header(of_flat_tree + sizeof(image_header_t)) != 0) {
+ if (fdt_check_header (of_flat_tree) != 0) {
#endif
puts ("ERROR: image is not a fdt - "
"must RESET the board to recover.\n");
@@ -845,9 +849,11 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
}
#if defined(CONFIG_OF_FLAT_TREE)
- if (((struct boot_param_header *)of_data)->totalsize != ntohl(len_ptr[2])) {
+ if (((struct boot_param_header *)of_flat_tree)->totalsize !=
+ ntohl (len_ptr[2])) {
#else
- if (be32_to_cpu(fdt_totalsize(of_data)) != ntohl(len_ptr[2])) {
+ if (be32_to_cpu (fdt_totalsize (of_flat_tree)) !=
+ ntohl(len_ptr[2])) {
#endif
puts ("ERROR: fdt size != image size - "
"must RESET the board to recover.\n");
@@ -957,6 +963,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
"must RESET the board to recover.\n");
do_reset (cmdtp, flag, argc, argv);
}
+ puts ("OK\n");
}
/*
* Add the chosen node if it doesn't exist, add the env and bd_t
@@ -1011,6 +1018,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
printf (" Loading Device Tree to %08lx, end %08lx ... ",
of_start, of_start + of_len - 1);
memmove ((void *)of_start, (void *)of_data, of_len);
+ puts ("OK\n");
}
/*
* Create the /chosen node and modify the blob with board specific
next reply other threads:[~2007-08-31 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-31 16:20 Bartlomiej Sieka [this message]
2007-08-31 16:23 ` [U-Boot-Users] [PATCH] Fix do_bootm_linux() so that multi-file images with FDT blob boot Timur Tabi
2007-08-31 16:33 ` Bartlomiej Sieka
2007-08-31 16:38 ` Timur Tabi
2007-08-31 16:50 ` Bartlomiej Sieka
2007-09-04 15:31 ` [U-Boot-Users] [PATCH V2] " Bartlomiej Sieka
2007-09-06 22:14 ` Wolfgang Denk
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=20070831162010.GA15703@frozen.semihalf.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.