All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: Xilinx ZynqMP SPL boot: psu_init_gpl.c code corrupts U-Boot memory
Date: Mon, 1 Feb 2021 08:52:24 +0100	[thread overview]
Message-ID: <d5b0085c-739b-6525-6c13-60f5262ae108@xilinx.com> (raw)
In-Reply-To: <fca1cb68-a3ca-cc9e-9163-f1715f9535b4@gmail.com>

Hi,

On 1/30/21 5:52 AM, Sean Anderson wrote:
> On 1/21/21 3:41 AM, Michal Simek wrote:
>> Hi,
>>
>> On 1/20/21 9:25 PM, Robert Hancock wrote:
>>> I've been trying to get the U-Boot SPL to work on a Xilinx ZCU102
>>> development board. I have been testing with U-Boot 2021.01, and using
>>> the generated psu_init_gpl HW initialization code generated by Vivado
>>> 2020.2, rather than the versions in the U-Boot tree, as we are
>>> expecting to make changes to the configuration as we move to our own
>>> board design.
>>>
>>> The issue I was seeing is that the SPL seemingly locking up or crashing
>>> early in the boot process, just after the SPL banner was printed. I've
>>> CCed "Major A" as he reported something similar on the mailing list in
>>> March ('ZynqMP boot: no messages from SPL other than "Debug uart
>>> enabled"') but I didn't see a resoution posted.
>>>
>>> After groveling around with the Xilinx JTAG debugger for a day or so, I
>>> figured out that the problem was that the SPL ended up reading from an
>>> invalid pointer address somewhere during the driver model
>>> initialization process, and crashing. After using memory watchpoints to
>>> identify where the bogus value was being written to the pointer storage
>>> location, the memory write was actually coming from the Vivado 2020.2-
>>> generated psu_init_gpl code. The offending code is in a function called
>>> serdes_illcalib_pcie_gen1 and looks like this:
>>>
>>> ?????????? if (gen2_calib != 1)
>>> ?????????? {
>>> ???????????? ill1_val[loop] = ((0x04 + meancount[loop]*8) % 0x100);
>>> ???????????? ill12_val[loop] = ((0x04 + meancount[loop]*8) >= 0x100) ?
>>> 0x10 : 0x00;
>>> ???????????? Xil_Out32(0xFFFE0000+loop*4,iterresult[loop]);
>>> ???????????? Xil_Out32(0xFFFE0010+loop*4,iterresult[loop+4]);
>>> ???????????? Xil_Out32(0xFFFE0020+loop*4,bistpasscount[loop]);
>>> ???????????? Xil_Out32(0xFFFE0030+loop*4,meancount[loop]);
>>> ?????????? }
>>> ?????????? if (gen2_calib == 1)
>>> ?????????? {
>>> ???????????? ill1_val[loop] = ((0x104 + meancount[loop]*8) % 0x100);
>>> ???????????? ill12_val[loop] = ((0x104 + meancount[loop]*8) >= 0x200) ?
>>> 0x02 : 0x01;
>>> ???????????? Xil_Out32(0xFFFE0040+loop*4,iterresult[loop]);
>>> ???????????? Xil_Out32(0xFFFE0050+loop*4,iterresult[loop+4]);
>>> ???????????? Xil_Out32(0xFFFE0060+loop*4,bistpasscount[loop]);
>>> ???????????? Xil_Out32(0xFFFE0070+loop*4,meancount[loop]);
>>> ?????????? }
>>>
>>> Those writes to 0xFFFExxxx are to on-chip memory addresses, not any
>>> hardware register, so I have no idea what this is trying to achieve.
>>> Possibly this is some debug code to store some calibration results that
>>> was left in by mistake? Those addresses may not be used in the Xilinx
>>> FSBL, but overwriting them in the U-Boot SPL wreaks havoc.
>>>
>>> For now, I've worked around it by hacking the Xil_Out32 implementation
>>> provided by U-Boot in board/xilinx/zynqmp/xil_io.h to trap and ignore
>>> writes to memory addresses in the OCRAM range (0xFFFC0000 to
>>> 0xFFFFFFFF). With that in place, things seem to be working. Probably
>>> this should be addressed in the Vivado psu_init code generator, but we
>>> may need some workaround like this to avoid those using the affected
>>> Xilinx tool versions from hitting this issue?
>>>
>>
>> I can't see any code like this in u-boot code. I can't see context of
>> this code that's why simply don't know what it does and why.
> 
> I believe it's to fix [1]. See [2] for other people with this problem.
> I'm not sure what Xilinx's stance on this behavior is.
> 
> --Sean
> 
> [1] https://www.xilinx.com/support/answers/72992.html
> [2]
> https://forums.xilinx.com/t5/Embedded-Development-Tools/Custom-zcu102-2020-1-SATA-link-down-SStatus-1-SControl-330/td-p/1143816
> 

I have let support team know about this but this is topic out of u-boot
mailing list because we simply don't have any code like this in the repo.
And it is just showing good decision to store psu_inits in u-boot repo
not to relay on specific design tool version.

Thanks,
Michal

      reply	other threads:[~2021-02-01  7:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 20:25 Xilinx ZynqMP SPL boot: psu_init_gpl.c code corrupts U-Boot memory Robert Hancock
2021-01-21  8:41 ` Michal Simek
2021-01-21 16:40   ` Robert Hancock
2021-01-30  0:39     ` Robert Hancock
2021-01-30  4:52   ` Sean Anderson
2021-02-01  7:52     ` Michal Simek [this message]

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-all 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=d5b0085c-739b-6525-6c13-60f5262ae108@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.