edison: Support for writing an xFSTK image
v2 cover edison: Support for writing an xFSTK image
At present it is painful to put Edison in a hardware lab because it has two separate recovery modes. When the board has a functioning U-Boot, DFU can be used. Otherwise an xFSTK image must be used.
This series converts Andy's script to a binman description so that U-Boot can produce an xFSTK image directly.
With this, I can put an Edison in my lab fairly easily.
The series is available at u-boot-dm/edison-working and is based on the reset binman series for sunxi.
[1] https://gist.github.com/andy-shev/2c388310f2773ead647d9c1a3f1c813f
Changes in v2:
- Minor indenting change in ObtainContents()
- Rename MBR to OSIP
- Drop git hash from U-Boot version string
Simon Glass (5):
x86: Use multiple images
binman: Show an error when a file is missing
binman: Support adding a U-Boot environment
x86: edison: Generate an image suitable for xFSTK
x86: edison: Add documentation for using am xFSTK image
arch/x86/cpu/tangier/Kconfig | 1 + arch/x86/dts/edison.dts | 34 ++++++ arch/x86/dts/u-boot.dtsi | 7 -- board/intel/edison/edison-environment.txt | 48 +++++++++ board/intel/edison/edison-osip.dat | Bin 0 -> 512 bytes doc/board/intel/edison.rst | 120 ++++++++++++++++++++++ tools/binman/etype/blob.py | 5 +- tools/binman/etype/u_boot_env.py | 42 ++++++++ tools/binman/ftest.py | 38 +++++++ tools/binman/test/173_missing_blob.dts | 14 +++ tools/binman/test/174_env.dts | 20 ++++ tools/binman/test/175_env_no_size.dts | 19 ++++ tools/binman/test/176_env_too_small.dts | 20 ++++ 13 files changed, 359 insertions(+), 9 deletions(-) create mode 100644 board/intel/edison/edison-environment.txt create mode 100644 board/intel/edison/edison-osip.dat create mode 100644 tools/binman/etype/u_boot_env.py create mode 100644 tools/binman/test/173_missing_blob.dts create mode 100644 tools/binman/test/174_env.dts create mode 100644 tools/binman/test/175_env_no_size.dts create mode 100644 tools/binman/test/176_env_too_small.dts
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v2 1/5 x86: Use multiple images
We already use binman's 'multiple-images' feature with Chrome OS and we want to use it for Edison. There is no real down-side.
Adjust x86 to always use multiple-images.
---
(no changes since v1)
arch/x86/dts/u-boot.dtsi | 7 ------- 1 file changed, 7 deletions(-)
arch/x86/dts/u-boot.dtsi +0 -7
@@ -6,7 +6,6 @@ #include <config.h> -#ifdef CONFIG_CHROMEOS / { binman { multiple-images;
@@ -14,12 +13,6 @@ }; }; }; -#else -/ { - rom: binman { - }; -}; -#endif #ifdef CONFIG_ROM_SIZE &rom {
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v2 2/5 binman: Show an error when a file is missing
In reply to Simon GlassThe recent support for missing external binaries does not show an error message when a file is genuinely missing (i.e. it is missing but not marked as 'external'). This means that when -m is passed to binman, it will never report a missing file.
Fix this and add a test.
---
Changes in v2:
- Minor indenting change in ObtainContents()
tools/binman/etype/blob.py | 5 +++-- tools/binman/ftest.py | 7 +++++++ tools/binman/test/173_missing_blob.dts | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tools/binman/test/173_missing_blob.dts
tools/binman/etype/blob.py +3 -2
@@ -38,12 +38,13 @@ class Entry_blob(Entry): def ObtainContents(self): self._filename = self.GetDefaultFilename() self._pathname = tools.GetInputFilename(self._filename, - self.section.GetAllowMissing()) + self.external and self.section.GetAllowMissing()) # Allow the file to be missing - if self.external and not self._pathname: + if not self._pathname: self.SetContents(b'') self.missing = True return True + self.ReadBlobContents() return True
tools/binman/ftest.py +7 -0
@@ -3708,5 +3708,12 @@ class TestFunctional(unittest.TestCase): self.assertIn('Wibble test', err) self.assertIn('Another test', err) + def testMissingBlob(self): + """Test handling of a blob containing a missing file""" + with self.assertRaises(ValueError) as e: + self._DoTestFile('173_missing_blob.dts', allow_missing=True) + self.assertIn("Filename 'missing' not found in input path", + str(e.exception)) + if __name__ == "__main__": unittest.main()
tools/binman/test/173_missing_blob.dts new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + blob { + filename = "missing"; + }; + }; +};
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v2 3/5 binman: Support adding a U-Boot environment
In reply to Simon GlassIn some cases it is useful to include a U-Boot environment region in an image. This allows the board to start up with an environment ready to go.
Add a new entry type for this. The input is a text file containing the environment entries, one per line, in the format:
var=value
---
(no changes since v1)
tools/binman/etype/u_boot_env.py | 42 +++++++++++++++++++++++++ tools/binman/ftest.py | 31 ++++++++++++++++++ tools/binman/test/174_env.dts | 20 ++++++++++++ tools/binman/test/175_env_no_size.dts | 19 +++++++++++ tools/binman/test/176_env_too_small.dts | 20 ++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 tools/binman/etype/u_boot_env.py create mode 100644 tools/binman/test/174_env.dts create mode 100644 tools/binman/test/175_env_no_size.dts create mode 100644 tools/binman/test/176_env_too_small.dts
tools/binman/etype/u_boot_env.py new file +42 -0
@@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2018 Google, Inc +# Written by Simon Glass <[email protected]> +# + +import struct +import zlib + +from binman.etype.blob import Entry_blob +from dtoc import fdt_util +from patman import tools + +class Entry_u_boot_env(Entry_blob): + """An entry which contains a U-Boot environment + + Properties / Entry arguments: + - filename: File containing the environment text, with each line in the + form var=value + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node) + + def ReadNode(self): + super().ReadNode() + if self.size is None: + self.Raise("'u-boot-env' entry must have a size property") + self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0) + + def ReadBlobContents(self): + indata = tools.ReadFile(self._pathname) + data = b'' + for line in indata.splitlines(): + data += line + b'\0' + data += b'\0'; + pad = self.size - len(data) - 5 + if pad < 0: + self.Raise("'u-boot-env' entry too small to hold data (need %#x more bytes)" % -pad) + data += tools.GetBytes(self.fill_value, pad) + crc = zlib.crc32(data) + buf = struct.pack('<I', crc) + b'\x01' + data + self.SetContents(buf) + return True
tools/binman/ftest.py +31 -0
@@ -77,6 +77,7 @@ FSP_T_DATA = b'fsp_t' ATF_BL31_DATA = b'bl31' TEST_FDT1_DATA = b'fdt1' TEST_FDT2_DATA = b'test-fdt2' +ENV_DATA = b'var1=1\nvar2="2"' # Subdirectory of the input dir to use to put test FDTs TEST_FDT_SUBDIR = 'fdts'
@@ -181,6 +182,8 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('%s/test-fdt2.dtb' % TEST_FDT_SUBDIR, TEST_FDT2_DATA) + TestFunctional._MakeInputFile('env.txt', ENV_DATA) + # Travis-CI may have an old lz4 cls.have_lz4 = True try:
@@ -3715,5 +3718,33 @@ class TestFunctional(unittest.TestCase): self.assertIn("Filename 'missing' not found in input path", str(e.exception)) + def testEnvironment(self): + """Test adding a U-Boot environment""" + data = self._DoReadFile('174_env.dts') + self.assertEqual(U_BOOT_DATA, data[:len(U_BOOT_DATA)]) + self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):]) + env = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)] + self.assertEqual(b'\x1b\x97\x22\x7c\x01var1=1\0var2="2"\0\0\xff\xff', + env) + + def testEnvironmentNoSize(self): + """Test that a missing 'size' property is detected""" + with self.assertRaises(ValueError) as e: + data = self._DoTestFile('175_env_no_size.dts') + self.assertIn("'u-boot-env' entry must have a size property", + str(e.exception)) + + def testEnvironmentTooSmall(self): + """Test handling of an environment that does not fit""" + with self.assertRaises(ValueError) as e: + data = self._DoTestFile('176_env_too_small.dts') + + # checksum, start byte, environment with \0 terminator, final \0 + need = 4 + 1 + len(ENV_DATA) + 1 + 1 + short = need - 0x8 + self.assertIn("too small to hold data (need %#x more bytes)" % short, + str(e.exception)) + + if __name__ == "__main__": unittest.main()
tools/binman/test/174_env.dts new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + u-boot-env { + filename = "env.txt"; + size = <0x18>; + fill-byte = [ff]; + }; + u-boot-nodtb { + }; + }; +};
tools/binman/test/175_env_no_size.dts new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + u-boot-env { + filename = "env.txt"; + fill-byte = [ff]; + }; + u-boot-nodtb { + }; + }; +};
tools/binman/test/176_env_too_small.dts new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + u-boot-env { + filename = "env.txt"; + size = <0x8>; + fill-byte = [ff]; + }; + u-boot-nodtb { + }; + }; +};
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v2 4/5 x86: edison: Generate an image suitable for xFSTK
In reply to Simon GlassIt is useful to be able to flash Edison directly without relying on the installed U-Boot being functional.
Add a binman image for this. It includes a 'OSIP' header (which happens to look like an MBR / (Master-Boot Record), U-Boot binary and an environment.
I am not able to find a specification for OSIP.
---
Changes in v2:
- Rename MBR to OSIP
arch/x86/cpu/tangier/Kconfig | 1 + arch/x86/dts/edison.dts | 34 +++++++++++++++ board/intel/edison/edison-environment.txt | 48 ++++++++++++++++++++++ board/intel/edison/edison-osip.dat | Bin 0 -> 512 bytes 4 files changed, 83 insertions(+) create mode 100644 board/intel/edison/edison-environment.txt create mode 100644 board/intel/edison/edison-osip.dat
arch/x86/cpu/tangier/Kconfig +1 -0
@@ -12,6 +12,7 @@ config INTEL_TANGIER imply MMC_SDHCI_TANGIER imply USB imply USB_DWC3 + imply BINMAN if INTEL_TANGIER
arch/x86/dts/edison.dts +34 -0
@@ -22,6 +22,10 @@ serial2 = &serial2; }; + binman: binman { + multiple-images; + }; + chosen { stdout-path = &serial2; };
@@ -130,3 +134,33 @@ }; }; }; + +&binman { + u-boot-edison { + filename = "u-boot-edison.img"; + + /* This is the OSIP */ + blob { + filename = "edison-osip.dat"; + }; + + u-boot { + offset = <0x200>; + }; + + u-boot-env { + offset = <0x200200>; + filename = "edison-environment.txt"; + size = <0x10000>; + fill-byte = [ff]; + }; + + u-boot-env2 { + type = "u-boot-env"; + offset = <0x500200>; + filename = "edison-environment.txt"; + size = <0x10000>; + fill-byte = [ff]; + }; + }; +};
board/intel/edison/edison-environment.txt new file +48 -0
48 lines not on this page · raw message
board/intel/edison/edison-osip.dat new file binary +0 -0
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v2 5/5 x86: edison: Add documentation for using am xFSTK image
In reply to Simon GlassAdd a description of how to flash Edison using the xFSTK tool.
---
Changes in v2:
- Drop git hash from U-Boot version string
doc/board/intel/edison.rst | 120 +++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
doc/board/intel/edison.rst +120 -0
@@ -39,3 +39,123 @@ use. reset the board:: => reset + + +Updating U-Boot using xFSTK +--------------------------- + +You can also update U-Boot using the xfstk-dldr-solo tool if you can build it. +One way to do that is to follow the `xFSTK`_ instructions. You may need to use +a virtual machine running Ubuntu Trusty. Once you have built it and installed +libboost-all-dev, you can copy xfstk-dldr-solo to /usr/local/bin and +libboost_program_options.so.1.54.0 to /usr/lib/i386-linux-gnu/ and with luck +it will work. You might fine this `drive`_ helpful. + +If it does, then you can download and unpack the Edison reocovery image, +install dfu-util, reset your board and flash U-Boot like this:: + + $ xfstk-dldr-solo --gpflags 0x80000007 \ + --osimage u-boot-edison.img \ + --fwdnx recover/edison_dnx_fwr.bin \ + --fwimage recover/edison_ifwi-dbg-00.bin \ + --osdnx recover/edison_dnx_osr.bin + +This should show the following + +.. code-block:: none + + XFSTK Downloader Solo 0.0.0 + Copyright (c) 2015 Intel Corporation + Build date and time: Aug 15 2020 15:07:13 + + .Intel SoC Device Detection Found + Parsing Commandline.... + Registering Status Callback.... + .Initiating Download Process.... + .......(lots of dots)........XFSTK-STATUS--Reconnecting to device - Attempt #1 + .......(even more dots)...................... + + +You have about 10 seconds after resetting the board to type the above command. +If you want to check if the board is ready, type: + +.. code-block:: none + + lsusb |egrep "8087|8086" + Bus 001 Device 004: ID 8086:e005 Intel Corp. + +If you see a device with the same ID as above, the board is waiting for your +command. + +After about 5 seconds you should see some console output from the board: + +.. code-block:: none + + ****************************** + PSH KERNEL VERSION: b0182b2b + WR: 20104000 + ****************************** + + SCU IPC: 0x800000d0 0xfffce92c + + PSH miaHOB version: TNG.B0.VVBD.0000000c + + microkernel built 11:24:08 Feb 5 2015 + + ******* PSH loader ******* + PCM page cache size = 192 KB + Cache Constraint = 0 Pages + Arming IPC driver .. + Adding page store pool .. + PagestoreAddr(IMR Start Address) = 0x04899000 + pageStoreSize(IMR Size) = 0x00080000 + + *** Ready to receive application *** + + After another 10 seconds the xFSTK tool completes and the board resets. About + 10 seconds after that should see the above message again and then within a + few seconds U-Boot should start on your board: + +.. code-block:: none + + U-Boot 2020.10-rc3 (Sep 03 2020 - 18:44:28 -0600) + + CPU: Genuine Intel(R) CPU 4000 @ 500MHz + DRAM: 980.6 MiB + WDT: Started with servicing (60s timeout) + MMC: mmc at ff3fc000: 0, mmc at ff3fa000: 1 + Loading Environment from MMC... OK + In: serial + Out: serial + Err: serial + Saving Environment to MMC... Writing to redundant MMC(0)... OK + Saving Environment to MMC... Writing to MMC(0)... OK + Net: No ethernet found. + Hit any key to stop autoboot: 0 + Target:blank + Partitioning using GPT + Writing GPT: success! + Saving Environment to MMC... Writing to redundant MMC(0)... OK + Flashing already done... + 5442816 bytes read in 238 ms (21.8 MiB/s) + Valid Boot Flag + Setup Size = 0x00003c00 + Magic signature found + Using boot protocol version 2.0c + Linux kernel version 3.10.17-poky-edison+ (ferry at kalamata) #1 SMP PREEMPT Mon Jan 11 14:54:18 CET 2016 + Building boot_params at 0x00090000 + Loading bzImage at address 100000 (5427456 bytes) + Magic signature found + Kernel command line: "rootwait root=PARTUUID=ada722ed-6410-764e-8619-abff6f66e10e rootfstype=ext4 console=ttyMFD2 earlyprintk=ttyMFD2,keep loglevel=4 g_multi.ethernet_config=cdc systemd.unit=multi-user.target hardware_id=00 g_multi.iSerialNumber=2249baf774c675598661a63098c0ad41 g_multi.dev_addr=02:00:86:c0:ad:41 platform_mrfld_audio.audio_codec=dummy" + Magic signature found + + Starting kernel ... + + ... + + Poky (Yocto Project Reference Distro) 1.7.2 edison ttyMFD2 + + edison login: + +.. _xFSTK: https://community.intel.com/t5/Intel-Makers/Building-xFSTK-on-Ubuntu-14-04-32-bit-for-flashing-Edison/td-p/538081 +.. _drive: https://drive.google.com/drive/u/0/folders/1URPHrOk9-UBsh8hjv-7WwC0W6Fy61uAJ
Signature · 1 line
2.28.0.526.ge36021eeef-goog