binman: Rename 'position' to 'offset'
PATCH v2 2/29 binman: Rename 'position' to 'offset'
After some thought, I believe there is an unfortunate naming flaw in binman. Entries have a position and size, but now that we support hierarchical sections it is unclear whether a position should be an absolute position within the image, or a relative position within its parent section.
At present 'position' actually means the relative position. This indicates a need for an 'image position' for code that wants to find the location of an entry without having to do calculations back through parents to discover this image position.
A better name for the current 'position' or 'pos' is 'offset'. It is not always an absolute position, but it is always an offset from its parent offset.
It is unfortunate to rename this concept now, 18 months after binman was introduced. However I believe it is the right thing to do. The impact is mostly limited to binman itself and a few changes to in-tree users to binman:
tegra
sunxi
x86
The change makes old binman definitions (e.g. downstream or out-of-tree) incompatible if they use the 'pos = <...>' property. Later work will adjust binman to generate an error when it is used.
---
Changes in v2:
- Adjust symbols in the U-Boot tree also
arch/arm/dts/sunxi-u-boot.dtsi | 2 +- arch/arm/dts/tegra-u-boot.dtsi | 6 +- arch/x86/dts/u-boot.dtsi | 24 ++--- common/spl/spl.c | 4 +- common/spl/spl_ram.c | 2 +- include/spl.h | 2 +- tools/binman/README | 79 ++++++++-------- tools/binman/bsection.py | 88 +++++++++--------- tools/binman/cmdline.py | 2 +- tools/binman/control.py | 4 +- tools/binman/elf.py | 6 +- tools/binman/entry.py | 73 ++++++++------- tools/binman/etype/_testing.py | 4 +- tools/binman/etype/intel_descriptor.py | 8 +- tools/binman/etype/section.py | 14 +-- tools/binman/etype/u_boot_dtb_with_ucode.py | 4 +- tools/binman/etype/u_boot_ucode.py | 4 +- tools/binman/etype/u_boot_with_ucode_ptr.py | 35 +++---- tools/binman/ftest.py | 85 +++++++++-------- tools/binman/image.py | 12 +-- tools/binman/test/08_pack.dts | 2 +- tools/binman/test/12_pack_inv_align.dts | 2 +- tools/binman/test/14_pack_overlap.dts | 2 +- tools/binman/test/21_image_pad.dts | 2 +- tools/binman/test/24_sorted.dts | 6 +- tools/binman/test/25_pack_zero_size.dts | 2 +- tools/binman/test/27_pack_4gb_no_size.dts | 6 +- tools/binman/test/28_pack_4gb_outside.dts | 6 +- tools/binman/test/29_x86-rom.dts | 6 +- tools/binman/test/30_x86-rom-me-no-desc.dts | 4 +- tools/binman/test/31_x86-rom-me.dts | 4 +- tools/binman/test/34_x86_ucode.dts | 2 +- tools/binman/test/35_x86_single_ucode.dts | 2 +- tools/binman/test/37_x86_no_ucode.dts | 2 +- .../binman/test/38_x86_ucode_missing_node.dts | 2 +- .../test/39_x86_ucode_missing_node2.dts | 2 +- .../binman/test/40_x86_ucode_not_in_image.dts | 2 +- tools/binman/test/44_x86_optional_ucode.dts | 2 +- tools/binman/test/45_prop_test.dts | 4 +- tools/binman/test/49_x86_ucode_spl.dts | 2 +- tools/binman/test/53_symbols.dts | 2 +- .../test/58_x86_ucode_spl_needs_retry.dts | 2 +- tools/binman/test/u_boot_binman_syms | Bin 4921 -> 4916 bytes tools/binman/test/u_boot_binman_syms.c | 6 +- 44 files changed, 267 insertions(+), 263 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +1 -1
@@ -8,7 +8,7 @@ filename = "spl/sunxi-spl.bin"; }; u-boot-img { - pos = <CONFIG_SPL_PAD_TO>; + offset = <CONFIG_SPL_PAD_TO>; }; }; };
arch/arm/dts/tegra-u-boot.dtsi +3 -3
@@ -15,7 +15,7 @@ u-boot-spl { }; u-boot { - pos = <(U_BOOT_OFFSET)>; + offset = <(U_BOOT_OFFSET)>; }; };
@@ -26,7 +26,7 @@ u-boot-spl { }; u-boot { - pos = <(U_BOOT_OFFSET)>; + offset = <(U_BOOT_OFFSET)>; }; };
@@ -36,7 +36,7 @@ u-boot-spl { }; u-boot-nodtb { - pos = <(U_BOOT_OFFSET)>; + offset = <(U_BOOT_OFFSET)>; }; }; };
arch/x86/dts/u-boot.dtsi +12 -12
@@ -11,7 +11,7 @@ binman { filename = "u-boot.rom"; end-at-4gb; - sort-by-pos; + sort-by-offset; pad-byte = <0xff>; size = <CONFIG_ROM_SIZE>; #ifdef CONFIG_HAVE_INTEL_ME
@@ -24,18 +24,18 @@ #endif #ifdef CONFIG_SPL u-boot-spl-with-ucode-ptr { - pos = <CONFIG_SPL_TEXT_BASE>; + offset = <CONFIG_SPL_TEXT_BASE>; }; u-boot-dtb-with-ucode2 { type = "u-boot-dtb-with-ucode"; }; u-boot { - pos = <0xfff00000>; + offset = <0xfff00000>; }; #else u-boot-with-ucode-ptr { - pos = <CONFIG_SYS_TEXT_BASE>; + offset = <CONFIG_SYS_TEXT_BASE>; }; #endif u-boot-dtb-with-ucode {
@@ -45,45 +45,45 @@ }; #ifdef CONFIG_HAVE_MRC intel-mrc { - pos = <CONFIG_X86_MRC_ADDR>; + offset = <CONFIG_X86_MRC_ADDR>; }; #endif #ifdef CONFIG_HAVE_FSP intel-fsp { filename = CONFIG_FSP_FILE; - pos = <CONFIG_FSP_ADDR>; + offset = <CONFIG_FSP_ADDR>; }; #endif #ifdef CONFIG_HAVE_CMC intel-cmc { filename = CONFIG_CMC_FILE; - pos = <CONFIG_CMC_ADDR>; + offset = <CONFIG_CMC_ADDR>; }; #endif #ifdef CONFIG_HAVE_VGA_BIOS intel-vga { filename = CONFIG_VGA_BIOS_FILE; - pos = <CONFIG_VGA_BIOS_ADDR>; + offset = <CONFIG_VGA_BIOS_ADDR>; }; #endif #ifdef CONFIG_HAVE_VBT intel-vbt { filename = CONFIG_VBT_FILE; - pos = <CONFIG_VBT_ADDR>; + offset = <CONFIG_VBT_ADDR>; }; #endif #ifdef CONFIG_HAVE_REFCODE intel-refcode { - pos = <CONFIG_X86_REFCODE_ADDR>; + offset = <CONFIG_X86_REFCODE_ADDR>; }; #endif #ifdef CONFIG_SPL x86-start16-spl { - pos = <CONFIG_SYS_X86_START16>; + offset = <CONFIG_SYS_X86_START16>; }; #else x86-start16 { - pos = <CONFIG_SYS_X86_START16>; + offset = <CONFIG_SYS_X86_START16>; }; #endif };
common/spl/spl.c +2 -2
@@ -34,7 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;u32 *boot_params_ptr =NULL ;/* See spl.h for information about this */ -binman_sym_declare (ulong, u_boot_any, pos); +binman_sym_declare (ulong, u_boot_any, offset);/* Define board data structure */ static bd_t bdata __attribute__ ((section(".data")));
@@ -129,7 +129,7 @@ __weak void spl_board_prepare_for_boot(void)void spl_set_header_raw_uboot (struct spl_image_info *spl_image) { -ulong u_boot_pos =binman_sym (ulong, u_boot_any, pos); +ulong u_boot_pos =binman_sym (ulong, u_boot_any, offset); spl_image->size =CONFIG_SYS_MONITOR_LEN ;
common/spl/spl_ram.c +1 -1
@@ -49,7 +49,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, load.read = spl_ram_load_read;spl_load_simple_fit (spl_image, &load,0 , header); }else { -ulong u_boot_pos =binman_sym (ulong, u_boot_any, pos); +ulong u_boot_pos =binman_sym (ulong, u_boot_any, offset);debug ("Legacy image\n" );/*
include/spl.h +1 -1
@@ -60,7 +60,7 @@ struct spl_load_info {* image is found. For * example if u-boot.img is used we don't check that * spl_parse_image_header() can parse a valid header. */ -binman_sym_extern (ulong, u_boot_any, pos); +binman_sym_extern (ulong, u_boot_any, offset);/** * spl_load_simple_fit() - Loads a fit image from a device.
tools/binman/README +40 -39
198 lines not on this page · raw message
tools/binman/bsection.py +45 -43
186 lines not on this page · raw message
tools/binman/cmdline.py +1 -1
@@ -43,7 +43,7 @@ def ParseArgs(argv): parser.add_option('-T', '--test-coverage', action='store_true', default=False, help='run tests and check for 100% coverage') parser.add_option('-u', '--update-fdt', action='store_true', - default=False, help='Update the binman node with position/size info') + default=False, help='Update the binman node with offset/size info') parser.add_option('-v', '--verbosity', default=1, type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, ' '4=debug')
tools/binman/control.py +2 -2
@@ -142,7 +142,7 @@ def Binman(options, args): # size of the device tree is correct. Later, in # SetCalculatedProperties() we will insert the correct values # without changing the device-tree size, thus ensuring that our - # entry positions remain the same. + # entry offsets remain the same. for image in images.values(): if options.update_fdt: image.AddMissingProperties()
@@ -157,7 +157,7 @@ def Binman(options, args): # image will be reported after earlier images are already # completed and written, but that does not seem important. image.GetEntryContents() - image.GetEntryPositions() + image.GetEntryOffsets() image.PackEntries() image.CheckSize() image.CheckEntries()
tools/binman/elf.py +3 -3
@@ -81,9 +81,9 @@ def LookupAndWriteSymbols(elf_fname, entry, section): """Replace all symbols in an entry with their correct values The entry contents is updated so that values for referenced symbols will be - visible at run time. This is done by finding out the symbols positions in - the entry (using the ELF file) and replacing them with values from binman's - data structures. + visible at run time. This is done by finding out the symbols offsets in the + entry (using the ELF file) and replacing them with values from binman's data + structures. Args: elf_fname: Filename of ELF image containing the symbol information for
tools/binman/entry.py +37 -36
168 lines not on this page · raw message
tools/binman/etype/_testing.py +2 -2
@@ -14,7 +14,7 @@ class Entry__testing(Entry): """A fake entry used for testing Properties: - return_invalid_entry: Return an invalid entry from GetPositions() + return_invalid_entry: Return an invalid entry from GetOffsets() """ def __init__(self, section, etype, node): Entry.__init__(self, section, etype, node)
@@ -35,7 +35,7 @@ class Entry__testing(Entry): self.contents_size = len(self.data) return True - def GetPositions(self): + def GetOffsets(self): if self.return_invalid_entry : return {'invalid-entry': [1, 2]} return {}
tools/binman/etype/intel_descriptor.py +4 -4
@@ -36,12 +36,12 @@ class Entry_intel_descriptor(Entry_blob): Entry_blob.__init__(self, section, etype, node) self._regions = [] - def GetPositions(self): - pos = self.data.find(FD_SIGNATURE) - if pos == -1: + def GetOffsets(self): + offset = self.data.find(FD_SIGNATURE) + if offset == -1: self.Raise('Cannot find FD signature') flvalsig, flmap0, flmap1, flmap2 = struct.unpack('<LLLL', - self.data[pos:pos + 16]) + self.data[offset:offset + 16]) frba = ((flmap0 >> 16) & 0xff) << 4 for i in range(MAX_REGIONS): self._regions.append(Region(self.data, frba, i))
tools/binman/etype/section.py +7 -7
@@ -30,20 +30,20 @@ class Entry_section(Entry): def GetData(self): return self._section.GetData() - def GetPositions(self): - """Handle entries that want to set the position/size of other entries + def GetOffsets(self): + """Handle entries that want to set the offset/size of other entries - This calls each entry's GetPositions() method. If it returns a list + This calls each entry's GetOffsets() method. If it returns a list of entries to update, it updates them. """ - self._section.GetEntryPositions() + self._section.GetEntryOffsets() return {} - def Pack(self, pos): + def Pack(self, offset): """Pack all entries into the section""" self._section.PackEntries() self.size = self._section.CheckSize() - return super(Entry_section, self).Pack(pos) + return super(Entry_section, self).Pack(offset) def WriteSymbols(self, section): """Write symbol values into binary files for access at run time"""
@@ -57,7 +57,7 @@ class Entry_section(Entry): self._section.ProcessEntryContents() super(Entry_section, self).ProcessContents() - def CheckPosition(self): + def CheckOffset(self): self._section.CheckEntries() def WriteMap(self, fd, indent):
tools/binman/etype/u_boot_dtb_with_ucode.py +2 -2
@@ -33,10 +33,10 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob): # If the section does not need microcode, there is nothing to do ucode_dest_entry = self.section.FindEntryType( 'u-boot-spl-with-ucode-ptr') - if not ucode_dest_entry or not ucode_dest_entry.target_pos: + if not ucode_dest_entry or not ucode_dest_entry.target_offset: ucode_dest_entry = self.section.FindEntryType( 'u-boot-with-ucode-ptr') - if not ucode_dest_entry or not ucode_dest_entry.target_pos: + if not ucode_dest_entry or not ucode_dest_entry.target_offset: return True # Remove the microcode
tools/binman/etype/u_boot_ucode.py +2 -2
@@ -59,8 +59,8 @@ class Entry_u_boot_ucode(Entry_blob): ucode_dest_entry = self.section.FindEntryType('u-boot-with-ucode-ptr') ucode_dest_entry_spl = self.section.FindEntryType( 'u-boot-spl-with-ucode-ptr') - if ((not ucode_dest_entry or not ucode_dest_entry.target_pos) and - (not ucode_dest_entry_spl or not ucode_dest_entry_spl.target_pos)): + if ((not ucode_dest_entry or not ucode_dest_entry.target_offset) and + (not ucode_dest_entry_spl or not ucode_dest_entry_spl.target_offset)): self.data = '' return True
tools/binman/etype/u_boot_with_ucode_ptr.py +18 -17
@@ -23,7 +23,7 @@ class Entry_u_boot_with_ucode_ptr(Entry_blob): def __init__(self, section, etype, node): Entry_blob.__init__(self, section, etype, node) self.elf_fname = 'u-boot' - self.target_pos = None + self.target_offset = None def GetDefaultFilename(self): return 'u-boot-nodtb.bin'
@@ -33,52 +33,53 @@ class Entry_u_boot_with_ucode_ptr(Entry_blob): fname = tools.GetInputFilename(self.elf_fname) sym = elf.GetSymbolAddress(fname, '_dt_ucode_base_size') if sym: - self.target_pos = sym + self.target_offset = sym elif not fdt_util.GetBool(self._node, 'optional-ucode'): self.Raise('Cannot locate _dt_ucode_base_size symbol in u-boot') return True def ProcessContents(self): # If the image does not need microcode, there is nothing to do - if not self.target_pos: + if not self.target_offset: return - # Get the position of the microcode + # Get the offset of the microcode ucode_entry = self.section.FindEntryType('u-boot-ucode') if not ucode_entry: self.Raise('Cannot find microcode region u-boot-ucode') # Check the target pos is in the section. If it is not, then U-Boot is - # being linked incorrectly, or is being placed at the wrong position + # being linked incorrectly, or is being placed at the wrong offset # in the section. # # The section must be set up so that U-Boot is placed at the # flash address to which it is linked. For example, if # CONFIG_SYS_TEXT_BASE is 0xfff00000, and the ROM is 8MB, then - # the U-Boot region must start at position 7MB in the section. In this - # case the ROM starts at 0xff800000, so the position of the first + # the U-Boot region must start at offset 7MB in the section. In this + # case the ROM starts@0xff800000, so the offset of the first # entry in the section corresponds to that. - if (self.target_pos < self.pos or - self.target_pos >= self.pos + self.size): + if (self.target_offset < self.offset or + self.target_offset >= self.offset + self.size): self.Raise('Microcode pointer _dt_ucode_base_size at %08x is ' 'outside the section ranging from %08x to %08x' % - (self.target_pos, self.pos, self.pos + self.size)) + (self.target_offset, self.offset, self.offset + self.size)) # Get the microcode, either from u-boot-ucode or u-boot-dtb-with-ucode. # If we have left the microcode in the device tree, then it will be # in the former. If we extracted the microcode from the device tree # and collated it in one place, it will be in the latter. if ucode_entry.size: - pos, size = ucode_entry.pos, ucode_entry.size + offset, size = ucode_entry.offset, ucode_entry.size else: dtb_entry = self.section.FindEntryType('u-boot-dtb-with-ucode') if not dtb_entry or not dtb_entry.ready: self.Raise('Cannot find microcode region u-boot-dtb-with-ucode') - pos = dtb_entry.pos + dtb_entry.ucode_offset + offset = dtb_entry.offset + dtb_entry.ucode_offset size = dtb_entry.ucode_size - # Write the microcode position and size into the entry - pos_and_size = struct.pack('<2L', pos, size) - self.target_pos -= self.pos - self.ProcessContentsUpdate(self.data[:self.target_pos] + pos_and_size + - self.data[self.target_pos + 8:]) + # Write the microcode offset and size into the entry + offset_and_size = struct.pack('<2L', offset, size) + self.target_offset -= self.offset + self.ProcessContentsUpdate(self.data[:self.target_offset] + + offset_and_size + + self.data[self.target_offset + 8:])
tools/binman/ftest.py +42 -43
264 lines not on this page · raw message
tools/binman/image.py +6 -6
@@ -57,7 +57,7 @@ class Image: def AddMissingProperties(self): """Add properties that are not present in the device tree - When binman has completed packing the entries the position and size of + When binman has completed packing the entries the offset and size of each entry are known. But before this the device tree may not specify these. Add any missing properties, with a dummy value, so that the size of the entry is correct. That way we can insert the correct values
@@ -73,13 +73,13 @@ class Image: """ self._section.GetEntryContents() - def GetEntryPositions(self): - """Handle entries that want to set the position/size of other entries + def GetEntryOffsets(self): + """Handle entries that want to set the offset/size of other entries - This calls each entry's GetPositions() method. If it returns a list + This calls each entry's GetOffsets() method. If it returns a list of entries to update, it updates them. """ - self._section.GetEntryPositions() + self._section.GetEntryOffsets() def PackEntries(self): """Pack all entries into the image"""
@@ -121,5 +121,5 @@ class Image: filename = '%s.map' % self._name fname = tools.GetOutputFilename(filename) with open(fname, 'w') as fd: - print('%8s %8s %s' % ('Position', 'Size', 'Name'), file=fd) + print('%8s %8s %s' % ('Offset', 'Size', 'Name'), file=fd) self._section.WriteMap(fd, 0)
tools/binman/test/08_pack.dts +1 -1
@@ -24,7 +24,7 @@ u-boot-fixed { type = "u-boot"; - pos = <61>; + offset = <61>; }; }; };
tools/binman/test/12_pack_inv_align.dts +1 -1
@@ -6,7 +6,7 @@ binman { u-boot { - pos = <5>; + offset = <5>; align = <4>; }; };
tools/binman/test/14_pack_overlap.dts +1 -1
@@ -10,7 +10,7 @@ u-boot-align { type = "u-boot"; - pos = <3>; + offset = <3>; }; }; };
tools/binman/test/21_image_pad.dts +1 -1
@@ -10,7 +10,7 @@ }; u-boot { - pos = <20>; + offset = <20>; }; }; };
tools/binman/test/24_sorted.dts +3 -3
@@ -5,13 +5,13 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; u-boot { - pos = <22>; + offset = <22>; }; u-boot-spl { - pos = <1>; + offset = <1>; }; }; };
tools/binman/test/25_pack_zero_size.dts +1 -1
@@ -9,7 +9,7 @@ }; u-boot-spl { - pos = <0>; + offset = <0>; }; }; };
tools/binman/test/27_pack_4gb_no_size.dts +3 -3
@@ -5,14 +5,14 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; u-boot { - pos = <0xfffffff0>; + offset = <0xfffffff0>; }; u-boot-spl { - pos = <0xfffffff7>; + offset = <0xfffffff7>; }; }; };
tools/binman/test/28_pack_4gb_outside.dts +3 -3
@@ -5,15 +5,15 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <32>; u-boot { - pos = <0>; + offset = <0>; }; u-boot-spl { - pos = <0xffffffeb>; + offset = <0xffffffeb>; }; }; };
tools/binman/test/29_x86-rom.dts +3 -3
@@ -5,15 +5,15 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <32>; u-boot { - pos = <0xffffffe0>; + offset = <0xffffffe0>; }; u-boot-spl { - pos = <0xffffffeb>; + offset = <0xffffffeb>; }; }; };
tools/binman/test/30_x86-rom-me-no-desc.dts +2 -2
@@ -5,12 +5,12 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <16>; intel-me { filename = "me.bin"; - pos-unset; + offset-unset; }; }; };
tools/binman/test/31_x86-rom-me.dts +2 -2
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x800000>; intel-descriptor {
@@ -14,7 +14,7 @@ intel-me { filename = "me.bin"; - pos-unset; + offset-unset; }; }; };
tools/binman/test/34_x86_ucode.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-with-ucode-ptr {
tools/binman/test/35_x86_single_ucode.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-with-ucode-ptr {
tools/binman/test/37_x86_no_ucode.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-with-ucode-ptr {
tools/binman/test/38_x86_ucode_missing_node.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-with-ucode-ptr {
tools/binman/test/39_x86_ucode_missing_node2.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-with-ucode-ptr {
tools/binman/test/40_x86_ucode_not_in_image.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; size = <0x200>; u-boot-with-ucode-ptr { };
tools/binman/test/44_x86_optional_ucode.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-with-ucode-ptr {
tools/binman/test/45_prop_test.dts +2 -2
@@ -5,12 +5,12 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <16>; intel-me { filename = "me.bin"; - pos-unset; + offset-unset; intval = <3>; intarray = <5 6>; byteval = [08];
tools/binman/test/49_x86_ucode_spl.dts +1 -1
@@ -5,7 +5,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-spl-with-ucode-ptr {
tools/binman/test/53_symbols.dts +1 -1
@@ -10,7 +10,7 @@ }; u-boot { - pos = <20>; + offset = <20>; }; u-boot-spl2 {
tools/binman/test/58_x86_ucode_spl_needs_retry.dts +1 -1
@@ -7,7 +7,7 @@ #size-cells = <1>; binman { - sort-by-pos; + sort-by-offset; end-at-4gb; size = <0x200>; u-boot-spl-with-ucode-ptr {
tools/binman/test/u_boot_binman_syms binary +0 -0
z1 at ZZ5X~n4}4Dm^sdAW&s at ul%e`S~UBiFuXyq>Br3kfkRx3R_H$7r4r3GTBs6nd!3N k<S0Qk-V6Z-h66w=*?^dJa<8DYgoYpk!)hQ81{k3X02qTyEC2ui
delta 311
zcmdm at wo3_0@DhCjY{wM{giSY5Bn9IT;WmHowz;j+V6#vLY6V00e5F-D+P_vq|&^S zQUwz|3q2EEqf#)>u+Gp#&%i{_SQ8>XI6u at M(xQfg_N1%1ty;pQsX@!$iQ#XdW8~ zPi7RBW}P6!z_4=iMIqsdGh;W2$<9(+s4B1 at xK^QKm~|dfLM@$iNOd-fdB&|gC&r! z0mK|o7jD0K_o$ML@O*5QBgKP=7O!2AKx}ApSHUjo>p*Ru|Nq+%L$+RghoI5MNx9 XSX46ER#1u=$ekQ3C<&%#3t9jG`lCCI
tools/binman/test/u_boot_binman_syms.c +3 -3
@@ -8,6 +8,6 @@#define CONFIG_BINMAN #include <binman_sym.h> -binman_sym_declare(unsigned long, u_boot_spl, pos); -binman_sym_declare(unsigned long long, u_boot_spl2, pos); -binman_sym_declare(unsigned long, u_boot_any, pos); +binman_sym_declare(unsigned long, u_boot_spl, offset); +binman_sym_declare(unsigned long long, u_boot_spl2, offset); +binman_sym_declare(unsigned long, u_boot_any, offset);
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
PATCH v2 7/29 binman: Add a new 'image-pos' property
At present each entry has an offset within its parent section. This is useful for figuring out how entries relate to one another. However it is sometimes necessary to locate an entry within an image, regardless of which sections it is nested inside.
Add a new 'image-pos' property to provide this information. Also add some documentation for the -u option binman provides, which updates the device tree with final entry information.
Since the image position is a better symbol to use for the position of U-Boot as obtained by SPL, update the SPL symbols to use this instead of offset, which might be incorrect if hierarchical sections are used.
---
Changes in v2:
- Update U-Boot symbols to use image_pos instead of offset
- Update tests to include test coverage of image_pos
common/spl/spl.c | 4 ++-- common/spl/spl_ram.c | 2 +- include/spl.h | 2 +- tools/binman/README | 22 ++++++++++++++++++++-- tools/binman/bsection.py | 10 +++++++++- tools/binman/control.py | 1 + tools/binman/entry.py | 12 +++++++++++- tools/binman/etype/section.py | 4 ++++ tools/binman/ftest.py | 9 ++++++++- tools/binman/image.py | 3 +++ tools/binman/test/u_boot_binman_syms | Bin 4916 -> 4924 bytes tools/binman/test/u_boot_binman_syms.c | 2 +- 12 files changed, 61 insertions(+), 10 deletions(-)
common/spl/spl.c +2 -2
@@ -34,7 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;u32 *boot_params_ptr =NULL ;/* See spl.h for information about this */ -binman_sym_declare (ulong, u_boot_any, offset); +binman_sym_declare (ulong, u_boot_any, image_pos);/* Define board data structure */ static bd_t bdata __attribute__ ((section(".data")));
@@ -129,7 +129,7 @@ __weak void spl_board_prepare_for_boot(void)void spl_set_header_raw_uboot (struct spl_image_info *spl_image) { -ulong u_boot_pos =binman_sym (ulong, u_boot_any, offset); +ulong u_boot_pos =binman_sym (ulong, u_boot_any, image_pos); spl_image->size =CONFIG_SYS_MONITOR_LEN ;
common/spl/spl_ram.c +1 -1
@@ -49,7 +49,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, load.read = spl_ram_load_read;spl_load_simple_fit (spl_image, &load,0 , header); }else { -ulong u_boot_pos =binman_sym (ulong, u_boot_any, offset); +ulong u_boot_pos =binman_sym (ulong, u_boot_any, image_pos);debug ("Legacy image\n" );/*
include/spl.h +1 -1
@@ -60,7 +60,7 @@ struct spl_load_info {* image is found. For * example if u-boot.img is used we don't check that * spl_parse_image_header() can parse a valid header. */ -binman_sym_extern (ulong, u_boot_any, offset); +binman_sym_extern (ulong, u_boot_any, image_pos);/** * spl_load_simple_fit() - Loads a fit image from a device.
tools/binman/README +20 -2
@@ -324,6 +324,12 @@ offset-unset: property is present, binman will give an error if another entry does not set the offset (with the GetOffsets() method). +image-pos: + This cannot be set on entry (or at least it is ignored if it is), but + with the -u option, binman will set it to the absolute image position + for each entry. This makes it easy to find out exactly where the entry + ended up in the image, regardless of parent sections, etc. + The attributes supported for images are described below. Several are similar to those for entries.
@@ -550,8 +556,8 @@ the 'warning' line in scripts/Makefile.lib to see what it has found: # u_boot_dtsi_options_debug = $(u_boot_dtsi_options_raw) -Access to binman entry offsets at run time ------------------------------------------- +Access to binman entry offsets at run time (symbols) +---------------------------------------------------- Binman assembles images and determines where each entry is placed in the image. This information may be useful to U-Boot at run time. For example, in SPL it
@@ -577,6 +583,18 @@ At present this feature is only supported in SPL. In principle it is possible to fill in such symbols in U-Boot proper, as well. +Access to binman entry offsets at run time (fdt) +------------------------------------------------ + +Binman can update the U-Boot FDT to include the final position and size of +each entry in the images it processes. The option to enable this is -u and it +causes binman to make sure that the 'offset', 'image-pos' and 'size' properties +are set correctly for every entry. Since it is not necessary to specify these in +the image definition, binman calculates the final values and writes these to +the device tree. These can be used by U-Boot at run-time to find the location +of each entry. + + Map files ---------
tools/binman/bsection.py +9 -1
@@ -96,7 +96,7 @@ class Section(object): def AddMissingProperties(self): """Add new properties to the device tree as needed for this entry""" - for prop in ['offset', 'size']: + for prop in ['offset', 'size', 'image-pos']: if not prop in self._node.props: self._node.AddZeroProp(prop) for entry in self._entries.values():
@@ -105,6 +105,7 @@ class Section(object): def SetCalculatedProperties(self): self._node.SetInt('offset', self._offset) self._node.SetInt('size', self._size) + self._node.SetInt('image-pos', self._image_pos) for entry in self._entries.values(): entry.SetCalculatedProperties()
@@ -260,6 +261,11 @@ class Section(object): offset = entry.offset + entry.size prev_name = entry.GetPath() + def SetImagePos(self, image_pos): + self._image_pos = image_pos + for entry in self._entries.values(): + entry.SetImagePos(image_pos) + def ProcessEntryContents(self): """Call the ProcessContents() method for each entry
@@ -341,6 +347,8 @@ class Section(object): raise ValueError(err) if prop_name == 'offset': return entry.offset + elif prop_name == 'image_pos': + return entry.image_pos else: raise ValueError("%s: No such property '%s'" % (msg, prop_name))
tools/binman/control.py +1 -0
@@ -161,6 +161,7 @@ def Binman(options, args): image.PackEntries() image.CheckSize() image.CheckEntries() + image.SetImagePos() if options.update_fdt: image.SetCalculatedProperties() image.ProcessEntryContents()
tools/binman/entry.py +11 -1
@@ -64,6 +64,7 @@ class Entry(object): self.pad_before = 0 self.pad_after = 0 self.offset_unset = False + self.image_pos = None if read_node: self.ReadNode()
@@ -133,7 +134,7 @@ class Entry(object): def AddMissingProperties(self): """Add new properties to the device tree as needed for this entry""" - for prop in ['offset', 'size']: + for prop in ['offset', 'size', 'image-pos']: if not prop in self._node.props: self._node.AddZeroProp(prop)
@@ -141,6 +142,7 @@ class Entry(object): """Set the value of device-tree properties calculated by binman""" self._node.SetInt('offset', self.offset) self._node.SetInt('size', self.size) + self._node.SetInt('image-pos', self.image_pos) def ProcessFdt(self, fdt): return True
@@ -265,6 +267,14 @@ class Entry(object): self.offset = pos self.size = size + def SetImagePos(self, image_pos): + """Set the position in the image + + Args: + image_pos: Position of this entry in the image + """ + self.image_pos = image_pos + self.offset + def ProcessContents(self): pass
tools/binman/etype/section.py +4 -0
@@ -46,6 +46,10 @@ class Entry_section(Entry): self.size = self._section.GetSize() return super(Entry_section, self).Pack(offset) + def SetImagePos(self, image_pos): + Entry.SetImagePos(self, image_pos) + self._section.SetImagePos(image_pos + self.offset) + def WriteSymbols(self, section): """Write symbol values into binary files for access at run time""" self._section.WriteSymbols()
tools/binman/ftest.py +8 -1
@@ -1051,23 +1051,30 @@ class TestFunctional(unittest.TestCase): """Test that we can update the device tree with offset/size info""" _, _, _, out_dtb_fname = self._DoReadFileDtb('60_fdt_update.dts', update_dtb=True) - props = self._GetPropTree(out_dtb_fname, ['offset', 'size']) + props = self._GetPropTree(out_dtb_fname, ['offset', 'size', + 'image-pos']) with open('/tmp/x.dtb', 'wb') as outf: with open(out_dtb_fname) as inf: outf.write(inf.read()) self.assertEqual({ + 'image-pos': 0, 'offset': 0, '_testing:offset': 32, '_testing:size': 1, + '_testing:image-pos': 32, 'section at 0/u-boot:offset': 0, 'section at 0/u-boot:size': len(U_BOOT_DATA), + 'section at 0/u-boot:image-pos': 0, 'section at 0:offset': 0, 'section at 0:size': 16, + 'section at 0:image-pos': 0, 'section at 1/u-boot:offset': 0, 'section at 1/u-boot:size': len(U_BOOT_DATA), + 'section at 1/u-boot:image-pos': 16, 'section at 1:offset': 16, 'section at 1:size': 16, + 'section at 1:image-pos': 16, 'size': 40 }, props)
tools/binman/image.py +3 -0
@@ -96,6 +96,9 @@ class Image: def SetCalculatedProperties(self): self._section.SetCalculatedProperties() + def SetImagePos(self): + self._section.SetImagePos(0) + def ProcessEntryContents(self): """Call the ProcessContents() method for each entry
tools/binman/test/u_boot_binman_syms binary +0 -0
zcmdm at wnuG(0;9 at C#rOOoD(}AY&Moeq!@T5hu>ITRenxu^(Lzb7%>?dOb!>&o!ltk z?W at ATzz2;f(%RyQ-CxK2rw*gaSDRKn#;F2eM6|3Iu at aJAiDEeh>ihXHS+C44K> zC^$J at P@FR}H!(dmz97GN@@&DClbwZ98BHgz6jElqHTkTNI%Ce{uR`jqI)V%g>n2|m G5(WUg>nL;p
delta 188 zcmdm^wnc4%0;9}E#rOOo%aW%XXzPXS$a9c<vVEPO>0A{L|H&!>MvRt|BLs9OcL;d+ z8Za<0umG_j0~13ikXAwBPXw}IK!Aafp#;b=feHu!)wcrKAoU;s;?I~YD;P3)f*|MQ vXhHSKO9Yos_7O^9G?~0nNSX2S<f}sJj2V;v3aLwI2r@9NhG+wmj8HZJbRHr-
tools/binman/test/u_boot_binman_syms.c +1 -1
@@ -10,4 +10,4 @@ binman_sym_declare(unsigned long, u_boot_spl, offset); binman_sym_declare(unsigned long long, u_boot_spl2, offset); -binman_sym_declare(unsigned long, u_boot_any, offset); +binman_sym_declare(unsigned long, u_boot_any, image_pos);
Signature · 1 line
2.18.0.597.ga71716f1ad-goog