From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 614D3740038 for ; 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" 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: Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: 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: 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 #include #include #include //#include #include //#include 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
Hi,

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;

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

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.

<= /div>
The current versions of EDK2 and Slimboot from = github I am using are listed below
 
EDK2 - d13f31c3fe17eb532bf9016a2d8de3885642cba0= (https://github.com/tianocore/edk2/tree/d13f31c3fe17eb532bf9016a2d8de38856= 42cba0) from September 30th (I tried a newer version, but got build errors)=  
Slimboot - ca00703127e34c84c3e6d3d129ebc5ef292b= a963 (https://github.com/slimbootloader/slimbootloader/tree/ca00703127e34c8= 4c3e6d3d129ebc5ef292ba963) from 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 <Proto= col/Ip4Config2.h>
//#include <Library/BaseMemoryLib.h>
#= include <Library/MemoryAllocationLib.h>
//#include <Library/P= rintLib.h>
EFI_STATUS
EFIAPI
StaticIpDriverEntryPoint (
  IN = EFI_HANDLE        ImageHandle,
  IN EFI_SYSTE= M_TABLE  *SystemTable
  )
{
  EFI_STATUS &nbs= p;               Status;
  EFI= _IP4_CONFIG2_PROTOCOL   *Ip4Config2;
  EFI_IP4_CONFIG2_MANUA= L_ADDRESS Address;
  EFI_HANDLE          = ;       *HandleBuffer;
  UINTN      = ;                HandleCount;
=   UINTN                  =    Index;
  // Print(L"GREG - Setting Static IP Address - Using StaticIpDri= verEntryPoint\n");
  DEBUG ((DEBUG_INFO, "GREG -  - Setting = Static IP Address - Using StaticIpDriverEntryPoint\n"));
  // Locate all handles that support the EFI_IP4_CONFIG2_PROTOCOL=
  Status =3D gBS->LocateHandleBuffer(ByProtocol, &gEfiIp4= Config2ProtocolGuid, NULL, &HandleCount, &HandleBuffer);
 = ; if (EFI_ERROR(Status)) {
    return Status;
  }<= /div>
  for (Index =3D 0; Index < HandleCount; Index++) {
 = ;   Status =3D gBS->HandleProtocol(HandleBuffer[Index], &gEfiIp= 4Config2ProtocolGuid, (VOID **)&Ip4Config2);
    if (EFI= _ERROR(Status)) {
      continue;
    }<= /div>
    // Set the manual IP address
    Address.= Address.Addr[0] =3D 192;
    Address.Address.Addr[1] =3D 168= ;
    Address.Address.Addr[2] =3D 1;
    Addr= ess.Address.Addr[3] =3D 5;
    Address.SubnetMask.Addr[0] = =3D 255;
    Address.SubnetMask.Addr[1] =3D 255;
 =   Address.SubnetMask.Addr[2] =3D 255;
    Address.Subn= etMask.Addr[3] =3D 0;
    
    Status = =3D Ip4Config2->SetData(Ip4Config2, Ip4Config2DataTypeManualAddress, siz= eof(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 NUL= L) {
    FreePool(HandleBuffer);
  }
  return Status;
}
//VOID
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
 = ; IN EFI_HANDLE        ImageHandle,
  IN EFI_= SYSTEM_TABLE  *SystemTable
  )
{
  EFI_STATUS=                 Status;
 = ; EFI_IP4_CONFIG2_PROTOCOL   *Ip4Config2;
  EFI_IP4_CONFIG2_= MANUAL_ADDRESS Address;
  EFI_HANDLE         =         *HandleBuffer;
  UINTN     =                  HandleCount;<= br />  UINTN                 &= nbsp;    Index;
//  Print(L"GREG - Setting Static IP Address - Using _ModuleEntry= Point\n");
  DEBUG ((DEBUG_INFO, "GREG -  - Setting Static I= P Address - Using _ModuleEntryPoint\n"));
  // Locate all handles that support the EFI_IP4_CONFIG2_PROTOCOL=
  Status =3D gBS->LocateHandleBuffer(ByProtocol, &gEfiIp4= Config2ProtocolGuid, NULL, &HandleCount, &HandleBuffer);
 = ; if (EFI_ERROR(Status)) {
    return Status;
  }<= /div>
  for (Index =3D 0; Index < HandleCount; Index++) {
 = ;   Status =3D gBS->HandleProtocol(HandleBuffer[Index], &gEfiIp= 4Config2ProtocolGuid, (VOID **)&Ip4Config2);
    if (EFI= _ERROR(Status)) {
      continue;
    }<= /div>
    // Set the manual IP address
    Address.= Address.Addr[0] =3D 192;
    Address.Address.Addr[1] =3D 168= ;
    Address.Address.Addr[2] =3D 1;
    Addr= ess.Address.Addr[3] =3D 100;
    Address.SubnetMask.Addr[0] = =3D 255;
    Address.SubnetMask.Addr[1] =3D 255;
 =   Address.SubnetMask.Addr[2] =3D 255;
    Address.Subn= etMask.Addr[3] =3D 0;
    Status =3D Ip4Config2->SetData(Ip4Config2, Ip4Config2= DataTypeManualAddress, sizeof(Address), &Address);
    i= f (EFI_ERROR(Status)) {
      continue;
  &nb= sp; }
    // 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 NUL= L) {
    FreePool(HandleBuffer);
  }
  return Status;
}

and INF File

[Defines]
  INF_VERSION           &= nbsp;        =3D 0x00010017
  BASE_NAME  = ;                    =3D = StaticIpConfigDxe
  FILE_GUID           =            =3D 7283e2fb-eeca-47d8-8576-5d5522= 5ec820
  MODULE_TYPE             &n= bsp;      =3D DXE_DRIVER
  VERSION_STRING   &= nbsp;             =3D 1.0
  ENTRY_P= OINT                    = =3D StaticIpDriverEntryPoint
[Sources]
  StaticIpConfigDxe.c
[Packages]
  MdePkg/MdePkg.dec
  MdeModulePkg/MdeM= odulePkg.dec
  UefiPayloadPkg/UefiPayloadPkg.dec
[LibraryClasses]
  UefiLib
  UefiBootServicesTable= Lib
  DebugLib
  MemoryAllocationLib
  PrintL= ib
[Protocols]
  gEfiIp4Config2ProtocolGuid
[Depex]
  gEfiIp4Config2ProtocolGuid


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.

I commented out the above entries and then modified sbl_0= 2\edk2\UefiPayloadPkg\UefiPayloadPkg.dsc and sbl_02\edk2\UefiPayloadPkg\Uef= iPayloadPkg.dec

I added into the dsc the following

&n= bsp; # Disable DHCP
  gUefiPayloadPkgTokenSpaceGuid.PcdIPv4Enable= |TRUE
  gUefiPayloadPkgTokenSpaceGuid.PcdDhcp|FALSE
 &n= bsp;
  # Static IP configuration for eth0
  gUefiPayloa= dPkgTokenSpaceGuid.PcdIp4Address0|192.168.1.5
  gUefiPayloadPkgTo= kenSpaceGuid.PcdIp4SubnetMask0|255.255.255.0
  gUefiPayloadPkgTok= enSpaceGuid.PcdIp4Gateway0|192.168.1.1
 
In the dec I added

[PcdsFixedAtBuild]
  gUefiPayl= oadPkgTokenSpaceGuid.PcdIPv4Enable|TRUE|BOOLEAN|0x00000001
  gUef= iPayloadPkgTokenSpaceGuid.PcdDhcp|FALSE|BOOLEAN|0x00000002
  gUef= iPayloadPkgTokenSpaceGuid.PcdIp4Address0|192.168.1.5|VOID*|0x00000042
=   gUefiPayloadPkgTokenSpaceGuid.PcdIp4SubnetMask0|255.255.255.0|VOID*|= 0x00000043
  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 eth0 is of course the first :-)
 
Any help gratefully received.

Kind regards
_._,_._,_

Groups.io Links:

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

View/Reply Online (#120902) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--vjaGgjQKeKGp0BzdFExD--