Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Handle U-Boot config for a machine |
| 2 | # |
| 3 | # The format to specify it, in the machine, is: |
| 4 | # |
| 5 | # UBOOT_CONFIG ??= <default> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6 | # UBOOT_CONFIG[foo] = "config,images,binary" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | # |
| 8 | # or |
| 9 | # |
| 10 | # UBOOT_MACHINE = "config" |
| 11 | # |
| 12 | # Copyright 2013, 2014 (C) O.S. Systems Software LTDA. |
| 13 | |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 14 | # Some versions of u-boot use .bin and others use .img. By default use .bin |
| 15 | # but enable individual recipes to change this value. |
| 16 | UBOOT_SUFFIX ??= "bin" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 17 | UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}" |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 18 | UBOOT_BINARYNAME ?= "${@os.path.splitext(d.getVar("UBOOT_BINARY"))[0]}" |
| 19 | UBOOT_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}" |
| 20 | UBOOT_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_SUFFIX}" |
| 21 | UBOOT_MAKE_TARGET ?= "all" |
| 22 | |
| 23 | # Output the ELF generated. Some platforms can use the ELF file and directly |
| 24 | # load it (JTAG booting, QEMU) additionally the ELF can be used for debugging |
| 25 | # purposes. |
| 26 | UBOOT_ELF ?= "" |
| 27 | UBOOT_ELF_SUFFIX ?= "elf" |
| 28 | UBOOT_ELF_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}" |
| 29 | UBOOT_ELF_BINARY ?= "u-boot.${UBOOT_ELF_SUFFIX}" |
| 30 | UBOOT_ELF_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_ELF_SUFFIX}" |
| 31 | |
| 32 | # Some versions of u-boot build an SPL (Second Program Loader) image that |
| 33 | # should be packaged along with the u-boot binary as well as placed in the |
| 34 | # deploy directory. For those versions they can set the following variables |
| 35 | # to allow packaging the SPL. |
| 36 | SPL_BINARY ?= "" |
| 37 | SPL_BINARYNAME ?= "${@os.path.basename(d.getVar("SPL_BINARY"))}" |
| 38 | SPL_IMAGE ?= "${SPL_BINARYNAME}-${MACHINE}-${PV}-${PR}" |
| 39 | SPL_SYMLINK ?= "${SPL_BINARYNAME}-${MACHINE}" |
| 40 | |
| 41 | # Additional environment variables or a script can be installed alongside |
| 42 | # u-boot to be used automatically on boot. This file, typically 'uEnv.txt' |
| 43 | # or 'boot.scr', should be packaged along with u-boot as well as placed in the |
| 44 | # deploy directory. Machine configurations needing one of these files should |
| 45 | # include it in the SRC_URI and set the UBOOT_ENV parameter. |
| 46 | UBOOT_ENV_SUFFIX ?= "txt" |
| 47 | UBOOT_ENV ?= "" |
| 48 | UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}" |
| 49 | UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}" |
| 50 | UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}" |
| 51 | |
| 52 | # Default name of u-boot initial env, but enable individual recipes to change |
| 53 | # this value. |
| 54 | UBOOT_INITIAL_ENV ?= "${PN}-initial-env" |
| 55 | |
| 56 | # U-Boot EXTLINUX variables. U-Boot searches for /boot/extlinux/extlinux.conf |
| 57 | # to find EXTLINUX conf file. |
| 58 | UBOOT_EXTLINUX_INSTALL_DIR ?= "/boot/extlinux" |
| 59 | UBOOT_EXTLINUX_CONF_NAME ?= "extlinux.conf" |
| 60 | UBOOT_EXTLINUX_SYMLINK ?= "${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}-${PR}" |
| 61 | |
| 62 | # Options for the device tree compiler passed to mkimage '-D' feature: |
| 63 | UBOOT_MKIMAGE_DTCOPTS ??= "" |
| 64 | SPL_MKIMAGE_DTCOPTS ??= "" |
| 65 | |
| 66 | # mkimage command |
| 67 | UBOOT_MKIMAGE ?= "uboot-mkimage" |
| 68 | UBOOT_MKIMAGE_SIGN ?= "${UBOOT_MKIMAGE}" |
| 69 | |
| 70 | # Arguments passed to mkimage for signing |
| 71 | UBOOT_MKIMAGE_SIGN_ARGS ?= "" |
| 72 | SPL_MKIMAGE_SIGN_ARGS ?= "" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 73 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | ubootmachine = d.getVar("UBOOT_MACHINE") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | ubootconfigflags = d.getVarFlags('UBOOT_CONFIG') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 77 | ubootbinary = d.getVar('UBOOT_BINARY') |
| 78 | ubootbinaries = d.getVar('UBOOT_BINARIES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | # The "doc" varflag is special, we don't want to see it here |
| 80 | ubootconfigflags.pop('doc', None) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 81 | ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 82 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 83 | if not ubootmachine and not ubootconfig: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 84 | PN = d.getVar("PN") |
| 85 | FILE = os.path.basename(d.getVar("FILE")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | bb.debug(1, "To build %s, see %s for instructions on \ |
| 87 | setting up your machine config" % (PN, FILE)) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 88 | raise bb.parse.SkipRecipe("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 90 | if ubootmachine and ubootconfig: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 91 | raise bb.parse.SkipRecipe("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 92 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 93 | if ubootconfigflags and ubootbinaries: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 94 | raise bb.parse.SkipRecipe("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 95 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | if len(ubootconfig) > 0: |
| 97 | for config in ubootconfig: |
| 98 | for f, v in ubootconfigflags.items(): |
| 99 | if config == f: |
| 100 | items = v.split(',') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 101 | if items[0] and len(items) > 3: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 102 | raise bb.parse.SkipRecipe('Only config,images,binary can be specified!') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | d.appendVar('UBOOT_MACHINE', ' ' + items[0]) |
| 104 | # IMAGE_FSTYPES appending |
| 105 | if len(items) > 1 and items[1]: |
| 106 | bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1]) |
| 107 | d.appendVar('IMAGE_FSTYPES', ' ' + items[1]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 108 | if len(items) > 2 and items[2]: |
| 109 | bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2]) |
| 110 | d.appendVar('UBOOT_BINARIES', ' ' + items[2]) |
| 111 | else: |
| 112 | bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary) |
| 113 | d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | break |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | } |