blob: 07a303d0a07019983ef1bf030e509093b50f2a61 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Handle U-Boot config for a machine
2#
3# The format to specify it, in the machine, is:
4#
5# UBOOT_CONFIG ??= <default>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06006# UBOOT_CONFIG[foo] = "config,images,binary"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007#
8# or
9#
10# UBOOT_MACHINE = "config"
11#
12# Copyright 2013, 2014 (C) O.S. Systems Software LTDA.
13
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050014def removesuffix(s, suffix):
15 if suffix and s.endswith(suffix):
16 return s[:-len(suffix)]
17 return s
18
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050019# Some versions of u-boot use .bin and others use .img. By default use .bin
20# but enable individual recipes to change this value.
21UBOOT_SUFFIX ??= "bin"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060022UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}"
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050023UBOOT_BINARYNAME ?= "${@os.path.splitext(d.getVar("UBOOT_BINARY"))[0]}"
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050024UBOOT_IMAGE ?= "${UBOOT_BINARYNAME}-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}"
25UBOOT_SYMLINK ?= "${UBOOT_BINARYNAME}-${MACHINE}.${UBOOT_SUFFIX}"
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050026UBOOT_MAKE_TARGET ?= "all"
27
28# Output the ELF generated. Some platforms can use the ELF file and directly
29# load it (JTAG booting, QEMU) additionally the ELF can be used for debugging
30# purposes.
31UBOOT_ELF ?= ""
32UBOOT_ELF_SUFFIX ?= "elf"
33UBOOT_ELF_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}"
34UBOOT_ELF_BINARY ?= "u-boot.${UBOOT_ELF_SUFFIX}"
35UBOOT_ELF_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_ELF_SUFFIX}"
36
37# Some versions of u-boot build an SPL (Second Program Loader) image that
38# should be packaged along with the u-boot binary as well as placed in the
39# deploy directory. For those versions they can set the following variables
40# to allow packaging the SPL.
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050041SPL_SUFFIX ?= ""
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050042SPL_BINARY ?= ""
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050043SPL_DELIMITER ?= "${@'.' if d.getVar("SPL_SUFFIX") else ''}"
44SPL_BINARYFILE ?= "${@os.path.basename(d.getVar("SPL_BINARY"))}"
45SPL_BINARYNAME ?= "${@removesuffix(d.getVar("SPL_BINARYFILE"), "." + d.getVar("SPL_SUFFIX"))}"
46SPL_IMAGE ?= "${SPL_BINARYNAME}-${MACHINE}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX}"
47SPL_SYMLINK ?= "${SPL_BINARYNAME}-${MACHINE}${SPL_DELIMITER}${SPL_SUFFIX}"
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050048
49# Additional environment variables or a script can be installed alongside
50# u-boot to be used automatically on boot. This file, typically 'uEnv.txt'
51# or 'boot.scr', should be packaged along with u-boot as well as placed in the
52# deploy directory. Machine configurations needing one of these files should
53# include it in the SRC_URI and set the UBOOT_ENV parameter.
54UBOOT_ENV_SUFFIX ?= "txt"
55UBOOT_ENV ?= ""
56UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}"
57UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}"
58UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}"
59
60# Default name of u-boot initial env, but enable individual recipes to change
61# this value.
62UBOOT_INITIAL_ENV ?= "${PN}-initial-env"
63
64# U-Boot EXTLINUX variables. U-Boot searches for /boot/extlinux/extlinux.conf
65# to find EXTLINUX conf file.
66UBOOT_EXTLINUX_INSTALL_DIR ?= "/boot/extlinux"
67UBOOT_EXTLINUX_CONF_NAME ?= "extlinux.conf"
68UBOOT_EXTLINUX_SYMLINK ?= "${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}-${PR}"
69
70# Options for the device tree compiler passed to mkimage '-D' feature:
71UBOOT_MKIMAGE_DTCOPTS ??= ""
72SPL_MKIMAGE_DTCOPTS ??= ""
73
74# mkimage command
75UBOOT_MKIMAGE ?= "uboot-mkimage"
76UBOOT_MKIMAGE_SIGN ?= "${UBOOT_MKIMAGE}"
77
78# Arguments passed to mkimage for signing
79UBOOT_MKIMAGE_SIGN_ARGS ?= ""
80SPL_MKIMAGE_SIGN_ARGS ?= ""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060081
Andrew Geissler09036742021-06-25 14:25:14 -050082# Options to deploy the u-boot device tree
83UBOOT_DTB ?= ""
84UBOOT_DTB_BINARY ??= ""
85
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086python () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050087 ubootmachine = d.getVar("UBOOT_MACHINE")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050089 ubootbinary = d.getVar('UBOOT_BINARY')
90 ubootbinaries = d.getVar('UBOOT_BINARIES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 # The "doc" varflag is special, we don't want to see it here
92 ubootconfigflags.pop('doc', None)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050093 ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094
Brad Bishopd7bf8c12018-02-25 22:55:05 -050095 if not ubootmachine and not ubootconfig:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050096 PN = d.getVar("PN")
97 FILE = os.path.basename(d.getVar("FILE"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 bb.debug(1, "To build %s, see %s for instructions on \
99 setting up your machine config" % (PN, FILE))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400100 raise bb.parse.SkipRecipe("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500102 if ubootmachine and ubootconfig:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400103 raise bb.parse.SkipRecipe("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600105 if ubootconfigflags and ubootbinaries:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400106 raise bb.parse.SkipRecipe("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600107
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108 if len(ubootconfig) > 0:
109 for config in ubootconfig:
110 for f, v in ubootconfigflags.items():
111 if config == f:
112 items = v.split(',')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600113 if items[0] and len(items) > 3:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400114 raise bb.parse.SkipRecipe('Only config,images,binary can be specified!')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 d.appendVar('UBOOT_MACHINE', ' ' + items[0])
116 # IMAGE_FSTYPES appending
117 if len(items) > 1 and items[1]:
118 bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1])
119 d.appendVar('IMAGE_FSTYPES', ' ' + items[1])
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600120 if len(items) > 2 and items[2]:
121 bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2])
122 d.appendVar('UBOOT_BINARIES', ' ' + items[2])
123 else:
124 bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary)
125 d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 break
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127}