imx8qxpmek: spi does not work on sd card boot

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx8qxpmek: spi does not work on sd card boot

2,771 Views
heikoschocher
Contributor II

Hi all,

I have an imx8qxpmek board developer kit and boot with sd card bootmode and the delivered sd card into U-Boot (or linux), and spi access works fine, see[1].

Now I builded the sd card image from the sources with:

$ repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-thud -m imx-4.19.35-1.0.0.xml

$ repo sync

$ DISTRO=fsl-imx-xwayland MACHINE=imx8qxpmek source fsl-setup-release.sh -b build-xwayland

[...]
$ bitbake fsl-image-qt5-validation-imx

and boot this image, but sf probe fails, see [2]. Building the spi image (with setting UBOOT_CONFIG = "fspi") from this source code and burning this image into SPI NOR (luckily this works with the original sd card) and booting the board with bootmode SPI results in working U-Boot with SPI NOR access [3]. Also linux boots and detect the SPI NOR now.

Ok, there are different U-Boot versions, also (and I think more important) other scfw firmware verions.

The U-Boot error log shows:

lsio_fspi0 [237] not owned by curr partition
sc_pm_set_resource_power_mode: resource:237 mode:3: res:4
Error: lsio_fspi0 Power up failed! (error = 243)

which means:

resource

#define SC_R_FSPI_0 237

and errorcode 4 = SC_ERR_NOACCESS

Ok, so I think I have to adapt the scfw ... but I am totally new to imx8 ... and I just wonder why with newer source SPI access does not work from sd card boot. Any reason for disabling this?

Remark: I downloaded the scfw porting kit:
https://www.nxp.com/webapp/Download?colCode=L4.19.35_1.1.0_SCFWKIT-1.2.7.1&appType=license&location=...

builded it and added the image successfully to the yocto build, but same result.

Any ideas, help, hint, where I have to tweak the source to get SPI NOR on sd card boot working again?

Thanks!

bye,

Heiko

[1] sd card bootlog with original sd card image

U-Boot 2017.03-imx_v2017.03_4.9.88_imx8qxp_beta2+g84c4e82 (Jun 28 2018 - 09:07:20 +0800)
 
CPU:   Freescale i.MX8QXP revB A35 at 1200 MHz at 17C
Model: Freescale i.MX8QXP MEK
Board: iMX8QXP MEK
Boot:  SD1
DRAM:  3 GiB
TCPC:  Vendor ID [0x1fc9], Product ID [0x5110]
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
[pcie_ctrlb_sata_phy_init_rc] LNK DOWN 8600000
In:    serial
Out:   serial
Err:   serial
 
BuildInfo:
  - SCFW 3301c1a9, SECO-FW eeb55e1e, IMX-MKIMAGE 5c18f544, ATF 00b653e
   - U-Boot 2017.03-imx_v2017.03_4.9.88_imx8qxp_beta2+g84c4e82
 
switch to partitions #0, OK
mmc1 is current device
Net:   eth0: ethernet@5b040000 [PRIME]
Warning: ethernet@5b050000 (eth1) using random MAC address - 9e:97:b2:b1:f1:c7
, eth1: ethernet@5b050000
Normal Boot
Hit any key to stop autoboot:  0
=>
 
=>

=> sf probe
SF: Detected mt35xu512aba with page size 256 Bytes, erase size 128 KiB, total 64 MiB
=>

[2] sd card bootlog with thud branch builded sources:
U-Boot 2019.04-imx_v2019.04_4.19.35_1.0.0+g85bdcc7 (Dec 11 2019 - 11:59:46 +0000)

CPU:   NXP i.MX8QXP RevB A35 at 1200 MHz at 19C

Model: Freescale i.MX8QXP MEK
Board: iMX8QXP MEK
Boot:  SD1
DRAM:  2.8 GiB
VService: Connection is ok on MU mu@5d230000
TCPC:  Vendor ID [0x1fc9], Product ID [0x5110], Addr [I2C1 0x50]
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... Run CMD11 1.8V switch
*** Warning - bad CRC, using default environment

[pcie_ctrlb_sata_phy_init_rc] LNK DOWN 8600000
In:    serial
Out:   serial
Err:   serial

 BuildInfo:
  - SCFW 4e91f37b, SECO-FW d7523fe8, IMX-MKIMAGE 2a3ec5e2, ATF f92d379
  - U-Boot 2019.04-imx_v2019.04_4.19.35_1.0.0+g85bdcc7

