The mask ROM loads the OS image to 0x01100000 but enters it at
0x01101000, so U-Boot must sit 0x1000 (4KB) into the loaded image. This
is arranged by board/intel/edison/config.mk, which prepends 4096 zero
bytes to u-boot.bin through an 'INPUTS-y += u-boot-align.bin' rule whose
recipe moves its output back over u-boot.bin.

Since the Edison image is assembled by binman, provide the gap there
instead: pad with a 'fill' of 4096 zero bytes ahead of the u-boot entry.
Wrap the fill and U-Boot in a section that is also written out as
u-boot-edison-dfu.bin, the [gap + U-Boot] payload to flash into the
u-boot0 partition over DFU, so that no longer needs a manual prepend.
Drop the now-redundant alignment hack from the board config.mk.

The stock v2014.04 DFU also needs the whole payload to be a multiple of
4KB, so round U-Boot's size up to a full block. With the 4KB gap ahead
of it, that makes u-boot-edison-dfu.bin 4KB-aligned as a whole. The tail
is padded with zeroes, matching what the old 'truncate -s %4096' step
produced.

Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Simon Glass <[email protected]>
---

Changes in v3:
- Round U-Boot's size up to a 4KB boundary

Changes in v2:
- Reframe as a binman conversion (the boot fix is now a precursor) and
  drop the duplicate 'Fixes' tag
- Wrap the gap and U-Boot in a section emitted as u-boot-edison-dfu.bin,
  the ready-to-flash DFU payload

 arch/x86/dts/edison.dts      | 28 ++++++++++++++++++++++++++--
 board/intel/edison/config.mk | 10 ----------
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/arch/x86/dts/edison.dts b/arch/x86/dts/edison.dts
index 8fdacfb0fd8..c8c8426b0ae 100644
--- a/arch/x86/dts/edison.dts
+++ b/arch/x86/dts/edison.dts
@@ -177,8 +177,32 @@
                        intel,load-address = <(CONFIG_TEXT_BASE - 0x1000)>;
                };
 
-               u-boot {
-                       offset = <0x200>;
+               /*
+                * The OSII loads the image to (CONFIG_TEXT_BASE - 0x1000) but
+                * enters it at CONFIG_TEXT_BASE, so U-Boot must sit 0x1000
+                * (4KB) into the loaded data. Pad with zeroes ahead of U-Boot
+                * to provide that gap, and emit the [gap + U-Boot] payload as
+                * its own file (u-boot-edison-dfu.bin) for flashing into the
+                * u-boot0 partition over DFU.
+                */
+               u-boot-dfu {
+                       type = "section";
+                       filename = "u-boot-edison-dfu.bin";
+
+                       fill {
+                               size = <0x1000>;
+                               fill-byte = [00];
+                       };
+
+                       /*
+                        * The stock v2014.04 DFU needs the whole payload to be
+                        * a multiple of 4KB. With the 4KB gap above, rounding
+                        * U-Boot's size up to a full block (the tail is padded
+                        * with zeroes) makes the emitted file 4KB-aligned too.
+                        */
+                       u-boot {
+                               align-size = <0x1000>;
+                       };
                };
 
                u-boot-env {
diff --git a/board/intel/edison/config.mk b/board/intel/edison/config.mk
index fff187caa15..da7c9acf1a2 100644
--- a/board/intel/edison/config.mk
+++ b/board/intel/edison/config.mk
@@ -4,14 +4,4 @@
 # Copyright (c) 2017 Intel Corporation
 #
 
-# Add 4096 bytes of zeroes to u-boot.bin
-quiet_cmd_mkalign_eds = EDSALGN $@
-cmd_mkalign_eds =                                                      \
-       dd if=$< of=$@ bs=4k seek=1 2>/dev/null &&                      \
-       mv $@ $<
-
-INPUTS-y += u-boot-align.bin
-u-boot-align.bin: u-boot.bin FORCE
-       $(call if_changed,mkalign_eds)
-
 HOSTCFLAGS_include/autoconf.mk.dep = -Wno-variadic-macros
-- 
2.43.0

Reply via email to