Discussion:
[edk2] USB3 driver development setup suggestions.
Eric Wittmayer
2015-06-13 16:38:36 UTC
Permalink
Hello EDK developers,
I'm looking for suggestions on the easiest development setup for a USB 3
device Dxe driver. Ideally, I'd prefer a virtualized on a windows host that
lets me pass through the USB3 device to the UEFI guest.
I have been using Duet and can build and run a basic driver that will start
on my device. I haven't been able to get debug output using the DEBUG macro
from my driver. I check DebugPrintEnabled ( ) and DebugCodeEnabled ( ) in
my driver and I can see they are both enabled so I'm not sure why I don't
see output from DEBUG.
I would also like to see the debug output from the USB stack. Is that
possible with Duet?

Thanks,
Eric


------------------------------------------------------------------------------
Andrew Fish
2015-06-13 17:17:38 UTC
Permalink
Post by Eric Wittmayer
Hello EDK developers,
I'm looking for suggestions on the easiest development setup for a USB 3
device Dxe driver. Ideally, I'd prefer a virtualized on a windows host that
lets me pass through the USB3 device to the UEFI guest.
I have been using Duet and can build and run a basic driver that will start
on my device. I haven't been able to get debug output using the DEBUG macro
from my driver. I check DebugPrintEnabled ( ) and DebugCodeEnabled ( ) in
my driver and I can see they are both enabled so I'm not sure why I don't
see output from DEBUG.
I would also like to see the debug output from the USB stack. Is that
possible with Duet?
Eric,

I’m not sure what Duet does? But if you add the -y build.log (or --report-file=build.log) to the build command the log file will show you what instance of the DebugLib is in use. You can also see the PCD settings, and other useful information about all the drivers.

Thanks,

Andrew Fish
Post by Eric Wittmayer
Thanks,
Eric
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Eric Wittmayer
2015-06-14 19:48:16 UTC
Permalink
Post by Eric Wittmayer
Hello EDK developers,
I'm looking for suggestions on the easiest development setup for a USB
3
Post by Eric Wittmayer
device Dxe driver. Ideally, I'd prefer a virtualized on a windows host
that
Post by Eric Wittmayer
lets me pass through the USB3 device to the UEFI guest.
I have been using Duet and can build and run a basic driver that will
start
Post by Eric Wittmayer
on my device. I haven't been able to get debug output using the DEBUG
macro
Post by Eric Wittmayer
from my driver. I check DebugPrintEnabled ( ) and DebugCodeEnabled ( )
in
Post by Eric Wittmayer
my driver and I can see they are both enabled so I'm not sure why I don't
see output from DEBUG.
I would also like to see the debug output from the USB stack. Is that
possible with Duet?
Eric,
I?m not sure what Duet does? But if you add the -y build.log (or
--report-file=build.log) to the build command the log file will show you
what instance of the DebugLib is in use. You can also see the PCD settings,
and other useful information about all the drivers.

Andrew,
here is the build report for my driver. Is the default target for debug
output the serial port or the console and how do I change it?

Thanks,
Eric
===========================================================================
===========================================<
Module Summary
Module Name: FOneDxe
Module INF Path: FOneDxe\FOneDxe.inf
File GUID: b336c0c0-0ea9-11e5-af3c-74d435885aa3
Size: 0x42A0 (16.66K)
Build Time Stamp: 1969-12-31 16:00:00
Driver Type: 0x7 (DRIVER)
============================================================================
============================================
---------------------------------------------------------------------------
-------------------------------------------<
PCD
----------------------------------------------------------------------------
--------------------------------------------
gEfiMdePkgTokenSpaceGuid
PcdVerifyNodeInList : FLAG (BOOLEAN) = 0

PcdDriverDiagnosticsDisable : FLAG (BOOLEAN) = 0

PcdComponentNameDisable : FLAG (BOOLEAN) = 0

PcdDriverDiagnostics2Disable : FLAG (BOOLEAN) = 0

PcdComponentName2Disable : FLAG (BOOLEAN) = 0

PcdUgaConsumeSupport : FLAG (BOOLEAN) = 1

PcdMaximumDevicePathNodeCount : FIXED (UINT32) = 0

*P PcdDebugPrintErrorLevel : FIXED (UINT32) =
0x900805C3
DEC DEFAULT =
0x80000000
PcdDebugClearMemoryValue : FIXED (UINT8) = 0xAF

*P PcdDebugPropertyMask : FIXED (UINT8) = 0x7

DEC DEFAULT = 0
PcdFixedDebugPrintErrorLevel : FIXED (UINT32) =
0xFFFFFFFF
*P PcdReportStatusCodePropertyMask : FIXED (UINT8) = 0x7

DEC DEFAULT = 0
PcdMaximumLinkedListLength : FIXED (UINT32) =
1000000
PcdMaximumAsciiStringLength : FIXED (UINT32) =
1000000
PcdMaximumUnicodeStringLength : FIXED (UINT32) =
1000000
PcdUefiLibMaxPrintBufferSize : FIXED (UINT32) = 320