Run CMD11 1.8V switch
switch to partitions #0, OK
mmc1 is current device
flash target is MMC:1
Run CMD11 1.8V switch
Net:   
Warning: ethernet@5b040000 using MAC address from ROM
eth0: ethernet@5b040000 [PRIME]
Warning: ethernet@5b050000 (eth1) using random MAC address - 8e:57:bf:a1:d5:be
, eth1: ethernet@5b050000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
=> sf probe
lsio_fspi0 [237] not owned by curr partition
sc_pm_set_resource_power_mode: resource:237 mode:3: res:4
Error: lsio_fspi0 Power up failed! (error = 243)
Invalid bus 0 (err=-5)
Failed to initialize SPI flash at 0:0 (error -5)
=>

[3] spi bootmode with spi image created from imx-linux-thud -m branch

U-Boot SPL 2019.04-imx_v2019.04_4.19.35_1.0.0+g85bdcc7981 (Dec 05 2019 - 06:54:18 +0000)
Normal Boot
Trying to boot from SPI
Load image from QSPI 0x48000
U

U-Boot 2019.04-imx_v2019.04_4.19.35_1.0.0+g85bdcc7981 (Dec 05 2019 - 06:54:18 +0000)

CPU:   NXP i.MX8QXP RevB A35 at 1200 MHz at 20C

Model: Freescale i.MX8QXP MEK
Board: iMX8QXP MEK
Boot:  FLEXSPI
DRAM:  3 GiB
TCPC:  Vendor ID [0x1fc9], Product ID [0x5110], Addr [I2C1 0x50]
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... Run CMD11 1.8V switch
*** Warning - bad CRC, using default environment

[pcie_ctrlb_sata_phy_init_rc] LNK DOWN 8600000
In:    serial
Out:   serial
Err:   serial

 BuildInfo:
  - SCFW cb6f758b, SECO-FW d7523fe8, IMX-MKIMAGE 2a3ec5e2, ATF f92d379
  - U-Boot 2019.04-imx_v2019.04_4.19.35_1.0.0+g85bdcc7981

Run CMD11 1.8V switch
switch to partitions #0, OK
mmc1 is current device
Net:   
Warning: ethernet@5b040000 using MAC address from ROM
eth0: ethernet@5b040000 [PRIME]
Warning: ethernet@5b050000 (eth1) using random MAC address - ba:99:1a:4a:4d:9d
, eth1: ethernet@5b050000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
=>

Tags (1)
8 Replies

1,802 Views
alexlu6
Contributor I

I still has this problem (lsio_fspi0[237] not owned by the curr partition) when using Linux 5.10.9 version from building Yocto .

Can anyone help ?

Alex Lu

0 Kudos

2,212 Views
山水之间
Contributor II

Hi Heiko,

   Have you solved this problem?I'm having the same problem as you。

pastedImage_1.png

0 Kudos

2,212 Views
heikoschocher
Contributor II

Hi Hagen,

it seems to me it is a problem with scfw firmware ...

I added to "imx-scfw-porting-kit-1.2.7.1" the following 2 patches (Sorry do not know how to add here files)

hs@xmglap:scfw_export_mx8qx_b0 [master] $ cat 0001-spi.patch
From ed274d498488417615ce7a39156000fd70457ce7 Mon Sep 17 00:00:00 2001
From: Heiko Schocher <hs@denx.de>
Date: Wed, 18 Dec 2019 11:05:30 +0100
Subject: [PATCH] platform/board/mx8qx_mek/board.c: get SPI flash working

remove some code to get SPI flash working.

Signed-off-by: Heiko Schocher <hs@denx.de>

diff --git a/platform/board/mx8qx_mek/board.c b/platform/board/mx8qx_mek/board.c
index d0a6b4e..8f40f28 100755
--- a/platform/board/mx8qx_mek/board.c
+++ b/platform/board/mx8qx_mek/board.c
@@ -721,8 +721,17 @@ sc_err_t board_system_config(sc_bool_t early, sc_rm_pt_t pt_boot)
SC_R_CAN_2, SC_TRUE));
BRD_ERR(rm_set_resource_movable(pt_boot, SC_R_I2C_1,
SC_R_I2C_1, SC_TRUE));
+#if 0
+ /*
+ * without this code I see now in U-Boot:
+ * => sf probe
+ * unrecognized JEDEC id bytes: 00, 00, 00
+ * Failed to initialize SPI flash at 0:0 (error -2)
+ * =>
+ */
BRD_ERR(rm_set_resource_movable(pt_boot, SC_R_FSPI_0,
SC_R_FSPI_0, SC_TRUE));
+#endif

