Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame^] | 1 | SUMMARY = "SCP and MCP Firmware" |
| 2 | DESCRIPTION = "Firmware for SCP and MCP software reference implementation" |
| 3 | HOMEPAGE = "https://github.com/ARM-software/SCP-firmware" |
| 4 | |
| 5 | LICENSE = "BSD-3-Clause & Apache-2.0" |
| 6 | LIC_FILES_CHKSUM = "file://license.md;beginline=5;md5=9db9e3d2fb8d9300a6c3d15101b19731 \ |
| 7 | file://contrib/cmsis/git/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" |
| 8 | |
| 9 | SRC_URI = "gitsm://github.com/ARM-software/SCP-firmware.git;protocol=https;branch=master" |
| 10 | |
| 11 | SRCREV = "673d014f3861ad81cc5ab06d2884a314a610799b" |
| 12 | |
| 13 | PROVIDES += "virtual/control-processor-firmware" |
| 14 | |
| 15 | SCP_BUILD_RELEASE ?= "1" |
| 16 | SCP_PLATFORM ?= "invalid" |
| 17 | SCP_COMPILER ?= "arm-none-eabi" |
| 18 | SCP_LOG_LEVEL ?= "WARN" |
| 19 | SCP_PLATFORM_FEATURE_SET ?= "0" |
| 20 | |
| 21 | INHIBIT_DEFAULT_DEPS = "1" |
| 22 | DEPENDS = "virtual/arm-none-eabi-gcc-native \ |
| 23 | cmake-native \ |
| 24 | ninja-native \ |
| 25 | " |
| 26 | |
| 27 | # For now we only build with GCC, so stop meta-clang trying to get involved |
| 28 | TOOLCHAIN = "gcc" |
| 29 | |
| 30 | SCP_BUILD_STR = "${@bb.utils.contains('SCP_BUILD_RELEASE', '1', 'release', 'debug', d)}" |
| 31 | |
| 32 | inherit deploy |
| 33 | |
| 34 | B = "${WORKDIR}/build" |
| 35 | S = "${WORKDIR}/git" |
| 36 | |
| 37 | # Allow platform specific copying of only scp or both scp & mcp, default to both |
| 38 | FW_TARGETS ?= "scp mcp" |
| 39 | FW_INSTALL ?= "ramfw romfw" |
| 40 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 41 | COMPATIBLE_MACHINE ?= "invalid" |
| 42 | |
| 43 | LDFLAGS[unexport] = "1" |
| 44 | CFLAGS[unexport] = "1" |
| 45 | |
| 46 | EXTRA_OECMAKE = "-D CMAKE_BUILD_TYPE=${SCP_BUILD_STR} \ |
| 47 | -D SCP_LOG_LEVEL=${SCP_LOG_LEVEL} \ |
| 48 | -D SCP_PLATFORM_FEATURE_SET=${SCP_PLATFORM_FEATURE_SET} \ |
| 49 | " |
| 50 | |
| 51 | do_configure() { |
| 52 | for FW in ${FW_TARGETS}; do |
| 53 | for TYPE in ${FW_INSTALL}; do |
| 54 | cmake -GNinja ${EXTRA_OECMAKE} -S ${S} -B "${B}/${TYPE}/${FW}" -D SCP_FIRMWARE_SOURCE_DIR="${SCP_PLATFORM}/${FW}_${TYPE}" |
| 55 | done |
| 56 | done |
| 57 | } |
| 58 | |
| 59 | do_configure[cleandirs] += "${B}" |
| 60 | |
| 61 | do_compile() { |
| 62 | for FW in ${FW_TARGETS}; do |
| 63 | for TYPE in ${FW_INSTALL}; do |
| 64 | cmake --build ${B}/${TYPE}/${FW} --target all |
| 65 | done |
| 66 | done |
| 67 | } |
| 68 | |
| 69 | do_install() { |
| 70 | install -d ${D}/firmware |
| 71 | for TYPE in ${FW_INSTALL}; do |
| 72 | for FW in ${FW_TARGETS}; do |
| 73 | if [ "$TYPE" = "romfw" ]; then |
| 74 | if [ "$FW" = "scp" ]; then |
| 75 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl1.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
| 76 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl1" "${D}/firmware/${FW}_${TYPE}.elf" |
| 77 | elif [ "$FW" = "mcp" ]; then |
| 78 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-mcp-bl1.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
| 79 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-mcp-bl1" "${D}/firmware/${FW}_${TYPE}.elf" |
| 80 | fi |
| 81 | elif [ "$TYPE" = "ramfw" ]; then |
| 82 | if [ "$FW" = "scp" ]; then |
| 83 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl2.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
| 84 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl2" "${D}/firmware/${FW}_${TYPE}.elf" |
| 85 | elif [ "$FW" = "mcp" ]; then |
| 86 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-mcp-bl2.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
| 87 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-mcp-bl2" "${D}/firmware/${FW}_${TYPE}.elf" |
| 88 | fi |
| 89 | fi |
| 90 | done |
| 91 | done |
| 92 | } |
| 93 | |
| 94 | FILES:${PN} = "/firmware" |
| 95 | SYSROOT_DIRS += "/firmware" |
| 96 | |
| 97 | FILES:${PN}-dbg += "/firmware/*.elf" |
| 98 | # Skip QA check for relocations in .text of elf binaries |
| 99 | INSANE_SKIP:${PN}-dbg = "arch textrel" |
| 100 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" |
| 101 | INHIBIT_PACKAGE_STRIP = "1" |
| 102 | |
| 103 | do_deploy() { |
| 104 | # Copy the images to deploy directory |
| 105 | cp -rf ${D}/firmware/* ${DEPLOYDIR}/ |
| 106 | } |
| 107 | addtask deploy after do_install |