cancel
Showing results for 
Search instead for 
Did you mean: 

how to use NAND Controller in linux kernel 5.4-stm32mp-r2?

jandriea
Associate II

I have modified STM32MP157C-DK2 board with NAND flash connected through FMC and it works properly with linux kernel 5.4-stm32mp-r1. I notice that there are some changes to FMC in 5.4-stm32mp-r2 and tried to build my custom linux using the newer release. Unfortunately, the kernel always crashed because it can't open the MTD device. The device can boot TF-A and u-boot properly but it always stuck at the kernel.

in 5.4-stm32mp-r1 version I only modify the DK2 device tree by stripping unused nodes, removing nodes that use the same pin as FMC, and adding FMC node by copying the configuration from stm32mp15xx-evx.dtsi. I use the same approach in 5.4-stm32mp-r2 as I assume the configuration from stm32mp15xx-evx.dtsi is enough to make the device boot from NAND.

[    1.158408] UBI error: cannot open mtd UBI, error -2
[    1.162737] stm32_rtc 5c004000.rtc: setting system clock to 2000-01-16T08:50:47 UTC (948012647)
[    1.173134] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    1.179147] Please append a correct "root=" boot option; here are the available partitions:
[    1.187592] 0100           65536 ram0
[    1.187596]  (driver?)
[    1.193642] 0101           65536 ram1
[    1.193645]  (driver?)
[    1.199654] 0102           65536 ram2
[    1.199657]  (driver?)
[    1.205750] 0103           65536 ram3
[    1.205754]  (driver?)
[    1.211906] 0104           65536 ram4
[    1.211910]  (driver?)
[    1.217898] 0105           65536 ram5
[    1.217901]  (driver?)
[    1.223980] 0106           65536 ram6
[    1.223983]  (driver?)
[    1.230269] 0107           65536 ram7
[    1.230273]  (driver?)
[    1.236141] 0108           65536 ram8
[    1.236144]  (driver?)
[    1.242243] 0109           65536 ram9
[    1.242246]  (driver?)
[    1.248303] 010a           65536 ram10
[    1.248306]  (driver?)
[    1.254473] 010b           65536 ram11
[    1.254476]  (driver?)
[    1.260653] 010c           65536 ram12
[    1.260656]  (driver?)
[    1.266808] 010d           65536 ram13
[    1.266811]  (driver?)
[    1.272977] 010e           65536 ram14
[    1.272980]  (driver?)
[    1.279144] 010f           65536 ram15
[    1.279147]  (driver?)
[    1.285319] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.293566] CPU: 0 PID: 1 Comm: swapper Not tainted 5.4.56 #1
[    1.299293] Hardware name: STM32 (Device Tree Support)
[    1.304450] [<c010d5e0>] (unwind_backtrace) from [<c010b01c>] (show_stack+0x10/0x14)
[    1.312163] [<c010b01c>] (show_stack) from [<c0116e08>] (panic+0x114/0x2fc)
[    1.319118] [<c0116e08>] (panic) from [<c0901318>] (mount_block_root+0x248/0x2f8)
[    1.326586] [<c0901318>] (mount_block_root) from [<c0901718>] (prepare_namespace+0x180/0x1c4)
[    1.335097] [<c0901718>] (prepare_namespace) from [<c06157d8>] (kernel_init+0x8/0x110)
[    1.343003] [<c06157d8>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[    1.350551] Exception stack(0xc7033fb0 to 0xc7033ff8)
[    1.355594] 3fa0:                                     00000000 00000000 00000000 00000000
[    1.363763] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.371927] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.378534] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

I have another DK2 board without any modification and the kernel runs without any problem

2 REPLIES 2
Olivier GALLIEN
ST Employee

Hi @jandriea​ ,

Moving to  5.4-stm32mp-r2  did you also upgradre TF-A and U-boot with V2.1 version ?

It's recommended to be consistent and not mix element from various deliveries.

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Community member​ 

Thanks for your response. I am pretty sure that I also upgrade the TF-A and U-Boot as I clone the meta-st-stm32mp layer from STMicroelectronis github site and checked out openstlinux-5.4-dunfell-mp1-20-11-12 tag.

The bootloader runs properly as it can run from NAND and I can load the zImage and kernel device tree from U-Boot. The problem only occurred when the kernel is already loaded. As I search on another site, someone mentioned that the problem is the kernel didn't detect NAND flash. Thus, the kernel failed to load the UBI volume