public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pankaj Bansal" <pankaj.bansal@nxp.com>
To: Leif Lindholm <leif@nuviainc.com>,
	Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
	devel@edk2.groups.io, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH edk2-platforms 3/3] Silicon/NXP: Add Support for git commit info print
Date: Wed,  8 Jul 2020 00:19:33 -0500	[thread overview]
Message-ID: <20200708051933.8123-4-pankaj.bansal@oss.nxp.com> (raw)
In-Reply-To: <20200708051933.8123-1-pankaj.bansal@oss.nxp.com>

From: Pankaj Bansal <pankaj.bansal@nxp.com>

This patch adds the Support for printing the git commit information
in linux build environment.

Ideal place of retrieving this information should be python script in
BaseTools.

A Feature request for the same has been created:
https://bugzilla.tianocore.org/show_bug.cgi?id=2838

Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
---
 Silicon/NXP/NxpQoriqLs.dsc.inc                           |  3 ++
 Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf   |  5 +++
 Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.inf |  5 +++
 Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.c     | 17 +++++++++
 Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.c   | 17 +++++++++
 Silicon/NXP/set_firmware_ver.sh                          | 36 ++++++++++++++++++++
 6 files changed, 83 insertions(+)

diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
index 06ee012c227a..a0762a6ef61d 100644
--- a/Silicon/NXP/NxpQoriqLs.dsc.inc
+++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
@@ -224,6 +224,9 @@ [PcdsDynamicHii.common.DEFAULT]
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10
 
 [PcdsFixedAtBuild.common]
+  !ifdef $(FIRMWARE_VER)
+    gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
+  !endif
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
diff --git a/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf b/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf
index f5dbd1349dc5..69f884af9e34 100644
--- a/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf
+++ b/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf
@@ -16,6 +16,7 @@ [Defines]
 
 [Packages]
   ArmPkg/ArmPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Silicon/NXP/Chassis2/Chassis2.dec
   Silicon/NXP/NxpQoriqLs.dec
@@ -24,6 +25,7 @@ [LibraryClasses]
   IoAccessLib
   IoLib
   PcdLib
+  PrintLib
   SerialPortLib
 
 [Sources.common]
@@ -31,3 +33,6 @@ [Sources.common]
 
 [FeaturePcd]
   gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
diff --git a/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.inf b/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.inf
index 75b68cc4ca2d..632acc52b20a 100644
--- a/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.inf
+++ b/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.inf
@@ -16,6 +16,7 @@ [Defines]
 
 [Packages]
   ArmPkg/ArmPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Silicon/NXP/Chassis3V2/Chassis3V2.dec
   Silicon/NXP/NxpQoriqLs.dec
@@ -24,6 +25,7 @@ [LibraryClasses]
   IoAccessLib
   IoLib
   PcdLib
+  PrintLib
   SerialPortLib
 
 [Sources.common]
@@ -31,3 +33,6 @@ [Sources.common]
 
 [FeaturePcd]
   gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
diff --git a/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.c b/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.c
index 91b19f832f00..bc782e7e3873 100644
--- a/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.c
+++ b/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.c
@@ -12,6 +12,7 @@
 #include <Library/IoAccessLib.h>
 #include <Library/IoLib.h>
 #include <Library/PcdLib.h>
