1SUMMARY = "Nuvoton NPCM8XX bootloader"
2DESCRIPTION = "This is front end recipe for NPCM8XX IGPS. It replace \
3original IGPS recipe which need implement many redundant function in \
4recipe or class. After we add some hook in IGPS, now we can generate \
5full bootbloader by IGPS script. We only need collect all built images \
6from deploy folder, put them to IGPS input folder, and run script."
7HOMEPAGE = "https://github.com/Nuvoton-Israel/igps-npcm8xx"
8LICENSE = "GPL-2.0-only"
9LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"
10
11IGPS_BRANCH ?= "main"
12SRC_URI = " \
13    git://github.com/Nuvoton-Israel/igps-npcm8xx;branch=${IGPS_BRANCH};protocol=https \
14"
15SRCREV = "de9ca8d9ab84b8b9ad519449f0a85feff30eaff0"
16
17S = "${WORKDIR}/git"
18
19DEPENDS = "npcm7xx-bingo-native openssl-native"
20inherit obmc-phosphor-utils
21inherit python3native deploy
22FILE_FMT = "file://{}"
23
24# Sign keys, replace them for production
25IGPS_KEYS = ""
26# Configuration files, clean them if no need
27IGPS_CSVS = ""
28IGPS_SETTINGS = "settings.json"
29IGPS_CONFS = "${IGPS_KEYS} ${IGPS_CSVS} ${IGPS_SETTINGS}"
30SRC_URI += "${@compose_list(d, 'FILE_FMT', 'IGPS_CONFS')}"
31
32IGPS_SCRIPT_BASE = "${S}/py_scripts/ImageGeneration"
33BB_BIN = "arbel_a35_bootblock"
34BB_BIN .= "${@'_no_tip.bin' if d.getVar("TIP_IMAGE") != 'True' else '.bin'}"
35
36do_configure[dirs] = "${WORKDIR}"
37do_configure() {
38    KEY_FOLDER=${IGPS_SCRIPT_BASE}/keys/openssl
39    CSV_FOLDER=${IGPS_SCRIPT_BASE}/inputs/registers
40    # keys
41    install -d ${KEY_FOLDER}
42    if [ -n "${IGPS_KEYS}" ];then
43        cp -v ${IGPS_KEYS} ${KEY_FOLDER}
44    fi
45
46    # csv files
47    install -d ${CSV_FOLDER}
48    if [ -n "${IGPS_CSVS}" ];then
49        cp -v ${IGPS_CSVS} ${CSV_FOLDER}
50    fi
51
52    # change customized settings for XML and key setting
53    if [ -n "${IGPS_SETTINGS}" ];then
54        cd ${S}
55        python3 ${IGPS_SCRIPT_BASE}/config_replacer.py ${WORKDIR}/${IGPS_SETTINGS}
56    fi
57}
58
59do_compile[depends] += " \
60    npcm8xx-tip-fw:do_deploy npcm8xx-bootblock:do_deploy \
61    trusted-firmware-a:do_deploy optee-os:do_deploy \
62    u-boot-nuvoton:do_deploy"
63do_compile() {
64    # copy Openbmc built images
65    cd ${DEPLOY_DIR_IMAGE}
66    cp -v ${BB_BIN} bl31.bin tee.bin u-boot.bin ${IGPS_SCRIPT_BASE}/inputs
67
68    cd ${IGPS_SCRIPT_BASE}
69    install -d output_binaries/tmp
70    install -d inputs/key_input
71    if [ "${TIP_IMAGE}" = "True" ] || [ "${SA_TIP_IMAGE}" = "True" ];then
72      # Do not sign combo0 image again
73      python3 ${S}/py_scripts/GenerateAll.py openssl ${DEPLOY_DIR_IMAGE}
74    else
75      # for No TIP, we can run IGPS script directly
76      python3 ${S}/py_scripts/GenerateAll.py openssl
77    fi
78}
79
80do_deploy() {
81    OUT=${IGPS_SCRIPT_BASE}/output_binaries
82    BOOTLOADER=u-boot.bin.merged
83    install -d ${DEPLOYDIR}
84    if [ "${SA_TIP_IMAGE}" = "True" ];then
85        install -m 644 ${OUT}/Secure/image_no_tip_SA.bin ${DEPLOYDIR}/${BOOTLOADER}
86    elif [ "${TIP_IMAGE}" = "True" ];then
87        install -m 644 ${OUT}/Secure/Kmt_TipFwL0_Skmt_TipFwL1_BootBlock_BL31_Tee_uboot.bin ${DEPLOYDIR}/${BOOTLOADER}
88    else
89        install -m 644 ${OUT}/Basic/image_no_tip.bin ${DEPLOYDIR}/${BOOTLOADER}
90    fi
91}
92addtask deploy before do_build after do_compile
93PACKAGE_ARCH = "${MACHINE_ARCH}"
94