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