<---------------------------------------------------------------------------
------------------------------------------->
---------------------------------------------------------------------------
-------------------------------------------<
Library
----------------------------------------------------------------------------
--------------------------------------------
c:\src\uefi\edk2\MdePkg\Library\BasePrintLib\BasePrintLib.inf
{PrintLib}
c:\src\uefi\edk2\MdePkg\Library\BaseDebugPrintErrorLevelLib\BaseDebugPrintEr
rorLevelLib.inf
{DebugPrintErrorLevelLib}
c:\src\uefi\edk2\MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatus
CodeLib.inf
{ReportStatusCodeLib}
c:\src\uefi\edk2\MdePkg\Library\BasePcdLibNull\BasePcdLibNull.inf
{PcdLib}
c:\src\uefi\edk2\IntelFrameworkModulePkg\Library\PeiDxeDebugLibReportStatusC
ode\PeiDxeDebugLibReportStatusCode.inf
{DebugLib}
c:\src\uefi\edk2\MdePkg\Library\UefiDevicePathLib\UefiDevicePathLib.inf
{DevicePathLib}
c:\src\uefi\edk2\MdePkg\Library\BaseLib\BaseLib.inf
{BaseLib}
c:\src\uefi\edk2\MdePkg\Library\BaseMemoryLib\BaseMemoryLib.inf
{BaseMemoryLib}
c:\src\uefi\edk2\MdePkg\Library\UefiMemoryAllocationLib\UefiMemoryAllocation
Lib.inf
{MemoryAllocationLib}
c:\src\uefi\edk2\MdePkg\Library\UefiBootServicesTableLib\UefiBootServicesTab
leLib.inf
{UefiBootServicesTableLib: C = UefiBootServicesTableLibConstructor}
c:\src\uefi\edk2\MdePkg\Library\UefiRuntimeServicesTableLib\UefiRuntimeServi
cesTableLib.inf
{UefiRuntimeServicesTableLib: C = UefiRuntimeServicesTableLibConstructor}
c:\src\uefi\edk2\MdePkg\Library\UefiDriverEntryPoint\UefiDriverEntryPoint.in
f
{UefiDriverEntryPoint: Depex = gEfiBdsArchProtocolGuid AND
gEfiCpuArchProtocolGuid AND gEfiMetronomeArchProtocolGuid
AND gEfiMonotonicCounterArchProtocolGuid AND
gEfiRealTimeClockArchProtocolGuid AND gEfiResetArchProtocolGuid AND
gEfiRuntimeArchProtocolGuid AND gEfiSecurityArchProtocolGuid AND
gEfiTimerArchProtocolGuid AND
gEfiVariableWriteArchProtocolGuid AND gEfiVariableArchProtocolGuid AND
gEfiWatchdogTimerArchProtocolGuid }
c:\src\uefi\edk2\MdePkg\Library\UefiLib\UefiLib.inf
{UefiLib: C = UefiLibConstructor}
<---------------------------------------------------------------------------
------------------------------------------->


------------------------------------------------------------------------------
Andrew Fish
2015-06-14 22:48:34 UTC
Permalink
Post by Eric Wittmayer
c:\src\uefi\edk2\IntelFrameworkModulePkg\Library\PeiDxeDebugLibReportStatusC
ode\PeiDxeDebugLibReportStatusCode.inf
{DebugLib}
c:\src\uefi\edk2\IntelFrameworkModulePkg\Library\PeiDxeDebugLibReportStatusC
ode\PeiDxeDebugLibReportStatusCode.inf
{DebugLib}

The mapping of your DebugLib instance comes from your .DSC file. You could try one of the other DebugLib instances, like the SerialPort, StdErr, or ConOut.

~/work/src/edk2(master)>git grep -e "DebugLib" --and -e "LIBRARY_CLASS"
ArmPkg/Library/SemiHostingDebugLib/SemiHostingDebugLib.inf:24: LIBRARY_CLASS = DebugLib|BASE SEC DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf:24: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE PEIM SEC PEI_CORE UEFI_APPLICATION UEFI_DRIVER
IntelFspPkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.inf:21: LIBRARY_CLASS = DebugLib
MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf:24: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE PEIM SEC PEI_CORE UEFI_APPLICATION UEFI_DRIVER
MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf:23: LIBRARY_CLASS = DebugLib
MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf:24: LIBRARY_CLASS = DebugLib
MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf:25: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf:25: LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf:24: LIBRARY_CLASS = DebugLib

Thanks,

Andrew Fish
Eric Wittmayer
2015-06-16 06:37:49 UTC
Permalink
Post by Andrew Fish
Post by Eric Wittmayer
c:\src\uefi\edk2\IntelFrameworkModulePkg\Library\PeiDxeDebugLibReportStatu
sC
Post by Andrew Fish
Post by Eric Wittmayer
ode\PeiDxeDebugLibReportStatusCode.inf
{DebugLib}
c:\src\uefi\edk2\IntelFrameworkModulePkg\Library\PeiDxeDebugLibReportStatu
sC
Post by Andrew Fish
Post by Eric Wittmayer
ode\PeiDxeDebugLibReportStatusCode.inf
{DebugLib}
The mapping of your DebugLib instance comes from your .DSC file. You could
try one of the other DebugLib instances, like the SerialPort, StdErr, or
ConOut.
Andrew,
The different mappings was the bit of understanding I was lacking. Now I
can get debug output from my driver over serialo.
Thanks,
Eric


