diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-06-29 08:37:30 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-07-03 22:06:15 +0200 |
commit | 5bf59d3f2baa0f98ab93ddb4ea8a3b37986db608 (patch) | |
tree | a1fcde704ba8a88a2ef6133fc27af341994a03bf /arch/sandbox/board | |
parent | d4efa05303408d84a347c1c560ea860cf9ad953c (diff) | |
download | barebox-5bf59d3f2baa0f98ab93ddb4ea8a3b37986db608.tar.gz barebox-5bf59d3f2baa0f98ab93ddb4ea8a3b37986db608.tar.xz |
sandbox: ship sample environment
The idea of the stickypage was to have a 4K memory region persistent
over resets. This region was implemented as mmap of a temporary hostfile,
which was created on first barebox start and maintained over resets.
Usability was a bit lacking however:
- The temporary files weren't deleted
- state always showed warnings and errors on first boot. The banner
telling users to ignore this wasn't best user experience
- In the same vein, the power driver had logic to handle a fresh
(zeroed) stickypage and interpret that as POR boot
We can avoid all that, by just shipping a default stickypage and
referencing that from DT. Do that.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210629063730.7001-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/board')
-rw-r--r-- | arch/sandbox/board/Makefile | 2 | ||||
-rw-r--r-- | arch/sandbox/board/env/init/state | 13 | ||||
-rw-r--r-- | arch/sandbox/board/hostfile.c | 19 | ||||
-rw-r--r-- | arch/sandbox/board/power.c | 2 | ||||
-rw-r--r-- | arch/sandbox/board/stickypage.S | 26 |
5 files changed, 39 insertions, 23 deletions
diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile index ffb1dbc21e..59fece60ef 100644 --- a/arch/sandbox/board/Makefile +++ b/arch/sandbox/board/Makefile @@ -10,3 +10,5 @@ obj-y += watchdog.o obj-$(CONFIG_LED) += led.o extra-y += barebox.lds + +extra-y += stickypage.o diff --git a/arch/sandbox/board/env/init/state b/arch/sandbox/board/env/init/state deleted file mode 100644 index b8a2b42a53..0000000000 --- a/arch/sandbox/board/env/init/state +++ /dev/null @@ -1,13 +0,0 @@ -if [ "x$state.dirty" != "x1" -o $global.system.reset != "POR" ]; then - exit -fi - -source /env/data/ansi-colors - -echo -e $CYAN -echo "*******************************************************" -echo "*** Inconsistent barebox state buckets detected ***" -echo "*** This is normal for a first boot ***" -echo "*** barebox will repair them on next poweroff/reset ***" -echo "*******************************************************" -echo -e -n $NC diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 0346590889..f110621979 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -232,12 +232,21 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx) for_each_compatible_node_from(node, root, NULL, hostfile_dt_ids->compatible) { struct hf_info hf = {}; uint64_t reg[2] = {}; - bool no_filename; hf.devname = node->name; ret = of_property_read_string(node, "barebox,filename", &hf.filename); - no_filename = ret; + if (ret) { + pr_err("skipping nameless hostfile %s\n", hf.devname); + continue; + } + + if (memcmp(hf.filename, "$build/", 7) == 0) { + char *fullpath = xasprintf("%s/%s", linux_get_builddir(), + hf.filename + sizeof "$build/" - 1); + + hf.filename = fullpath; + } hf.is_blockdev = of_property_read_bool(node, "barebox,blockdev"); hf.is_cdev = of_property_read_bool(node, "barebox,cdev"); @@ -263,12 +272,6 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx) if (ret) goto out; - if (no_filename) { - ret = of_property_write_string(node, "barebox,filename", hf.filename); - if (ret) - goto out; - } - ret = of_property_write_u32(node, "barebox,fd", hf.fd); out: if (ret) diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c index 57801c8c3d..3112c80348 100644 --- a/arch/sandbox/board/power.c +++ b/arch/sandbox/board/power.c @@ -64,8 +64,6 @@ static int sandbox_power_probe(struct device_d *dev) rst = nvmem_cell_read(power->reset_source_cell, &len); if (!IS_ERR(rst)) { - if (*rst == 0) - *rst = RESET_POR; reset_source_set_prinst(*rst, RESET_SOURCE_DEFAULT_PRIORITY, 0); free(rst); diff --git a/arch/sandbox/board/stickypage.S b/arch/sandbox/board/stickypage.S new file mode 100644 index 0000000000..f1915ab986 --- /dev/null +++ b/arch/sandbox/board/stickypage.S @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +.globl stickypage; +stickypage: + +/* nvmem */ .org 0x300 +.byte 0x01 + +/* env */ .org 0x400 +.byte 0x79, 0xba, 0x8f, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +.byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x69, 0x9c, 0x7f, 0x00, 0x00, 0x00, 0x00 + +/* state */ .org 0xC00 +.byte 0xf3, 0xfd, 0x54, 0x23, 0x18, 0x00, 0x00, 0x00, 0xa6, 0x86, 0x3b, 0xaa, 0x00, 0x00, 0x08, 0x00 +.byte 0x19, 0x70, 0x3d, 0xbb, 0x64, 0x89, 0x3b, 0x31, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 +.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +.byte 0xf3, 0xfd, 0x54, 0x23, 0x18, 0x00, 0x00, 0x00, 0xa6, 0x86, 0x3b, 0xaa, 0x00, 0x00, 0x08, 0x00 +.byte 0x19, 0x70, 0x3d, 0xbb, 0x64, 0x89, 0x3b, 0x31, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 +.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +.byte 0xf3, 0xfd, 0x54, 0x23, 0x18, 0x00, 0x00, 0x00, 0xa6, 0x86, 0x3b, 0xaa, 0x00, 0x00, 0x08, 0x00 +.byte 0x19, 0x70, 0x3d, 0xbb, 0x64, 0x89, 0x3b, 0x31, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 + +.fill 4096-(.-stickypage), 1, 0 +.size stickypage, 4096 |