/* Move some pads not in the M4_0 subsystem */
BRD_ERR(rm_set_pad_movable(pt_boot, SC_P_FLEXCAN0_RX,
@@ -731,8 +740,16 @@ sc_err_t board_system_config(sc_bool_t early, sc_rm_pt_t pt_boot)
SC_P_USB_SS3_TC1, SC_TRUE));
BRD_ERR(rm_set_pad_movable(pt_boot,SC_P_USB_SS3_TC3,
SC_P_USB_SS3_TC3, SC_TRUE));
+#if 0
+ /*
+ * and without this code:
+ * => sf probe
+ * SF: Detected mt35xu512aba with page size 256 Bytes, erase size 128 KiB, total 64 MiB
+ * =>
+ */
BRD_ERR(rm_set_pad_movable(pt_boot, SC_P_QSPI0A_DATA0,
SC_P_COMP_CTL_GPIO_1V8_3V3_QSPI0B, SC_TRUE));
+#endif

/* Move everything flagged as movable */
BRD_ERR(rm_move_all(pt_boot, pt_boot, pt_m4_0, SC_TRUE,

and

hs@xmglap:scfw_export_mx8qx_b0  [master] $ cat 0002-spi.patch
From cccbf78ed6800a54c073ae0411069ed54ff49bf7 Mon Sep 17 00:00:00 2001
From: Heiko Schocher <hs@denx.de>
Date: Wed, 18 Dec 2019 12:32:14 +0100
Subject: [PATCH] platform/board/mx8qx_mek/board.c: fix sf read with sizes >
 0x80000

without this code, sf read with sizes > 0x80000 works.

Signed-off-by: Heiko Schocher <hs@denx.de>

diff --git a/platform/board/mx8qx_mek/board.c b/platform/board/mx8qx_mek/board.c
index 8f40f28..b21ab76 100755
--- a/platform/board/mx8qx_mek/board.c
+++ b/platform/board/mx8qx_mek/board.c
@@ -769,10 +769,15 @@ sc_err_t board_system_config(sc_bool_t early, sc_rm_pt_t pt_boot)
             0x088000000ULL, 0x08FFFFFFFULL));
         BRD_ERR(rm_assign_memreg(pt_boot, pt_m4_0, mr_m4_0));
 
+#if 0
+       /*
+        * without this code, sf read works with sizes > 0x80000
+        */
         /* Reserve FlexSPI for M4_0 */
         BRD_ERR(rm_memreg_frag(pt_boot, &mr_m4_0, 0x08081000ULL,
             0x08180FFFULL));
         BRD_ERR(rm_assign_memreg(pt_boot, pt_m4_0, mr_m4_0));
+#endif
 
         /* Allow AP and M4_1 to use SYSTEM */
         BRD_ERR(rm_set_peripheral_permissions(pt_m4_0, SC_R_SYSTEM,

and compiled the firmware new with:

$ make qx B=mek R=B0

and added it to my yocto build ... with that change it works like a charm ...

bye,

Heiko

2,212 Views
山水之间
Contributor II

HI Heiko,

   I tried your method is feasible.But I have a question.Same source code, I use Makefile to manually compile a flash.bin file to write into sd card, can use SPI flash.I suspect there is a problem with the yocto build.I tried to call SCFW's API in UBOOT to get the permission of SPI Flash, but it was not successful. Do you have any idea?Please tell me. Thank you very much..

Best regards
Hagen

0 Kudos

2,212 Views
heikoschocher
Contributor II

Hello Hagen,

Hmm... I am sorry, I cannot say very much, but a good lead. I did not thought about there could be a problem with SCFW API in U-Boot,as it is source from NXP. I just wait for the real hw from the customer, and if I got them, I can take a look again into it.

Thanks for the hint!

bye,

Heiko

0 Kudos

2,212 Views
igorpadykov
NXP Employee
NXP Employee

Hi Heiko

for "fspi0 [237] not owned by curr partition" error one can check
partition management discussion on SCFW Resource Management Confusion 

Partition APIs description can be found in SCFW documentation included in SCFW Porting Kit

The i.MX 8 and 8X families require a minimum SCFW release version for correct operation and

to prevent potential reliability issues. Versions compatibility can be found on

i.MX Software and Development Tools | NXP 

and described in  Linux 4.19.35_1.1.0 Documentation  (Release Notes)  

For example L4.19.35_1.1.0 should be used with SCFWKIT-1.2.7.1 and uboot v2019.04

uboot-imx - i.MX U-Boot 

It is not recommended to use SCFW release tied to a non-GA BSP release,

as early versions of the SCFW may lead to operational or reliability issues with the processor.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,212 Views
heikoschocher
Contributor II

Hello Igor,

thanks for your answer ... I use as base:

repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-thud -m imx-4.19.35-1.0.0.xml

So this should be correct, or?

And if building the image for the spi flash, and burning it, spi access works. But booting the sd card
image, SPI does not work (in u-boot and linux)

bye,

Heiko

0 Kudos

2,212 Views
igorpadykov
NXP Employee
NXP Employee

Hi Heiko

for building please use Yocto Guide included in Linux 4.19.35_1.1.0 Documentation

and Chapter 3 Porting U-Boot i.MX Porting Guide.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos