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+" |
| 7 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=0507cd7da8e7ad6d6701926ec9b84c95" |
| 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 ?= "" |
| 53 | SPL_IMAGE ?= "${SPL_BINARY}-${MACHINE}-${PV}-${PR}" |
| 54 | SPL_SYMLINK ?= "${SPL_BINARY}-${MACHINE}" |
| 55 | |
| 56 | # Additional environment variables or a script can be installed alongside |
| 57 | # u-boot to be used automatically on boot. This file, typically 'uEnv.txt' |
| 58 | # or 'boot.scr', should be packaged along with u-boot as well as placed in the |
| 59 | # deploy directory. Machine configurations needing one of these files should |
| 60 | # include it in the SRC_URI and set the UBOOT_ENV parameter. |
| 61 | UBOOT_ENV_SUFFIX ?= "txt" |
| 62 | UBOOT_ENV ?= "" |
| 63 | UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}" |
| 64 | UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}" |
| 65 | UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}" |
| 66 | |
| 67 | do_compile () { |
| 68 | if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then |
| 69 | sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' config.mk |
| 70 | fi |
| 71 | |
| 72 | unset LDFLAGS |
| 73 | unset CFLAGS |
| 74 | unset CPPFLAGS |
| 75 | |
| 76 | if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ] |
| 77 | then |
| 78 | echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion |
| 79 | echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion |
| 80 | fi |
| 81 | |
| 82 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 83 | then |
| 84 | for config in ${UBOOT_MACHINE}; do |
| 85 | i=`expr $i + 1`; |
| 86 | for type in ${UBOOT_CONFIG}; do |
| 87 | j=`expr $j + 1`; |
| 88 | if [ $j -eq $i ] |
| 89 | then |
| 90 | oe_runmake O=${config} ${config} |
| 91 | oe_runmake O=${config} ${UBOOT_MAKE_TARGET} |
| 92 | cp ${S}/${config}/${UBOOT_BINARY} ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} |
| 93 | fi |
| 94 | done |
| 95 | unset j |
| 96 | done |
| 97 | unset i |
| 98 | else |
| 99 | oe_runmake ${UBOOT_MACHINE} |
| 100 | oe_runmake ${UBOOT_MAKE_TARGET} |
| 101 | fi |
| 102 | |
| 103 | } |
| 104 | |
| 105 | do_install () { |
| 106 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 107 | then |
| 108 | for config in ${UBOOT_MACHINE}; do |
| 109 | i=`expr $i + 1`; |
| 110 | for type in ${UBOOT_CONFIG}; do |
| 111 | j=`expr $j + 1`; |
| 112 | if [ $j -eq $i ] |
| 113 | then |
| 114 | install -d ${D}/boot |
| 115 | install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} |
| 116 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} |
| 117 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY} |
| 118 | fi |
| 119 | done |
| 120 | unset j |
| 121 | done |
| 122 | unset i |
| 123 | else |
| 124 | install -d ${D}/boot |
| 125 | install ${S}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE} |
| 126 | ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY} |
| 127 | fi |
| 128 | |
| 129 | if [ "x${UBOOT_ELF}" != "x" ] |
| 130 | then |
| 131 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 132 | then |
| 133 | for config in ${UBOOT_MACHINE}; do |
| 134 | i=`expr $i + 1`; |
| 135 | for type in ${UBOOT_CONFIG}; do |
| 136 | j=`expr $j + 1`; |
| 137 | if [ $j -eq $i ] |
| 138 | then |
| 139 | install ${S}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} |
| 140 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} |
| 141 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY} |
| 142 | fi |
| 143 | done |
| 144 | unset j |
| 145 | done |
| 146 | unset i |
| 147 | else |
| 148 | install ${S}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE} |
| 149 | ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY} |
| 150 | fi |
| 151 | fi |
| 152 | |
| 153 | if [ -e ${WORKDIR}/fw_env.config ] ; then |
| 154 | install -d ${D}${sysconfdir} |
| 155 | install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config |
| 156 | fi |
| 157 | |
| 158 | if [ "x${SPL_BINARY}" != "x" ] |
| 159 | then |
| 160 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 161 | then |
| 162 | for config in ${UBOOT_MACHINE}; do |
| 163 | i=`expr $i + 1`; |
| 164 | for type in ${UBOOT_CONFIG}; do |
| 165 | j=`expr $j + 1`; |
| 166 | if [ $j -eq $i ] |
| 167 | then |
| 168 | install ${S}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR} |
| 169 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARY}-${type} |
| 170 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARY} |
| 171 | fi |
| 172 | done |
| 173 | unset j |
| 174 | done |
| 175 | unset i |
| 176 | else |
| 177 | install ${S}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE} |
| 178 | ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARY} |
| 179 | fi |
| 180 | fi |
| 181 | |
| 182 | if [ "x${UBOOT_ENV}" != "x" ] |
| 183 | then |
| 184 | install ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE} |
| 185 | ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY} |
| 186 | fi |
| 187 | } |
| 188 | |
| 189 | FILES_${PN} = "/boot ${sysconfdir}" |
| 190 | # Ensure the split debug part of any elf files are put into dbg |
| 191 | FILES_${PN}-dbg += "/boot/.debug" |
| 192 | |
| 193 | do_deploy () { |
| 194 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 195 | then |
| 196 | for config in ${UBOOT_MACHINE}; do |
| 197 | i=`expr $i + 1`; |
| 198 | for type in ${UBOOT_CONFIG}; do |
| 199 | j=`expr $j + 1`; |
| 200 | if [ $j -eq $i ] |
| 201 | then |
| 202 | install -d ${DEPLOYDIR} |
| 203 | install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} |
| 204 | cd ${DEPLOYDIR} |
| 205 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type} |
| 206 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK} |
| 207 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type} |
| 208 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY} |
| 209 | fi |
| 210 | done |
| 211 | unset j |
| 212 | done |
| 213 | unset i |
| 214 | else |
| 215 | install -d ${DEPLOYDIR} |
| 216 | install ${S}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE} |
| 217 | cd ${DEPLOYDIR} |
| 218 | rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK} |
| 219 | ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK} |
| 220 | ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY} |
| 221 | fi |
| 222 | |
| 223 | if [ "x${UBOOT_ELF}" != "x" ] |
| 224 | then |
| 225 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 226 | then |
| 227 | for config in ${UBOOT_MACHINE}; do |
| 228 | i=`expr $i + 1`; |
| 229 | for type in ${UBOOT_CONFIG}; do |
| 230 | j=`expr $j + 1`; |
| 231 | if [ $j -eq $i ] |
| 232 | then |
| 233 | install ${S}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} |
| 234 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type} |
| 235 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY} |
| 236 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type} |
| 237 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK} |
| 238 | fi |
| 239 | done |
| 240 | unset j |
| 241 | done |
| 242 | unset i |
| 243 | else |
| 244 | install ${S}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE} |
| 245 | ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY} |
| 246 | ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK} |
| 247 | fi |
| 248 | fi |
| 249 | |
| 250 | |
| 251 | if [ "x${SPL_BINARY}" != "x" ] |
| 252 | then |
| 253 | if [ "x${UBOOT_CONFIG}" != "x" ] |
| 254 | then |
| 255 | for config in ${UBOOT_MACHINE}; do |
| 256 | i=`expr $i + 1`; |
| 257 | for type in ${UBOOT_CONFIG}; do |
| 258 | j=`expr $j + 1`; |
| 259 | if [ $j -eq $i ] |
| 260 | then |
| 261 | install ${S}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR} |
| 262 | rm -f ${DEPLOYDIR}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} |
| 263 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARY}-${type} |
| 264 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARY} |
| 265 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} |
| 266 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 267 | fi |
| 268 | done |
| 269 | unset j |
| 270 | done |
| 271 | unset i |
| 272 | else |
| 273 | install ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE} |
| 274 | rm -f ${DEPLOYDIR}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 275 | ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARY} |
| 276 | ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 277 | fi |
| 278 | fi |
| 279 | |
| 280 | |
| 281 | if [ "x${UBOOT_ENV}" != "x" ] |
| 282 | then |
| 283 | install ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE} |
| 284 | rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} |
| 285 | ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY} |
| 286 | ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} |
| 287 | fi |
| 288 | } |
| 289 | |
| 290 | addtask deploy before do_build after do_compile |