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