Re: [edk2] gST->ConOut is NULL and Timer issues (Was: RE: SerialPrint not working in DxeServicesLib.c)

Subject: Re: [edk2] gST->ConOut is NULL and Timer issues (Was: RE: SerialPrint not working in DxeServicesLib.c)

From: Andrew Fish <afish@apple.com>

To: Bhupesh Sharma <bhupesh.sharma@freescale.com>

Date: 2013-12-02 17:24:56


On Dec 2, 2013, at 3:08 AM, Bhupesh Sharma  wrote:

> Hi,
> 
> I managed to trace down the issues with my UEFI ported code for a Cortex-A9 MP core based SoC.
> 
> I see two issues (after solving a few on the way) on which I cannot seem to make any headway.
> 
> 1. gST->ConOut is NULL causing the Print routines inside StartDefaultBootOnTimeout 
>  (https://github.com/tianocore/edk2/blob/master/ArmPlatformPkg/Bds/Bds.c#L327), to not print
>  anything on the UART console.
> 
>  - At first, I suspected this to be an issue with my .dsc file as I don't have a LCD available on my SoC
>    and I had serial port as well as (a left over) LCD configured as SIMPLE TEXT protocols for ConOut.
>    I have hence changed my .dsc to something like:
> 
>  # Use the serial console for both ConIn & ConOut
>  gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();"
>  gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi()"
> 
>  However, still I see that gST->ConOut is NULL (via the DS-5 source debugger).

The console is platform policy and set by the BDS. To get prints out of early code you need to use the DebugLib DEBUG macro.  

> 
> 2. Timer support in UEFI:
> 
> - For every BoardPkg (e.g. ArmPlatformPkg/SP804, BeagleBoardPkg and Samsung etc), I can see that there are two Timer helper layers:
> 
> 	# [1] Timer Dxe Driver:
> 		https://github.com/tianocore/edk2/tree/master/ArmPlatformPkg/Drivers/SP804TimerDxe
> 
> 	# [2] Timer Lib:
> 		https://github.com/tianocore/edk2/tree/master/ArmPlatformPkg/Library/SP804TimerLib
> 
> 
> 	When I start to look at this code it seems that the UEFI code requires support for atleast 2 timers: Performance Timer (used in [1])
>      and another free SoC timer which is used to provide delays ([2]). 
> 
> 	Is this understanding correct? Does UEFI require atleast 2 timers to be supported by the SoC and are these timers used in parallel
> 	by the UEFI framework?
> 

No only the Timer DXE Driver timer is required. UEFI requires the support of timer based events. PI Implements this via the Timer Architecture Protocol https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Protocol/Timer.h

UEFI code should be using gBS->Stall() for delays and this is implemented via the Metronome Architectural Protocol https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Protocol/Metronome.h

For UEFI the Performance Lib is use for performance profiling, and this is edk2 implementation specific, and not required. 

If pre-UEFI code needs a calibrated delay it uses the TimerLib  https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/TimerLib.h

Thanks,

Andrew Fish


> Thanks for any pointers on the above two aspects.
> 
> Regards,
> Bhupesh
> 
> 
>> -----Original Message-----
>> From: Sharma Bhupesh-B45370
>> Sent: Tuesday, November 26, 2013 5:02 PM
>> To: Olivier Martin; 'Andrew Fish'; edk2-devel@lists.sourceforge.net
>> Cc: Kushwaha Prabhakar-B32579
>> Subject: RE: SerialPrint not working in DxeServicesLib.c
>> 
>> Hi Olivier,
>> 
>> Thanks for your mail.
>> 
>> I have a SerialPortLib which tries to configure Serial controller
>> specific to my board (so *no* 'SerialPortLib' pointing to
>> 'MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf'
>> in my DSC).
>> 
>> I am getting the UEFI firmware .. banner at the very start.
>> 
>> I will now try to add some SerialPortWrite() before calling
>> GetSectionFromAnyFv().
>> 
>> Regards,
>> Bhupesh
>> 
>> 
>>> -----Original Message-----
>>> From: Olivier Martin [mailto:olivier.martin@arm.com]
>>> Sent: Tuesday, November 26, 2013 4:27 PM
>>> To: Sharma Bhupesh-B45370; 'Andrew Fish'; edk2-
>>> devel@lists.sourceforge.net
>>> Cc: Kushwaha Prabhakar-B32579
>>> Subject: RE: SerialPrint not working in DxeServicesLib.c
>>> 
>>> Sorry to not reply earlier, I was on holiday in the last two weeks.
>>> 
>>> If you do not see any output from the serial, ensure your are using
>>> the appropriate 'SerialPortLib'.
>>> Check in your DSC file, there is no 'SerialPortLib' pointing to
>>> 'MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf'.
>>> Example:
>>> 
>>> [LibraryClasses.common]
>>>  (...)
>>> 
>>> SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNu
>>> SerialPortLib|ll
>>> SerialPortLib|.inf
>>>  (...)
>>> 
>>> SerialPortLib should use the implementation for your Serial controller.
>>> 
>>> Try also to add some SerialPortWrite() before calling
>>> GetSectionFromAnyFv().
>>> I would not be surprised if the crash happens much earlier than the
>>> DXE phase.
>>> 
>>> 
>>>> -----Original Message-----
>>>> From: Bhupesh Sharma [mailto:bhupesh.sharma@freescale.com]
>>>> Sent: 20 November 2013 11:50
>>>> To: 'Andrew Fish'; 'edk2-devel@lists.sourceforge.net'; Olivier
>>>> Martin
>>>> Cc: Prabhakar Kushwaha
>>>> Subject: RE: SerialPrint not working in DxeServicesLib.c
>>>> 
>>>> I don't know why but I didn't get any mail from the mail list server
>>>> for my original mail below, though I can see same in the mail list
>>>> archives.
>>>> 
>>>> Adding Andrew..
>>>> 
>>>> Can you guys please help me with the issue mentioned below.
>>>> 
>>>> Regards,
>>>> Bhupesh
>>>> 
>>>>> -----Original Message-----
>>>>> From: Sharma Bhupesh-B45370
>>>>> Sent: Tuesday, November 19, 2013 4:25 PM
>>>>> To: 'edk2-devel@lists.sourceforge.net'; 'Olivier Martin'
>>>>> Cc: 'boot-architecture@lists.linaro.org'; Kushwaha
>>>>> Prabhakar-B32579
>>>>> Subject: SerialPrint not working in DxeServicesLib.c
>>>>> 
>>>>> Hi List,
>>>>> 
>>>>> I am experiencing a Data Abort inside function
>> 'GetSectionFromAnyFv'
>>>> in
>>>>> file 'DxeServicesLib.c'
>>>>> on my ARMv7 UEFI platform.
>>>>> 
>>>>> To debug the same I added some print messages like:
>>>>> 
>>>>> /* Added for debugging */
>>>>>  CHAR8                         Buffer1[100];
>>>>>  UINTN                         CharCount;
>>>>>  CharCount = AsciiSPrint (Buffer1,sizeof (Buffer1),"Inside
>>>> Func\n\r");
>>>>>  SerialPortWrite ((UINT8 *) Buffer1, CharCount);
>>>>> 
>>>>> 
>>>>> And also something like:
>>>>>  SerialPrint ("Inside Func\n\r");
>>>>> 
>>>>> I have included:
>>>>> #include 
>>>>> #include 
>>>>> 
>>>>> and defined:
>>>>> 
>>>>> #define SerialPrint(txt)  SerialPortWrite ((UINT8*)(txt),
>>>>> AsciiStrLen(txt)+1);
>>>>> 
>>>>> I still cannot see any debug prints on the UART (placed right
>>>>> after
>>>> the
>>>>> entry point of 'GetSectionFromAnyFv' function).
>>>>> Debugger (DS-5) suggests that the crash is inside
>>>> 'GetSectionFromAnyFv'
>>>>> itself.
>>>>> 
>>>>> I get the UEFI firmware >>>> Abort Exception PC at xx prints on the console, but no prints from
>>>>> 'DxeServicesLib.c'
>>>>> 
>>>>> Any pointers to what I may be missing here.
>>>>> 
>>>>> Regards,
>>>>> Bhupesh
>>>> 
>>>> 
>>> 
>>> 
>>> 
>>> 
> 
> 


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel