cros_bundle_firmware: Try to find a default FDT file
Where no FDT is specified it is nice to try pretty hard to find the
correct one. So use a wildcard to pick up something based on the board
name. Provided that we only find one match this should be safe enough.
BUG=chromium-os:28958
TEST=manual:
$ cros_write_firmware -b daisy -i /build/daisy/firmware/legacy_image.bin -w sd:
See that it automatically finds the FDT file now.
Change-Id: I76187cf48c1428b2056372cf02ae6ffce8f1e1ed
Reviewed-on: https://gerrit.chromium.org/gerrit/19597
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index 9dfc52d..a605f15 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -16,6 +16,7 @@
signed (uboot + fdt + bct) signed blob
"""
+import glob
import os
import re
@@ -145,8 +146,19 @@
raise ValueError('No board defined - please define a board to use')
build_root = os.path.join('##', 'build', self._board, 'firmware')
if not self._fdt_fname:
- self._fdt_fname = os.path.join(build_root, 'dts', '%s.dts' %
- re.sub('_', '-', self._board))
+ # Figure out where the file should be, and the name we expect.
+ dir_name = os.path.join(build_root, 'dts')
+ base_name = re.sub('_', '-', self._board)
+
+ # In case the name exists with a prefix or suffix, find it.
+ wildcard = os.path.join(dir_name, '*%s*.dts' % base_name)
+ found_list = glob.glob(self._tools.Filename(wildcard))
+ if len(found_list) == 1:
+ self._fdt_fname = found_list[0]
+ else:
+ # We didn't find anything definite, so set up our expected name.
+ self._fdt_fname = os.path.join(dir_name, '%s.dts' % base_name)
+
if not self.uboot_fname:
self.uboot_fname = os.path.join(build_root, 'u-boot.bin')
if not self.bct_fname: