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 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 14 | UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}" |
| 15 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | ubootmachine = d.getVar("UBOOT_MACHINE") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | ubootconfigflags = d.getVarFlags('UBOOT_CONFIG') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 19 | ubootbinary = d.getVar('UBOOT_BINARY') |
| 20 | ubootbinaries = d.getVar('UBOOT_BINARIES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | # The "doc" varflag is special, we don't want to see it here |
| 22 | ubootconfigflags.pop('doc', None) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 23 | ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | if not ubootmachine and not ubootconfig: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 26 | PN = d.getVar("PN") |
| 27 | FILE = os.path.basename(d.getVar("FILE")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | bb.debug(1, "To build %s, see %s for instructions on \ |
| 29 | setting up your machine config" % (PN, FILE)) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 30 | 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] | 31 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | if ubootmachine and ubootconfig: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 33 | 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] | 34 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 35 | if ubootconfigflags and ubootbinaries: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 36 | 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] | 37 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | if len(ubootconfig) > 0: |
| 39 | for config in ubootconfig: |
| 40 | for f, v in ubootconfigflags.items(): |
| 41 | if config == f: |
| 42 | items = v.split(',') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 43 | if items[0] and len(items) > 3: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | raise bb.parse.SkipRecipe('Only config,images,binary can be specified!') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | d.appendVar('UBOOT_MACHINE', ' ' + items[0]) |
| 46 | # IMAGE_FSTYPES appending |
| 47 | if len(items) > 1 and items[1]: |
| 48 | bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1]) |
| 49 | d.appendVar('IMAGE_FSTYPES', ' ' + items[1]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 50 | if len(items) > 2 and items[2]: |
| 51 | bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2]) |
| 52 | d.appendVar('UBOOT_BINARIES', ' ' + items[2]) |
| 53 | else: |
| 54 | bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary) |
| 55 | d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | break |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | } |