Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Universal Boot Loader for embedded devices" |
| 2 | HOMEPAGE = "http://www.denx.de/wiki/U-Boot/WebHome" |
| 3 | SECTION = "bootloaders" |
| 4 | PROVIDES = "virtual/bootloader" |
| 5 | |
| 6 | LICENSE = "GPLv2+" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | |
| 9 | SRC_URI = "git://git.denx.de/u-boot.git;branch=master" |
| 10 | |
| 11 | S = "${WORKDIR}/git" |
| 12 | |
| 13 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 14 | |
| 15 | inherit uboot-config deploy |
| 16 | |
| 17 | EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1' |
| 18 | EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"' |
| 19 | |
| 20 | PACKAGECONFIG ??= "openssl" |
| 21 | # u-boot will compile its own tools during the build, with specific |
| 22 | # configurations (aka when CONFIG_FIT_SIGNATURE is enabled) openssl is needed as |
| 23 | # a host build dependency. |
| 24 | PACKAGECONFIG[openssl] = ",,openssl-native" |
| 25 | |
| 26 | # Allow setting an additional version string that will be picked up by the |
| 27 | # u-boot build system and appended to the u-boot version. If the .scmversion |
| 28 | # file already exists it will not be overwritten. |
| 29 | UBOOT_LOCALVERSION ?= "" |
| 30 | |
| 31 | # Some versions of u-boot use .bin and others use .img. By default use .bin |
| 32 | # but enable individual recipes to change this value. |
| 33 | UBOOT_SUFFIX ??= "bin" |
| 34 | UBOOT_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}" |
| 35 | UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}" |
| 36 | UBOOT_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_SUFFIX}" |
| 37 | UBOOT_MAKE_TARGET ?= "all" |
| 38 | |
| 39 | # Output the ELF generated. Some platforms can use the ELF file and directly |
| 40 | # load it (JTAG booting, QEMU) additionally the ELF can be used for debugging |
| 41 | # purposes. |
| 42 | UBOOT_ELF ?= "" |
| 43 | UBOOT_ELF_SUFFIX ?= "elf" |
| 44 | UBOOT_ELF_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}" |
| 45 | UBOOT_ELF_BINARY ?= "u-boot.${UBOOT_ELF_SUFFIX}" |
| 46 | UBOOT_ELF_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_ELF_SUFFIX}" |
| 47 | |
| 48 | # Some versions of u-boot build an SPL (Second Program Loader) image that |
| 49 | # should be packaged along with the u-boot binary as well as placed in the |
| 50 | # deploy directory. For those versions they can set the following variables |
| 51 | # to allow packaging the SPL. |
| 52 | SPL_BINARY ?= "" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 53 | SPL_BINARYNAME ?= "${@os.path.basename(d.getVar("SPL_BINARY", True))}" |
| 54 | SPL_IMAGE ?= "${SPL_BINARYNAME}-${MACHINE}-${PV}-${PR}" |
| 55 | SPL_SYMLINK ?= "${SPL_BINARYNAME}-${MACHINE}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | |
| 57 | # Additional environment variables or a script can be installed alongside |
| 58 | # u-boot to be used automatically on boot. This file, typically 'uEnv.txt' |
| 59 | # or 'boot.scr', should be packaged along with u-boot as well as placed in the |
| 60 | # deploy directory. Machine configurations needing one of these files should |
| 61 | # include it in the SRC_URI and set the UBOOT_ENV parameter. |
| 62 | UBOOT_ENV_SUFFIX ?= "txt" |
| 63 | UBOOT_ENV ?= "" |
| 64 | UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}" |
| 65 | UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}" |
| 66 | UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}" |
| 67 | |
| 68 | do_compile () { |
| 69 | if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then |
| 70 | sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' config.mk |
| 71 | fi |
| 72 | |
| 73 | unset LDFLAGS |
| 74 | unset CFLAGS |
| 75 | unset CPPFLAGS |
| 76 | |
| 77 | if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ] |
| 78 | then |
| 79 | echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion |
| 80 | echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion |
| 81 | fi |
| 82 | |
| 83 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 84 | then |
| 85 | for config in ${UBOOT_MACHINE}; do |
| 86 | i=`expr $i + 1`; |
| 87 | for type in ${UBOOT_CONFIG}; do |
| 88 | j=`expr $j + 1`; |
| 89 | if [ $j -eq $i ] |
| 90 | then |
| 91 | oe_runmake O=${config} ${config} |
| 92 | oe_runmake O=${config} ${UBOOT_MAKE_TARGET} |
| 93 | cp ${S}/${config}/${UBOOT_BINARY} ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} |
| 94 | fi |
| 95 | done |
| 96 | unset j |
| 97 | done |
| 98 | unset i |
| 99 | else |
| 100 | oe_runmake ${UBOOT_MACHINE} |
| 101 | oe_runmake ${UBOOT_MAKE_TARGET} |
| 102 | fi |
| 103 | |
| 104 | } |
| 105 | |
| 106 | do_install () { |
| 107 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 108 | then |
| 109 | for config in ${UBOOT_MACHINE}; do |
| 110 | i=`expr $i + 1`; |
| 111 | for type in ${UBOOT_CONFIG}; do |
| 112 | j=`expr $j + 1`; |
| 113 | if [ $j -eq $i ] |
| 114 | then |
| 115 | install -d ${D}/boot |
| 116 | install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} |
| 117 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} |
| 118 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY} |
| 119 | fi |
| 120 | done |
| 121 | unset j |
| 122 | done |
| 123 | unset i |
| 124 | else |
| 125 | install -d ${D}/boot |
| 126 | install ${S}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE} |
| 127 | ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY} |
| 128 | fi |
| 129 | |
| 130 | if [ "x${UBOOT_ELF}" != "x" ] |
| 131 | then |
| 132 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 133 | then |
| 134 | for config in ${UBOOT_MACHINE}; do |
| 135 | i=`expr $i + 1`; |
| 136 | for type in ${UBOOT_CONFIG}; do |
| 137 | j=`expr $j + 1`; |
| 138 | if [ $j -eq $i ] |
| 139 | then |
| 140 | install ${S}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} |
| 141 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} |
| 142 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY} |
| 143 | fi |
| 144 | done |
| 145 | unset j |
| 146 | done |
| 147 | unset i |
| 148 | else |
| 149 | install ${S}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE} |
| 150 | ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY} |
| 151 | fi |
| 152 | fi |
| 153 | |
| 154 | if [ -e ${WORKDIR}/fw_env.config ] ; then |
| 155 | install -d ${D}${sysconfdir} |
| 156 | install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config |
| 157 | fi |
| 158 | |
| 159 | if [ "x${SPL_BINARY}" != "x" ] |
| 160 | then |
| 161 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 162 | then |
| 163 | for config in ${UBOOT_MACHINE}; do |
| 164 | i=`expr $i + 1`; |
| 165 | for type in ${UBOOT_CONFIG}; do |
| 166 | j=`expr $j + 1`; |
| 167 | if [ $j -eq $i ] |
| 168 | then |
| 169 | install ${S}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 170 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}-${type} |
| 171 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 172 | fi |
| 173 | done |
| 174 | unset j |
| 175 | done |
| 176 | unset i |
| 177 | else |
| 178 | install ${S}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 179 | ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYNAME} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | fi |
| 181 | fi |
| 182 | |
| 183 | if [ "x${UBOOT_ENV}" != "x" ] |
| 184 | then |
| 185 | install ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE} |
| 186 | ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY} |
| 187 | fi |
| 188 | } |
| 189 | |
| 190 | FILES_${PN} = "/boot ${sysconfdir}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 | |
| 192 | do_deploy () { |
| 193 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 194 | then |
| 195 | for config in ${UBOOT_MACHINE}; do |
| 196 | i=`expr $i + 1`; |
| 197 | for type in ${UBOOT_CONFIG}; do |
| 198 | j=`expr $j + 1`; |
| 199 | if [ $j -eq $i ] |
| 200 | then |
| 201 | install -d ${DEPLOYDIR} |
| 202 | install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} |
| 203 | cd ${DEPLOYDIR} |
| 204 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type} |
| 205 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK} |
| 206 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type} |
| 207 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY} |
| 208 | fi |
| 209 | done |
| 210 | unset j |
| 211 | done |
| 212 | unset i |
| 213 | else |
| 214 | install -d ${DEPLOYDIR} |
| 215 | install ${S}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE} |
| 216 | cd ${DEPLOYDIR} |
| 217 | rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK} |
| 218 | ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK} |
| 219 | ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY} |
| 220 | fi |
| 221 | |
| 222 | if [ "x${UBOOT_ELF}" != "x" ] |
| 223 | then |
| 224 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 225 | then |
| 226 | for config in ${UBOOT_MACHINE}; do |
| 227 | i=`expr $i + 1`; |
| 228 | for type in ${UBOOT_CONFIG}; do |
| 229 | j=`expr $j + 1`; |
| 230 | if [ $j -eq $i ] |
| 231 | then |
| 232 | install ${S}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} |
| 233 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type} |
| 234 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY} |
| 235 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type} |
| 236 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK} |
| 237 | fi |
| 238 | done |
| 239 | unset j |
| 240 | done |
| 241 | unset i |
| 242 | else |
| 243 | install ${S}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE} |
| 244 | ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY} |
| 245 | ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK} |
| 246 | fi |
| 247 | fi |
| 248 | |
| 249 | |
| 250 | if [ "x${SPL_BINARY}" != "x" ] |
| 251 | then |
| 252 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 253 | then |
| 254 | for config in ${UBOOT_MACHINE}; do |
| 255 | i=`expr $i + 1`; |
| 256 | for type in ${UBOOT_CONFIG}; do |
| 257 | j=`expr $j + 1`; |
| 258 | if [ $j -eq $i ] |
| 259 | then |
| 260 | install ${S}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 261 | rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} |
| 262 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type} |
| 263 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 264 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} |
| 265 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 266 | fi |
| 267 | done |
| 268 | unset j |
| 269 | done |
| 270 | unset i |
| 271 | else |
| 272 | install ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 273 | rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 274 | ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 275 | ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 276 | fi |
| 277 | fi |
| 278 | |
| 279 | |
| 280 | if [ "x${UBOOT_ENV}" != "x" ] |
| 281 | then |
| 282 | install ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE} |
| 283 | rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} |
| 284 | ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY} |
| 285 | ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} |
| 286 | fi |
| 287 | } |
| 288 | |
| 289 | addtask deploy before do_build after do_compile |