+#include <Library/PrintLib.h>
 #include <Library/SerialPortLib.h>
 
 /**
@@ -89,10 +90,26 @@ ChassisInit (
   VOID
   )
 {
+  CHAR8                         Buffer[100];
+  UINTN                         CharCount;
+
   //
   // Early init serial Port to get board information.
   //
   SerialPortInitialize ();
 
+  CharCount = AsciiSPrint (
+                Buffer, sizeof (Buffer),
+                "UEFI firmware built at %a on %a. version:\n\r",
+                __TIME__, __DATE__
+              );
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);
+
+  CharCount = AsciiSPrint (
+                Buffer, sizeof (Buffer), "%s\n\r",
+                (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString)
+              );
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);
+
   SmmuInit ();
 }
diff --git a/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.c b/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.c
index 30f8f945b233..6d546f4754f9 100644
--- a/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.c
+++ b/Silicon/NXP/Chassis3V2/Library/ChassisLib/ChassisLib.c
@@ -12,6 +12,7 @@
 #include <Library/IoAccessLib.h>
 #include <Library/IoLib.h>
 #include <Library/PcdLib.h>
+#include <Library/PrintLib.h>
 #include <Library/SerialPortLib.h>
 
 /**
@@ -64,8 +65,24 @@ ChassisInit (
   VOID
   )
 {
+  CHAR8                         Buffer[100];
+  UINTN                         CharCount;
+
   //
   // Early init serial Port to get board information.
   //
   SerialPortInitialize ();
+
+  CharCount = AsciiSPrint (
+                Buffer, sizeof (Buffer),
+                "UEFI firmware built at %a on %a. version:\n\r",
+                __TIME__, __DATE__
+              );
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);
+
+  CharCount = AsciiSPrint (
+                Buffer, sizeof (Buffer), "%s\n\r",
+                (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString)
+              );
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);
 }
diff --git a/Silicon/NXP/set_firmware_ver.sh b/Silicon/NXP/set_firmware_ver.sh
new file mode 100755
index 000000000000..ba2336ad23dc
--- /dev/null
+++ b/Silicon/NXP/set_firmware_ver.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright 2020 NXP
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+# parse PACKAGES_PATH and set FIRMWARE_VER based on that
+
+get_git_version()
+{
+  command -v git>/dev/null 2>&1
+  if [ $? -eq 0 ] && [ -n "$1" ]
+  then
+    head_or_tag=`git -C $1 describe --tag --dirty --broken --always 2>/dev/null`
+    printf $head_or_tag
+  fi
+}
+
+if [ -n "$FIRMWARE_VER" ]; then
+  echo "Warning FIRMWARE_VER=$FIRMWARE_VER is already set"
+  echo "Please retry after 'unset FIRMWARE_VER' command"
+fi
+
+directories=$(echo $PACKAGES_PATH | tr ":" "\n")
+for dir in $directories; do
+  if [ -n "$FIRMWARE_VER" ]; then
+    FIRMWARE_VER="$FIRMWARE_VER;$(basename $dir):$(get_git_version $dir)"
+  else
+    FIRMWARE_VER=$(basename $dir):$(get_git_version $dir)
+  fi
+done
+
+echo "FIRMWARE_VER=$FIRMWARE_VER"
+export FIRMWARE_VER=$FIRMWARE_VER
+
+echo "build edk2 firmware with -D FIRMWARE_VER=\$FIRMWARE_VER"
-- 
2.17.1


  parent reply	other threads:[~2020-07-08  5:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08  5:19 [PATCH edk2-platforms 0/3] Add Features to NXP Platforms Pankaj Bansal
2020-07-08  5:19 ` [PATCH edk2-platforms 1/3] Silicon/NXP: Use runtime safe version of DebugLib Pankaj Bansal
2020-08-05 14:11   ` Leif Lindholm
2020-07-08  5:19 ` [PATCH edk2-platforms 2/3] Silicon/NXP: Add support for reserving a chunk from RAM Pankaj Bansal
2020-07-18 17:32   ` Pankaj Bansal
2020-08-05 15:12   ` Leif Lindholm
2020-08-05 19:16     ` [EXTERNAL] Re: [edk2-devel] " Bret Barkelew
2020-07-08  5:19 ` Pankaj Bansal [this message]
2020-08-05 14:44   ` [PATCH edk2-platforms 3/3] Silicon/NXP: Add Support for git commit info print Leif Lindholm
2020-08-08  2:39     ` Pankaj Bansal
2020-08-12 12:45       ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708051933.8123-4-pankaj.bansal@oss.nxp.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox