Andrew Geissler | ee5626e | 2020-04-29 10:53:34 -0500 | [diff] [blame] | 1 | SUMMARY = "Universal Boot Loader for embedded devices" |
| 2 | PROVIDES = "virtual/bootloader" |
| 3 | |
| 4 | B = "${WORKDIR}/build" |
| 5 | |
| 6 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 7 | |
| 8 | DEPENDS += "kern-tools-native" |
| 9 | |
Andrew Geissler | 6dc303a | 2020-04-29 11:11:19 -0500 | [diff] [blame] | 10 | inherit uboot-config uboot-extlinux-config uboot-sign deploy cml1 python3native |
Andrew Geissler | ee5626e | 2020-04-29 10:53:34 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | 6dc303a | 2020-04-29 11:11:19 -0500 | [diff] [blame] | 12 | DEPENDS += "swig-native" |
Andrew Geissler | ee5626e | 2020-04-29 10:53:34 -0500 | [diff] [blame] | 13 | |
| 14 | EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1' |
| 15 | EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"' |
Andrew Geissler | 6dc303a | 2020-04-29 11:11:19 -0500 | [diff] [blame] | 16 | EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}' |
Andrew Geissler | ee5626e | 2020-04-29 10:53:34 -0500 | [diff] [blame] | 17 | |
| 18 | PACKAGECONFIG ??= "openssl" |
| 19 | # u-boot will compile its own tools during the build, with specific |
| 20 | # configurations (aka when CONFIG_FIT_SIGNATURE is enabled) openssl is needed as |
| 21 | # a host build dependency. |
| 22 | PACKAGECONFIG[openssl] = ",,openssl-native" |
| 23 | |
| 24 | # Allow setting an additional version string that will be picked up by the |
| 25 | # u-boot build system and appended to the u-boot version. If the .scmversion |
| 26 | # file already exists it will not be overwritten. |
| 27 | UBOOT_LOCALVERSION ?= "" |
| 28 | |
Andrew Geissler | ee5626e | 2020-04-29 10:53:34 -0500 | [diff] [blame] | 29 | # returns all the elements from the src uri that are .cfg files |
| 30 | def find_cfgs(d): |
| 31 | sources=src_patches(d, True) |
| 32 | sources_list=[] |
| 33 | for s in sources: |
| 34 | if s.endswith('.cfg'): |
| 35 | sources_list.append(s) |
| 36 | |
| 37 | return sources_list |
| 38 | |
| 39 | do_configure () { |
| 40 | if [ -z "${UBOOT_CONFIG}" ]; then |
| 41 | if [ -n "${UBOOT_MACHINE}" ]; then |
| 42 | oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE} |
| 43 | else |
| 44 | oe_runmake -C ${S} O=${B} oldconfig |
| 45 | fi |
| 46 | merge_config.sh -m .config ${@" ".join(find_cfgs(d))} |
| 47 | cml1_do_configure |
| 48 | fi |
| 49 | } |
| 50 | |
| 51 | do_compile () { |
| 52 | if [ "${@bb.utils.filter('DISTRO_FEATURES', 'ld-is-gold', d)}" ]; then |
| 53 | sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/config.mk |
| 54 | fi |
| 55 | |
| 56 | unset LDFLAGS |
| 57 | unset CFLAGS |
| 58 | unset CPPFLAGS |
| 59 | |
| 60 | if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ] |
| 61 | then |
| 62 | echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion |
| 63 | echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion |
| 64 | fi |
| 65 | |
| 66 | if [ -n "${UBOOT_CONFIG}" ] |
| 67 | then |
| 68 | unset i j k |
| 69 | for config in ${UBOOT_MACHINE}; do |
| 70 | i=$(expr $i + 1); |
| 71 | for type in ${UBOOT_CONFIG}; do |
| 72 | j=$(expr $j + 1); |
| 73 | if [ $j -eq $i ] |
| 74 | then |
| 75 | oe_runmake -C ${S} O=${B}/${config} ${config} |
| 76 | oe_runmake -C ${S} O=${B}/${config} ${UBOOT_MAKE_TARGET} |
| 77 | for binary in ${UBOOT_BINARIES}; do |
| 78 | k=$(expr $k + 1); |
| 79 | if [ $k -eq $i ]; then |
| 80 | cp ${B}/${config}/${binary} ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} |
| 81 | fi |
| 82 | done |
| 83 | unset k |
| 84 | fi |
| 85 | done |
| 86 | unset j |
| 87 | done |
| 88 | unset i |
| 89 | else |
| 90 | oe_runmake -C ${S} O=${B} ${UBOOT_MAKE_TARGET} |
| 91 | fi |
| 92 | |
| 93 | } |
| 94 | |
| 95 | do_install () { |
| 96 | if [ -n "${UBOOT_CONFIG}" ] |
| 97 | then |
| 98 | for config in ${UBOOT_MACHINE}; do |
| 99 | i=$(expr $i + 1); |
| 100 | for type in ${UBOOT_CONFIG}; do |
| 101 | j=$(expr $j + 1); |
| 102 | if [ $j -eq $i ] |
| 103 | then |
| 104 | install -d ${D}/boot |
| 105 | install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} |
| 106 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} |
| 107 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY} |
| 108 | fi |
| 109 | done |
| 110 | unset j |
| 111 | done |
| 112 | unset i |
| 113 | else |
| 114 | install -d ${D}/boot |
| 115 | install -m 644 ${B}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE} |
| 116 | ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY} |
| 117 | fi |
| 118 | |
| 119 | if [ -n "${UBOOT_ELF}" ] |
| 120 | then |
| 121 | if [ -n "${UBOOT_CONFIG}" ] |
| 122 | then |
| 123 | for config in ${UBOOT_MACHINE}; do |
| 124 | i=$(expr $i + 1); |
| 125 | for type in ${UBOOT_CONFIG}; do |
| 126 | j=$(expr $j + 1); |
| 127 | if [ $j -eq $i ] |
| 128 | then |
| 129 | install -m 644 ${B}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} |
| 130 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} |
| 131 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY} |
| 132 | fi |
| 133 | done |
| 134 | unset j |
| 135 | done |
| 136 | unset i |
| 137 | else |
| 138 | install -m 644 ${B}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE} |
| 139 | ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY} |
| 140 | fi |
| 141 | fi |
| 142 | |
| 143 | if [ -e ${WORKDIR}/fw_env.config ] ; then |
| 144 | install -d ${D}${sysconfdir} |
| 145 | install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config |
| 146 | fi |
| 147 | |
| 148 | if [ -n "${SPL_BINARY}" ] |
| 149 | then |
| 150 | if [ -n "${UBOOT_CONFIG}" ] |
| 151 | then |
| 152 | for config in ${UBOOT_MACHINE}; do |
| 153 | i=$(expr $i + 1); |
| 154 | for type in ${UBOOT_CONFIG}; do |
| 155 | j=$(expr $j + 1); |
| 156 | if [ $j -eq $i ] |
| 157 | then |
| 158 | install -m 644 ${B}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR} |
| 159 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}-${type} |
| 160 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME} |
| 161 | fi |
| 162 | done |
| 163 | unset j |
| 164 | done |
| 165 | unset i |
| 166 | else |
| 167 | install -m 644 ${B}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE} |
| 168 | ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYNAME} |
| 169 | fi |
| 170 | fi |
| 171 | |
| 172 | if [ -n "${UBOOT_ENV}" ] |
| 173 | then |
| 174 | install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE} |
| 175 | ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY} |
| 176 | fi |
| 177 | |
| 178 | if [ "${UBOOT_EXTLINUX}" = "1" ] |
| 179 | then |
| 180 | install -Dm 0644 ${UBOOT_EXTLINUX_CONFIG} ${D}/${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME} |
| 181 | fi |
| 182 | |
| 183 | } |
| 184 | |
Andrei Kartashev | b60b7b1 | 2021-07-29 09:01:35 +0300 | [diff] [blame] | 185 | PACKAGE_BEFORE_PN += "${PN}-env" |
| 186 | |
| 187 | RPROVIDES:${PN}-env += "u-boot-default-env" |
Patrick Williams | b9799be | 2021-08-06 09:13:33 -0500 | [diff] [blame] | 188 | FILES:${PN} = "/boot ${sysconfdir} ${datadir}" |
Andrei Kartashev | b60b7b1 | 2021-07-29 09:01:35 +0300 | [diff] [blame] | 189 | RDEPENDS:${PN} += "${PN}-env" |
Andrew Geissler | ee5626e | 2020-04-29 10:53:34 -0500 | [diff] [blame] | 190 | |
| 191 | do_deploy () { |
| 192 | if [ -n "${UBOOT_CONFIG}" ] |
| 193 | then |
| 194 | for config in ${UBOOT_MACHINE}; do |
| 195 | i=$(expr $i + 1); |
| 196 | for type in ${UBOOT_CONFIG}; do |
| 197 | j=$(expr $j + 1); |
| 198 | if [ $j -eq $i ] |
| 199 | then |
| 200 | install -d ${DEPLOYDIR} |
| 201 | install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} |
| 202 | cd ${DEPLOYDIR} |
| 203 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type} |
| 204 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK} |
| 205 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type} |
| 206 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY} |
| 207 | fi |
| 208 | done |
| 209 | unset j |
| 210 | done |
| 211 | unset i |
| 212 | else |
| 213 | install -d ${DEPLOYDIR} |
| 214 | install -m 644 ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE} |
| 215 | cd ${DEPLOYDIR} |
| 216 | rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK} |
| 217 | ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK} |
| 218 | ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY} |
| 219 | fi |
| 220 | |
| 221 | if [ -n "${UBOOT_ELF}" ] |
| 222 | then |
| 223 | if [ -n "${UBOOT_CONFIG}" ] |
| 224 | then |
| 225 | for config in ${UBOOT_MACHINE}; do |
| 226 | i=$(expr $i + 1); |
| 227 | for type in ${UBOOT_CONFIG}; do |
| 228 | j=$(expr $j + 1); |
| 229 | if [ $j -eq $i ] |
| 230 | then |
| 231 | install -m 644 ${B}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} |
| 232 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type} |
| 233 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY} |
| 234 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type} |
| 235 | ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK} |
| 236 | fi |
| 237 | done |
| 238 | unset j |
| 239 | done |
| 240 | unset i |
| 241 | else |
| 242 | install -m 644 ${B}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE} |
| 243 | ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY} |
| 244 | ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK} |
| 245 | fi |
| 246 | fi |
| 247 | |
| 248 | |
| 249 | if [ -n "${SPL_BINARY}" ] |
| 250 | then |
| 251 | if [ -n "${UBOOT_CONFIG}" ] |
| 252 | then |
| 253 | for config in ${UBOOT_MACHINE}; do |
| 254 | i=$(expr $i + 1); |
| 255 | for type in ${UBOOT_CONFIG}; do |
| 256 | j=$(expr $j + 1); |
| 257 | if [ $j -eq $i ] |
| 258 | then |
| 259 | install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR} |
| 260 | rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} |
| 261 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type} |
| 262 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME} |
| 263 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} |
| 264 | ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 265 | fi |
| 266 | done |
| 267 | unset j |
| 268 | done |
| 269 | unset i |
| 270 | else |
| 271 | install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE} |
| 272 | rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 273 | ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME} |
| 274 | ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK} |
| 275 | fi |
| 276 | fi |
| 277 | |
| 278 | |
| 279 | if [ -n "${UBOOT_ENV}" ] |
| 280 | then |
| 281 | install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE} |
| 282 | rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} |
| 283 | ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY} |
| 284 | ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} |
| 285 | fi |
| 286 | |
| 287 | if [ "${UBOOT_EXTLINUX}" = "1" ] |
| 288 | then |
| 289 | install -m 644 ${UBOOT_EXTLINUX_CONFIG} ${DEPLOYDIR}/${UBOOT_EXTLINUX_SYMLINK} |
| 290 | ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE} |
| 291 | ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME} |
| 292 | fi |
| 293 | } |
| 294 | |
| 295 | addtask deploy before do_build after do_compile |