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

You are currently reviewing an older revision of this page.

  • History View current version

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 comprising Board Support Package (BSP) and Debian distribution. 

The detial software component  can be found here. For this tc2-2024.02.22-lsc release, the BL33 is implemented as EDK2 boot loader. TF-A BL31 passes execution control to EDK2 UEFI FW bootloader (BL33). EDK2 UEFI FW will load and verify signature of Grub.

This article will demo how to add one simple "HellowWorld" application into edk2 for tc2 lsc platform, you can perform the following steps to achieve the goal.

Step 1: Setup the TC22 LSC software stack.

You can follow the user-guide to set up the work space on your local host machine, once you set up and build out the images successfully, there will be below image is created in directory "$workspace/output/debian/deploy/tc2/ ":

 

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

You can create the HelloWorld directory into EDK2 code base:

cd $workspace/src/uefi/edk2
mkdir HelloWorld

Then add the related source into "HelloWorld" directory as below:

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 configruation files for the TC22 platform.

The HelloWorld application need to be added into TC22 platform description files and flash definition file, they are part of "$workspace/src/uefi/edk2/edk2-platforms/Platform/ARM/Tc" directory, you can modify it  as below:

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 would like to build the uefi standlone, you need to follow below 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

If you would like to build the software stack totally, you can use below command:

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

Step 5: Run the Hello World application into the edk2 shell.

Run the 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 have not installed the TC22 FVP fast model yet, it can be downloaded from here.

Then, you can see the HelloWorld.efi application from edk2 shell:

You can run the HelloWorld.efi application as following: