1# SPDX-License-Identifier: GPL-2.0+
2# Copyright (c) 2018 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
5# Entry-type module for U-Boot ELF image
6#
7
8from binman.entry import Entry
9from binman.etype.blob import Entry_blob
10
11from dtoc import fdt_util
12from u_boot_pylib import tools
13
14class Entry_u_boot_elf(Entry_blob):
15    """U-Boot ELF image
16
17    Properties / Entry arguments:
18        - filename: Filename of u-boot (default 'u-boot')
19
20    This is the U-Boot ELF image. It does not include a device tree but can be
21    relocated to any address for execution.
22    """
23    def __init__(self, section, etype, node):
24        super().__init__(section, etype, node)
25        self._strip = fdt_util.GetBool(self._node, 'strip')
26
27    def ReadBlobContents(self):
28        if self._strip:
29            uniq = self.GetUniqueName()
30            out_fname = tools.get_output_filename('%s.stripped' % uniq)
31            tools.write_file(out_fname, tools.read_file(self._pathname))
32            tools.run('strip', out_fname)
33            self._pathname = out_fname
34        super().ReadBlobContents()
35        return True
36
37    def GetDefaultFilename(self):
38        return 'u-boot'
39