binman: Add support for adding TPL binaries
[platform/kernel/u-boot.git] / tools / binman / etype / u_boot_spl.py
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2016 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5 # Entry-type module for spl/u-boot-spl.bin
6 #
7
8 import elf
9
10 from entry import Entry
11 from blob import Entry_blob
12
13 class Entry_u_boot_spl(Entry_blob):
14     """U-Boot SPL binary
15
16     Properties / Entry arguments:
17         - filename: Filename of u-boot-spl.bin (default 'spl/u-boot-spl.bin')
18
19     This is the U-Boot SPL (Secondary Program Loader) binary. This is a small
20     binary which loads before U-Boot proper, typically into on-chip SRAM. It is
21     responsible for locating, loading and jumping to U-Boot. Note that SPL is
22     not relocatable so must be loaded to the correct address in SRAM, or written
23     to run from the correct address if direct flash execution is possible (e.g.
24     on x86 devices).
25
26     SPL can access binman symbols at runtime. See:
27
28         'Access to binman entry offsets at run time (symbols)'
29
30     in the binman README for more information.
31
32     The ELF file 'spl/u-boot-spl' must also be available for this to work, since
33     binman uses that to look up symbols to write into the SPL binary.
34     """
35     def __init__(self, section, etype, node):
36         Entry_blob.__init__(self, section, etype, node)
37         self.elf_fname = 'spl/u-boot-spl'
38
39     def GetDefaultFilename(self):
40         return 'spl/u-boot-spl.bin'
41
42     def WriteSymbols(self, section):
43         elf.LookupAndWriteSymbols(self.elf_fname, self, section)