2002-11-03 00:01:44 +00:00
|
|
|
/*
|
2006-03-13 10:16:36 +00:00
|
|
|
* (C) Copyright 2000-2006
|
2002-11-03 00:01:44 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Boot support
|
|
|
|
*/
|
|
|
|
#include <common.h>
|
2007-07-05 16:01:25 +00:00
|
|
|
#include <driver.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
#include <command.h>
|
|
|
|
#include <image.h>
|
|
|
|
#include <malloc.h>
|
2003-05-20 14:25:27 +00:00
|
|
|
#include <environment.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
#include <asm/byteorder.h>
|
2007-07-05 16:02:07 +00:00
|
|
|
#include <xfuncs.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fs.h>
|
|
|
|
#include <errno.h>
|
2007-07-05 16:02:10 +00:00
|
|
|
#include <boot.h>
|
2011-12-14 10:09:13 +00:00
|
|
|
#include <of.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
#include <rtc.h>
|
2008-02-20 18:01:54 +00:00
|
|
|
#include <init.h>
|
2011-12-06 07:53:26 +00:00
|
|
|
#include <of.h>
|
2011-11-27 12:02:48 +00:00
|
|
|
#include <magicvar.h>
|
2011-11-28 21:07:15 +00:00
|
|
|
#include <uncompress.h>
|
2011-12-06 07:53:26 +00:00
|
|
|
#include <memory.h>
|
|
|
|
#include <filetype.h>
|
2012-04-13 07:08:04 +00:00
|
|
|
#include <binfmt.h>
|
2012-04-29 18:24:39 +00:00
|
|
|
#include <globalvar.h>
|
|
|
|
#include <magicvar.h>
|
2008-06-04 09:43:10 +00:00
|
|
|
#include <asm-generic/memory_layout.h>
|
2002-11-03 00:01:44 +00:00
|
|
|
|
2013-09-22 09:52:34 +00:00
|
|
|
#define BOOTM_OPTS_COMMON "ca:e:vo:fd"
|
2012-04-29 18:30:32 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_CMD_BOOTM_INITRD
|
|
|
|
#define BOOTM_OPTS BOOTM_OPTS_COMMON "L:r:"
|
|
|
|
#else
|
|
|
|
#define BOOTM_OPTS BOOTM_OPTS_COMMON
|
|
|
|
#endif
|
|
|
|
|
2011-12-21 13:18:57 +00:00
|
|
|
static int do_bootm(int argc, char *argv[])
|
2007-07-05 16:02:07 +00:00
|
|
|
{
|
2011-12-06 07:53:26 +00:00
|
|
|
int opt;
|
2013-09-23 09:15:46 +00:00
|
|
|
struct bootm_data data = {};
|
2011-11-27 14:57:03 +00:00
|
|
|
int ret = 1;
|
2012-04-29 18:24:39 +00:00
|
|
|
const char *oftree = NULL, *initrd_file = NULL, *os_file = NULL;
|
2008-02-20 18:01:54 +00:00
|
|
|
|
2013-05-02 09:07:11 +00:00
|
|
|
data.initrd_address = UIMAGE_INVALID_ADDRESS;
|
2011-12-06 07:53:26 +00:00
|
|
|
data.os_address = UIMAGE_SOME_ADDRESS;
|
|
|
|
data.verify = 0;
|
|
|
|
data.verbose = 0;
|
|
|
|
|
2012-04-29 18:24:39 +00:00
|
|
|
oftree = getenv("global.bootm.oftree");
|
|
|
|
os_file = getenv("global.bootm.image");
|
2013-09-25 06:10:07 +00:00
|
|
|
getenv_ul("global.bootm.image.loadaddr", &data.os_address);
|
|
|
|
getenv_ul("global.bootm.initrd.loadaddr", &data.initrd_address);
|
2012-04-29 18:24:39 +00:00
|
|
|
if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
|
|
|
|
initrd_file = getenv("global.bootm.initrd");
|
|
|
|
|
2012-04-29 18:30:32 +00:00
|
|
|
while ((opt = getopt(argc, argv, BOOTM_OPTS)) > 0) {
|
2007-07-05 16:02:07 +00:00
|
|
|
switch(opt) {
|
2011-12-06 07:53:26 +00:00
|
|
|
case 'c':
|
|
|
|
data.verify = 1;
|
2007-07-05 16:02:07 +00:00
|
|
|
break;
|
2011-12-06 07:53:26 +00:00
|
|
|
#ifdef CONFIG_CMD_BOOTM_INITRD
|
2011-11-27 14:25:37 +00:00
|
|
|
case 'L':
|
2011-11-27 15:20:51 +00:00
|
|
|
data.initrd_address = simple_strtoul(optarg, NULL, 0);
|
2011-11-27 14:25:37 +00:00
|
|
|
break;
|
|
|
|
case 'r':
|
2012-04-29 18:24:39 +00:00
|
|
|
initrd_file = optarg;
|
2011-12-06 07:53:26 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case 'a':
|
|
|
|
data.os_address = simple_strtoul(optarg, NULL, 0);
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
data.os_entry = simple_strtoul(optarg, NULL, 0);
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
data.verbose++;
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
oftree = optarg;
|
|
|
|
break;
|
|
|
|
case 'f':
|
2013-06-10 10:13:44 +00:00
|
|
|
data.force = 1;
|
2011-11-27 14:25:37 +00:00
|
|
|
break;
|
2013-09-22 09:52:34 +00:00
|
|
|
case 'd':
|
|
|
|
data.dryrun = 1;
|
|
|
|
break;
|
2007-07-05 16:02:07 +00:00
|
|
|
default:
|
2011-10-08 14:29:49 +00:00
|
|
|
break;
|
2007-07-05 16:02:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-29 18:24:39 +00:00
|
|
|
if (optind != argc)
|
|
|
|
os_file = argv[optind];
|
|
|
|
|
|
|
|
if (!os_file || !*os_file) {
|
|
|
|
printf("no boot image given\n");
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (initrd_file && !*initrd_file)
|
|
|
|
initrd_file = NULL;
|
2011-12-06 07:53:26 +00:00
|
|
|
|
2012-04-29 18:24:39 +00:00
|
|
|
if (oftree && !*oftree)
|
|
|
|
oftree = NULL;
|
2011-12-14 10:09:13 +00:00
|
|
|
|
2013-09-23 09:15:46 +00:00
|
|
|
data.os_file = os_file;
|
|
|
|
data.oftree_file = oftree;
|
|
|
|
data.initrd_file = initrd_file;
|
2011-12-06 07:53:26 +00:00
|
|
|
|
2013-06-10 10:13:44 +00:00
|
|
|
ret = bootm_boot(&data);
|
2013-09-22 09:52:34 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("handler failed with: %s\n", strerror(-ret));
|
|
|
|
goto err_out;
|
|
|
|
}
|
2011-12-06 07:53:26 +00:00
|
|
|
|
2013-09-22 09:52:34 +00:00
|
|
|
if (data.dryrun)
|
|
|
|
printf("Dryrun. Aborted\n");
|
2007-07-05 16:02:10 +00:00
|
|
|
|
|
|
|
err_out:
|
2013-09-22 09:52:34 +00:00
|
|
|
return ret ? 1 : 0;
|
2002-11-03 00:01:44 +00:00
|
|
|
}
|
|
|
|
|
2010-10-17 16:18:37 +00:00
|
|
|
BAREBOX_CMD_HELP_START(bootm)
|
commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 08:28:42 +00:00
|
|
|
BAREBOX_CMD_HELP_TEXT("Options:")
|
2014-05-30 09:07:34 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-c\t", "crc check uImage data")
|
|
|
|
BAREBOX_CMD_HELP_OPT ("-d\t", "dryrun: check data, but do not run")
|
|
|
|
BAREBOX_CMD_HELP_OPT ("-f\t", "load images even if type is undetectable")
|
2011-12-06 07:53:26 +00:00
|
|
|
#ifdef CONFIG_CMD_BOOTM_INITRD
|
commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 08:28:42 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-r INITRD","specify an initrd image")
|
2014-05-30 09:07:34 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-L ADDR\t","specify initrd load address")
|
2011-12-06 07:53:26 +00:00
|
|
|
#endif
|
2014-05-30 09:07:34 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-a ADDR\t","specify os load address")
|
|
|
|
BAREBOX_CMD_HELP_OPT ("-e OFFS\t","entry point to the image relative to start (0)")
|
2011-12-06 07:53:26 +00:00
|
|
|
#ifdef CONFIG_OFTREE
|
2014-05-30 09:07:34 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-o DTS\t","specify open firmware device tree")
|
2011-12-06 07:53:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CMD_BOOTM_VERBOSE
|
commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 08:28:42 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-v\t","verbose")
|
2011-12-06 07:53:26 +00:00
|
|
|
#endif
|
2010-10-17 16:18:37 +00:00
|
|
|
BAREBOX_CMD_HELP_END
|
2008-04-04 09:46:55 +00:00
|
|
|
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_START(bootm)
|
2007-07-05 16:01:53 +00:00
|
|
|
.cmd = do_bootm,
|
commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 08:28:42 +00:00
|
|
|
BAREBOX_CMD_DESC("boot an application image")
|
2014-05-30 09:07:34 +00:00
|
|
|
BAREBOX_CMD_OPTS("[-cdf"
|
commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 08:28:42 +00:00
|
|
|
#ifdef CONFIG_CMD_BOOTM_INITRD
|
|
|
|
"rL"
|
|
|
|
#endif
|
|
|
|
"ae"
|
|
|
|
#ifdef CONFIG_OFTREE
|
|
|
|
"o"
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CMD_BOOTM_VERBOSE
|
|
|
|
"v"
|
|
|
|
#endif
|
|
|
|
"] IMAGE")
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_HELP(cmd_bootm_help)
|
|
|
|
BAREBOX_CMD_END
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-11-27 12:02:48 +00:00
|
|
|
BAREBOX_MAGICVAR(bootargs, "Linux Kernel parameters");
|
2012-04-29 18:24:39 +00:00
|
|
|
BAREBOX_MAGICVAR_NAMED(global_bootm_image, global.bootm.image, "bootm default boot image");
|
2013-09-01 06:04:47 +00:00
|
|
|
BAREBOX_MAGICVAR_NAMED(global_bootm_image_loadaddr, global.bootm.image.loadaddr, "bootm default boot image loadaddr");
|
2012-04-29 18:24:39 +00:00
|
|
|
BAREBOX_MAGICVAR_NAMED(global_bootm_initrd, global.bootm.initrd, "bootm default initrd");
|
2013-09-01 06:04:47 +00:00
|
|
|
BAREBOX_MAGICVAR_NAMED(global_bootm_initrd_loadaddr, global.bootm.initrd.loadaddr, "bootm default initrd loadaddr");
|
2011-11-27 12:02:48 +00:00
|
|
|
|
2012-04-13 07:08:04 +00:00
|
|
|
static struct binfmt_hook binfmt_uimage_hook = {
|
|
|
|
.type = filetype_uimage,
|
|
|
|
.exec = "bootm",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int binfmt_uimage_init(void)
|
|
|
|
{
|
|
|
|
return binfmt_register(&binfmt_uimage_hook);
|
|
|
|
}
|
|
|
|
fs_initcall(binfmt_uimage_init);
|