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 | |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame] | 9 | SRC_URI_SCP_FIRMWARE ?= "gitsm://github.com/ARM-software/SCP-firmware.git;protocol=https" |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame^] | 10 | SRC_URI = "${SRC_URI_SCP_FIRMWARE};branch=${SRCBRANCH} \ |
| 11 | file://optee-private-includes.patch" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 12 | |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame^] | 13 | SRCBRANCH = "master" |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 14 | SRCREV = "0c7236b1851d90124210a0414fd982dc55322c7c" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 15 | |
| 16 | PROVIDES += "virtual/control-processor-firmware" |
| 17 | |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 18 | CMAKE_BUILD_TYPE ?= "RelWithDebInfo" |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame^] | 19 | SCP_PLATFORM ?= "${MACHINE}" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 20 | SCP_LOG_LEVEL ?= "WARN" |
| 21 | SCP_PLATFORM_FEATURE_SET ?= "0" |
| 22 | |
| 23 | INHIBIT_DEFAULT_DEPS = "1" |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 24 | DEPENDS = "gcc-arm-none-eabi-native \ |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 25 | cmake-native \ |
| 26 | ninja-native \ |
| 27 | " |
| 28 | |
| 29 | # For now we only build with GCC, so stop meta-clang trying to get involved |
| 30 | TOOLCHAIN = "gcc" |
| 31 | |
Patrick Williams | b542dec | 2023-06-09 01:26:37 -0500 | [diff] [blame] | 32 | # remove once arm-none-eabi-gcc updates to 13 or newer like poky |
| 33 | DEBUG_PREFIX_MAP:remove = "-fcanon-prefix-map" |
| 34 | |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 35 | inherit deploy |
| 36 | |
| 37 | B = "${WORKDIR}/build" |
| 38 | S = "${WORKDIR}/git" |
| 39 | |
| 40 | # Allow platform specific copying of only scp or both scp & mcp, default to both |
| 41 | FW_TARGETS ?= "scp mcp" |
| 42 | FW_INSTALL ?= "ramfw romfw" |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 43 | |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 44 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 45 | COMPATIBLE_MACHINE ?= "invalid" |
| 46 | |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 47 | export CFLAGS = "${DEBUG_PREFIX_MAP}" |
| 48 | export ASMFLAGS = "${DEBUG_PREFIX_MAP}" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 49 | |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 50 | LDFLAGS[unexport] = "1" |
| 51 | |
| 52 | EXTRA_OECMAKE = "-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 53 | -D SCP_LOG_LEVEL=${SCP_LOG_LEVEL} \ |
| 54 | -D SCP_PLATFORM_FEATURE_SET=${SCP_PLATFORM_FEATURE_SET} \ |
Andrew Geissler | ea144b03 | 2023-01-27 16:03:57 -0600 | [diff] [blame] | 55 | -D DISABLE_CPPCHECK=1 \ |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame^] | 56 | -D SCP_TOOLCHAIN=GNU \ |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 57 | " |
| 58 | |
| 59 | do_configure() { |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 60 | for FW in ${FW_TARGETS}; do |
| 61 | for TYPE in ${FW_INSTALL}; do |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame^] | 62 | bbnote Configuring ${SCP_PLATFORM}/${FW}_${TYPE}... |
| 63 | cmake -GNinja ${EXTRA_OECMAKE} -S ${S} -B "${B}/${TYPE}/${FW}" -D SCP_FIRMWARE_SOURCE_DIR:PATH="${SCP_PLATFORM}/${FW}_${TYPE}" |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 64 | done |
| 65 | done |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | do_configure[cleandirs] += "${B}" |
| 69 | |
| 70 | do_compile() { |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 71 | for FW in ${FW_TARGETS}; do |
| 72 | for TYPE in ${FW_INSTALL}; do |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame^] | 73 | bbnote Building ${SCP_PLATFORM}/${FW}_${TYPE}... |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 74 | VERBOSE=1 cmake --build ${B}/${TYPE}/${FW} --target all |
| 75 | done |
| 76 | done |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | do_install() { |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 80 | install -d ${D}/firmware |
| 81 | for TYPE in ${FW_INSTALL}; do |
| 82 | for FW in ${FW_TARGETS}; do |
| 83 | if [ "$TYPE" = "romfw" ]; then |
| 84 | if [ "$FW" = "scp" ]; then |
| 85 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl1.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame] | 86 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl1.elf" "${D}/firmware/${FW}_${TYPE}.elf" |
| 87 | else |
| 88 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-${FW}-bl1.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
| 89 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-${FW}-bl1.elf" "${D}/firmware/${FW}_${TYPE}.elf" |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 90 | fi |
| 91 | elif [ "$TYPE" = "ramfw" ]; then |
| 92 | if [ "$FW" = "scp" ]; then |
| 93 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl2.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame] | 94 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-bl2.elf" "${D}/firmware/${FW}_${TYPE}.elf" |
| 95 | else |
| 96 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-${FW}-bl2.bin" "${D}/firmware/${FW}_${TYPE}.bin" |
| 97 | install -D "${B}/${TYPE}/${FW}/bin/${SCP_PLATFORM}-${FW}-bl2.elf" "${D}/firmware/${FW}_${TYPE}.elf" |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 98 | fi |
| 99 | fi |
| 100 | done |
| 101 | done |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | FILES:${PN} = "/firmware" |
| 105 | SYSROOT_DIRS += "/firmware" |
| 106 | |
| 107 | FILES:${PN}-dbg += "/firmware/*.elf" |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 108 | # These binaries are specifically for 32-bit arm |
| 109 | INSANE_SKIP:${PN}-dbg += "arch" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 110 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" |
| 111 | INHIBIT_PACKAGE_STRIP = "1" |
| 112 | |
| 113 | do_deploy() { |
| 114 | # Copy the images to deploy directory |
| 115 | cp -rf ${D}/firmware/* ${DEPLOYDIR}/ |
| 116 | } |
| 117 | addtask deploy after do_install |