# UDK2018 on Ubuntu Slide: https://hackmd.io/@SquirrelPanda/r1Iaeq6xd --- > 本篇記錄在 Ubuntu 上編譯 UDK2018 的相關筆記 > [name=Nick Xiao] [time=February 2021] [color=#907bf7] > > Email: s9926004@gmail.com {%hackmd ryr9Ug6sd %} --- ## 前言 如果找尋相關的 "How to build?" 資訊會發現分別有 EDK2、UDK 以及 ARM 三個版本, 彼此安裝的套件等會有些差異, 依照使用的 Source Code 版本或是當前的編譯環境做調整. 文件網址如下: - [How to Build UDK2018](https://github.com/tianocore/tianocore.github.io/wiki/UDK2018-How-to-Build#how-to-build-linux-like-system) - [Using EDK II with Native GCC](https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC) - [Building EDKII UEFI firmware for Arm Platforms]( https://developer.arm.com/tools-and-software/open-source-software/firmware/edkii-uefi-firmware/building-edkii-uefi-firmware-for-arm-platforms/single-page) ## 環境 - VMware Workstation Player 16 免費版([官網連結](https://www.vmware.com/tw/products/workstation-player.html)) - Ubuntu 20.04 ([官網連結](https://www.ubuntu-tw.org/modules/tinyd0/)) - UDK2018 ([GitHub連結](https://github.com/tianocore/tianocore.github.io/wiki/UDK2018)) ## 正文 ### Set Build Environment - Install required software from apt ``` $ sudo apt-get update $ sudo apt-get install build-essential uuid-dev iasl git gcc nasm python3-distutils ``` :::info change "gcc-5" to "gcc", install newest gcc version ::: - Create workspace folder ``` $ mkdir ~/src $ mkdir ~/src/UDK2018_workspace ``` - Install NASM 2.12.01 or later ``` $ sudo apt-get install nasm ``` - Install IASL 20150818 or later ``` $ sudo apt-get install iasl ``` ### Create the full Source Code directory for the UDK2018 release - Change path to workspace ``` $ cd ~/src/UDK2018_workspace ``` - Checkout the vUDK2018 tag from GitHub with the following "git" command ``` $ git clone https://github.com/tianocore/edk2.git vUDK2018 ``` - Go to the vUDK2018 directory ``` $ cd vUDK2018 $ git checkout tags/vUDK2018 -b vUDK2018 ``` - Move all files and folders under "vUDK2018" to "~/src/MyWorkspace" ``` $ mv * ../ ``` ### Generate OpenSSL* Crypto Library ``` $ cd CryptoPkg/Library/OpensslLib $ wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_0g.zip $ unzip OpenSSL_1_1_0g.zip -d openssl ``` ### Build Steps *** MdeModulePkg *** ``` $ cd ~/src/UDK2018_workspace/ $ . edksetup.sh $ make -C BaseTools $ build -t GCC5 -a X64 -p MdeModulePkg/MdeModulePkg.dsc -m /home/nickxiao/src/UDK2018_workspace/MdeModulePkg/Application/HelloWorld/HelloWorld.inf ``` ### The issue of building step - Case1.  GCC 某一版之後會有這問題, 需要修改 Makefile([參照](https://github.com/tianocore/edk2/commit/1d212a83df0eaf32a6f5d4159beb2d77832e0231#diff-81141d6762d92d3c026f14cc02a9d383)) ``` $UDK2018_workspace/BaseTools/Source/C/Makefiles/header.makefile ``` - Case2.  不知名問題, 需要將 strcpy 改成 memcpy, 同樣參考 [issue](https://github.com/Azure/azure-iot-sdk-c/issues/532) ``` $UDK2018_workspace/BaseTools/Source/C/GenVtf/GenVtf.c ``` - Case3. 雖然根據 edk2 環境設定要我們安裝 python3-distutils ([連結](https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC)), 但我們在 $UDK2018_workspace/BaseTools/Tests/GNUmakefile 中可以看到使用的是 python2 (如下) ```makefile=14 all: test test: @if command -v python2 >/dev/null 2>&1; then python2 RunTests.py; else python RunTests.py; fi clean: find . -name '*.pyc' -exec rm '{}' ';' ``` 與其逐一修改成 python3 的格式, 我選擇直接安裝 python2 來解決 ``` $ sudo apt-get install python2 ``` ## Toolchain - Step1. Download toolchain: ``` wget "https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz?revision=ea238776-c7c7-43be-ba0d-40d7f594af1f&la=en&hash=2937ED76D3E6B85BA511BCBD46AE121DBA5268F3" ``` - Step2. set environment variable ``` export PATH=$PATH:/home/nickxiao/src/UDK2018_workspace/gcc-arm-9.2-2019.12-x86_64-aarch64 ``` - Step3. rebuild ``` make -C BaseTools ``` ``` . edksetup.sh ``` ``` build -t GCC5 -a AARCH64 -p MdeModulePkg/MdeModulePkg.dsc -m /home/nickxiao/src/UDK2018_workspace/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf ``` :::info 嘗試的過程中失敗的發現我對於 toolchain 有些誤解, 以至於沒有使用 [Building EDKII UEFI firmware for Arm Platforms]( https://developer.arm.com/tools-and-software/open-source-software/firmware/edkii-uefi-firmware/building-edkii-uefi-firmware-for-arm-platforms) 所提供的 toolchain, 而是自己從官方抓最新版, 結果就是遇到各種奇妙的問題. 針對這一點根據客戶的需求會再追蹤補上. ::: ## 參考資料 - [UDK2018 How to Build](https://github.com/tianocore/tianocore.github.io/wiki/UDK2018-How-to-Build) - [Building EDKII UEFI firmware for Arm Platforms]( https://developer.arm.com/tools-and-software/open-source-software/firmware/edkii-uefi-firmware/building-edkii-uefi-firmware-for-arm-platforms) ###### tags: `UEFI`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up