Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Open Source Software and Platforms
Open Source Software and Platforms
Wiki Guide to add "Hello World" application into edk2 of TC2 LSC platform?
  • Help
  • Jump...
  • Cancel
  • About this wiki
  • Supported platforms
  • Obtaining support
  • +Arm Reference Platforms deliverables
  • -A-class platforms
    • +Juno
    • +FVPs
    • -Total Compute Platforms
      • Guide to Set Up Debugging Environment for Total Compute Software Stack
      • Guide to Debug RSS Firmware Booting on Total Compute Platform
      • Guide to Debug SCP Firmware Booting on Total Compute Platform
      • Guide to Set Up TF-A Firmwares Debug Environment on Arm DS for Total Compute Platform
      • Guide to Debug Hafnium on Total Compute Platform
      • Guide to Disable AP Secure Images on Total Compute Platform
      • Guide to Run OpenEuler Embedded on TC2 Platform
      • Guide to add "Hello World" application into edk2 of TC2 LSC platform?
      • Guide to Set Up Linux Kernel Debug Environment on Arm DS for Total Compute Platform
      • Guide to Set Up U-boot Debug Environment on Arm DS for Total Compute Platform
    • +Morello Platform
    • +System Guidance for Infrastructure (SGI)
    • +System Guidance for Mobile (SGM)
    • Corstone-500
    • Cortex-A5 DesignStart
    • +Neoverse N1 SDP
    • Neoverse Reference Designs
    • +Legacy platforms
  • +M-class platforms
  • +R-class platforms
  • +FPGA prototyping boards
  • +Open source software

Guide to add "Hello World" application into edk2 of TC2 LSC platform?

The Total Compute 2022 (TC2) LSC software stack uses bash scripts to build an integrated solution that includes the Board Support Package (BSP) and the Debian distribution, as shown in the following figure: 

                   Total Compute Platform Software Components                           

The software component is available here. In the tc2-2024.02.22-lsc release, BL33 is implemented as the EDK2 boot loader. TF-A BL31 transfers execution control to the EDK2 UEFI FW bootloader (BL33). The EDK2 UEFI firmware loads and verifies the signature of Grub.

To add the HellowWorld application to edk2 for the TC2 LSC platform, perform the following steps:.

Step 1: Set up the TC22 LSC software stack.

Follow the Total Compute User Guide to set up the work space on your local host machine. After you set up and build the images successfully, you can find the images in the $workspace/output/debian/deploy/tc2/ directory, as shown in the following figure:

 

Step 2: Add the Hello World application into edk2 code base.

  1. Create the HelloWorld directory in the EDK2 code base:

    cd $workspace/src/uefi/edk2
    mkdir HelloWorld
  2. Add the related source files to the HelloWorld directory as follows:

    HelloWorld/HelloWorld.c   | 18 ++++++++++++++++++
    HelloWorld/HelloWorld.inf | 28 ++++++++++++++++++++++++++++
     2 files changed, 46 insertions(+)
     create mode 100644 HelloWorld/HelloWorld.c
     create mode 100644 HelloWorld/HelloWorld.inf
    
    diff --git a/HelloWorld/HelloWorld.c b/HelloWorld/HelloWorld.c
    new file mode 100644
    index 0000000000..3d7b10a6b0
    --- /dev/null
    +++ b/HelloWorld/HelloWorld.c
    @@ -0,0 +1,18 @@
    +#include <Uefi.h>
    +//#include <Library/UefiBootServicesTableLib.h>
    +#include <Library/UefiApplicationEntryPoint.h>
    +#include <Library/UefiLib.h>
    +
    +EFI_STATUS
    +EFIAPI
    +UefiMain(
    +  IN EFI_HANDLE ImageHandle,
    +  IN EFI_SYSTEM_TABLE *SystemTable
    +  )
    +{
    +  // Hello World
    +  Print(L"Hello, World!\n");
    +
    +  return EFI_SUCCESS;
    +}
    +
    diff --git a/HelloWorld/HelloWorld.inf b/HelloWorld/HelloWorld.inf
    new file mode 100644
    index 0000000000..60a7d3bc53
    --- /dev/null
    +++ b/HelloWorld/HelloWorld.inf
    @@ -0,0 +1,28 @@
    +[Defines]
    +  INF_VERSION                    = 0x00010005
    +  BASE_NAME                      = HelloWorld
    +  FILE_GUID                      = 35f8c5d2-1a18-45de-960a-5ba95954cad7
    +  MODULE_TYPE                    = UEFI_APPLICATION
    +  VERSION_STRING                 = 1.0
    +  ENTRY_POINT                    = UefiMain
    +
    +[Sources]
    +  HelloWorld.c
    +
    +[Packages]
    +  MdePkg/MdePkg.dec
    +
    +[LibraryClasses]
    +  UefiApplicationEntryPoint
    +  UefiLib
    +
    +[Guids]
    +
    +[Ppis]
    +
    +[Protocols]
    +
    +[FeaturePcd]
    +
    +[Pcd]
    +

Step 3: Modify the configuration files for the TC22 platform.

The HelloWorld application must be added to the TC22 platform description files and the flash definition file.

You can find these files in the $workspace/src/uefi/edk2/edk2-platforms/Platform/ARM/Tc directory, and modify the files as follows:

diff --git a/Platform/ARM/Tc/Tc.dsc.inc b/Platform/ARM/Tc/Tc.dsc.inc
index f7a4c65675..4f90750905 100644
--- a/Platform/ARM/Tc/Tc.dsc.inc
+++ b/Platform/ARM/Tc/Tc.dsc.inc
@@ -236,5 +236,8 @@
       PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   }

+  #Hello World
+  HelloWorld/HelloWorld.inf
+
   # RAM Disk
   MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
diff --git a/Platform/ARM/Tc/Tc.fdf b/Platform/ARM/Tc/Tc.fdf
index 637b2517fa..2f5f7e72a4 100644
--- a/Platform/ARM/Tc/Tc.fdf
+++ b/Platform/ARM/Tc/Tc.fdf
@@ -142,6 +142,8 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
   INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+  # Hello world
+  INF HelloWorld/HelloWorld.inf

 [FV.FVMAIN_COMPACT]
 FvAlignment        = 8

Step 4: Build the software stack.

If you want to build the UEFI standalone, use the following commands:

 ./run_docker.sh build-uefi.sh clean
 ./run_docker.sh build-uefi.sh build
 ./run_docker.sh build-tfa.sh build
 ./run_docker.sh build-tfa.sh deploy
 ./run_docker.sh build-flash-image.sh deploy

Then you can find the HelloWorld.efi is built out in directroy "$workspace/src/uefi/edk2/Build" as below:

./Tc2/DEBUG_GCC5/AARCH64/HelloWorld/HelloWorld/DEBUG/HelloWorld.efi

If you want to build the entire software stack, use the following commands:

 ./run_docker.sh build-all.sh clean
 ./run_docker.sh build-all.sh build

Step 5: Run the Hello World application in the EDK2 shell.

  1. Run the following command:

    ./run-scripts/tc2/run_model.sh -m /fvp/FVP_TC2_11.23_28/models/normal/FVP_TC2 -d debian -b uefi -t tap0

    Note: If you do not install the TC22 FVP Fast Model, you can download it here.

    Then, you can find the HelloWorld.efi application in the EDK2 shell:

  2. Run the efi application as follows:



  • Share
  • History
  • More
  • Cancel
Related
Recommended