Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / tools / binman / etype / u_boot_elf.py
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
8 from binman.entry import Entry
9 from binman.etype.blob import Entry_blob
10
11 from dtoc import fdt_util
12 from patman import tools
13
14 class 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         Entry_blob.__init__(self, 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.GetOutputFilename('%s.stripped' % uniq)
31             tools.WriteFile(out_fname, tools.ReadFile(self._pathname))
32             tools.Run('strip', out_fname)
33             self._pathname = out_fname
34         Entry_blob.ReadBlobContents(self)
35         return True
36
37     def GetDefaultFilename(self):
38         return 'u-boot'