summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/user/booting-linux.rst14
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boards/ccxmx53/flash-header-imx53-ccxmx53_1gib.imxcfg2
-rw-r--r--arch/arm/boards/ccxmx53/lowlevel.c41
-rw-r--r--arch/arm/boards/phytec-som-am335x/lowlevel.c1
-rw-r--r--arch/arm/boards/phytec-som-am335x/ram-timings.h20
-rw-r--r--arch/arm/dts/am335x-phytec-phycard-som.dtsi16
-rw-r--r--arch/arm/dts/am335x-phytec-phycore-som.dtsi24
-rw-r--r--arch/arm/dts/am335x-phytec-phyflex-som.dtsi24
-rw-r--r--arch/arm/dts/imx25-karo-tx25.dts6
-rw-r--r--arch/arm/dts/imx27-phytec-phycard-s-rdk-bb.dts10
-rw-r--r--arch/arm/dts/imx27-phytec-phycore-rdk.dts12
-rw-r--r--arch/arm/dts/imx51-babbage.dts4
-rw-r--r--arch/arm/dts/imx51-genesi-efika-sb.dts8
-rw-r--r--arch/arm/dts/imx53-ccxmx53.dts1
-rw-r--r--arch/arm/dts/imx53-ccxmx53.dtsi15
-rw-r--r--arch/arm/dts/imx53-guf-vincell-lt.dts8
-rw-r--r--arch/arm/dts/imx53-mba53.dts4
-rw-r--r--arch/arm/dts/imx53-qsb-common.dtsi4
-rw-r--r--arch/arm/dts/imx53-voipac-dmm-668.dtsi10
-rw-r--r--arch/arm/dts/imx6dl-eltec-hipercam.dts8
-rw-r--r--arch/arm/dts/imx6dl-hummingboard.dts6
-rw-r--r--arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts6
-rw-r--r--arch/arm/dts/imx6dl-wandboard.dts6
-rw-r--r--arch/arm/dts/imx6q-dmo-edmqmx6.dts18
-rw-r--r--arch/arm/dts/imx6q-embedsky-e9.dts12
-rw-r--r--arch/arm/dts/imx6q-guf-santaro.dts4
-rw-r--r--arch/arm/dts/imx6q-hummingboard.dts6
-rw-r--r--arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi14
-rw-r--r--arch/arm/dts/imx6q-phytec-phycore-som-nand.dts6
-rw-r--r--arch/arm/dts/imx6q-var-custom.dts6
-rw-r--r--arch/arm/dts/imx6q-var-som.dtsi6
-rw-r--r--arch/arm/dts/imx6q-wandboard.dts6
-rw-r--r--arch/arm/dts/imx6qdl-gw54xx.dtsi2
-rw-r--r--arch/arm/dts/imx6qdl-nitrogen6x.dtsi6
-rw-r--r--arch/arm/dts/imx6qdl-phytec-pfla02.dtsi20
-rw-r--r--arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi20
-rw-r--r--arch/arm/dts/imx6qdl-sabrelite.dtsi6
-rw-r--r--arch/arm/dts/imx6qdl-sabresd.dtsi6
-rw-r--r--arch/arm/dts/imx6qdl-tx6x.dtsi2
-rw-r--r--arch/arm/dts/imx6s-riotboard.dts4
-rw-r--r--arch/arm/dts/imx6sx-sdb.dts4
-rw-r--r--arch/arm/dts/rk3188-radxarock.dts2
-rw-r--r--arch/arm/lib/bootm.c53
-rw-r--r--arch/arm/mach-omap/am33xx_bbu_nand.c2
-rw-r--r--arch/arm/mach-omap/am33xx_bbu_spi_mlo.c2
-rw-r--r--arch/arm/mach-tegra/include/mach/lowlevel.h7
-rw-r--r--commands/Kconfig13
-rw-r--r--commands/bootm.c1
-rw-r--r--commands/flash.c2
-rw-r--r--commands/i2c.c4
-rw-r--r--common/Kconfig12
-rw-r--r--common/blspec.c39
-rw-r--r--common/bootm.c17
-rw-r--r--common/env.c28
-rw-r--r--common/environment.c3
-rw-r--r--common/filetype.c5
-rw-r--r--common/globalvar.c10
-rw-r--r--drivers/ata/sata-imx.c2
-rw-r--r--drivers/serial/serial_auart.c9
-rw-r--r--drivers/usb/gadget/dfu.c4
-rw-r--r--drivers/usb/gadget/f_fastboot.c2
-rw-r--r--fs/fs.c4
-rw-r--r--images/Makefile.am33xx6
-rw-r--r--images/Makefile.socfpga2
-rw-r--r--include/boot.h5
-rw-r--r--include/fs.h1
-rw-r--r--include/globalvar.h1
-rw-r--r--include/string.h1
-rw-r--r--lib/parameter.c12
-rw-r--r--lib/string.c43
-rw-r--r--scripts/imx/imx.c7
72 files changed, 422 insertions, 277 deletions
diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
index 98628faf9d..f26299efd9 100644
--- a/Documentation/user/booting-linux.rst
+++ b/Documentation/user/booting-linux.rst
@@ -99,6 +99,20 @@ with addpart to the Kernel:
Kernel command line: mtdparts=physmap-flash.0:512k(bootloader),512k(env),4M(kernel),-(root);
mxc_nand:1M(bootloader),1M(env),4M(kernel),-(root)
+Creating root= options for the Kernel
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+It's a common case that the Linux Kernel is loaded from a filesystem
+that later becomes the root filesystem for the Kernel. For several
+filesystems barebox can automatically append a suitable root= option
+to the Kernel command line. This is done when ``global.bootm.appendroot``
+is true. How the root= option is appended depends on the device type
+and filesystem the kernel is booted from. For disk like devices (SD/MMC,
+ATA) the partition UUID will be used, the root= option will be something
+like ``root=PARTUUID=deadbeef-1``. For UBIFS fileystems it will be
+``root=ubi0:volname ubi.mtd=mtdpartname rootfstype=ubifs``. NFS
+filesystems will result in ``root=/dev/nfs nfsroot=ip:/path/to/nfsroot,v3,tcp``.
+The ``v3,tcp`` part is configurable in ``global.linux.rootnfsopts``.
The boot command
----------------
diff --git a/Makefile b/Makefile
index 6b4c519657..93f1d17d99 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
VERSION = 2016
-PATCHLEVEL = 04
+PATCHLEVEL = 05
SUBLEVEL = 0
EXTRAVERSION =
NAME = None
diff --git a/arch/arm/boards/ccxmx53/flash-header-imx53-ccxmx53_1gib.imxcfg b/arch/arm/boards/ccxmx53/flash-header-imx53-ccxmx53_1gib.imxcfg
index 6f1cab60c7..68d947c01d 100644
--- a/arch/arm/boards/ccxmx53/flash-header-imx53-ccxmx53_1gib.imxcfg
+++ b/arch/arm/boards/ccxmx53/flash-header-imx53-ccxmx53_1gib.imxcfg
@@ -31,7 +31,7 @@ wm 32 0x63fd90f8 0x00000800
wm 32 0x63fd907c 0x020c0211
wm 32 0x63fd9080 0x014c0155
wm 32 0x63fd9018 0x000016d0
-wm 32 0x63fd9000 0xc4110000
+wm 32 0x63fd9000 0xc3110000
wm 32 0x63fd900c 0x4d5122d2
wm 32 0x63fd9010 0x92d18a22
wm 32 0x63fd9014 0x00c70092
diff --git a/arch/arm/boards/ccxmx53/lowlevel.c b/arch/arm/boards/ccxmx53/lowlevel.c
index b321811e95..55f6f366ac 100644
--- a/arch/arm/boards/ccxmx53/lowlevel.c
+++ b/arch/arm/boards/ccxmx53/lowlevel.c
@@ -13,7 +13,10 @@
*
*/
+#include <debug_ll.h>
#include <common.h>
+#include <linux/sizes.h>
+#include <io.h>
#include <mach/esdctl.h>
#include <mach/generic.h>
#include <image-metadata.h>
@@ -26,28 +29,32 @@
BAREBOX_IMD_TAG_STRING(ccxmx53_memsize_SZ_512M, IMD_TYPE_PARAMETER, "memsize=512", 0);
BAREBOX_IMD_TAG_STRING(ccxmx53_memsize_SZ_1G, IMD_TYPE_PARAMETER, "memsize=1024", 0);
-static void __noreturn start_imx53_ccxmx53_common(uint32_t size,
- void *fdt_blob_fixed_offset)
+extern char __dtb_imx53_ccxmx53_start[];
+
+ENTRY_FUNCTION(start_ccxmx53_512mb, r0, r1, r2)
{
void *fdt;
imx5_cpu_lowlevel_init();
arm_setup_stack(0xf8020000 - 8);
- fdt = fdt_blob_fixed_offset - get_runtime_offset();
- barebox_arm_entry(0x70000000, size, fdt);
+ IMD_USED(ccxmx53_memsize_SZ_512M);
+
+ fdt = __dtb_imx53_ccxmx53_start - get_runtime_offset();
+
+ imx53_barebox_entry(fdt);
}
-#define CCMX53_ENTRY(name, fdt_name, memory_size) \
- ENTRY_FUNCTION(name, r0, r1, r2) \
- { \
- extern char __dtb_##fdt_name##_start[]; \
- \
- IMD_USED(ccxmx53_memsize_##memory_size); \
- \
- start_imx53_ccxmx53_common(memory_size, \
- __dtb_##fdt_name##_start); \
- }
-
-CCMX53_ENTRY(start_ccxmx53_512mb, imx53_ccxmx53, SZ_512M);
-CCMX53_ENTRY(start_ccxmx53_1gib, imx53_ccxmx53, SZ_1G);
+ENTRY_FUNCTION(start_ccxmx53_1gib, r0, r1, r2)
+{
+ void *fdt;
+
+ imx5_cpu_lowlevel_init();
+ arm_setup_stack(0xf8020000 - 8);
+
+ IMD_USED(ccxmx53_memsize_SZ_1G);
+
+ fdt = __dtb_imx53_ccxmx53_start - get_runtime_offset();
+
+ imx53_barebox_entry(fdt);
+}
diff --git a/arch/arm/boards/phytec-som-am335x/lowlevel.c b/arch/arm/boards/phytec-som-am335x/lowlevel.c
index 73e75eb491..33e83c5a8e 100644
--- a/arch/arm/boards/phytec-som-am335x/lowlevel.c
+++ b/arch/arm/boards/phytec-som-am335x/lowlevel.c
@@ -125,6 +125,7 @@ PHYTEC_ENTRY_MLO(start_am33xx_phytec_phycore_sram_2x512mb, am335x_phytec_phycore
PHYTEC_ENTRY_MLO(start_am33xx_phytec_phycore_sram_1024mb, am335x_phytec_phycore_som_mlo, PHYCORE_IM8G16D3FBBG15EI_1024MB);
PHYTEC_ENTRY_MLO(start_am33xx_phytec_phycore_r2_sram_512mb, am335x_phytec_phycore_som_mlo, PHYCORE_R2_MT41K256M16TW107IT_512MB);
PHYTEC_ENTRY_MLO(start_am33xx_phytec_phycore_r2_sram_256mb, am335x_phytec_phycore_som_mlo, PHYCORE_R2_MT41K128M16JT_256MB);
+PHYTEC_ENTRY_MLO(start_am33xx_phytec_phycore_r2_sram_1024mb, am335x_phytec_phycore_som_mlo, PHYCORE_R2_MT41K512M16HA125IT_1024MB);
PHYTEC_ENTRY(start_am33xx_phytec_phycore_sdram, am335x_phytec_phycore_som);
PHYTEC_ENTRY(start_am33xx_phytec_phycore_no_spi_sdram, am335x_phytec_phycore_som_no_spi);
PHYTEC_ENTRY(start_am33xx_phytec_phycore_no_eeprom_sdram, am335x_phytec_phycore_som_no_eeprom);
diff --git a/arch/arm/boards/phytec-som-am335x/ram-timings.h b/arch/arm/boards/phytec-som-am335x/ram-timings.h
index 884874caf7..9576d265e5 100644
--- a/arch/arm/boards/phytec-som-am335x/ram-timings.h
+++ b/arch/arm/boards/phytec-som-am335x/ram-timings.h
@@ -32,6 +32,7 @@ enum {
PHYCORE_IM8G16D3FBBG15EI_1024MB,
PHYCORE_R2_MT41K256M16TW107IT_512MB,
PHYCORE_R2_MT41K128M16JT_256MB,
+ PHYCORE_R2_MT41K512M16HA125IT_1024MB,
PHYCARD_NT5CB128M16BP_256MB,
};
@@ -232,6 +233,25 @@ struct am335x_sdram_timings physom_timings[] = {
.wr_slave_ratio0 = 0x73,
},
},
+
+ /* 1024MB R2 */
+ [PHYCORE_R2_MT41K512M16HA125IT_1024MB] = {
+ .regs = {
+ .emif_read_latency = 0x7,
+ .emif_tim1 = 0x0AAAD4DB,
+ .emif_tim2 = 0x268F7FDA,
+ .emif_tim3 = 0x501F88BF,
+ .sdram_config = 0x61C053B2,
+ .zq_config = 0x50074BE4,
+ .sdram_ref_ctrl = 0x00000C30,
+ },
+ .data = {
+ .rd_slave_ratio0 = 0x38,
+ .wr_dqs_slave_ratio0 = 0x4d,
+ .fifo_we_slave_ratio0 = 0x9d,
+ .wr_slave_ratio0 = 0x82,
+ },
+ },
};
#endif
diff --git a/arch/arm/dts/am335x-phytec-phycard-som.dtsi b/arch/arm/dts/am335x-phytec-phycard-som.dtsi
index d1dfa86bca..f052f0cc3a 100644
--- a/arch/arm/dts/am335x-phytec-phycard-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phycard-som.dtsi
@@ -185,42 +185,42 @@
reg = <0x0 0x20000>;
};
- partition@1 {
+ partition@20000 {
label = "xload_backup1";
reg = <0x20000 0x20000>;
};
- partition@2 {
+ partition@40000 {
label = "xload_backup2";
reg = <0x40000 0x20000>;
};
- partition@3 {
+ partition@60000 {
label = "xload_backup3";
reg = <0x60000 0x20000>;
};
- partition@4 {
+ partition@80000 {
label = "barebox";
reg = <0x80000 0x80000>;
};
- partition@5 {
+ partition@100000 {
label = "bareboxenv";
reg = <0x100000 0x40000>;
};
- partition@6 {
+ partition@140000 {
label = "oftree";
reg = <0x140000 0x40000>;
};
- partition@7 {
+ partition@180000 {
label = "kernel";
reg = <0x180000 0x800000>;
};
- partition@8 {
+ partition@980000 {
label = "root";
reg = <0x980000 0x0>;
};
diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
index f3a1d4d45a..e48d545e64 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
@@ -174,22 +174,22 @@
reg = <0x0 0x20000>;
};
- partition@1 {
+ partition@20000 {
label = "barebox";
reg = <0x20000 0x80000>;
};
- partition@2 {
+ partition@a0000 {
label = "bareboxenv";
reg = <0xa0000 0x20000>;
};
- partition@3 {
+ partition@c0000 {
label = "oftree";
reg = <0xc0000 0x20000>;
};
- partition@4 {
+ partition@e0000 {
label = "kernel";
reg = <0xe0000 0x0>;
};
@@ -269,42 +269,42 @@
reg = <0x0 0x20000>;
};
- partition@1 {
+ partition@20000 {
label = "xload_backup1";
reg = <0x20000 0x20000>;
};
- partition@2 {
+ partition@40000 {
label = "xload_backup2";
reg = <0x40000 0x20000>;
};
- partition@3 {
+ partition@60000 {
label = "xload_backup3";
reg = <0x60000 0x20000>;
};
- partition@4 {
+ partition@80000 {
label = "barebox";
reg = <0x80000 0x80000>;
};
- partition@5 {
+ partition@100000 {
label = "bareboxenv";
reg = <0x100000 0x40000>;
};
- partition@6 {
+ partition@140000 {
label = "oftree";
reg = <0x140000 0x40000>;
};
- partition@7 {
+ partition@180000 {
label = "kernel";
reg = <0x180000 0x800000>;
};
- partition@8 {
+ partition@980000 {
label = "root";
/*
* Size 0x0 extends partition to
diff --git a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi
index c60943ccec..6561625686 100644
--- a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi
@@ -165,22 +165,22 @@
reg = <0x0 0x20000>;
};
- partition@1 {
+ partition@20000 {
label = "barebox";
reg = <0x20000 0x80000>;
};
- partition@2 {
+ partition@a0000 {
label = "bareboxenv";
reg = <0xa0000 0x20000>;
};
- partition@3 {
+ partition@c0000 {
label = "oftree";
reg = <0xc0000 0x20000>;
};
- partition@4 {
+ partition@e0000 {
label = "kernel";
reg = <0xe0000 0x0>;
};
@@ -283,42 +283,42 @@
reg = <0x0 0x20000>;
};
- partition@1 {
+ partition@20000 {
label = "xload_backup1";
reg = <0x20000 0x20000>;
};
- partition@2 {
+ partition@40000 {
label = "xload_backup2";
reg = <0x40000 0x20000>;
};
- partition@3 {
+ partition@60000 {
label = "xload_backup3";
reg = <0x60000 0x20000>;
};
- partition@4 {
+ partition@80000 {
label = "barebox";
reg = <0x80000 0x80000>;
};
- partition@5 {
+ partition@100000 {
label = "bareboxenv";
reg = <0x100000 0x40000>;
};
- partition@6 {
+ partition@140000 {
label = "oftree";
reg = <0x140000 0x40000>;
};
- partition@7 {
+ partition@180000 {
label = "kernel";
reg = <0x180000 0x800000>;
};
- partition@8 {
+ partition@980000 {
label = "root";
reg = <0x980000 0x0>;
};
diff --git a/arch/arm/dts/imx25-karo-tx25.dts b/arch/arm/dts/imx25-karo-tx25.dts
index d661463282..8d79471a30 100644
--- a/arch/arm/dts/imx25-karo-tx25.dts
+++ b/arch/arm/dts/imx25-karo-tx25.dts
@@ -126,17 +126,17 @@
reg = <0x0 0x80000>;
};
- partition@1 {
+ partition@80000 {
label = "environment";
reg = <0x80000 0x80000>;
};
- partition@2 {
+ partition@100000 {
label = "kernel";
reg = <0x100000 0x400000>;
};
- partition@3 {
+ partition@500000 {
label = "root";
reg = <0x500000 0x7b00000>;
};
diff --git a/arch/arm/dts/imx27-phytec-phycard-s-rdk-bb.dts b/arch/arm/dts/imx27-phytec-phycard-s-rdk-bb.dts
index 3ea1b5b052..cb02a1dfce 100644
--- a/arch/arm/dts/imx27-phytec-phycard-s-rdk-bb.dts
+++ b/arch/arm/dts/imx27-phytec-phycard-s-rdk-bb.dts
@@ -18,20 +18,20 @@
&nfc {
partition@0 {
label = "boot";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
- partition@2 {
+ partition@100000 {
label = "kernel";
reg = <0x100000 0x400000>;
};
- partition@3 {
+ partition@500000 {
label = "root";
reg = <0x500000 0x7b00000>;
};
diff --git a/arch/arm/dts/imx27-phytec-phycore-rdk.dts b/arch/arm/dts/imx27-phytec-phycore-rdk.dts
index f602045c7e..fff154cb97 100644
--- a/arch/arm/dts/imx27-phytec-phycore-rdk.dts
+++ b/arch/arm/dts/imx27-phytec-phycore-rdk.dts
@@ -32,17 +32,17 @@
reg = <0x00000000 0x00080000>;
};
- environment_nand: partition@1 {
+ environment_nand: partition@80000 {
label = "env";
reg = <0x00080000 0x00020000>;
};
- partition@2 {
+ partition@a0000 {
label = "kernel";
reg = <0x000a0000 0x00400000>;
};
- partition@3 {
+ partition@4a0000 {
label = "root";
reg = <0x004a0000 0>;
};
@@ -54,17 +54,17 @@
reg = <0x00000000 0x00080000>;
};
- environment_nor: partition@1 {
+ environment_nor: partition@80000 {
label = "env";
reg = <0x00080000 0x00020000>;
};
- partition@2 {
+ partition@a0000 {
label = "kernel";
reg = <0x000a0000 0x00400000>;
};
- partition@3 {
+ partition@4a0000 {
label = "root";
reg = <0x004a0000 0>;
};
diff --git a/arch/arm/dts/imx51-babbage.dts b/arch/arm/dts/imx51-babbage.dts
index f8402ca8fa..bde3031d1b 100644
--- a/arch/arm/dts/imx51-babbage.dts
+++ b/arch/arm/dts/imx51-babbage.dts
@@ -27,9 +27,9 @@
#address-cells = <1>;
#size-cells = <1>;
- environment_esdhc1: partition@0 {
+ environment_esdhc1: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x20000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx51-genesi-efika-sb.dts b/arch/arm/dts/imx51-genesi-efika-sb.dts
index 78cb1b7184..5a2c3a1c40 100644
--- a/arch/arm/dts/imx51-genesi-efika-sb.dts
+++ b/arch/arm/dts/imx51-genesi-efika-sb.dts
@@ -415,9 +415,9 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0xc0000 0x40000>;
+ reg = <0xe0000 0x20000>;
};
};
@@ -533,9 +533,9 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
};
diff --git a/arch/arm/dts/imx53-ccxmx53.dts b/arch/arm/dts/imx53-ccxmx53.dts
index 85d20c3b63..4b5ec6534f 100644
--- a/arch/arm/dts/imx53-ccxmx53.dts
+++ b/arch/arm/dts/imx53-ccxmx53.dts
@@ -12,6 +12,7 @@
/dts-v1/;
#include "imx53-ccxmx53.dtsi"
+#include "imx53.dtsi"
/ {
model = "Digi ConnectCore ccxmx53";
diff --git a/arch/arm/dts/imx53-ccxmx53.dtsi b/arch/arm/dts/imx53-ccxmx53.dtsi
index 5553c68e25..2ed24b65e4 100644
--- a/arch/arm/dts/imx53-ccxmx53.dtsi
+++ b/arch/arm/dts/imx53-ccxmx53.dtsi
@@ -27,7 +27,7 @@
/ {
memory {
- reg = <0x70000000 0x40000000>;
+ reg = <0x0 0x0>;
};
};
@@ -228,26 +228,27 @@
pinctrl-0 = <&pinctrl_nand>;
nand-bus-width = <8>;
nand-ecc-mode = "hw";
+ nand-on-flash-bbt;
status = "okay";
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
- partition@2 {
+ partition@100000 {
label = "kernel";
reg = <0x100000 0x400000>;
};
- partition@3 {
+ partition@500000 {
label = "rootfs";
- reg = <0x500000 0x07B00000>;
+ reg = <0x500000 0x0>;
};
};
diff --git a/arch/arm/dts/imx53-guf-vincell-lt.dts b/arch/arm/dts/imx53-guf-vincell-lt.dts
index a577ab262e..bcc378d07f 100644
--- a/arch/arm/dts/imx53-guf-vincell-lt.dts
+++ b/arch/arm/dts/imx53-guf-vincell-lt.dts
@@ -361,15 +361,15 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- bareboxenv: partition@1 {
+ bareboxenv: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
- partition@2 {
+ partition@100000 {
label = "ubi";
reg = <0x100000 0x0>;
};
diff --git a/arch/arm/dts/imx53-mba53.dts b/arch/arm/dts/imx53-mba53.dts
index c908c61671..28f463c451 100644
--- a/arch/arm/dts/imx53-mba53.dts
+++ b/arch/arm/dts/imx53-mba53.dts
@@ -28,9 +28,9 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ partition@e0000 {
label = "environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx53-qsb-common.dtsi b/arch/arm/dts/imx53-qsb-common.dtsi
index 85e1b8bd01..f363af975d 100644
--- a/arch/arm/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/dts/imx53-qsb-common.dtsi
@@ -43,9 +43,9 @@
#address-cells = <1>;
#size-cells = <1>;
- bareboxenv: partition@0 {
+ bareboxenv: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x20000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx53-voipac-dmm-668.dtsi b/arch/arm/dts/imx53-voipac-dmm-668.dtsi
index 6f76d2867a..e91c7d02a2 100644
--- a/arch/arm/dts/imx53-voipac-dmm-668.dtsi
+++ b/arch/arm/dts/imx53-voipac-dmm-668.dtsi
@@ -15,20 +15,20 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
- partition@2 {
+ partition@100000 {
label = "kernel";
reg = <0x100000 0x400000>;
};
- partition@3 {
+ partition@500000 {
label = "rootfs";
reg = <0x500000 0x07B00000>;
};
diff --git a/arch/arm/dts/imx6dl-eltec-hipercam.dts b/arch/arm/dts/imx6dl-eltec-hipercam.dts
index f272e78a59..4fe174437e 100644
--- a/arch/arm/dts/imx6dl-eltec-hipercam.dts
+++ b/arch/arm/dts/imx6dl-eltec-hipercam.dts
@@ -37,15 +37,15 @@
partition@0 {
label = "barebox";
- reg = <0x0 0xc0000>;
+ reg = <0x0 0xe0000>;
};
- environment_nor0: partition@1 {
+ environment_nor0: partition@e0000 {
label = "bareboxenv";
- reg = <0xc0000 0x8000>;
+ reg = <0xe0000 0x20000>;
};
- partition@2 {
+ partition@100000 {
label = "persistent";
reg = <0x100000 0xf00000>;
};
diff --git a/arch/arm/dts/imx6dl-hummingboard.dts b/arch/arm/dts/imx6dl-hummingboard.dts
index 2314965260..7f4d2b42f2 100644
--- a/arch/arm/dts/imx6dl-hummingboard.dts
+++ b/arch/arm/dts/imx6dl-hummingboard.dts
@@ -29,11 +29,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts b/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts
index 2324f3a6e5..3f2f1c7320 100644
--- a/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts
+++ b/arch/arm/dts/imx6dl-phytec-phycore-som-nand.dts
@@ -53,11 +53,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6dl-wandboard.dts b/arch/arm/dts/imx6dl-wandboard.dts
index a8674004c8..873e9d6985 100644
--- a/arch/arm/dts/imx6dl-wandboard.dts
+++ b/arch/arm/dts/imx6dl-wandboard.dts
@@ -27,11 +27,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0xc0000>;
+ reg = <0x0 0xe0000>;
};
- environment_usdhc3: partition@c0000 {
+ environment_usdhc3: partition@e0000 {
label = "barebox-environment";
- reg = <0xc0000 0x40000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-dmo-edmqmx6.dts b/arch/arm/dts/imx6q-dmo-edmqmx6.dts
index 071f5f5c5e..3576211be4 100644
--- a/arch/arm/dts/imx6q-dmo-edmqmx6.dts
+++ b/arch/arm/dts/imx6q-dmo-edmqmx6.dts
@@ -53,12 +53,12 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x20000>;
+ reg = <0xe0000 0x20000>;
};
};
};
@@ -97,11 +97,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
@@ -111,10 +111,10 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-embedsky-e9.dts b/arch/arm/dts/imx6q-embedsky-e9.dts
index 726d620681..3bbb60bba3 100644
--- a/arch/arm/dts/imx6q-embedsky-e9.dts
+++ b/arch/arm/dts/imx6q-embedsky-e9.dts
@@ -41,11 +41,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- environment_mmc1: partition@1 {
+ environment_mmc1: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
@@ -55,10 +55,10 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- environment_mmc3: partition@1 {
+ environment_mmc3: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-guf-santaro.dts b/arch/arm/dts/imx6q-guf-santaro.dts
index 27f538a356..2bd1a26317 100644
--- a/arch/arm/dts/imx6q-guf-santaro.dts
+++ b/arch/arm/dts/imx6q-guf-santaro.dts
@@ -587,9 +587,9 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-hummingboard.dts b/arch/arm/dts/imx6q-hummingboard.dts
index e1d2fa8ce2..e707eb91c9 100644
--- a/arch/arm/dts/imx6q-hummingboard.dts
+++ b/arch/arm/dts/imx6q-hummingboard.dts
@@ -29,11 +29,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi b/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi
index 05224657dc..a6ea7b5cce 100644
--- a/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi
+++ b/arch/arm/dts/imx6q-phytec-pcaaxl3.dtsi
@@ -139,22 +139,22 @@
reg = <0x0 0x400000>;
};
- environment_nand: partition@1 {
+ environment_nand: partition@400000 {
label = "barebox-environment";
reg = <0x400000 0x20000>;
};
- partition@2 {
+ partition@420000 {
label = "oftree";
reg = <0x420000 0x20000>;
};
- partition@3 {
+ partition@440000 {
label = "kernel";
reg = <0x440000 0x800000>;
};
- partition@4 {
+ partition@C40000 {
label = "root";
reg = <0xC40000 0x0>;
};
@@ -181,10 +181,10 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- environment_usdhc3: partition@1 {
+ environment_usdhc3: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-phytec-phycore-som-nand.dts b/arch/arm/dts/imx6q-phytec-phycore-som-nand.dts
index 06f2f71537..aa2c94abee 100644
--- a/arch/arm/dts/imx6q-phytec-phycore-som-nand.dts
+++ b/arch/arm/dts/imx6q-phytec-phycore-som-nand.dts
@@ -62,11 +62,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6q-var-custom.dts b/arch/arm/dts/imx6q-var-custom.dts
index ef6981e3bc..fe03589454 100644
--- a/arch/arm/dts/imx6q-var-custom.dts
+++ b/arch/arm/dts/imx6q-var-custom.dts
@@ -127,17 +127,17 @@
reg = <0x0 0x200000>;
};
- partition@1 {
+ partition@200000 {
label = "barebox-environment";
reg = <0x200000 0x20000>;
};
- partition@2 {
+ partition@220000 {
label = "kernel";
reg = <0x220000 0x600000>;
};
- partition@3 {
+ partition@820000 {
label = "rootfs";
reg = <0x820000 0x18000000>;
};
diff --git a/arch/arm/dts/imx6q-var-som.dtsi b/arch/arm/dts/imx6q-var-som.dtsi
index d005f319d6..63a17fc660 100644
--- a/arch/arm/dts/imx6q-var-som.dtsi
+++ b/arch/arm/dts/imx6q-var-som.dtsi
@@ -42,17 +42,17 @@
reg = <0x0 0x200000>;
};
- environment_nand: partition@1 {
+ environment_nand: partition@200000 {
label = "barebox-environment";
reg = <0x200000 0x20000>;
};
- partition@2 {
+ partition@220000 {
label = "kernel";
reg = <0x220000 0x600000>;
};
- partition@3 {
+ partition@820000 {
label = "rootfs";
reg = <0x820000 0x1F7E0000>;
};
diff --git a/arch/arm/dts/imx6q-wandboard.dts b/arch/arm/dts/imx6q-wandboard.dts
index 26d8a0077d..0606727a11 100644
--- a/arch/arm/dts/imx6q-wandboard.dts
+++ b/arch/arm/dts/imx6q-wandboard.dts
@@ -27,11 +27,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0xc0000>;
+ reg = <0x0 0xe0000>;
};
- environment_usdhc3: partition@c0000 {
+ environment_usdhc3: partition@e0000 {
label = "barebox-environment";
- reg = <0xc0000 0x40000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6qdl-gw54xx.dtsi b/arch/arm/dts/imx6qdl-gw54xx.dtsi
index ea5739ddcb..5f8e489aeb 100644
--- a/arch/arm/dts/imx6qdl-gw54xx.dtsi
+++ b/arch/arm/dts/imx6qdl-gw54xx.dtsi
@@ -31,7 +31,7 @@
reg = <0x0 0x400000>;
};
- partition@1 {
+ partition@400000 {
label = "barebox-environment";
reg = <0x400000 0x20000>;
};
diff --git a/arch/arm/dts/imx6qdl-nitrogen6x.dtsi b/arch/arm/dts/imx6qdl-nitrogen6x.dtsi
index 8fcd4e48a4..9ff7395f45 100644
--- a/arch/arm/dts/imx6qdl-nitrogen6x.dtsi
+++ b/arch/arm/dts/imx6qdl-nitrogen6x.dtsi
@@ -31,12 +31,12 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi b/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi
index b79ce2c0f9..26f9746283 100644
--- a/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi
+++ b/arch/arm/dts/imx6qdl-phytec-pfla02.dtsi
@@ -66,17 +66,17 @@
reg = <0x0 0x100000>;
};
- partition@1 {
+ partition@100000 {
label = "barebox-environment";
reg = <0x100000 0x20000>;
};
- partition@2 {
+ partition@120000 {
label = "oftree";
reg = <0x120000 0x20000>;
};
- partition@3 {
+ partition@140000 {
label = "kernel";
reg = <0x140000 0x0>;
};
@@ -108,22 +108,22 @@
reg = <0x0 0x400000>;
};
- partition@1 {
+ partition@400000 {
label = "barebox-environment";
reg = <0x400000 0x100000>;
};
- partition@2 {
+ partition@500000 {
label = "oftree";
reg = <0x500000 0x100000>;
};
- partition@3 {
+ partition@600000 {
label = "kernel";
reg = <0x600000 0x800000>;
};
- partition@4 {
+ partition@e00000 {
label = "root";
reg = <0xe00000 0x0>;
};
@@ -180,11 +180,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi b/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi
index 2a975d103e..139150e207 100644
--- a/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi
+++ b/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi
@@ -55,17 +55,17 @@
reg = <0x0 0x100000>;
};
- partition@1 {
+ partition@100000 {
label = "barebox-environment";
reg = <0x100000 0x20000>;
};
- partition@2 {
+ partition@120000 {
label = "oftree";
reg = <0x120000 0x20000>;
};
- partition@3 {
+ partition@140000 {
label = "kernel";
reg = <0x140000 0x0>;
};
@@ -91,22 +91,22 @@
reg = <0x0 0x400000>;
};
- partition@1 {
+ partition@400000 {
label = "barebox-environment";
reg = <0x400000 0x100000>;
};
- partition@2 {
+ partition@500000 {
label = "oftree";
reg = <0x500000 0x100000>;
};
- partition@3 {
+ partition@600000 {
label = "kernel";
reg = <0x600000 0x800000>;
};
- partition@4 {
+ partition@e00000 {
label = "root";
reg = <0xe00000 0x0>;
};
@@ -256,11 +256,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6qdl-sabrelite.dtsi b/arch/arm/dts/imx6qdl-sabrelite.dtsi
index d5a6ff4b1f..10b0002ec2 100644
--- a/arch/arm/dts/imx6qdl-sabrelite.dtsi
+++ b/arch/arm/dts/imx6qdl-sabrelite.dtsi
@@ -31,12 +31,12 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- partition@1 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6qdl-sabresd.dtsi b/arch/arm/dts/imx6qdl-sabresd.dtsi
index 32318cf389..6b10229c88 100644
--- a/arch/arm/dts/imx6qdl-sabresd.dtsi
+++ b/arch/arm/dts/imx6qdl-sabresd.dtsi
@@ -31,11 +31,11 @@
partition@0 {
label = "barebox";
- reg = <0x0 0x80000>;
+ reg = <0x0 0xe0000>;
};
- environment_usdhc3: partition@1 {
+ environment_usdhc3: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6qdl-tx6x.dtsi b/arch/arm/dts/imx6qdl-tx6x.dtsi
index 9c5d676a74..3898425d9c 100644
--- a/arch/arm/dts/imx6qdl-tx6x.dtsi
+++ b/arch/arm/dts/imx6qdl-tx6x.dtsi
@@ -32,7 +32,7 @@
reg = <0x0 0x400000>;
};
- partition@1 {
+ partition@400000 {
label = "barebox-environment";
reg = <0x400000 0x100000>;
};
diff --git a/arch/arm/dts/imx6s-riotboard.dts b/arch/arm/dts/imx6s-riotboard.dts
index 3d0a930c3f..09ac534625 100644
--- a/arch/arm/dts/imx6s-riotboard.dts
+++ b/arch/arm/dts/imx6s-riotboard.dts
@@ -233,9 +233,9 @@
reg = <0x0 0x80000>;
};
- environment_usdhc4: partition@1 {
+ environment_usdhc4: partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x80000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/imx6sx-sdb.dts b/arch/arm/dts/imx6sx-sdb.dts
index fbf098bbe6..7b60f9326a 100644
--- a/arch/arm/dts/imx6sx-sdb.dts
+++ b/arch/arm/dts/imx6sx-sdb.dts
@@ -52,9 +52,9 @@
#address-cells = <1>;
#size-cells = <1>;
- partition@0 {
+ partition@e0000 {
label = "barebox-environment";
- reg = <0x80000 0x20000>;
+ reg = <0xe0000 0x20000>;
};
};
diff --git a/arch/arm/dts/rk3188-radxarock.dts b/arch/arm/dts/rk3188-radxarock.dts
index 47b2487dd9..cafd4d36ed 100644
--- a/arch/arm/dts/rk3188-radxarock.dts
+++ b/arch/arm/dts/rk3188-radxarock.dts
@@ -34,7 +34,7 @@
label = "barebox";
reg = <0x0 0x80000>;
};
- partition@1 {
+ partition@80000 {
label = "barebox-environment";
reg = <0x80000 0x80000>;
};
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 28b4f4a4b4..f6024c80ec 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -67,21 +67,30 @@ static int sdram_start_and_size(unsigned long *start, unsigned long *size)
return 0;
}
-static void get_kernel_addresses(unsigned long mem_start, size_t image_size,
+static int get_kernel_addresses(size_t image_size,
int verbose, unsigned long *load_address,
- unsigned long *spacing)
+ unsigned long *mem_free)
{
+ unsigned long mem_start, mem_size;
+ int ret;
+ size_t image_decomp_size;
+ unsigned long spacing;
+
+ ret = sdram_start_and_size(&mem_start, &mem_size);
+ if (ret)
+ return ret;
+
/*
* We don't know the exact decompressed size so just use a conservative
* default of 4 times the size of the compressed image.
*/
- size_t image_decomp_size = PAGE_ALIGN(image_size * 4);
+ image_decomp_size = PAGE_ALIGN(image_size * 4);
/*
* By default put oftree/initrd close behind compressed kernel image to
* avoid placing it outside of the kernels lowmem region.
*/
- *spacing = SZ_1M;
+ spacing = SZ_1M;
if (*load_address == UIMAGE_INVALID_ADDRESS) {
/*
@@ -99,8 +108,12 @@ static void get_kernel_addresses(unsigned long mem_start, size_t image_size,
* spacing to allow this relocation to happen without
* overwriting anything placed behind the kernel.
*/
- *spacing += image_decomp_size;
+ spacing += image_decomp_size;
}
+
+ *mem_free = PAGE_ALIGN(*load_address + image_size + spacing);
+
+ return 0;
}
static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int swap)
@@ -160,24 +173,20 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
static int do_bootm_linux(struct image_data *data)
{
- unsigned long load_address, mem_start, mem_size, mem_free, spacing;
+ unsigned long load_address, mem_free;
int ret;
- ret = sdram_start_and_size(&mem_start, &mem_size);
- if (ret)
- return ret;
-
load_address = data->os_address;
- get_kernel_addresses(mem_start, bootm_get_os_size(data),
- bootm_verbose(data), &load_address, &spacing);
+ ret = get_kernel_addresses(bootm_get_os_size(data),
+ bootm_verbose(data), &load_address, &mem_free);
+ if (ret)
+ return ret;
ret = bootm_load_os(data, load_address);
if (ret)
return ret;
- mem_free = PAGE_ALIGN(data->os_res->end + spacing);
-
return __do_bootm_linux(data, mem_free, 0);
}
@@ -273,11 +282,7 @@ static int do_bootz_linux(struct image_data *data)
u32 end, start;
size_t image_size;
unsigned long load_address = data->os_address;
- unsigned long mem_start, mem_size, mem_free, spacing;
-
- ret = sdram_start_and_size(&mem_start, &mem_size);
- if (ret)
- return ret;
+ unsigned long mem_free;
fd = open(data->os_file, O_RDONLY);
if (fd < 0) {
@@ -315,8 +320,10 @@ static int do_bootz_linux(struct image_data *data)
image_size = end - start;
load_address = data->os_address;
- get_kernel_addresses(mem_start, image_size, bootm_verbose(data),
- &load_address, &spacing);
+ ret = get_kernel_addresses(image_size, bootm_verbose(data),
+ &load_address, &mem_free);
+ if (ret)
+ return ret;
data->os_res = request_sdram_region("zimage", load_address, image_size);
if (!data->os_res) {
@@ -352,8 +359,6 @@ static int do_bootz_linux(struct image_data *data)
close(fd);
- mem_free = PAGE_ALIGN(data->os_res->end + spacing);
-
return __do_bootm_linux(data, mem_free, swap);
err_out:
@@ -570,7 +575,7 @@ static int armlinux_register_image_handler(void)
register_image_handler(&aimage_handler);
binfmt_register(&binfmt_aimage_hook);
}
- if (IS_BUILTIN(CONFIG_CMD_BOOTM_FITIMAGE))
+ if (IS_BUILTIN(CONFIG_FITIMAGE))
register_image_handler(&arm_fit_handler);
binfmt_register(&binfmt_arm_zimage_hook);
binfmt_register(&binfmt_barebox_hook);
diff --git a/arch/arm/mach-omap/am33xx_bbu_nand.c b/arch/arm/mach-omap/am33xx_bbu_nand.c
index ee767d32e4..25f0e79ee6 100644
--- a/arch/arm/mach-omap/am33xx_bbu_nand.c
+++ b/arch/arm/mach-omap/am33xx_bbu_nand.c
@@ -40,7 +40,7 @@ static int write_image(const char *devfile, const void *image, size_t size)
return fd;
}
- ret = erase(fd, ~0, 0);
+ ret = erase(fd, ERASE_SIZE_ALL, 0);
if (ret < 0) {
pr_err("could not erase %s: %s\n", devfile,
errno_str());
diff --git a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
index 702bb9af59..69a73ffb06 100644
--- a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
+++ b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
@@ -70,7 +70,7 @@ static int spi_nor_mlo_handler(struct bbu_handler *handler,
goto out;
}
- ret = erase(dstfd, ~0, 0);
+ ret = erase(dstfd, ERASE_SIZE_ALL, 0);
if (ret < 0) {
printf("could not erase %s: %s", data->devicefile, errno_str());
goto out1;
diff --git a/arch/arm/mach-tegra/include/mach/lowlevel.h b/arch/arm/mach-tegra/include/mach/lowlevel.h
index f70688e029..e9ba5ee393 100644
--- a/arch/arm/mach-tegra/include/mach/lowlevel.h
+++ b/arch/arm/mach-tegra/include/mach/lowlevel.h
@@ -255,9 +255,6 @@ void tegra_cpu_lowlevel_setup(char *fdt)
{
uint32_t r;
- if (tegra_cpu_is_maincomplex())
- tegra_maincomplex_entry(fdt - get_runtime_offset());
-
/* set the cpu to SVC32 mode */
__asm__ __volatile__("mrs %0, cpsr":"=r"(r));
r &= ~0x1f;
@@ -265,6 +262,10 @@ void tegra_cpu_lowlevel_setup(char *fdt)
__asm__ __volatile__("msr cpsr, %0" : : "r"(r));
arm_setup_stack(TEGRA_IRAM_BASE + SZ_256K - 8);
+
+ if (tegra_cpu_is_maincomplex())
+ tegra_maincomplex_entry(fdt - get_runtime_offset());
+
tegra_ll_delay_setup();
}
diff --git a/commands/Kconfig b/commands/Kconfig
index 875c5f4f01..13dd9bb9b3 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -266,19 +266,6 @@ endmenu
menu "Boot"
-# TODO: isn't a command
-config FLEXIBLE_BOOTARGS
- bool
- prompt "flexible Linux bootargs generation"
- depends on CMD_GLOBAL
- help
- Select this to get a more flexible bootargs generation. With this
- option the bootargs are concatenated together from global variables
- beginning with 'global.linux.bootargs.' and 'global.linux.mtdparts.'
- This allows for more flexible scripting since with it it's possible
- to replace parts of the bootargs string without reconstructing it
- completely.
-
config CMD_AT91_BOOT_TEST
bool "at91_boot_test"
depends on ARCH_AT91
diff --git a/commands/bootm.c b/commands/bootm.c
index 7a19fa2948..bfec62c98b 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -166,6 +166,7 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_initrd, global.bootm.initrd, "bootm default
BAREBOX_MAGICVAR_NAMED(global_bootm_initrd_loadaddr, global.bootm.initrd.loadaddr, "bootm default initrd loadaddr");
BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, global.bootm.oftree, "bootm default oftree");
BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm default verify level");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from");
static struct binfmt_hook binfmt_uimage_hook = {
.type = filetype_uimage,
diff --git a/commands/flash.c b/commands/flash.c
index 99d3cb7c3f..d881b4d399 100644
--- a/commands/flash.c
+++ b/commands/flash.c
@@ -32,7 +32,7 @@ static int do_flerase(int argc, char *argv[])
int fd;
char *filename = NULL;
struct stat s;
- loff_t start = 0, size = ~0;
+ loff_t start = 0, size;
int ret = 0;
if (argc == 1)
diff --git a/commands/i2c.c b/commands/i2c.c
index f4ffc99827..ae7f7fc6d0 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -55,7 +55,7 @@ static int do_i2c_probe(int argc, char *argv[])
if (argc > 2)
startaddr = simple_strtol(argv[2], NULL, 0);
if (argc > 3)
- startaddr = simple_strtol(argv[3], NULL, 0);
+ stopaddr = simple_strtol(argv[3], NULL, 0);
if (startaddr > stopaddr)
@@ -243,7 +243,7 @@ BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(i2c_read)
.cmd = do_i2c_read,
BAREBOX_CMD_DESC("read from an i2c device")
- BAREBOX_CMD_OPTS("[-bacrwv] DATA...")
+ BAREBOX_CMD_OPTS("[-bacrwv]")
BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
BAREBOX_CMD_HELP(cmd_i2c_read_help)
BAREBOX_CMD_END
diff --git a/common/Kconfig b/common/Kconfig
index 7c09e8c117..d00ca6b0fb 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -536,6 +536,18 @@ config BLSPEC
on a device and it allows the Operating System to install / update
kernels.
+config FLEXIBLE_BOOTARGS
+ bool
+ prompt "flexible Linux bootargs generation"
+ depends on GLOBALVAR
+ help
+ Select this to get a more flexible bootargs generation. With this
+ option the bootargs are concatenated together from global variables
+ beginning with 'global.linux.bootargs.' and 'global.linux.mtdparts.'
+ This allows for more flexible scripting since with it it's possible
+ to replace parts of the bootargs string without reconstructing it
+ completely.
+
config IMD
bool "barebox metadata support"
diff --git a/common/blspec.c b/common/blspec.c
index 18005569ff..ac8f512891 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -637,29 +637,6 @@ int blspec_scan_devicename(struct blspec *blspec, const char *devname)
return blspec_scan_device(blspec, dev);
}
-static int blspec_append_root(struct blspec_entry *entry)
-{
- const char *appendroot;
- char *rootarg;
-
- appendroot = blspec_entry_var_get(entry, "linux-appendroot");
- if (!appendroot || strcmp(appendroot, "true"))
- return 0;
-
- rootarg = path_get_linux_rootarg(entry->rootpath);
- if (IS_ERR(rootarg)) {
- pr_err("Getting root argument for %s failed with: %s\n",
- entry->rootpath, strerrorp(rootarg));
- return PTR_ERR(rootarg);
- }
-
- globalvar_add_simple("linux.bootargs.dyn.blspec.appendroot", rootarg);
-
- free(rootarg);
-
- return 0;
-}
-
/*
* blspec_boot - boot an entry
*
@@ -671,6 +648,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
{
int ret;
const char *abspath, *devicetree, *options, *initrd, *linuximage;
+ const char *appendroot;
struct bootm_data data = {
.initrd_address = UIMAGE_INVALID_ADDRESS,
.os_address = UIMAGE_SOME_ADDRESS,
@@ -709,9 +687,18 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
globalvar_add_simple("linux.bootargs.dyn.blspec", options);
- ret = blspec_append_root(entry);
- if (ret)
- goto err_out;
+ appendroot = blspec_entry_var_get(entry, "linux-appendroot");
+ if (appendroot) {
+ int val;
+
+ ret = strtobool(appendroot, &val);
+ if (ret) {
+ pr_err("Invalid value \"%s\" for appendroot option\n",
+ appendroot);
+ goto err_out;
+ }
+ data.appendroot = val;
+ }
pr_info("booting %s from %s\n", blspec_entry_var_get(entry, "title"),
entry->cdev ? dev_name(entry->cdev->dev) : "none");
diff --git a/common/bootm.c b/common/bootm.c
index 6d22aab289..cad8c73efe 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -48,6 +48,8 @@ static struct image_handler *bootm_find_handler(enum filetype filetype,
return NULL;
}
+static int bootm_appendroot;
+
void bootm_data_init_defaults(struct bootm_data *data)
{
data->initrd_address = UIMAGE_INVALID_ADDRESS;
@@ -58,6 +60,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
data->verify = bootm_get_verify_mode();
+ data->appendroot = bootm_appendroot;
}
static enum bootm_verify bootm_verify_mode = BOOTM_VERIFY_HASH;
@@ -576,6 +579,18 @@ int bootm_boot(struct bootm_data *bootm_data)
}
}
+ if (bootm_data->appendroot) {
+ char *rootarg;
+
+ rootarg = path_get_linux_rootarg(data->os_file);
+ if (!IS_ERR(rootarg)) {
+ printf("Adding \"%s\" to Kernel commandline\n", rootarg);
+ globalvar_add_simple("linux.bootargs.bootm.appendroot",
+ rootarg);
+ free(rootarg);
+ }
+ }
+
printf("\nLoading %s '%s'", file_type_to_string(os_type),
data->os_file);
if (os_type == filetype_uimage &&
@@ -621,6 +636,7 @@ err_out:
if (data->of_root_node && data->of_root_node != of_get_root_node())
of_delete_node(data->of_root_node);
+ globalvar_remove("linux.bootargs.bootm.appendroot");
free(data->os_file);
free(data->oftree_file);
free(data->initrd_file);
@@ -634,6 +650,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+ globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD)) {
globalvar_add_simple("bootm.initrd", NULL);
globalvar_add_simple("bootm.initrd.loadaddr", NULL);
diff --git a/common/env.c b/common/env.c
index c98ed73f9b..d6cab52a4b 100644
--- a/common/env.c
+++ b/common/env.c
@@ -28,6 +28,7 @@
#include <xfuncs.h>
#include <errno.h>
#include <init.h>
+#include <string.h>
#include <environment.h>
static struct env_context root = {
@@ -323,20 +324,25 @@ int getenv_uint(const char *var , unsigned int *val)
}
EXPORT_SYMBOL(getenv_uint);
+/**
+ * getenv_bool - get a boolean value from an environment variable
+ * @var - Variable name
+ * @val - The boolean value returned.
+ *
+ * This function treats
+ * - any positive (nonzero) number as true
+ * - "0" as false
+ * - "true" (case insensitive) as true
+ * - "false" (case insensitive) as false
+ *
+ * Returns 0 for success or negative error code if the variable does
+ * not exist or contains something this function does not recognize
+ * as true or false.
+ */
int getenv_bool(const char *var, int *val)
{
const char *valstr = getenv(var);
- if (!valstr || !*valstr)
- return -EINVAL;
-
- if (!*valstr)
- *val = false;
- else if (*valstr == '0')
- *val = false;
- else
- *val = true;
-
- return 0;
+ return strtobool(valstr, val);
}
EXPORT_SYMBOL(getenv_bool);
diff --git a/common/environment.c b/common/environment.c
index 9cf44a0f06..be102db3d2 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -88,6 +88,7 @@ static int do_compare_file(const char *filename, const char *base)
}
#else
+#define ERASE_SIZE_ALL 0
static inline int protect(int fd, size_t count, unsigned long offset, int prot)
{
return 0;
@@ -329,7 +330,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags)
goto out;
}
- ret = erase(envfd, ~0, 0);
+ ret = erase(envfd, ERASE_SIZE_ALL, 0);
/* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */
if (ret && errno != ENOSYS && errno != EOPNOTSUPP) {
diff --git a/common/filetype.c b/common/filetype.c
index 74baf51446..a8666a1439 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -291,8 +291,6 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (bufsize < 64)
return filetype_unknown;
- if (buf8[0] == 'M' && buf8[1] == 'Z')
- return filetype_exe;
if (le32_to_cpu(buf[5]) == 0x504d5453)
return filetype_mxs_bootstream;
@@ -301,6 +299,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01)
return filetype_arm_zimage;
+ if (buf8[0] == 'M' && buf8[1] == 'Z')
+ return filetype_exe;
+
if (bufsize < 512)
return filetype_unknown;
diff --git a/common/globalvar.c b/common/globalvar.c
index 9a793ac4a9..05c3e798d7 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -33,6 +33,16 @@ int globalvar_add(const char *name,
return 0;
}
+void globalvar_remove(const char *name)
+{
+ struct param_d *param = get_param_by_name(&global_device, name);
+
+ if (!param)
+ return;
+
+ dev_remove_param(param);
+}
+
static int nv_save(const char *name, const char *val)
{
int fd, ret;
diff --git a/drivers/ata/sata-imx.c b/drivers/ata/sata-imx.c
index 6a601956db..7b8036bbf3 100644
--- a/drivers/ata/sata-imx.c
+++ b/drivers/ata/sata-imx.c
@@ -112,7 +112,7 @@ static int imx_sata_probe(struct device_d *dev)
imx_ahci->ahci.dev = dev;
dev->priv = &imx_ahci->ahci;
- dev->info = ahci_info,
+ dev->info = ahci_info;
ret = ahci_add_host(&imx_ahci->ahci);
if (ret)
diff --git a/drivers/serial/serial_auart.c b/drivers/serial/serial_auart.c
index 9bef576cd7..c3b9a1995f 100644
--- a/drivers/serial/serial_auart.c
+++ b/drivers/serial/serial_auart.c
@@ -230,9 +230,18 @@ static void auart_serial_remove(struct device_d *dev)
free(priv);
}
+static const __maybe_unused struct of_device_id auart_serial_dt_ids[] = {
+ {
+ .compatible = "fsl,imx23-auart",
+ }, {
+ /* sentinel */
+ }
+};
+
static struct driver_d auart_serial_driver = {
.name = "auart_serial",
.probe = auart_serial_probe,
.remove = auart_serial_remove,
+ .of_compatible = DRV_OF_COMPAT(auart_serial_dt_ids),
};
console_platform_driver(auart_serial_driver);
diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index 351b584796..d7bf92cdff 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -359,7 +359,7 @@ static int handle_dnload(struct usb_function *f, const struct usb_ctrlrequest *c
ret = -EINVAL;
goto err_out;
}
- ret = erase(fd, ~0, 0);
+ ret = erase(fd, ERASE_SIZE_ALL, 0);
close(fd);
if (ret && ret != -ENOSYS) {
perror("erase");
@@ -479,7 +479,7 @@ static int dfu_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
goto out;
}
- ret = erase(dfufd, ~0, 0);
+ ret = erase(dfufd, ERASE_SIZE_ALL, 0);
if (ret && ret != -ENOSYS) {
dfu->dfu_status = DFU_STATUS_errERASE;
perror("erase");
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 0df08c9a2b..aaf784913b 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -784,7 +784,7 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req, const char *cmd
if (fd < 0)
fastboot_tx_print(f_fb, "FAIL%s", strerror(-fd));
- ret = erase(fd, ~0, 0);
+ ret = erase(fd, ERASE_SIZE_ALL, 0);
close(fd);
diff --git a/fs/fs.c b/fs/fs.c
index 440adae14c..966abe9408 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -935,8 +935,10 @@ int erase(int fd, loff_t count, loff_t offset)
f = &files[fd];
if (offset >= f->size)
return 0;
- if (count > f->size - offset)
+ if (count == ERASE_SIZE_ALL || count > f->size - offset)
count = f->size - offset;
+ if (count < 0)
+ return -EINVAL;
fsdrv = f->fsdev->driver;
if (fsdrv->erase)
diff --git a/images/Makefile.am33xx b/images/Makefile.am33xx
index 6c7e81a9dc..8be78eff89 100644
--- a/images/Makefile.am33xx
+++ b/images/Makefile.am33xx
@@ -83,6 +83,12 @@ FILE_barebox-am33xx-phytec-phycore-mlo-1024mb.spi.img = start_am33xx_phytec_phyc
am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-1024mb.img
am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-1024mb.spi.img
+pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_r2_sram_1024mb
+FILE_barebox-am33xx-phytec-phycore-r2-mlo-1024mb.img = start_am33xx_phytec_phycore_r2_sram_1024mb.pblx.mlo
+FILE_barebox-am33xx-phytec-phycore-r2-mlo-1024mb.spi.img = start_am33xx_phytec_phycore_r2_sram_1024mb.pblx.mlospi
+am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-1024mb.img
+am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-1024mb.spi.img
+
pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phyflex_sdram
FILE_barebox-am33xx-phytec-phyflex.img = start_am33xx_phytec_phyflex_sdram.pblx
am33xx-barebox-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phyflex.img
diff --git a/images/Makefile.socfpga b/images/Makefile.socfpga
index d52b909ff3..7e642c06c9 100644
--- a/images/Makefile.socfpga
+++ b/images/Makefile.socfpga
@@ -2,7 +2,7 @@
# barebox image generation Makefile for Altera socfpga
#
-# %.socfpga - convert into socfpga image
+# %.socfpgaimg - convert into socfpga image
# ----------------------------------------------------------------
quiet_cmd_socfpga_image = SOCFPGA-IMG $@
cmd_socfpga_image = scripts/socfpga_mkimage -b -o $@ $<
diff --git a/include/boot.h b/include/boot.h
index 0198cc8826..8fcbb7f012 100644
--- a/include/boot.h
+++ b/include/boot.h
@@ -21,6 +21,11 @@ struct bootm_data {
enum bootm_verify verify;
bool force;
bool dryrun;
+ /*
+ * appendroot - if true, try to add a suitable root= Kernel option to
+ * mount the rootfs from the same device as the Kernel comes from.
+ */
+ bool appendroot;
unsigned long initrd_address;
unsigned long os_address;
unsigned long os_entry;
diff --git a/include/fs.h b/include/fs.h
index b9d1e6e09a..943ba55439 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -147,6 +147,7 @@ int umount(const char *pathname);
int umount_by_cdev(struct cdev *cdev);
/* not-so-standard functions */
+#define ERASE_SIZE_ALL ((loff_t) - 1)
int erase(int fd, loff_t count, loff_t offset);
int protect(int fd, size_t count, loff_t offset, int prot);
int protect_file(const char *file, int prot);
diff --git a/include/globalvar.h b/include/globalvar.h
index e77209bd79..d0c79c07a8 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -14,6 +14,7 @@ int globalvar_add(const char *name,
int (*set)(struct device_d *dev, struct param_d *p, const char *val),
const char *(*get)(struct device_d *, struct param_d *p),
unsigned long flags);
+void globalvar_remove(const char *name);
char *globalvar_get_match(const char *match, const char *separator);
void globalvar_set_match(const char *match, const char *val);
diff --git a/include/string.h b/include/string.h
index a833da131b..0c557d6f15 100644
--- a/include/string.h
+++ b/include/string.h
@@ -4,5 +4,6 @@
#include <linux/string.h>
void *memdup(const void *, size_t);
+int strtobool(const char *str, int *val);
#endif /* __STRING_H */
diff --git a/lib/parameter.c b/lib/parameter.c
index fd05b49adf..cf34817dc2 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -27,6 +27,7 @@
#include <net.h>
#include <malloc.h>
#include <driver.h>
+#include <string.h>
#include <linux/err.h>
struct param_d *get_param_by_name(struct device_d *dev, const char *name)
@@ -314,10 +315,13 @@ static int param_int_set(struct device_d *dev, struct param_d *p, const char *va
if (!val)
return -EINVAL;
- *pi->value = simple_strtol(val, NULL, 0);
-
- if (pi->flags & PARAM_INT_FLAG_BOOL)
- *pi->value = !!*pi->value;
+ if (pi->flags & PARAM_INT_FLAG_BOOL) {
+ ret = strtobool(val, pi->value);
+ if (ret)
+ return ret;
+ } else {
+ *pi->value = simple_strtol(val, NULL, 0);
+ }
if (!pi->set)
return 0;
diff --git a/lib/string.c b/lib/string.c
index 6a39eb5ced..a3e9fd819b 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -739,3 +739,46 @@ void *memdup(const void *orig, size_t size)
return buf;
}
EXPORT_SYMBOL(memdup);
+
+/**
+ * strtobool - convert a string to a boolean value
+ * @str - The string
+ * @val - The boolean value returned.
+ *
+ * This function treats
+ * - any positive (nonzero) number as true
+ * - "0" as false
+ * - "true" (case insensitive) as true
+ * - "false" (case insensitive) as false
+ *
+ * Every other value results in an error and the @val is not
+ * modified. The caller is expected to initialize @val with the
+ * correct default before calling strtobool.
+ *
+ * Returns 0 for success or negative error code if the variable does
+ * not exist or contains something this function does not recognize
+ * as true or false.
+ */
+int strtobool(const char *str, int *val)
+{
+ if (!str || !*str)
+ return -EINVAL;
+
+ if (simple_strtoul(str, NULL, 0) > 0) {
+ *val = true;
+ return 0;
+ }
+
+ if (!strcmp(str, "0") || !strcasecmp(str, "false")) {
+ *val = false;
+ return 0;
+ }
+
+ if (!strcasecmp(str, "true")) {
+ *val = true;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+EXPORT_SYMBOL(strtobool);
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 523368aa54..70936babfd 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -237,6 +237,10 @@ static int do_soc(struct config_data *data, int argc, char *argv[])
if (!strcmp(socs[i].name, soc)) {
data->header_version = socs[i].header_version;
data->cpu_type = socs[i].cpu_type;
+
+ if (data->cpu_type == 35)
+ data->load_size += HEADER_LEN;
+
return 0;
}
}
@@ -246,9 +250,6 @@ static int do_soc(struct config_data *data, int argc, char *argv[])
fprintf(stderr, "%s ", socs[i].name);
fprintf(stderr, "\n");
- if (data->cpu_type == 35)
- data->load_size += HEADER_LEN;
-
return -EINVAL;
}