------------------------------------------------------------------------------
Scott Duplichan
2015-06-15 05:20:13 UTC
Permalink
Eric Wittmayer [mailto:***@frescologic.com] wrote:

]Sent: Saturday, June 13, 2015 11:39 AM
]To: edk2-***@lists.sourceforge.net
]Subject: [edk2] USB3 driver development setup suggestions.
]
]Hello EDK developers,
] I'm looking for suggestions on the easiest development setup for a USB 3
]device Dxe driver. Ideally, I'd prefer a virtualized on a windows host that
]lets me pass through the USB3 device to the UEFI guest.
]I have been using Duet and can build and run a basic driver that will start
]on my device. I haven't been able to get debug output using the DEBUG macro
]from my driver. I check DebugPrintEnabled ( ) and DebugCodeEnabled ( ) in
]my driver and I can see they are both enabled so I'm not sure why I don't
]see output from DEBUG.
]I would also like to see the debug output from the USB stack. Is that
]possible with Duet?
]
]Thanks,
]Eric

For USB, I don't know of a good substitute for debugging on real hardware.
But the good news is that the Duet DEBUG() print macro can be made to work.
The DEBUG() output code was removed to reduce code size. Duet code size is
limited because it uses the MS-DOS 640KB low memory area as a temporary
buffer during boot.

Testing with today's EDK2 trunk (SVN rev 17629) shows that debug output such
as DEBUG (( EFI_D_INFO, "xxx\n")) is not generating any code. Here is one
way to make it work:
1) DuetPkgX64.dsc:
a) replace DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
with DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
b) replace gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x0
with gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|6
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
I removed the DxeMain.inf overrides for these 3 items so that uniform
values are used through the project.
2) DuetPkg.fdf: Comment out non-essential items to avoid a memory size related
build fail caused by change #1. Standard Duet uses the MS-DOS 640KB low
memory area as a temporary buffer, so code size increases have to be
countered with code size reductions elsewhere.

There is a Windows utility for making a Duet FAT image here:
http://notabs.org/uefi/Edk2DuetBoot.htm
The utility generates the image directly without writing to a physical
drive, so it can streamline the Duet build process.

Thanks,
Scott




------------------------------------------------------------------------------
Eric Wittmayer
2015-06-16 06:47:04 UTC
Permalink
Date: Mon, 15 Jun 2015 00:20:13 -0500
Subject: Re: [edk2] USB3 driver development setup suggestions.
Content-Type: text/plain; charset="utf-8"
]Sent: Saturday, June 13, 2015 11:39 AM
]Subject: [edk2] USB3 driver development setup suggestions.
]
]Hello EDK developers,
] I'm looking for suggestions on the easiest development setup for a USB
3
]device Dxe driver. Ideally, I'd prefer a virtualized on a windows host
that ]lets me pass through the USB3 device to the UEFI guest.
]I have been using Duet and can build and run a basic driver that will
start ]on my device. I haven't been able to get debug output using the
DEBUG macro ]from my driver. I check DebugPrintEnabled ( ) and
DebugCodeEnabled ( ) in ]my driver and I can see they are both enabled so
I'm not sure why I don't ]see output from DEBUG.
]I would also like to see the debug output from the USB stack. Is that
]possible with Duet?
]
]Thanks,
]Eric
For USB, I don't know of a good substitute for debugging on real hardware.
But the good news is that the Duet DEBUG() print macro can be made to work.
The DEBUG() output code was removed to reduce code size. Duet code size is
limited because it uses the MS-DOS 640KB low memory area as a temporary
buffer during boot.
Testing with today's EDK2 trunk (SVN rev 17629) shows that debug output
such as DEBUG (( EFI_D_INFO, "xxx\n")) is not generating any code. Here is
a) replace DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
with
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
b) replace gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x0
with gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|6
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
I removed the DxeMain.inf overrides for these 3 items so that uniform
values are used through the project.
2) DuetPkg.fdf: Comment out non-essential items to avoid a memory size
related
build fail caused by change #1. Standard Duet uses the MS-DOS 640KB low
memory area as a temporary buffer, so code size increases have to be
countered with code size reductions elsewhere.
http://notabs.org/uefi/Edk2DuetBoot.htm
The utility generates the image directly without writing to a physical
drive, so it can streamline the Duet build process.
Thanks,
Scott
Scott,
Thanks for the info on getting the debug output from the duet build and on
the dev environment. Am I correct that if I am able to build Duet and boot
it from the bios on a real machine it should use the USB stack from my duet
build and not from the underlying UEFI build that is in the system rom?

Regards,
Eric


------------------------------------------------------------------------------
Continue reading on narkive:
Loading...