summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-01-15 07:58:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-01-15 07:58:30 +0100
commit38188906dce22189462cea0b23e67fd122e22dea (patch)
tree7c3c70ad7ff6c274e5fe72a33e58305180e9c390
parente1907bca0cf0237ad4cd7340dbadaf8f4bcd5bad (diff)
parent661ef436f2a1e0efcf90f469f7200404717da64d (diff)
downloadbarebox-38188906dce22189462cea0b23e67fd122e22dea.tar.gz
barebox-38188906dce22189462cea0b23e67fd122e22dea.tar.xz
Merge branch 'for-next/misc'
-rw-r--r--arch/mips/Kconfig4
-rw-r--r--arch/mips/Makefile2
-rw-r--r--arch/mips/boards/tplink-mr3020/lowlevel.S2
-rw-r--r--arch/mips/dts/Makefile2
-rw-r--r--arch/mips/dts/ar9331_tl_mr3020.dts (renamed from arch/mips/dts/tplink-mr3020.dts)0
-rw-r--r--arch/mips/include/asm/cpu.h4
-rw-r--r--arch/mips/lib/cpu-probe.c4
-rw-r--r--commands/digest.c2
-rw-r--r--commands/led.c4
-rw-r--r--commands/miitool.c7
-rw-r--r--commands/nv.c5
-rw-r--r--common/Kconfig24
-rw-r--r--common/Makefile3
-rw-r--r--common/envfs-core.c197
-rw-r--r--common/environment.c172
-rw-r--r--common/globalvar.c16
-rw-r--r--common/startup.c24
-rw-r--r--drivers/led/led-pca955x.c1
-rw-r--r--drivers/mci/imx-esdhc.c2
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c2
-rw-r--r--drivers/of/address.c24
-rw-r--r--images/.gitignore2
-rw-r--r--include/envfs.h5
-rw-r--r--include/linux/amba/bus.h6
-rw-r--r--scripts/bareboxenv.c1
25 files changed, 285 insertions, 230 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1395ad4c6f..7a8f010506 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -174,7 +174,7 @@ choice
config CPU_LOONGSON1B
bool "Loongson 1B"
depends on SYS_HAS_CPU_LOONGSON1B
- select CPU_LOONGSON1
+ select CPU_GS232
help
The Loongson 1B is a 32-bit SoC, which implements the MIPS32
release 2 instruction set.
@@ -235,7 +235,7 @@ config CPU_MIPS64_R2
endchoice
-config CPU_LOONGSON1
+config CPU_GS232
bool
select CPU_MIPS32
select CPU_MIPSR2
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 1c10db599c..72b77adc4c 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -52,7 +52,7 @@ cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips32 -U_MIPS
cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) -Wa,-mips32r2 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips64 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) -Wa,-mips64 -Wa,--trap
cflags-$(CONFIG_CPU_MIPS64_R2) += $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) -Wa,-mips64r2 -Wa,--trap
-cflags-$(CONFIG_CPU_LOONGSON1) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) -Wa,-mips32r2 -Wa,--trap
+cflags-$(CONFIG_CPU_GS232) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) -Wa,-mips32r2 -Wa,--trap
CPPFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE)
diff --git a/arch/mips/boards/tplink-mr3020/lowlevel.S b/arch/mips/boards/tplink-mr3020/lowlevel.S
index b96292ecc4..5844530986 100644
--- a/arch/mips/boards/tplink-mr3020/lowlevel.S
+++ b/arch/mips/boards/tplink-mr3020/lowlevel.S
@@ -17,4 +17,4 @@ ENTRY_FUNCTION(BOARD_PBL_START)
ar9331_pbl_generic_start
-ENTRY_FUNCTION_END(BOARD_PBL_START, tplink_mr3020, SZ_32M)
+ENTRY_FUNCTION_END(BOARD_PBL_START, ar9331_tl_mr3020, SZ_32M)
diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
index 7485f85a14..b3660cd286 100644
--- a/arch/mips/dts/Makefile
+++ b/arch/mips/dts/Makefile
@@ -11,7 +11,7 @@ pbl-dtb-$(CONFIG_BOARD_DPTECHNICS_DPT_MODULE) += ar9331-dptechnics-dpt-module.dt
pbl-dtb-$(CONFIG_BOARD_LOONGSON_TECH_LS1B) += loongson-ls1b.dtb.o
pbl-dtb-$(CONFIG_BOARD_QEMU_MALTA) += qemu-malta.dtb.o
pbl-dtb-$(CONFIG_BOARD_RZX50) += rzx50.dtb.o
-pbl-dtb-$(CONFIG_BOARD_TPLINK_MR3020) += tplink-mr3020.dtb.o
+pbl-dtb-$(CONFIG_BOARD_TPLINK_MR3020) += ar9331_tl_mr3020.dtb.o
pbl-dtb-$(CONFIG_BOARD_TPLINK_WDR4300) += ar9344-tl-wdr4300-v1.7.dtb.o
clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
diff --git a/arch/mips/dts/tplink-mr3020.dts b/arch/mips/dts/ar9331_tl_mr3020.dts
index c6ae154f4f..c6ae154f4f 100644
--- a/arch/mips/dts/tplink-mr3020.dts
+++ b/arch/mips/dts/ar9331_tl_mr3020.dts
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index e0bb78ea61..9d94eb346b 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -41,7 +41,7 @@
* These are valid when 23:16 == PRID_COMP_LEGACY
*/
-#define PRID_IMP_LOONGSON1 0x4200
+#define PRID_IMP_GS232 0x4200
#define PRID_IMP_UNKNOWN 0xff00
@@ -109,7 +109,7 @@ enum cpu_type_enum {
CPU_74K,
CPU_BMIPS3300,
CPU_JZRISC,
- CPU_LOONGSON1,
+ CPU_GS232,
CPU_LAST
};
diff --git a/arch/mips/lib/cpu-probe.c b/arch/mips/lib/cpu-probe.c
index ddabddd466..cbde43a595 100644
--- a/arch/mips/lib/cpu-probe.c
+++ b/arch/mips/lib/cpu-probe.c
@@ -83,10 +83,10 @@ static void decode_configs(struct cpuinfo_mips *c)
static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
{
switch (c->processor_id & PRID_IMP_MASK) {
- case PRID_IMP_LOONGSON1:
+ case PRID_IMP_GS232:
decode_configs(c);
- c->cputype = CPU_LOONGSON1;
+ c->cputype = CPU_GS232;
switch (c->processor_id & PRID_REV_MASK) {
case PRID_REV_LOONGSON1B:
diff --git a/commands/digest.c b/commands/digest.c
index 99b27dcc25..21a0917170 100644
--- a/commands/digest.c
+++ b/commands/digest.c
@@ -164,7 +164,7 @@ static int do_digest(int argc, char *argv[])
if (sig) {
digestlen = digest_length(d);
- if (siglen == 2 * digestlen) {
+ if (siglen >= 2 * digestlen) {
if (!tmp_sig)
tmp_sig = xmalloc(digestlen);
diff --git a/commands/led.c b/commands/led.c
index a53f0df6a2..b608fcfa2c 100644
--- a/commands/led.c
+++ b/commands/led.c
@@ -101,8 +101,8 @@ static int do_led(int argc, char *argv[])
ret = led_set(led, value);
if (ret < 0) {
- perror("led");
- return 1;
+ printf("led: %s\n", strerror(-ret));
+ return COMMAND_ERROR;
}
return 0;
diff --git a/commands/miitool.c b/commands/miitool.c
index 4ea6fda34d..a87d567ace 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -140,7 +140,10 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
}
*buf = '\0';
- if (bmcr & BMCR_ANENABLE) {
+
+ if (bmcr & BMCR_PDOWN) {
+ sprintf(buf, "powerdown, ");
+ } else if (bmcr & BMCR_ANENABLE) {
if (bmsr & BMSR_ANEGCOMPLETE) {
if (advert & lkpar) {
sprintf(buf, "%s%s, ", (lkpar & LPA_LPACK) ?
@@ -192,6 +195,8 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
printf("loopback, ");
if (bmcr & BMCR_ISOLATE)
printf("isolate, ");
+ if (bmcr & BMCR_PDOWN)
+ printf("powerdown, ");
if (bmcr & BMCR_CTST)
printf("collision test, ");
if (bmcr & BMCR_ANENABLE) {
diff --git a/commands/nv.c b/commands/nv.c
index 01c25a108f..315019345c 100644
--- a/commands/nv.c
+++ b/commands/nv.c
@@ -50,6 +50,11 @@ static int do_nv(int argc, char *argv[])
}
if (do_save) {
+ if (!IS_ENABLED(CONFIG_ENV_HANDLING)) {
+ printf("Error: Current configuration does not support saving variables\n");
+ return COMMAND_ERROR;
+ }
+
return nvvar_save();
}
diff --git a/common/Kconfig b/common/Kconfig
index 60237d3056..f9ef9bd83b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -174,19 +174,19 @@ config GLOBALVAR
config NVVAR
bool "Non volatile global environment variables support"
- default y if !SHELL_NONE
+ default y if !SHELL_NONE && ENV_HANDLING
depends on GLOBALVAR
- depends on ENV_HANDLING
select FNMATCH
help
Non volatile environment variables begin with "nv.". They behave like
- global variables above, but their values are saved in the environment
- storage with 'saveenv' and thus are persistent over restarts. nv variables
- are coupled with global variables of the same name. Setting "nv.foo" results
- in "global.foo" changed also (but not the other way round: setting "global.foo"
- leaves "nv.foo" untouched). The idea is that nv variables can store defaults
- while global variables can be changed during runtime without changing the
- default.
+ global variables above, but when CONFIG_ENV_HANDLING is enabled, they
+ can be stored in the environment storage with 'saveenv' and thus
+ persisted over restarts. nv variables are coupled with global
+ variables of the same name. Setting "nv.foo" results in "global.foo"
+ changed also (but not the other way round: setting "global.foo" leaves
+ "nv.foo" untouched). The idea is that nv variables can store defaults
+ while global variables can be changed during runtime without changing
+ the default.
menu "memory layout"
@@ -805,12 +805,12 @@ config ENV_HANDLING
config DEFAULT_ENVIRONMENT
bool
- default y
- depends on ENV_HANDLING
+ default y if ENV_HANDLING
prompt "Compile in default environment"
help
Enabling this option will give you a default environment when
- the environment found in the environment sector is invalid
+ the environment found in the environment sector is invalid or when
+ CONFIG_ENV_HANDLING is not enabled.
choice
prompt "default compression for in-barebox binaries"
diff --git a/common/Makefile b/common/Makefile
index 10960169f9..11c91dd016 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -26,7 +26,8 @@ obj-$(CONFIG_CONSOLE_FULL) += console.o
obj-$(CONFIG_CONSOLE_SIMPLE) += console_simple.o
obj-y += console_countdown.o
obj-pbl-$(CONFIG_DDR_SPD) += ddr_spd.o
-obj-$(CONFIG_ENV_HANDLING) += environment.o
+obj-$(CONFIG_ENV_HANDLING) += environment.o envfs-core.o
+obj-$(CONFIG_DEFAULT_ENVIRONMENT) += envfs-core.o
obj-$(CONFIG_ENVIRONMENT_VARIABLES) += env.o
obj-$(CONFIG_FILETYPE) += filetype.o
CFLAGS_filetype.o = -I$(srctree)/arch/
diff --git a/common/envfs-core.c b/common/envfs-core.c
new file mode 100644
index 0000000000..1898c1c8cb
--- /dev/null
+++ b/common/envfs-core.c
@@ -0,0 +1,197 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 Albert Schwarzkopf <a.schwarzkopf@phytec.de>, PHYTEC Messtechnik GmbH
+ * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ */
+
+/**
+ * @file
+ * @brief Environment handling support (host and target)
+ *
+ * Important: This file will also be used on the host to create
+ * the default environment when building the barebox binary. So
+ * do not add any new barebox related functions here!
+ */
+#ifdef __BAREBOX__
+#include <common.h>
+#include <fs.h>
+#include <crc.h>
+#include <envfs.h>
+#include <libbb.h>
+#include <libgen.h>
+#include <environment.h>
+#include <libfile.h>
+#else
+# define errno_str(x) ("void")
+#endif
+
+static int dir_remove_action(const char *filename, struct stat *statbuf,
+ void *userdata, int depth)
+{
+ if (!depth)
+ return 1;
+
+ rmdir(filename);
+
+ return 1;
+}
+
+int envfs_check_super(struct envfs_super *super, size_t *size)
+{
+ if (ENVFS_32(super->magic) != ENVFS_MAGIC) {
+ printf("envfs: no envfs (magic mismatch) - envfs never written?\n");
+ return -EIO;
+ }
+
+ if (crc32(0, super, sizeof(*super) - 4) != ENVFS_32(super->sb_crc)) {
+ printf("wrong crc on env superblock\n");
+ return -EIO;
+ }
+
+ if (super->major < ENVFS_MAJOR)
+ printf("envfs version %d.%d loaded into %d.%d\n",
+ super->major, super->minor,
+ ENVFS_MAJOR, ENVFS_MINOR);
+
+ *size = ENVFS_32(super->size);
+
+ return 0;
+}
+
+int envfs_check_data(struct envfs_super *super, const void *buf, size_t size)
+{
+ uint32_t crc;
+
+ crc = crc32(0, buf, size);
+ if (crc != ENVFS_32(super->crc)) {
+ printf("wrong crc on env\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int envfs_load_data(struct envfs_super *super, void *buf, size_t size,
+ const char *dir, unsigned flags)
+{
+ int fd, ret = 0;
+ char *str, *tmp;
+ int headerlen_full;
+ /* for envfs < 1.0 */
+ struct envfs_inode_end inode_end_dummy;
+ struct stat s;
+
+ inode_end_dummy.mode = ENVFS_32(S_IRWXU | S_IRWXG | S_IRWXO);
+ inode_end_dummy.magic = ENVFS_32(ENVFS_INODE_END_MAGIC);
+
+ while (size) {
+ struct envfs_inode *inode;
+ struct envfs_inode_end *inode_end;
+ uint32_t inode_size, inode_headerlen, namelen;
+
+ inode = buf;
+ buf += sizeof(struct envfs_inode);
+
+ if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) {
+ printf("envfs: wrong magic\n");
+ ret = -EIO;
+ goto out;
+ }
+ inode_size = ENVFS_32(inode->size);
+ inode_headerlen = ENVFS_32(inode->headerlen);
+ namelen = strlen(inode->data) + 1;
+ if (super->major < 1)
+ inode_end = &inode_end_dummy;
+ else
+ inode_end = buf + PAD4(namelen);
+
+ debug("loading %s size %d namelen %d headerlen %d\n", inode->data,
+ inode_size, namelen, inode_headerlen);
+
+ str = concat_path_file(dir, inode->data);
+
+ headerlen_full = PAD4(inode_headerlen);
+ buf += headerlen_full;
+
+ if (ENVFS_32(inode_end->magic) != ENVFS_INODE_END_MAGIC) {
+ printf("envfs: wrong inode_end_magic\n");
+ ret = -EIO;
+ goto out;
+ }
+
+ tmp = strdup(str);
+ make_directory(dirname(tmp));
+ free(tmp);
+
+ ret = stat(str, &s);
+ if (!ret && (flags & ENV_FLAG_NO_OVERWRITE)) {
+ printf("skip %s\n", str);
+ goto skip;
+ }
+
+ if (S_ISLNK(ENVFS_32(inode_end->mode))) {
+ debug("symlink: %s -> %s\n", str, (char*)buf);
+ if (!strcmp(buf, basename(str))) {
+ unlink(str);
+ } else {
+ if (!ret)
+ unlink(str);
+
+ ret = symlink(buf, str);
+ if (ret < 0)
+ printf("symlink: %s -> %s : %s\n",
+ str, (char*)buf, strerror(-errno));
+ }
+ free(str);
+ } else {
+ fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ free(str);
+ if (fd < 0) {
+ printf("Open %s\n", errno_str());
+ ret = fd;
+ goto out;
+ }
+
+ ret = write(fd, buf, inode_size);
+ if (ret < inode_size) {
+ perror("write");
+ ret = -errno;
+ close(fd);
+ goto out;
+ }
+ close(fd);
+ }
+skip:
+ buf += PAD4(inode_size);
+ size -= headerlen_full + PAD4(inode_size) +
+ sizeof(struct envfs_inode);
+ }
+
+ recursive_action(dir, ACTION_RECURSE | ACTION_DEPTHFIRST, NULL,
+ dir_remove_action, NULL, 0);
+
+ ret = 0;
+out:
+ return ret;
+}
+
+int envfs_load_from_buf(void *buf, int len, const char *dir, unsigned flags)
+{
+ int ret;
+ size_t size;
+ struct envfs_super *super = buf;
+
+ buf = super + 1;
+
+ ret = envfs_check_super(super, &size);
+ if (ret)
+ return ret;
+
+ ret = envfs_check_data(super, buf, size);
+ if (ret)
+ return ret;
+
+ ret = envfs_load_data(super, buf, size, dir, flags);
+
+ return ret;
+}
diff --git a/common/environment.c b/common/environment.c
index aba6dcde48..005caf45e6 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -56,7 +56,6 @@ struct action_data {
void *writep;
struct envfs_entry *env;
};
-#define PAD4(x) ((x + 3) & ~3)
#ifdef __BAREBOX__
@@ -228,17 +227,6 @@ static int file_remove_action(const char *filename, struct stat *statbuf,
}
#endif
-static int dir_remove_action(const char *filename, struct stat *statbuf,
- void *userdata, int depth)
-{
- if (!depth)
- return 1;
-
- rmdir(filename);
-
- return 1;
-}
-
/**
* Make the current environment persistent
* @param[in] filename where to store
@@ -382,166 +370,6 @@ out1:
}
EXPORT_SYMBOL(envfs_save);
-static int envfs_check_super(struct envfs_super *super, size_t *size)
-{
- if (ENVFS_32(super->magic) != ENVFS_MAGIC) {
- printf("envfs: no envfs (magic mismatch) - envfs never written?\n");
- return -EIO;
- }
-
- if (crc32(0, super, sizeof(*super) - 4) != ENVFS_32(super->sb_crc)) {
- printf("wrong crc on env superblock\n");
- return -EIO;
- }
-
- if (super->major < ENVFS_MAJOR)
- printf("envfs version %d.%d loaded into %d.%d\n",
- super->major, super->minor,
- ENVFS_MAJOR, ENVFS_MINOR);
-
- *size = ENVFS_32(super->size);
-
- return 0;
-}
-
-static int envfs_check_data(struct envfs_super *super, const void *buf, size_t size)
-{
- uint32_t crc;
-
- crc = crc32(0, buf, size);
- if (crc != ENVFS_32(super->crc)) {
- printf("wrong crc on env\n");
- return -EIO;
- }
-
- return 0;
-}
-
-static int envfs_load_data(struct envfs_super *super, void *buf, size_t size,
- const char *dir, unsigned flags)
-{
- int fd, ret = 0;
- char *str, *tmp;
- int headerlen_full;
- /* for envfs < 1.0 */
- struct envfs_inode_end inode_end_dummy;
- struct stat s;
-
- inode_end_dummy.mode = ENVFS_32(S_IRWXU | S_IRWXG | S_IRWXO);
- inode_end_dummy.magic = ENVFS_32(ENVFS_INODE_END_MAGIC);
-
- while (size) {
- struct envfs_inode *inode;
- struct envfs_inode_end *inode_end;
- uint32_t inode_size, inode_headerlen, namelen;
-
- inode = buf;
- buf += sizeof(struct envfs_inode);
-
- if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) {
- printf("envfs: wrong magic\n");
- ret = -EIO;
- goto out;
- }
- inode_size = ENVFS_32(inode->size);
- inode_headerlen = ENVFS_32(inode->headerlen);
- namelen = strlen(inode->data) + 1;
- if (super->major < 1)
- inode_end = &inode_end_dummy;
- else
- inode_end = buf + PAD4(namelen);
-
- debug("loading %s size %d namelen %d headerlen %d\n", inode->data,
- inode_size, namelen, inode_headerlen);
-
- str = concat_path_file(dir, inode->data);
-
- headerlen_full = PAD4(inode_headerlen);
- buf += headerlen_full;
-
- if (ENVFS_32(inode_end->magic) != ENVFS_INODE_END_MAGIC) {
- printf("envfs: wrong inode_end_magic\n");
- ret = -EIO;
- goto out;
- }
-
- tmp = strdup(str);
- make_directory(dirname(tmp));
- free(tmp);
-
- ret = stat(str, &s);
- if (!ret && (flags & ENV_FLAG_NO_OVERWRITE)) {
- printf("skip %s\n", str);
- goto skip;
- }
-
- if (S_ISLNK(ENVFS_32(inode_end->mode))) {
- debug("symlink: %s -> %s\n", str, (char*)buf);
- if (!strcmp(buf, basename(str))) {
- unlink(str);
- } else {
- if (!ret)
- unlink(str);
-
- ret = symlink(buf, str);
- if (ret < 0)
- printf("symlink: %s -> %s : %s\n",
- str, (char*)buf, strerror(-errno));
- }
- free(str);
- } else {
- fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- free(str);
- if (fd < 0) {
- printf("Open %s\n", errno_str());
- ret = fd;
- goto out;
- }
-
- ret = write(fd, buf, inode_size);
- if (ret < inode_size) {
- perror("write");
- ret = -errno;
- close(fd);
- goto out;
- }
- close(fd);
- }
-skip:
- buf += PAD4(inode_size);
- size -= headerlen_full + PAD4(inode_size) +
- sizeof(struct envfs_inode);
- }
-
- recursive_action(dir, ACTION_RECURSE | ACTION_DEPTHFIRST, NULL,
- dir_remove_action, NULL, 0);
-
- ret = 0;
-out:
- return ret;
-}
-
-int envfs_load_from_buf(void *buf, int len, const char *dir, unsigned flags)
-{
- int ret;
- size_t size;
- struct envfs_super *super = buf;
-
- buf = super + 1;
-
- ret = envfs_check_super(super, &size);
- if (ret)
- return ret;
-
- ret = envfs_check_data(super, buf, size);
- if (ret)
- return ret;
-
- ret = envfs_load_data(super, buf, size, dir, flags);
-
- return ret;
-}
-
/**
* Restore the last environment into the current one
* @param[in] filename from where to restore
diff --git a/common/globalvar.c b/common/globalvar.c
index 1bea7425d4..a826e1bc12 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -75,13 +75,19 @@ static int nv_save(const char *name, const char *val)
if (ret)
return ret;
- if (once) {
- pr_info("nv variable modified, will save nv variables on shutdown\n");
- once = 0;
+ if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
+ if (once) {
+ pr_info("nv variable modified, will save nv variables on shutdown\n");
+ once = 0;
+ }
+ nv_dirty = 1;
+ } else {
+ if (once) {
+ pr_info("nv variable modified, but won't be saved in this configuration\n");
+ once = 0;
+ }
}
- nv_dirty = 1;
-
return 0;
}
diff --git a/common/startup.c b/common/startup.c
index c6e119966a..c417a4d078 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -122,29 +122,39 @@ conflict:
return -EINVAL;
}
+#else
+static int check_overlap(const char *path)
+{
+ return 0;
+}
+#endif
static int load_environment(void)
{
const char *default_environment_path;
- int ret;
+ int __maybe_unused ret = 0;
default_environment_path = default_environment_path_get();
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT))
defaultenv_load("/env", 0);
- ret = check_overlap(default_environment_path);
- if (ret)
- default_environment_path_set(NULL);
- else
- envfs_load(default_environment_path, "/env", 0);
+ if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
+ ret = check_overlap(default_environment_path);
+ if (ret)
+ default_environment_path_set(NULL);
+ else
+ envfs_load(default_environment_path, "/env", 0);
+ } else {
+ if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT))
+ pr_notice("No support for persistent environment. Using default environment");
+ }
nvvar_load();
return 0;
}
environment_initcall(load_environment);
-#endif
static int global_autoboot_abort_key;
static const char * const global_autoboot_abort_keys[] = {
diff --git a/drivers/led/led-pca955x.c b/drivers/led/led-pca955x.c
index 9c4f7967fb..27fefce8d5 100644
--- a/drivers/led/led-pca955x.c
+++ b/drivers/led/led-pca955x.c
@@ -316,7 +316,6 @@ led_pca955x_pdata_of_init(struct device_node *np, struct pca955x *pca955x)
pca955x_led->led_cdev.name = pca955x_led->name;
pca955x_led->led_cdev.set = pca955x_led_set;
- pca955x_led->led_cdev.num = pca955x_led->led_num;
pca955x_led->led_cdev.max_value = 255;
err = led_register(&pca955x_led->led_cdev);
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 4816608a23..6a9f1196cb 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -314,7 +314,7 @@ static int fsl_esdhc_probe(struct device_d *dev)
host->mci.card_present = esdhc_card_present;
host->mci.hw_dev = dev;
- dev->detect = fsl_esdhc_detect,
+ dev->detect = fsl_esdhc_detect;
rate = clk_get_rate(host->clk);
host->mci.f_min = rate >> 12;
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 1e1b69626a..038d7072aa 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -646,6 +646,8 @@ static const struct spi_device_id spi_nor_ids[] = {
{ "en25q32b", INFO(0x1c3016, 0, 64 * 1024, 64, 0) },
{ "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) },
{ "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) },
+ { "en25qh64", INFO(0x1c7017, 0, 64 * 1024, 128,
+ SECT_4K | SPI_NOR_DUAL_READ) },
{ "en25qh128", INFO(0x1c7018, 0, 64 * 1024, 256, 0) },
{ "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) },
{ "en25s64", INFO(0x1c3817, 0, 64 * 1024, 128, 0) },
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 4e12522a0a..007c5fd9d0 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -74,7 +74,7 @@ static u64 of_bus_default_map(__be32 *addr, const __be32 *range,
s = of_read_number(range + na + pna, ns);
da = of_read_number(addr, na);
- pr_debug("OF: default map, cp=%llx, s=%llx, da=%llx\n",
+ pr_vdebug("OF: default map, cp=%llx, s=%llx, da=%llx\n",
(unsigned long long)cp, (unsigned long long)s,
(unsigned long long)da);
@@ -164,7 +164,7 @@ static u64 of_bus_pci_map(__be32 *addr, const __be32 *range, int na, int ns,
s = of_read_number(range + na + pna, ns);
da = of_read_number(addr + 1, na - 1);
- pr_debug("OF: PCI map, cp=%llx, s=%llx, da=%llx\n",
+ pr_vdebug("OF: PCI map, cp=%llx, s=%llx, da=%llx\n",
(unsigned long long)cp, (unsigned long long)s,
(unsigned long long)da);
@@ -314,18 +314,18 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
ranges = of_get_property(parent, rprop, &rlen);
#if !defined(CONFIG_PPC)
if (ranges == NULL) {
- pr_debug("OF: no ranges; cannot translate\n");
+ pr_vdebug("OF: no ranges; cannot translate\n");
return 1;
}
#endif /* !defined(CONFIG_PPC) */
if (ranges == NULL || rlen == 0) {
offset = of_read_number(addr, na);
memset(addr, 0, pna * 4);
- pr_debug("OF: empty ranges; 1:1 translation\n");
+ pr_vdebug("OF: empty ranges; 1:1 translation\n");
goto finish;
}
- pr_debug("OF: walking ranges...\n");
+ pr_vdebug("OF: walking ranges...\n");
/* Now walk through the ranges */
rlen /= 4;
@@ -336,14 +336,14 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
break;
}
if (offset == OF_BAD_ADDR) {
- pr_debug("OF: not found !\n");
+ pr_vdebug("OF: not found !\n");
return 1;
}
memcpy(addr, ranges + na, 4 * pna);
finish:
of_dump_addr("OF: parent translation for:", addr, pna);
- pr_debug("OF: with offset: %llx\n", (unsigned long long)offset);
+ pr_vdebug("OF: with offset: %llx\n", (unsigned long long)offset);
/* Translate it into parent bus space */
return pbus->translate(addr, offset, pna);
@@ -368,7 +368,7 @@ static u64 __of_translate_address(struct device_node *dev,
int na, ns, pna, pns;
u64 result = OF_BAD_ADDR;
- pr_debug("OF: ** translation for device %s **\n", dev->full_name);
+ pr_vdebug("OF: ** translation for device %s **\n", dev->full_name);
/* Get parent & match bus type */
parent = of_get_parent(dev);
@@ -379,13 +379,13 @@ static u64 __of_translate_address(struct device_node *dev,
/* Count address cells & copy address locally */
bus->count_cells(dev, &na, &ns);
if (!OF_CHECK_COUNTS(na, ns)) {
- pr_debug("prom_parse: Bad cell count for %s\n",
+ pr_vdebug("prom_parse: Bad cell count for %s\n",
dev->full_name);
return OF_BAD_ADDR;
}
memcpy(addr, in_addr, na * 4);
- pr_debug("OF: bus is %s (na=%d, ns=%d) on %s\n",
+ pr_vdebug("OF: bus is %s (na=%d, ns=%d) on %s\n",
bus->name, na, ns, parent->full_name);
of_dump_addr("OF: translating address:", addr, na);
@@ -397,7 +397,7 @@ static u64 __of_translate_address(struct device_node *dev,
/* If root, we have finished */
if (parent == NULL) {
- pr_debug("OF: reached root node\n");
+ pr_vdebug("OF: reached root node\n");
result = of_read_number(addr, na);
break;
}
@@ -411,7 +411,7 @@ static u64 __of_translate_address(struct device_node *dev,
break;
}
- pr_debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n",
+ pr_vdebug("OF: parent bus is %s (na=%d, ns=%d) on %s\n",
pbus->name, pna, pns, parent->full_name);
/* Apply bus translation */
diff --git a/images/.gitignore b/images/.gitignore
index b673c98194..2f8b87dcbd 100644
--- a/images/.gitignore
+++ b/images/.gitignore
@@ -28,3 +28,5 @@ barebox.sum
*.pimximg
*.psimximg
*.zynqimg
+*.image
+*.mvebu1img
diff --git a/include/envfs.h b/include/envfs.h
index 27c4b42c6b..c8fc3759c6 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -93,8 +93,13 @@ struct envfs_super {
#endif
#define ENV_FLAG_NO_OVERWRITE (1 << 0)
+#define PAD4(x) ((x + 3) & ~3)
int envfs_load(const char *filename, const char *dirname, unsigned flags);
int envfs_save(const char *filename, const char *dirname, unsigned flags);
+int envfs_check_super(struct envfs_super *super, size_t *size);
+int envfs_check_data(struct envfs_super *super, const void *buf, size_t size);
+int envfs_load_data(struct envfs_super *super, void *buf, size_t size,
+ const char *dir, unsigned flags);
int envfs_load_from_buf(void *buf, int len, const char *dir, unsigned flags);
/* defaults to /dev/env0 */
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index 2ecef35a40..7b3e603322 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -90,12 +90,6 @@ amba_ahb_device_add(struct device_d *parent, const char *name, int id,
periphid);
}
-
-void amba_device_unregister(struct amba_device *);
-struct amba_device *amba_find_device(const char *, struct device_d *, unsigned int, unsigned int);
-int amba_request_regions(struct amba_device *, const char *);
-void amba_release_regions(struct amba_device *);
-
static inline void __iomem *amba_get_mem_region(struct amba_device *dev)
{
return dev->base;
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index c512a105ef..d1cf33a4d9 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -104,6 +104,7 @@ static char *concat_subpath_file(const char *path, const char *f)
#include "../include/envfs.h"
#include "../crypto/crc32.c"
#include "../lib/make_directory.c"
+#include "../common/envfs-core.c"
#include "../common/environment.c"
static void usage(char *prgname)