From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <bounce+27952+120902+7686176+12367111@groups.io>
Received: from mail05.groups.io (mail05.groups.io [45.79.224.7])
	by spool.mail.gandi.net (Postfix) with ESMTPS id 614D3740038
	for <rebecca@openfw.io>; Tue, 17 Dec 2024 10:14:59 +0000 (UTC)
DKIM-Signature: a=rsa-sha256; bh=KICcHksNrdcm2aB5NOyx4pCz1z3wvBgM5m2Nq69R4Wg=;
 c=relaxed/simple; d=groups.io;
 h=Subject:To:From:User-Agent:MIME-Version:Date:Message-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type;
 s=20240830; t=1734430499; v=1; x=1734689697;
 b=YpKL97vl76grXzWWhACEtvoE/NVDIVisPj2dGb8lLyTD/4zm3vWOnJNDOYs341PvIxsVZ7fP
 d1Bg8kCxGR7VdAJ7VImDT8pO2CPDtZPkWErsFsVkUPjA0E3me80BMBEC0OsFsm9VWroCxSiFTet
 /qdwtDRWvOkoNH2QJ+3xVOegf+0FiJc61BiZ+nfgkyFnAHPVAiiy+2YjErhB3yax9voWviV50mO
 FfMpu5p8eCr0bC/H8oGK2x63M351svPbUskk+Ny5Q2SDM8fdNZtjNjoWd6U2vAeGPGZxYfxPBx4
 WePPmnGd/3NMu3oiCDBg3yL4Ue3BziDExLHvAVvcbgHRA==
X-Received: by 127.0.0.2 with SMTP id AOP5YY7687511xwESpFv8rxd; Tue, 17 Dec 2024 02:14:57 -0800
Subject: [edk2-devel] Setting a static IP address in EDK2 Payload prior to UEFI Shell
To: devel@edk2.groups.io
From: "greg.wilson via groups.io" <greg.wilson=gd-ms.uk@groups.io>
X-Originating-Location: Winchester, England, GB (31.121.119.225)
X-Originating-Platform: Windows Chrome 131
User-Agent: GROUPS.IO Web Poster
MIME-Version: 1.0
Date: Tue, 17 Dec 2024 02:14:57 -0800
Message-ID: <rOXg.1734430497123281356.CwVt@groups.io>
Precedence: Bulk
List-Subscribe: <mailto:devel+subscribe@edk2.groups.io>
List-Help: <mailto:devel+help@edk2.groups.io>
Sender: devel@edk2.groups.io
List-Id: <devel.edk2.groups.io>
Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io
Reply-To: devel@edk2.groups.io,greg.wilson@gd-ms.uk
List-Unsubscribe-Post: List-Unsubscribe=One-Click
List-Unsubscribe: <https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/plugh>
X-Gm-Message-State: ce9rDQqpjbd2L36rfXdXFpvBx7686176AA=
Content-Type: multipart/alternative; boundary="vjaGgjQKeKGp0BzdFExD"
X-GND-Status: LEGIT
Authentication-Results: spool.mail.gandi.net;
	dkim=pass header.d=groups.io header.s=20240830 header.b=YpKL97vl;
	dmarc=pass (policy=none) header.from=groups.io;
	spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io

--vjaGgjQKeKGp0BzdFExD
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Hi,

Within EDK2 payload, I am trying to get a static IP address set, so that wh=
en I enter UEFI Shell, I can ping another computer.

At the moment I have the network stack elements started automatically, but =
still need to type 'ifconfig -s eth0 static 192.168.1.5 255.255.255.0 192.1=
68.1.1' every time to get the IP address assigned before i can ping 192.168=
.1.10

I'd like to start the UEFI shell and just run the ping command, and it chec=
k if 192.168.1.10 is available.

The current versions of EDK2 and Slimboot from github I am using are listed=
 below

EDK2 - d13f31c3fe17eb532bf9016a2d8de3885642cba0 (https://github.com/tianoco=
re/edk2/tree/d13f31c3fe17eb532bf9016a2d8de3885642cba0) from September 30th =
(I tried a newer version, but got build errors)
Slimboot - ca00703127e34c84c3e6d3d129ebc5ef292ba963 (https://github.com/sli=
mbootloader/slimbootloader/tree/ca00703127e34c84c3e6d3d129ebc5ef292ba963) f=
rom October 25th

