* [U-Boot] [PATCH 1/3] MIPS: bootm.c: separate linux jump code
@ 2013-01-07 12:53 Gabor Juhos
2013-01-07 12:53 ` [U-Boot] [PATCH 2/3] MIPS: bootm.c: separate environment initialization Gabor Juhos
2013-01-07 12:53 ` [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands Gabor Juhos
0 siblings, 2 replies; 6+ messages in thread
From: Gabor Juhos @ 2013-01-07 12:53 UTC (permalink / raw)
To: u-boot
Move the actual jump code into a separate function.
This make the code reusable for bootm subcommands.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
arch/mips/lib/bootm.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 4ac712a..689d17b 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -43,10 +43,27 @@ static int linux_env_idx;
static void linux_params_init(ulong start, char *commandline);
static void linux_env_set(char *env_name, char *env_val);
+static void boot_jump_linux(bootm_headers_t *images)
+{
+ void (*theKernel) (int, char **, char **, int *);
+
+ /* find kernel entry point */
+ theKernel = (void (*)(int, char **, char **, int *))images->ep;
+
+ debug("## Transferring control to Linux (at address %08lx) ...\n",
+ (ulong) theKernel);
+
+ bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+ /* we assume that the kernel is in place */
+ printf("\nStarting kernel ...\n\n");
+
+ theKernel(linux_argc, linux_argv, linux_env, 0);
+}
+
int do_bootm_linux(int flag, int argc, char * const argv[],
bootm_headers_t *images)
{
- void (*theKernel) (int, char **, char **, int *);
char *commandline = getenv("bootargs");
char env_buf[12];
char *cp;
@@ -54,14 +71,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
return 1;
- /* find kernel entry point */
- theKernel = (void (*)(int, char **, char **, int *))images->ep;
-
- bootstage_mark(BOOTSTAGE_ID_RUN_OS);
-
- debug("## Transferring control to Linux (at address %08lx) ...\n",
- (ulong) theKernel);
-
linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline);
#ifdef CONFIG_MEMSIZE_IN_BYTES
@@ -95,10 +104,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
if (cp)
linux_env_set("eth1addr", cp);
- /* we assume that the kernel is in place */
- printf("\nStarting kernel ...\n\n");
-
- theKernel(linux_argc, linux_argv, linux_env, 0);
+ boot_jump_linux(images);
/* does not return */
return 1;
--
1.7.10
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 2/3] MIPS: bootm.c: separate environment initialization
2013-01-07 12:53 [U-Boot] [PATCH 1/3] MIPS: bootm.c: separate linux jump code Gabor Juhos
@ 2013-01-07 12:53 ` Gabor Juhos
2013-01-07 12:53 ` [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands Gabor Juhos
1 sibling, 0 replies; 6+ messages in thread
From: Gabor Juhos @ 2013-01-07 12:53 UTC (permalink / raw)
To: u-boot
Move the environment initialization code into a
separate function. This make the code reusable
for bootm subcommands.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
arch/mips/lib/bootm.c | 50 ++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 689d17b..8c2e508 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -43,34 +43,12 @@ static int linux_env_idx;
static void linux_params_init(ulong start, char *commandline);
static void linux_env_set(char *env_name, char *env_val);
-static void boot_jump_linux(bootm_headers_t *images)
-{
- void (*theKernel) (int, char **, char **, int *);
-
- /* find kernel entry point */
- theKernel = (void (*)(int, char **, char **, int *))images->ep;
-
- debug("## Transferring control to Linux (at address %08lx) ...\n",
- (ulong) theKernel);
-
- bootstage_mark(BOOTSTAGE_ID_RUN_OS);
-
- /* we assume that the kernel is in place */
- printf("\nStarting kernel ...\n\n");
-
- theKernel(linux_argc, linux_argv, linux_env, 0);
-}
-
-int do_bootm_linux(int flag, int argc, char * const argv[],
- bootm_headers_t *images)
+static void boot_prep_linux(bootm_headers_t *images)
{
char *commandline = getenv("bootargs");
char env_buf[12];
char *cp;
- if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
- return 1;
-
linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline);
#ifdef CONFIG_MEMSIZE_IN_BYTES
@@ -103,7 +81,33 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
cp = getenv("eth1addr");
if (cp)
linux_env_set("eth1addr", cp);
+}
+
+static void boot_jump_linux(bootm_headers_t *images)
+{
+ void (*theKernel) (int, char **, char **, int *);
+
+ /* find kernel entry point */
+ theKernel = (void (*)(int, char **, char **, int *))images->ep;
+
+ debug("## Transferring control to Linux (at address %08lx) ...\n",
+ (ulong) theKernel);
+
+ bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+ /* we assume that the kernel is in place */
+ printf("\nStarting kernel ...\n\n");
+
+ theKernel(linux_argc, linux_argv, linux_env, 0);
+}
+
+int do_bootm_linux(int flag, int argc, char * const argv[],
+ bootm_headers_t *images)
+{
+ if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+ return 1;
+ boot_prep_linux(images);
boot_jump_linux(images);
/* does not return */
--
1.7.10
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands
2013-01-07 12:53 [U-Boot] [PATCH 1/3] MIPS: bootm.c: separate linux jump code Gabor Juhos
2013-01-07 12:53 ` [U-Boot] [PATCH 2/3] MIPS: bootm.c: separate environment initialization Gabor Juhos
@ 2013-01-07 12:53 ` Gabor Juhos
2013-01-07 17:15 ` Daniel Schwierzeck
1 sibling, 1 reply; 6+ messages in thread
From: Gabor Juhos @ 2013-01-07 12:53 UTC (permalink / raw)
To: u-boot
The bootm command supports subcommands since long time
however those subcommands are not yet usable on MIPS.
The patch is based on the ARM implementation, and it adds
support for the 'prep' and 'go' subcommands only.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
arch/mips/lib/bootm.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 8c2e508..a36154a 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -104,8 +104,19 @@ static void boot_jump_linux(bootm_headers_t *images)
int do_bootm_linux(int flag, int argc, char * const argv[],
bootm_headers_t *images)
{
- if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
- return 1;
+ /* No need for those on MIPS */
+ if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
+ return -1;
+
+ if (flag & BOOTM_STATE_OS_PREP) {
+ boot_prep_linux(images);
+ return 0;
+ }
+
+ if (flag & BOOTM_STATE_OS_GO) {
+ boot_jump_linux(images);
+ return 0;
+ }
boot_prep_linux(images);
boot_jump_linux(images);
--
1.7.10
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands
2013-01-07 12:53 ` [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands Gabor Juhos
@ 2013-01-07 17:15 ` Daniel Schwierzeck
2013-01-07 19:44 ` Gabor Juhos
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Schwierzeck @ 2013-01-07 17:15 UTC (permalink / raw)
To: u-boot
2013/1/7 Gabor Juhos <juhosg@openwrt.org>:
> The bootm command supports subcommands since long time
> however those subcommands are not yet usable on MIPS.
>
> The patch is based on the ARM implementation, and it adds
> support for the 'prep' and 'go' subcommands only.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
> ---
> arch/mips/lib/bootm.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
thanks but how did you test it?
I needed to fix a relocation problem in cmd_bootm.c [1] to make it
properly working.
I have queued all three patches at u-boot-mips/testing for now. I will
merge them
when my patch is in mainline.
[1] http://patchwork.ozlabs.org/patch/210005/
--
Best regards,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands
2013-01-07 17:15 ` Daniel Schwierzeck
@ 2013-01-07 19:44 ` Gabor Juhos
2013-01-07 20:31 ` Gabor Juhos
0 siblings, 1 reply; 6+ messages in thread
From: Gabor Juhos @ 2013-01-07 19:44 UTC (permalink / raw)
To: u-boot
2013.01.07. 18:15 keltez?ssel, Daniel Schwierzeck ?rta:
> 2013/1/7 Gabor Juhos <juhosg@openwrt.org>:
>> The bootm command supports subcommands since long time
>> however those subcommands are not yet usable on MIPS.
>>
>> The patch is based on the ARM implementation, and it adds
>> support for the 'prep' and 'go' subcommands only.
>>
>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
>> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
>> ---
>> arch/mips/lib/bootm.c | 15 +++++++++++++--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>
> thanks but how did you test it?
I have tested it with the following commands:
U-Boot> setenv serverip 192.168.1.254; setenv ipaddr 192.168.1.1
U-Boot> tftp 0xa0800000 openwrt-ath79-uImage-initramfs-lzma.bin
dup 1 speed 100
Using eth0 device
TFTP from server 192.168.1.254; our IP address is 192.168.1.1
Filename 'openwrt-ath79-uImage-initramfs-lzma.bin'.
Load address: 0xa0800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################################
done
Bytes transferred = 2627082 (28160a hex)
U-Boot> bootm loados
Trying to execute a command out of order
bootm - boot application image from memory
U-Boot> bootm start 0xa0800000
## Booting kernel from Legacy Image at a0800000 ...
Image Name: MIPS OpenWrt Linux-3.8-rc2
Created: 2013-01-07 19:19:26 UTC
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 2627018 Bytes = 2.5 MiB
Load Address: 80100000
Entry Point: 80100000
Verifying Checksum ... OK
U-Boot> bootm loados
Uncompressing Kernel Image ... OK
U-Boot> bootm prep
U-Boot> bootm go
Starting kernel ...
Linux version 3.8.0-rc2 (juhosg at mag2) (gcc version 4.6.4 20121106 (prerelease)
(Linaro GCC 4.6-2012.11) ) #24 Mon Jan 7 20:19:20 CET 2013
bootconsole [early0] enabled
CPU revision is: 00019374 (MIPS 24Kc)
...
> I needed to fix a relocation problem in cmd_bootm.c [1] to make it
> properly working.
Hm, I think that I know why I did not notice that. I have tested it on a board
which uses an old U-Boot version as the primary bootloader. Because lots of
features are disabled in that I have compiled a more usable version and I'm
using that as a 2nd stage loader. It is loaded to address 0x80060000 by the
original bootloader. The Linux kernel uncompressed to 0x80100000 so it did not
clobber the strings.
> I have queued all three patches at u-boot-mips/testing for now. I will
> merge them when my patch is in mainline.
Thanks!
-Gabor
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands
2013-01-07 19:44 ` Gabor Juhos
@ 2013-01-07 20:31 ` Gabor Juhos
0 siblings, 0 replies; 6+ messages in thread
From: Gabor Juhos @ 2013-01-07 20:31 UTC (permalink / raw)
To: u-boot
2013.01.07. 20:44 keltez?ssel, Gabor Juhos ?rta:
> 2013.01.07. 18:15 keltez?ssel, Daniel Schwierzeck ?rta:
>> 2013/1/7 Gabor Juhos <juhosg@openwrt.org>:
>>> The bootm command supports subcommands since long time
>>> however those subcommands are not yet usable on MIPS.
>>>
>>> The patch is based on the ARM implementation, and it adds
>>> support for the 'prep' and 'go' subcommands only.
>>>
>>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
>>> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
>>> ---
>>> arch/mips/lib/bootm.c | 15 +++++++++++++--
>>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>
>> thanks but how did you test it?
>
> I have tested it with the following commands:
>
> U-Boot> setenv serverip 192.168.1.254; setenv ipaddr 192.168.1.1
> U-Boot> tftp 0xa0800000 openwrt-ath79-uImage-initramfs-lzma.bin
> dup 1 speed 100
> Using eth0 device
> TFTP from server 192.168.1.254; our IP address is 192.168.1.1
> Filename 'openwrt-ath79-uImage-initramfs-lzma.bin'.
> Load address: 0xa0800000
> Loading: #################################################################
> #################################################################
> #################################################################
> #################################################################
> #################################################################
> #################################################################
> #################################################################
> ###########################################################
> done
> Bytes transferred = 2627082 (28160a hex)
> U-Boot> bootm loados
> Trying to execute a command out of order
> bootm - boot application image from memory
>
> U-Boot> bootm start 0xa0800000
> ## Booting kernel from Legacy Image at a0800000 ...
> Image Name: MIPS OpenWrt Linux-3.8-rc2
> Created: 2013-01-07 19:19:26 UTC
> Image Type: MIPS Linux Kernel Image (lzma compressed)
> Data Size: 2627018 Bytes = 2.5 MiB
> Load Address: 80100000
> Entry Point: 80100000
> Verifying Checksum ... OK
> U-Boot> bootm loados
> Uncompressing Kernel Image ... OK
> U-Boot> bootm prep
> U-Boot> bootm go
>
> Starting kernel ...
>
> Linux version 3.8.0-rc2 (juhosg at mag2) (gcc version 4.6.4 20121106 (prerelease)
> (Linaro GCC 4.6-2012.11) ) #24 Mon Jan 7 20:19:20 CET 2013
> bootconsole [early0] enabled
> CPU revision is: 00019374 (MIPS 24Kc)
> ...
>
>> I needed to fix a relocation problem in cmd_bootm.c [1] to make it
>> properly working.
>
> Hm, I think that I know why I did not notice that. I have tested it on a board
> which uses an old U-Boot version as the primary bootloader. Because lots of
> features are disabled in that I have compiled a more usable version and I'm
> using that as a 2nd stage loader. It is loaded to address 0x80060000 by the
> original bootloader. The Linux kernel uncompressed to 0x80100000 so it did not
> clobber the strings.
I have changed the load address of the kernel and it indeed fails:
U-Boot> setenv serverip 192.168.1.254; setenv ipaddr 192.168.1.1
U-Boot> tftp 0xa0800000 openwrt-ath79-uImage-initramfs-lzma.bin
dup 1 speed 100
Using eth0 device
TFTP from server 192.168.1.254; our IP address is 192.168.1.1
Filename 'openwrt-ath79-uImage-initramfs-lzma.bin'.
Load address: 0xa0800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###########################################################
done
Bytes transferred = 2627551 (2817df hex)
U-Boot> bootm start 0xa0800000
## Booting kernel from Legacy Image at a0800000 ...
Image Name: MIPS OpenWrt Linux-3.8-rc2
Created: 2013-01-07 19:54:05 UTC
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 2627487 Bytes = 2.5 MiB
Load Address: 80060000
Entry Point: 80060000
Verifying Checksum ... OK
U-Boot> bootm loados
Uncompressing Kernel Image ... OK
U-Boot> bootm prep
bootm - boot application image from memory
Usage:
bootm [addr [arg ...]]
- boot application image stored in memory
passing arguments 'arg ...'; when booting a Linux kernel,
'arg' can be the address of an initrd image
When booting a Linux kernel which requires a flat device-tree
a third argument is required which is the address of the
device-tree blob. To boot that kernel without an initrd image,
use a '-' for the second argument. If you do not pass a third
a bd_info struct will be passed instead
Sub-commands to do part of the bootm sequence. The sub-commands must be
issued in the order below (it's ok to not issue all sub-commands):
start [addr [arg ...]]
loados - load OS image
fdt - relocate flat device tree
cmdline - OS specific command line processing/setup
bdt - OS specific bd_t processing
prep - OS specific prep before relocation or go
go - start OS
U-Boot>
With your relocation patch the problem is gone.
-Gabor
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-01-07 20:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 12:53 [U-Boot] [PATCH 1/3] MIPS: bootm.c: separate linux jump code Gabor Juhos
2013-01-07 12:53 ` [U-Boot] [PATCH 2/3] MIPS: bootm.c: separate environment initialization Gabor Juhos
2013-01-07 12:53 ` [U-Boot] [PATCH 3/3] MIPS: bootm.c: add support for 'prep' and 'go' subcommands Gabor Juhos
2013-01-07 17:15 ` Daniel Schwierzeck
2013-01-07 19:44 ` Gabor Juhos
2013-01-07 20:31 ` Gabor Juhos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).