├── .gitignore ├── README.md ├── docker ├── Dockerfile └── entry.sh ├── .gitmodules └── runme.sh /.gitignore: -------------------------------------------------------------------------------- 1 | **/images 2 | **/build/toolchain 3 | **/build/tianocore/Build/ 4 | **/build/tianocore/build* 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SolidRun's LX2160A COM express type 7 UEFI build 2 | 3 | ## Build with host tools 4 | Simply running INITIALIZE=1 ./runme.sh then ./runme.sh will check for required tools, clone and build images and place results in images/ directory. 5 | 6 | ## Build with docker or podman 7 | docker build -t lx2160a_uefi docker/ 8 | docker run -v "$PWD":/work:Z --rm -i -t lx2160a_uefi build 9 | 10 | You can specify build variables with the -e option 11 | docker run -e SOC_SPEED=2200 -e BUS_SPEED=800 -e DDR_SPEED=3000 -e XMP_PROFILE=1 -v "$PWD":/work:Z --rm -i -t lx2160a_uefi build 12 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # use debian base 2 | FROM debian:buster-slim 3 | 4 | # update 5 | RUN set -e; \ 6 | apt-get update; \ 7 | apt-get -y upgrade; \ 8 | : 9 | 10 | RUN apt-get update ; apt-get -y --no-install-recommends install \ 11 | wget make acpica-tools device-tree-compiler xz-utils \ 12 | sudo git gettext-base uuid-dev bc gcc g++ python3 \ 13 | libc6-dev libssl-dev python3-distutils ca-certificates 14 | 15 | RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 16 | 17 | # build environment 18 | ARG ddr=2400 19 | ENV DDR_SPEED=$ddr 20 | ARG soc=2000 21 | ENV SOC_SPEED=$soc 22 | ARG bus=700 23 | ENV BUS_SPEED=$bus 24 | ARG serdes=8_5_2 25 | ENV SERDES=$serdes 26 | ARG release=RELEASE 27 | ENV UEFI_RELEASE=$release 28 | ARG boot=sd 29 | ENV BOOT_MODE=$boot 30 | ARG xmp_profile= 31 | ENV XMP_PROFILE=$xmp_profile 32 | ARG x86emu= 33 | ENV X86EMU=$x86emu 34 | ARG amdgop= 35 | ENV AMDGOP=$amdgop 36 | ARG clean= 37 | ENV CLEAN=$clean 38 | 39 | WORKDIR /work 40 | COPY entry.sh / 41 | ENTRYPOINT ["/bin/sh", "/entry.sh"] 42 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "build/arm-trusted-firmware"] 2 | path = build/arm-trusted-firmware 3 | url = https://github.com/SolidRun/arm-trusted-firmware.git 4 | branch = v2.5-lx2160acex7 5 | [submodule "build/ddr-phy-binary"] 6 | path = build/ddr-phy-binary 7 | url = https://github.com/NXP/ddr-phy-binary.git 8 | branch = master 9 | [submodule "build/rcw"] 10 | path = build/rcw 11 | url = https://github.com/SolidRun/rcw.git 12 | branch = LSDK-20.04-sr 13 | [submodule "build/optee_os"] 14 | path = build/optee_os 15 | url = https://github.com/SolidRun/optee_os.git 16 | branch = 3.14.0-cex7 17 | [submodule "build/tianocore/edk2"] 18 | path = build/tianocore/edk2 19 | url = https://github.com/SolidRun/edk2.git 20 | branch = edk2-stable202105-lx2160acex7 21 | [submodule "build/tianocore/edk2-platforms"] 22 | path = build/tianocore/edk2-platforms 23 | url = https://github.com/SolidRun/edk2-platforms.git 24 | branch = edk2-stable202105-lx2160acex7 25 | [submodule "build/tianocore/edk2-non-osi"] 26 | path = build/tianocore/edk2-non-osi 27 | url = https://github.com/SolidRun/edk2-non-osi.git 28 | branch = edk2-stable202105-lx2160acex7 29 | -------------------------------------------------------------------------------- /docker/entry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # Copyright 2018-2019 Josua Mayer 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | # 6 | # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | # 8 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | # 10 | 11 | # if [ $# -lt 2 ]; then 12 | # echo "Error: Missing arguments uid and gid!" 13 | # echo "Maybe you forgot to pass to docker run?" 14 | # exit 1 15 | #fi 16 | 17 | #_UID=$1 18 | #_GID=$2 19 | 20 | # create build user (and group if it does not exist) 21 | #groupadd -g $_GID build 2>/dev/null || true 22 | #useradd -s /bin/bash -m -u $_UID -g $_GID build 23 | 24 | # passwordless sudo for build user 25 | #adduser build sudo 26 | #echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers 27 | 28 | # preconfigure git identity 29 | #sudo -u build git config --global user.name "LX2160A Toolchain Container" 30 | #sudo -u build git config --global user.email "support@solid-run.com" 31 | 32 | cd /work 33 | 34 | if [ $1 = "shell" ]; then 35 | echo "Starting Bash Shell" 36 | /bin/bash 37 | elif [ $1 = "build" ]; then 38 | echo "Performing SW Build" 39 | INITIALIZE=1 ./runme.sh 40 | ./runme.sh 41 | fi 42 | -------------------------------------------------------------------------------- /runme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # DDR_SPEED=2400,2600,2900,3000,3200 5 | # SERDES=8_5_2, 13_5_2, 20_5_2 6 | 7 | ARM_GCC_VERSION="gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu" 8 | IFS='-' read SP1 SP2 SP3 SP4 SP5 <<< ${ARM_GCC_VERSION} 9 | ARM_GCC_SV="${SP3}-${SP4}" 10 | GIT_HASH=`git rev-parse --short HEAD` 11 | 12 | ############################################################################### 13 | # General configurations 14 | ############################################################################### 15 | 16 | #UEFI_RELEASE=DEBUG 17 | #DDR_SPEED=3200 18 | #SERDES=8_5_2 # 8x10g 19 | #SERDES=13_5_2 # dual 100g 20 | #SERDES=20_5_2 # dual 40g 21 | ############################################################################### 22 | # Misc 23 | ############################################################################### 24 | if [ "x$DDR_SPEED" == "x" ]; then 25 | DDR_SPEED=2400 26 | fi 27 | if [ "x$SOC_SPEED" == "x" ]; then 28 | SOC_SPEED=2000 29 | fi 30 | if [ "x$BUS_SPEED" == "x" ]; then 31 | BUS_SPEED=700 32 | fi 33 | if [ "x$SERDES" == "x" ]; then 34 | SERDES=8_5_2 35 | fi 36 | if [ "x$UEFI_RELEASE" == "x" ]; then 37 | UEFI_RELEASE=RELEASE 38 | fi 39 | if [ "x$BOOT_MODE" == "x" ]; then 40 | BOOT_MODE=sd 41 | fi 42 | if [ "x$XMP_PROFILE" != "x" ]; then 43 | XMP_PROFILE="XMP_PROFILE=${XMP_PROFILE}" 44 | fi 45 | if [ "x$X86EMU" != "x" ]; then 46 | X86EMU="-D X64EMU_ENABLE=TRUE" 47 | fi 48 | if [ "x$AMDGOP" == "x" ]; then 49 | AMDGOP="-D AARCH64_GOP_ENABLE=TRUE" 50 | fi 51 | 52 | if [ "x$BIFURCATE_PCIE" != "x" ]; then 53 | BIFURPCI="-D BIFURCATE_PCIE=TRUE" 54 | fi 55 | 56 | ROOTDIR=`pwd` 57 | PARALLEL=$(getconf _NPROCESSORS_ONLN) # Amount of parallel jobs for the builds 58 | SPEED=${SOC_SPEED}_${BUS_SPEED}_${DDR_SPEED} 59 | 60 | TOOLS="wget tar git make dd envsubst dtc iasl" 61 | 62 | HOST_ARCH=`arch` 63 | if [ "$HOST_ARCH" == "x86_64" ]; then 64 | export CROSS_COMPILE=$ROOTDIR/build/toolchain/${ARM_GCC_VERSION}/bin/aarch64-none-linux-gnu- 65 | export CROSS_COMPILE64=$ROOTDIR/build/toolchain/${ARM_GCC_VERSION}/bin/aarch64-none-linux-gnu- 66 | fi 67 | export ARCH=arm64 68 | 69 | if [ "x$SERDES" == "x" ]; then 70 | echo "Please define SERDES configuration" 71 | exit -1 72 | fi 73 | if [ "x${SERDES:0:3}" == "x13_" ]; then 74 | DPC=dpc-dual-100g.dtb 75 | DPL=dpl-eth.dual-100g.19.dtb 76 | fi 77 | if [ "x${SERDES:0:2}" == "x8_" ]; then 78 | DPC=dpc-8_x_usxgmii.dtb 79 | DPL=dpl-eth.8x10g.19.dtb 80 | fi 81 | if [ "x${SERDES:0:2}" == "x4_" ]; then 82 | DPC=dpc-8_x_usxgmii.dtb 83 | DPL=dpl-eth.8x10g.19.dtb 84 | fi 85 | if [ "x${SERDES:0:3}" == "x20_" ]; then 86 | DPC=dpc-dual-40g.dtb 87 | DPL=dpl-eth.dual-40g.19.dtb 88 | fi 89 | 90 | echo "Checking all required tools are installed" 91 | 92 | set +e 93 | for i in $TOOLS; do 94 | TOOL_PATH=`which $i` 95 | if [ "x$TOOL_PATH" == "x" ]; then 96 | echo "Tool $i is not installed" 97 | exit -1 98 | fi 99 | done 100 | set -e 101 | 102 | if [[ ! -d $ROOTDIR/images ]]; then 103 | mkdir $ROOTDIR/images 104 | fi 105 | 106 | if [[ ! -d $ROOTDIR/build/toolchain/${ARM_GCC_VERSION} && "$HOST_ARCH" == "x86_64" ]]; then 107 | mkdir -p $ROOTDIR/build/toolchain 108 | cd $ROOTDIR/build/toolchain 109 | wget https://developer.arm.com/-/media/Files/downloads/gnu-a/${ARM_GCC_SV}/binrel/${ARM_GCC_VERSION}.tar.xz 110 | tar -xf ${ARM_GCC_VERSION}.tar.xz --no-same-owner 111 | rm -f ${ARM_GCC_VERSION}.tar.xz 112 | fi 113 | 114 | echo "Building boot loader" 115 | cd $ROOTDIR 116 | 117 | ############################################################################### 118 | # submodule init 119 | ############################################################################### 120 | if [ "x$INITIALIZE" != "x" ]; then 121 | git submodule update --init 122 | cd build/tianocore/edk2/ && git submodule update --init 123 | cd $ROOTDIR 124 | exit 125 | fi 126 | 127 | ############################################################################### 128 | # clean 129 | ############################################################################### 130 | if [ "x$CLEAN" != "x" ]; then 131 | rm -rf $ROOTDIR/build/arm-trusted-firmware/build 132 | rm -rf $ROOTDIR/build/optee_os/out 133 | rm -rf $ROOTDIR/tianocore/Build 134 | rm -rf $ROOTDIR/tianocore/Build 135 | PYTHON_COMMAND=/usr/bin/python3 make -C $ROOTDIR/build/tianocore/edk2/BaseTools clean 136 | fi 137 | 138 | ############################################################################### 139 | # building sources 140 | ############################################################################### 141 | echo "Building RCW" 142 | cd $ROOTDIR/build/rcw/lx2160acex7 143 | export SP1 SP2 SP3 144 | IFS=_ read SP1 SP2 SP3 <<< $SERDES 145 | if [ "x$SP1" == "4" ]; then 146 | export SRC1="0" 147 | export SCL1="0" 148 | export SPD1="1" 149 | else 150 | export SRC1="1" 151 | export SCL1="2" 152 | export SPD1="1" 153 | fi 154 | 155 | if [ "x$BIFURCATE_PCIE" != "x" ]; then 156 | export SP3="3" 157 | fi 158 | 159 | envsubst < configs/lx2160a_serdes.def > configs/lx2160a_serdes.rcwi 160 | 161 | IFS=_ read CPU SYS MEM <<< $SPEED 162 | export CPU=${CPU::2} 163 | export SYS=$(( 2*${SYS::2} )) 164 | export SYS=${SYS::-1} 165 | export MEM=${MEM::2} 166 | 167 | envsubst < configs/lx2160a_timings.def > configs/lx2160a_timings.rcwi 168 | 169 | # Always rebuild the rcws to catch timing changes 170 | rm -f rcws/*.bin 171 | make -j${PARALLEL} 172 | 173 | echo "Build UEFI" 174 | cd $ROOTDIR/build/tianocore 175 | # set the aarch64-linux-gnu cross compiler to the oldie 4.9 linaro toolchain (UEFI build requirement) 176 | PYTHON_COMMAND=/usr/bin/python3 make -C $ROOTDIR/build/tianocore/edk2/BaseTools 177 | export ARCH=arm 178 | export GCC5_AARCH64_PREFIX=$CROSS_COMPILE 179 | export WORKSPACE=$ROOTDIR/build/tianocore 180 | export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi 181 | source edk2/edksetup.sh 182 | 183 | if [ "x$SECURE_BOOT" != "x" ]; then 184 | build -p "edk2-platforms/Platform/SolidRun/LX2160aCex7/LX2160aCex7.dsc" -a AARCH64 -t GCC5 -b ${UEFI_RELEASE} -y build.log -D SECURE_BOOT ${X86EMU} ${AMDGOP} ${BIFURPCI} 185 | export BL33=$ROOTDIR/build/tianocore/Build/LX2160aCex7/${UEFI_RELEASE}_GCC5/FV/LX2160ACEX7_EFI.fd 186 | build -p "edk2-platforms/Platform/SolidRun/StandAloneMm/StandaloneMm.dsc" -a AARCH64 -t GCC5 -b ${UEFI_RELEASE} -y build-mm.log 187 | export CFG_STMM_PATH=$ROOTDIR/build/tianocore/Build/NXPMmStandalone/${UEFI_RELEASE}_GCC5/FV/BL32_AP_MM.fd 188 | 189 | echo "Build optee_os" 190 | cd $ROOTDIR/build/optee_os 191 | make -j${PARALLEL} CFG_ARM64_core=y PLATFORM=ls-lx2160ardb CFG_SCTLR_ALIGNMENT_CHECK=n CFG_TEE_CORE_LOG_LEVEL=0 CFG_TEE_TA_LOG_LEVEL=0 CFG_WITH_STMM_SP=y 192 | ${CROSS_COMPILE}objcopy -v -O binary out/arm-plat-ls/core/tee.elf out/arm-plat-ls/core/tee.bin 193 | export BL32=$ROOTDIR/build/optee_os/out/arm-plat-ls/core/tee.bin 194 | else 195 | build -p "edk2-platforms/Platform/SolidRun/LX2160aCex7/LX2160aCex7.dsc" -a AARCH64 -t GCC5 -b ${UEFI_RELEASE} -y build.log ${X86EMU} ${AMDGOP} ${BIFURPCI} 196 | export BL33=$ROOTDIR/build/tianocore/Build/LX2160aCex7/${UEFI_RELEASE}_GCC5/FV/LX2160ACEX7_EFI.fd 197 | fi 198 | 199 | export ARCH=arm64 # While building UEFI ARCH is unset 200 | 201 | echo "Building trusted-firmware-a" 202 | cd $ROOTDIR/build/arm-trusted-firmware/ 203 | 204 | # TF-A is very picky about changing the boot mode and other settings 205 | # and it isn't very big so just remove the build directory regardless 206 | # and rebuild clean each time 207 | rm -rf build 208 | 209 | if [ "x$SECURE_BOOT" != "x" ]; then 210 | make PLAT=lx2160acex7 all fip pbl RCW=$ROOTDIR/build/rcw/lx2160acex7/rcws/rcw_lx2160acex7.bin BOOT_MODE=${BOOT_MODE} SPD=opteed ${XMP_PROFILE} ENABLE_STACK_PROTECTION=1 211 | else 212 | make PLAT=lx2160acex7 all fip pbl RCW=$ROOTDIR/build/rcw/lx2160acex7/rcws/rcw_lx2160acex7.bin TRUSTED_BOARD_BOOT=0 GENERATE_COT=0 BOOT_MODE=${BOOT_MODE} SECURE_BOOT=false ${XMP_PROFILE} ENABLE_STACK_PROTECTION=1 213 | fi 214 | 215 | cd $ROOTDIR/ 216 | if [ "x$SECURE_BOOT" != "x" ]; then 217 | IMG=lx2160acex7_${SPEED}_${SERDES}_${BOOT_MODE}_secure_${GIT_HASH}.img 218 | else 219 | IMG=lx2160acex7_${SPEED}_${SERDES}_${BOOT_MODE}_${GIT_HASH}.img 220 | fi 221 | truncate -s 8M $ROOTDIR/images/${IMG} 222 | 223 | # RCW+PBI+BL2 at block 8 224 | if [ "x$BOOT_MODE" == "xflexspi_nor" ]; then 225 | dd if=$ROOTDIR/build/arm-trusted-firmware/build/lx2160acex7/release/bl2_flexspi_nor.pbl of=images/${IMG} bs=512 conv=notrunc 226 | elif [ "x$BOOT_MODE" == "xsd" ]; then 227 | dd if=$ROOTDIR/build/arm-trusted-firmware/build/lx2160acex7/release/bl2_sd.pbl of=images/${IMG} bs=512 seek=8 conv=sparse 228 | fi 229 | 230 | # DDR PHY FIP at 0x100 231 | dd if=$ROOTDIR/build/ddr-phy-binary/lx2160a/fip_ddr.bin of=images/${IMG} bs=512 seek=256 conv=notrunc 232 | 233 | # FIP (BL31+BL32+BL33) at 0x800 234 | dd if=$ROOTDIR/build/arm-trusted-firmware/build/lx2160acex7/release/fip.bin of=images/${IMG} bs=512 seek=2048 conv=notrunc 235 | 236 | echo -e "\r\n\r\nBuilt: images/${IMG}" 237 | --------------------------------------------------------------------------------