I've tried the following...

Creating a C and INF file,

C File
=3D=3D=3D=3D
#include <Library/DebugLib.h>
#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/Ip4Config2.h>
//#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
//#include <Library/PrintLib.h>
EFI_STATUS
EFIAPI
StaticIpDriverEntryPoint (
IN EFI_HANDLE =C2=A0 =C2=A0 =C2=A0 =C2=A0ImageHandle,
IN EFI_SYSTEM_TABLE =C2=A0*SystemTable
)
{
EFI_STATUS =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status;
EFI_IP4_CONFIG2_PROTOCOL =C2=A0 *Ip4Config2;
EFI_IP4_CONFIG2_MANUAL_ADDRESS Address;
EFI_HANDLE =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *HandleB=
uffer;
UINTN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0HandleCount;
UINTN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0Index;
// Print(L"GREG - Setting Static IP Address - Using StaticIpDriverEntryPoin=
t\n");
DEBUG ((DEBUG_INFO, "GREG - =C2=A0- Setting Static IP Address - Using Stati=
cIpDriverEntryPoint\n"));
// Locate all handles that support the EFI_IP4_CONFIG2_PROTOCOL
Status =3D gBS->LocateHandleBuffer(ByProtocol, &gEfiIp4Config2ProtocolGuid,=
 NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR(Status)) {
return Status;
}
for (Index =3D 0; Index < HandleCount; Index++) {
Status =3D gBS->HandleProtocol(HandleBuffer[Index], &gEfiIp4Config2Protocol=
Guid, (VOID **)&Ip4Config2);
if (EFI_ERROR(Status)) {
continue;
}
// Set the manual IP address
Address.Address.Addr[0] =3D 192;
Address.Address.Addr[1] =3D 168;
Address.Address.Addr[2] =3D 1;
Address.Address.Addr[3] =3D 5;
Address.SubnetMask.Addr[0] =3D 255;
Address.SubnetMask.Addr[1] =3D 255;
Address.SubnetMask.Addr[2] =3D 255;
Address.SubnetMask.Addr[3] =3D 0;

Status =3D Ip4Config2->SetData(Ip4Config2, Ip4Config2DataTypeManualAddress,=
 sizeof(Address), &Address);
if (EFI_ERROR(Status)) {
continue;
}
// Optionally, set the gateway and DNS server addresses here
// Break after setting the IP on the first interface
break;
}
// Free the handle buffer
if (HandleBuffer !=3D NULL) {
FreePool(HandleBuffer);
}
return Status;
}
//VOID
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
IN EFI_HANDLE =C2=A0 =C2=A0 =C2=A0 =C2=A0ImageHandle,
IN EFI_SYSTEM_TABLE =C2=A0*SystemTable
)
{
EFI_STATUS =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status;
EFI_IP4_CONFIG2_PROTOCOL =C2=A0 *Ip4Config2;
EFI_IP4_CONFIG2_MANUAL_ADDRESS Address;
EFI_HANDLE =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *HandleB=
uffer;
UINTN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0HandleCount;
UINTN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0Index;
// =C2=A0Print(L"GREG - Setting Static IP Address - Using _ModuleEntryPoint=
\n");
DEBUG ((DEBUG_INFO, "GREG - =C2=A0- Setting Static IP Address - Using _Modu=
leEntryPoint\n"));
// Locate all handles that support the EFI_IP4_CONFIG2_PROTOCOL
Status =3D gBS->LocateHandleBuffer(ByProtocol, &gEfiIp4Config2ProtocolGuid,=
 NULL, &HandleCount, &HandleBuffer);
if (EFI_ERROR(Status)) {
return Status;
}
for (Index =3D 0; Index < HandleCount; Index++) {
Status =3D gBS->HandleProtocol(HandleBuffer[Index], &gEfiIp4Config2Protocol=
Guid, (VOID **)&Ip4Config2);
if (EFI_ERROR(Status)) {
continue;
}
// Set the manual IP address
Address.Address.Addr[0] =3D 192;
Address.Address.Addr[1] =3D 168;
Address.Address.Addr[2] =3D 1;
Address.Address.Addr[3] =3D 100;
Address.SubnetMask.Addr[0] =3D 255;
Address.SubnetMask.Addr[1] =3D 255;
Address.SubnetMask.Addr[2] =3D 255;
Address.SubnetMask.Addr[3] =3D 0;
Status =3D Ip4Config2->SetData(Ip4Config2, Ip4Config2DataTypeManualAddress,=
 sizeof(Address), &Address);
if (EFI_ERROR(Status)) {
continue;
}
// Optionally, set the gateway and DNS server addresses here
// Break after setting the IP on the first interface
break;
}
// Free the handle buffer
if (HandleBuffer !=3D NULL) {
FreePool(HandleBuffer);
}
return Status;
}

and INF File

[Defines]
INF_VERSION =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0=3D 0x00010017
BASE_NAME =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0=3D StaticIpConfigDxe
FILE_GUID =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0=3D 7283e2fb-eeca-47d8-8576-5d55225ec820
MODULE_TYPE =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0=3D DXE_DRIVER
VERSION_STRING =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D =
1.0
ENTRY_POINT =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0=3D StaticIpDriverEntryPoint
[Sources]
StaticIpConfigDxe.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiPayloadPkg/UefiPayloadPkg.dec
[LibraryClasses]
UefiLib
UefiBootServicesTableLib
DebugLib
MemoryAllocationLib
PrintLib
[Protocols]
gEfiIp4Config2ProtocolGuid
[Depex]
gEfiIp4Config2ProtocolGuid

but loading the INF file into sbl_02\edk2\UefiPayloadPkg\UefiPayloadPkg.dsc=
 and sbl_02\edk2\UefiPayloadPkg\UefiPayloadPkg.fdf caused the build binary =
to not load.

I commented out the above entries and then modified sbl_02\edk2\UefiPayload=
Pkg\UefiPayloadPkg.dsc and sbl_02\edk2\UefiPayloadPkg\UefiPayloadPkg.dec

I added into the dsc the following

# Disable DHCP
gUefiPayloadPkgTokenSpaceGuid.PcdIPv4Enable|TRUE
gUefiPayloadPkgTokenSpaceGuid.PcdDhcp|FALSE

# Static IP configuration for eth0
gUefiPayloadPkgTokenSpaceGuid.PcdIp4Address0|192.168.1.5
gUefiPayloadPkgTokenSpaceGuid.PcdIp4SubnetMask0|255.255.255.0
gUefiPayloadPkgTokenSpaceGuid.PcdIp4Gateway0|192.168.1.1

In the dec I added

[PcdsFixedAtBuild]
gUefiPayloadPkgTokenSpaceGuid.PcdIPv4Enable|TRUE|BOOLEAN|0x00000001
gUefiPayloadPkgTokenSpaceGuid.PcdDhcp|FALSE|BOOLEAN|0x00000002
gUefiPayloadPkgTokenSpaceGuid.PcdIp4Address0|192.168.1.5|VOID*|0x00000042
gUefiPayloadPkgTokenSpaceGuid.PcdIp4SubnetMask0|255.255.255.0|VOID*|0x00000=
043
gUefiPayloadPkgTokenSpaceGuid.PcdIp4Gateway0|192.168.1.1|VOID*|0x00000044

This booted into UEFI shell, but didn't assign the IP address.

I will have multiple interfaces i need to set static IP addresses to, but e=
th0 is of course the first :-)

Any help gratefully received.

Kind regards


-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120902): https://edk2.groups.io/g/devel/message/120902
Mute This Topic: https://groups.io/mt/110160546/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-



--vjaGgjQKeKGp0BzdFExD
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<div>Hi,<br /><br />Within EDK2 payload, I am trying to get a static IP add=
ress set, so that when I enter UEFI Shell, I can ping another computer.&nbs=
p;<br /><br />At the moment I have the network stack elements started autom=
atically, but still need to type 'ifconfig -s eth0 static 192.168.1.5 255.2=
55.255.0 192.168.1.1' every time to get the IP address assigned before i ca=
n ping 192.168.1.10<br /><br />I'd like to start the UEFI shell and just ru=
n the ping command, and it check if 192.168.1.10 is available.<br /><br /><=
/div>
<div>
<div style=3D"box-sizing: border-box; overflow-wrap: break-word !important;=
 color: #333333; font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neu=
e', 'Noto Sans', 'Liberation Sans', Arial, sans-serif, 'Apple Color Emoji',=
 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; =
font-style: normal; font-variant-ligatures: normal; font-variant-caps: norm=
al; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start=
; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -we=
bkit-text-stroke-width: 0px; white-space: normal; background-color: #ffffff=
; text-decoration-thickness: initial; text-decoration-style: initial; text-=
decoration-color: initial;">The current versions of EDK2 and Slimboot from =
github I am using are listed below</div>
<div style=3D"box-sizing: border-box; overflow-wrap: break-word !important;=
 color: #333333; font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neu=
e', 'Noto Sans', 'Liberation Sans', Arial, sans-serif, 'Apple Color Emoji',=
 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; =
font-style: normal; font-variant-ligatures: normal; font-variant-caps: norm=
al; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start=
; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -we=
bkit-text-stroke-width: 0px; white-space: normal; background-color: #ffffff=
; text-decoration-thickness: initial; text-decoration-style: initial; text-=
decoration-color: initial;">&nbsp;</div>
<div style=3D"box-sizing: border-box; overflow-wrap: break-word !important;=
 color: #333333; font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neu=
e', 'Noto Sans', 'Liberation Sans', Arial, sans-serif, 'Apple Color Emoji',=
 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; =
font-style: normal; font-variant-ligatures: normal; font-variant-caps: norm=
al; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start=
; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -we=
bkit-text-stroke-width: 0px; white-space: normal; background-color: #ffffff=
; text-decoration-thickness: initial; text-decoration-style: initial; text-=
decoration-color: initial;">EDK2 - d13f31c3fe17eb532bf9016a2d8de3885642cba0=
 (https://github.com/tianocore/edk2/tree/d13f31c3fe17eb532bf9016a2d8de38856=
42cba0) from September 30th (I tried a newer version, but got build errors)=
&nbsp;</div>
<div style=3D"box-sizing: border-box; overflow-wrap: break-word !important;=
 color: #333333; font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neu=
e', 'Noto Sans', 'Liberation Sans', Arial, sans-serif, 'Apple Color Emoji',=
 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; =
font-style: normal; font-variant-ligatures: normal; font-variant-caps: norm=
al; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start=
; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -we=
bkit-text-stroke-width: 0px; white-space: normal; background-color: #ffffff=
; text-decoration-thickness: initial; text-decoration-style: initial; text-=
decoration-color: initial;">Slimboot - ca00703127e34c84c3e6d3d129ebc5ef292b=
a963 (https://github.com/slimbootloader/slimbootloader/tree/ca00703127e34c8=
4c3e6d3d129ebc5ef292ba963) from October 25th</div>
<div style=3D"box-sizing: border-box; overflow-wrap: break-word !important;=
 color: #333333; font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neu=
e', 'Noto Sans', 'Liberation Sans', Arial, sans-serif, 'Apple Color Emoji',=
 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; =
font-style: normal; font-variant-ligatures: normal; font-variant-caps: norm=
al; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start=
; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -we=
bkit-text-stroke-width: 0px; white-space: normal; background-color: #ffffff=
; text-decoration-thickness: initial; text-decoration-style: initial; text-=
decoration-color: initial;">&nbsp;</div>
</div>
<div>I've tried the following...<br /><br />Creating a C and INF file,<br /=
><br /></div>
<div>C File</div>
<div>=3D=3D=3D=3D</div>
<div>
<div>#include &lt;Library/DebugLib.h&gt;<br />#include &lt;Uefi.h&gt;<br />=
#include &lt;Library/UefiBootServicesTableLib.h&gt;<br />#include &lt;Proto=
col/Ip4Config2.h&gt;<br />//#include &lt;Library/BaseMemoryLib.h&gt;<br />#=
include &lt;Library/MemoryAllocationLib.h&gt;<br />//#include &lt;Library/P=
rintLib.h&gt;</div>
<div>EFI_STATUS<br />EFIAPI<br />StaticIpDriverEntryPoint (<br />&nbsp; IN =
EFI_HANDLE &nbsp; &nbsp; &nbsp; &nbsp;ImageHandle,<br />&nbsp; IN EFI_SYSTE=
M_TABLE &nbsp;*SystemTable<br />&nbsp; )<br />{<br />&nbsp; EFI_STATUS &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Status;<br />&nbsp; EFI=
_IP4_CONFIG2_PROTOCOL &nbsp; *Ip4Config2;<br />&nbsp; EFI_IP4_CONFIG2_MANUA=
L_ADDRESS Address;<br />&nbsp; EFI_HANDLE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; *HandleBuffer;<br />&nbsp; UINTN &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HandleCount;<br />=
&nbsp; UINTN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp;Index;</div>
<div>&nbsp; // Print(L"GREG - Setting Static IP Address - Using StaticIpDri=
verEntryPoint\n");<br />&nbsp; DEBUG ((DEBUG_INFO, "GREG - &nbsp;- Setting =
Static IP Address - Using StaticIpDriverEntryPoint\n"));</div>
<div>&nbsp; // Locate all handles that support the EFI_IP4_CONFIG2_PROTOCOL=
<br />&nbsp; Status =3D gBS-&gt;LocateHandleBuffer(ByProtocol, &amp;gEfiIp4=
Config2ProtocolGuid, NULL, &amp;HandleCount, &amp;HandleBuffer);<br />&nbsp=
; if (EFI_ERROR(Status)) {<br />&nbsp; &nbsp; return Status;<br />&nbsp; }<=
/div>
<div>&nbsp; for (Index =3D 0; Index &lt; HandleCount; Index++) {<br />&nbsp=
; &nbsp; Status =3D gBS-&gt;HandleProtocol(HandleBuffer[Index], &amp;gEfiIp=
4Config2ProtocolGuid, (VOID **)&amp;Ip4Config2);<br />&nbsp; &nbsp; if (EFI=
_ERROR(Status)) {<br />&nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; }<=
/div>
<div>&nbsp; &nbsp; // Set the manual IP address<br />&nbsp; &nbsp; Address.=
Address.Addr[0] =3D 192;<br />&nbsp; &nbsp; Address.Address.Addr[1] =3D 168=
;<br />&nbsp; &nbsp; Address.Address.Addr[2] =3D 1;<br />&nbsp; &nbsp; Addr=
ess.Address.Addr[3] =3D 5;<br />&nbsp; &nbsp; Address.SubnetMask.Addr[0] =
=3D 255;<br />&nbsp; &nbsp; Address.SubnetMask.Addr[1] =3D 255;<br />&nbsp;=
 &nbsp; Address.SubnetMask.Addr[2] =3D 255;<br />&nbsp; &nbsp; Address.Subn=
etMask.Addr[3] =3D 0;<br />&nbsp; &nbsp;&nbsp;<br />&nbsp; &nbsp; Status =
=3D Ip4Config2-&gt;SetData(Ip4Config2, Ip4Config2DataTypeManualAddress, siz=
eof(Address), &amp;Address);<br />&nbsp; &nbsp; if (EFI_ERROR(Status)) {<br=
 />&nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; // Optionally, set the gateway and DNS server addresses =
here</div>
<div>&nbsp; &nbsp; // Break after setting the IP on the first interface<br =
/>&nbsp; &nbsp; break;<br />&nbsp; }</div>
<div>&nbsp; // Free the handle buffer<br />&nbsp; if (HandleBuffer !=3D NUL=
L) {<br />&nbsp; &nbsp; FreePool(HandleBuffer);<br />&nbsp; }</div>
<div>&nbsp; return Status;<br />}</div>
<div>//VOID<br />EFI_STATUS<br />EFIAPI<br />_ModuleEntryPoint (<br />&nbsp=
; IN EFI_HANDLE &nbsp; &nbsp; &nbsp; &nbsp;ImageHandle,<br />&nbsp; IN EFI_=
SYSTEM_TABLE &nbsp;*SystemTable<br />&nbsp; )<br />{<br />&nbsp; EFI_STATUS=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Status;<br />&nbsp=
; EFI_IP4_CONFIG2_PROTOCOL &nbsp; *Ip4Config2;<br />&nbsp; EFI_IP4_CONFIG2_=
MANUAL_ADDRESS Address;<br />&nbsp; EFI_HANDLE &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; *HandleBuffer;<br />&nbsp; UINTN &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HandleCount;<=
br />&nbsp; UINTN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp;Index;</div>
<div>// &nbsp;Print(L"GREG - Setting Static IP Address - Using _ModuleEntry=
Point\n");<br />&nbsp; DEBUG ((DEBUG_INFO, "GREG - &nbsp;- Setting Static I=
P Address - Using _ModuleEntryPoint\n"));</div>
<div>&nbsp; // Locate all handles that support the EFI_IP4_CONFIG2_PROTOCOL=
<br />&nbsp; Status =3D gBS-&gt;LocateHandleBuffer(ByProtocol, &amp;gEfiIp4=
Config2ProtocolGuid, NULL, &amp;HandleCount, &amp;HandleBuffer);<br />&nbsp=
; if (EFI_ERROR(Status)) {<br />&nbsp; &nbsp; return Status;<br />&nbsp; }<=
/div>
<div>&nbsp; for (Index =3D 0; Index &lt; HandleCount; Index++) {<br />&nbsp=
; &nbsp; Status =3D gBS-&gt;HandleProtocol(HandleBuffer[Index], &amp;gEfiIp=
4Config2ProtocolGuid, (VOID **)&amp;Ip4Config2);<br />&nbsp; &nbsp; if (EFI=
_ERROR(Status)) {<br />&nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; }<=
/div>
<div>&nbsp; &nbsp; // Set the manual IP address<br />&nbsp; &nbsp; Address.=
Address.Addr[0] =3D 192;<br />&nbsp; &nbsp; Address.Address.Addr[1] =3D 168=
;<br />&nbsp; &nbsp; Address.Address.Addr[2] =3D 1;<br />&nbsp; &nbsp; Addr=
ess.Address.Addr[3] =3D 100;<br />&nbsp; &nbsp; Address.SubnetMask.Addr[0] =
=3D 255;<br />&nbsp; &nbsp; Address.SubnetMask.Addr[1] =3D 255;<br />&nbsp;=
 &nbsp; Address.SubnetMask.Addr[2] =3D 255;<br />&nbsp; &nbsp; Address.Subn=
etMask.Addr[3] =3D 0;</div>
<div>&nbsp; &nbsp; Status =3D Ip4Config2-&gt;SetData(Ip4Config2, Ip4Config2=
DataTypeManualAddress, sizeof(Address), &amp;Address);<br />&nbsp; &nbsp; i=
f (EFI_ERROR(Status)) {<br />&nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nb=
sp; }</div>
<div>&nbsp; &nbsp; // Optionally, set the gateway and DNS server addresses =
here</div>
<div>&nbsp; &nbsp; // Break after setting the IP on the first interface<br =
/>&nbsp; &nbsp; break;<br />&nbsp; }</div>
<div>&nbsp; // Free the handle buffer<br />&nbsp; if (HandleBuffer !=3D NUL=
L) {<br />&nbsp; &nbsp; FreePool(HandleBuffer);<br />&nbsp; }</div>
<div>&nbsp; return Status;<br />}<br /><br />and INF File<br /><br />
<div>[Defines]<br />&nbsp; INF_VERSION &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=3D 0x00010017<br />&nbsp; BASE_NAME &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=3D =
StaticIpConfigDxe<br />&nbsp; FILE_GUID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=3D 7283e2fb-eeca-47d8-8576-5d5522=
5ec820<br />&nbsp; MODULE_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp;=3D DXE_DRIVER<br />&nbsp; VERSION_STRING &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =3D 1.0<br />&nbsp; ENTRY_P=
OINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
=3D StaticIpDriverEntryPoint</div>
<div>[Sources]<br />&nbsp; StaticIpConfigDxe.c</div>
<div>[Packages]<br />&nbsp; MdePkg/MdePkg.dec<br />&nbsp; MdeModulePkg/MdeM=
odulePkg.dec<br />&nbsp; UefiPayloadPkg/UefiPayloadPkg.dec</div>
<div>[LibraryClasses]<br />&nbsp; UefiLib<br />&nbsp; UefiBootServicesTable=
Lib<br />&nbsp; DebugLib<br />&nbsp; MemoryAllocationLib<br />&nbsp; PrintL=
ib</div>
<div>[Protocols]<br />&nbsp; gEfiIp4Config2ProtocolGuid</div>
<div>[Depex]<br />&nbsp; gEfiIp4Config2ProtocolGuid<br /><br /><br />but lo=
ading the INF file into sbl_02\edk2\UefiPayloadPkg\UefiPayloadPkg.dsc and s=
bl_02\edk2\UefiPayloadPkg\UefiPayloadPkg.fdf caused the build binary to not=
 load.<br /><br />I commented out the above entries and then modified sbl_0=
