Marginality with UFS chip change?



I got a batch of Hikey960 boards which I’m almost unable to reflash properly.

I’m using

to rebuild edk2/atf/l-loader etc.

It looks like the trigger is change in UFS chip. With older boards using chip marked “KLU8G…” (Samsung?) everything works like a charm using tools-image-hikey960 script then flashing l-loader’s ptable-aosp-32g.img, l-loader.bin, fip.bin.

Now with boards using chips marked “THGBF…” (Toshiba?), I get issues flashing ptable, or board not booting after BL2 stage such as:

when flashing ptable
Downloading 24576 bytes
24576 / 24576 bytes downloaded (100%)
Flashing partition ptable

Synchronous Exception at 0x0000000000000000

or later when booting:

NOTICE: BL2: Built : 13:46:43, Mar 29 2018
INFO: BL2: Doing platform setup
INFO: UFS LUN0 contains 1024 blocks with 4096-byte size
INFO: UFS LUN1 contains 1024 blocks with 4096-byte size
INFO: UFS LUN2 contains 2048 blocks with 4096-byte size
INFO: UFS LUN3 contains 7805952 blocks with 4096-byte size
INFO: ufs: change power mode success
INFO: BL2: Loading image id 2
WARNING: Firmware Image Package header check failed.
WARNING: Failed to obtain reference to image id=2 (-2)
ERROR: BL2: Failed to load image (-2)

Do you know about flashing issues after switching to this UFS chip and how to stabilize it?

Thanks and Regards.


When did you last pull the tools? Does your tree have:


Thanks for your reply.
Yes I have this patch when flashing with tools-image-hikey960 scripts, and indeed this way of recovery always work even on fresh boards.

Moving forward I wonder if this fix related to UFS init might be present in ATF where UFS chip is accessed (e.g. from BL2 to load subsequent images).
That’s where it seems I enter into trouble when rebuilding ATF from scratch… BL2 is not able to init properly and does not load further images ?..

Thanks & Regards.


Let me forward your question to HiSilicon. I’ll come back to you as soon as I got formal response. At the same time, would you mind to tell me the exact string on UFS “THGBF…”, and the number of boards you have with these THG UFS?

So far, I’m not aware of such UFS.


And please confirm one thing: the problem happens with ATF/UEFI only, and doesn’t happen when using the hisi bootloader ( Correct?



Thanks for your reply.

I can confirm the number by tomorrow; this is from a batch of ~15 boards purchased within the last few weeks.

Best Regards.



Yes exactly. No issue with the tools-image-hikey960 repository scripts.
I can flash the “faulty” boards without issue.

But for our own purposes, we need to rebuild ATF/edk2 from scratch.
Then trouble happens with those new boards after flashing the generated aosp ptable, fastboot image (l-loader.bin) then fip.bin. After reboot, it generally hangs around BL2 loader with:

ERROR: BL2: Failed to load image (-2)

So it made me think that the UFS device is not properly initialized and that BL2 is unable to load further images …

Best Regards.


Thanks, @baru for pointing out this issue. We can reproduce it. Linaro and HiSilicon are now working for a solution. Will update you soon.


Thanks for confirming and looking into it!!


to follow up on this thread

boards with the new UFS chip are recovered from edk2 fix:

reference build:


Awesome. Thanks for the update!


the reference build is not available anymore I tried the build:
but still have the same issue, i checked the source:

and the delay is not present. Was the delay implemented in master?




I must tell I think the issue is not totally gone. I got better results per latest fix but I still have 3 boards (out of 12) showing the issue consistently.

So I guess we should kindly highlight it to Huawei/Linaro folks to have a look at it again.



Hi @baou,
i agree with you, today I tested the build with the patch to be sure the edk2 fix was in and the boot is still failing.

Hi @guodong could you please follow up?



branch name is:


@hzhuang1 Please follow up this with HiSilicon.