2\edk2\UefiPayloadPkg\UefiPayloadPkg.dsc and sbl_02\edk2\UefiPayloadPkg\Uef=
iPayloadPkg.dec<br /><br />I added into the dsc the following<br /><br />&n=
bsp; # Disable DHCP<br />&nbsp; gUefiPayloadPkgTokenSpaceGuid.PcdIPv4Enable=
|TRUE<br />&nbsp; gUefiPayloadPkgTokenSpaceGuid.PcdDhcp|FALSE<br />&nbsp;&n=
bsp;<br />&nbsp; # Static IP configuration for eth0<br />&nbsp; gUefiPayloa=
dPkgTokenSpaceGuid.PcdIp4Address0|192.168.1.5<br />&nbsp; gUefiPayloadPkgTo=
kenSpaceGuid.PcdIp4SubnetMask0|255.255.255.0<br />&nbsp; gUefiPayloadPkgTok=
enSpaceGuid.PcdIp4Gateway0|192.168.1.1</div>
<div>&nbsp;</div>
<div>In the dec I added<br /><br />[PcdsFixedAtBuild]<br />&nbsp; gUefiPayl=
oadPkgTokenSpaceGuid.PcdIPv4Enable|TRUE|BOOLEAN|0x00000001<br />&nbsp; gUef=
iPayloadPkgTokenSpaceGuid.PcdDhcp|FALSE|BOOLEAN|0x00000002<br />&nbsp; gUef=
iPayloadPkgTokenSpaceGuid.PcdIp4Address0|192.168.1.5|VOID*|0x00000042<br />=
&nbsp; gUefiPayloadPkgTokenSpaceGuid.PcdIp4SubnetMask0|255.255.255.0|VOID*|=
0x00000043<br />&nbsp; gUefiPayloadPkgTokenSpaceGuid.PcdIp4Gateway0|192.168=
.1.1|VOID*|0x00000044</div>
<div>&nbsp;</div>
<div>This booted into UEFI shell, but didn't assign the IP address.&nbsp;</=
div>
<div>&nbsp;</div>
<div>I will have multiple interfaces i need to set static IP addresses to, =
but eth0 is of course the first :-)</div>
<div>&nbsp;</div>
<div>Any help gratefully received.<br /><br />Kind regards</div>
</div>
</div>


<div width=3D"1" style=3D"color:white;clear:both">_._,_._,_</div>
<hr>


Groups.io Links:<p>


 =20
    You receive all messages sent to this group.
 =20
 =20


<p>
<a target=3D"_blank" href=3D"https://edk2.groups.io/g/devel/message/120902"=
>View/Reply Online (#120902)</a> |


 =20

|

  <a target=3D"_blank" href=3D"https://groups.io/mt/110160546/7686176">Mute=
 This Topic</a>


| <a href=3D"https://edk2.groups.io/g/devel/post">New Topic</a>

<br>




<a href=3D"https://edk2.groups.io/g/devel/editsub/7686176">Your Subscriptio=
n</a> |
<a href=3D"mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href=3D"https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [rebecca@openfw.io]<br>
<div width=3D"1" style=3D"color:white;clear:both">_._,_._,_</div>


--vjaGgjQKeKGp0BzdFExD--