This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VEN-Q1: Dynamic selection of the root file system

Part Number: TDA4VEN-Q1


Tool/software:

Hi, experts

I have booted successfully by referring to that link J722S MCU+ SDK: SBL SD HLOS, but found that the root filesystem selection is fixed in the device tree, such as root=/dev/mmcblk1p2, if I want to be able to dynamically select different root filesystems how should I implement it. For example, when the sdcard exists, use mmcblk1p2, when the sdcard does not exist, use emmc's such as mmcblk0p2 or mmcblk0p3.

 

board: custom board

sdk: 10_00_00_08

Best Regards,

Bing

  • Hi Bing,

    Do you have u-boot in your boot flow? Or is it optimised boot flow. U-boot can be used to easily add this customisation.

    Regards,

    Tanmay

  • Hi Tanmay,

    U-boot can be used to easily add this customisation.

    Yes, I have implemented this in uboot as well. But now there is no more uboot, the kernel image Image is loaded directly by sbl.

    Best Regards,

    Bing

  • Hi Bing,

    So this is taken from the device-tree files's "bootargs". There might not be a standard way of doing this.

    What I can think of is that in "get_bootargs_cmdline()" at "arch/arm64/kernel/idreg-override.c", you parse the root mount point from bootargs. You can add a hook here to modify the argument here. But then I am not sure how you would check if the SD card exists or not.

    Regards,
    Tanmay

  • Hi Tanmay,

    I thought of using bit18 of register 0x0FA00024 of sd to detect it, but the kernel crashes while reading the register.

    I added a piece of code to the kernel source code ti-processor-sdk-linux-adas-j722s-evm-10_00_00_08/board-support/ti-linux-kernel-6.6.32+git-ti/init/main.c as follows

    #define MMC1_CTL_REG 0x0FA00024
    #define CARD_DETECT (1 << 18)
    /* return 1 use sd card file system */
    static int use_sdcard_filesystem(void)
    {
    	int ret;
    	void __iomem *mmc1_ctl_reg;
    	unsigned int val;
    
    	mmc1_ctl_reg = ioremap(MMC1_CTL_REG, 4);
    	val = readl(mmc1_ctl_reg);
    	ret = val & CARD_DETECT;
    
    	iounmap(mmc1_ctl_reg);
    
    	return ret;
    }

    log:

    [    0.000000] ------------[ cut here ]------------
    [    0.000000] WARNING: CPU: 0 PID: 0 at mm/ioremap.c:23 generic_ioremap_prot+0xc8/0x104
    [    0.000000] Modules linked in:
    [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.32 #57
    [    0.000000] Hardware name: Texas Instruments J722S EVM (DT)
    [    0.000000] pstate: 800000c5 (Nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [    0.000000] pc : generic_ioremap_prot+0xc8/0x104
    [    0.000000] lr : generic_ioremap_prot+0x28/0x104
    [    0.000000] sp : ffff8000812a3dd0
    [    0.000000] x29: ffff8000812a3dd0 x28: 00000000810360ac x27: 0000000000000000
    [    0.000000] x26: 0000000000000000 x25: 0000000000000000 x24: ffff8000813df000
    [    0.000000] x23: 0068000000000f13 x22: 0068000000000713 x21: ffff8000800ae5a0
    [    0.000000] x20: 000000000fa00024 x19: 0000000000000004 x18: 0000000000000006
    [    0.000000] x17: 000000000000002f x16: 00000000fdc612e0 x15: ffff8000812a3870
    [    0.000000] x14: 000000000000000a x13: ffff8000812bea50 x12: 00000000000000d8
    [    0.000000] x11: 0000000000000048 x10: ffff800081316a50 x9 : ffff8000812bea50
    [    0.000000] x8 : 00000000ffffefff x7 : 0000000000000018 x6 : ffff80008140e638
    [    0.000000] x5 : ffff80008140e638 x4 : 0000000000000000 x3 : 0000000000000000
    [    0.000000] x2 : 0068000000000713 x1 : 0000000000000004 x0 : 0000000000000000
    [    0.000000] Call trace:
    [    0.000000]  generic_ioremap_prot+0xc8/0x104
    [    0.000000]  ioremap_prot+0x50/0x78
    [    0.000000]  start_kernel+0xac/0x6f0
    [    0.000000]  __primary_switched+0xbc/0xc4
    [    0.000000] ---[ end trace 0000000000000000 ]---
    [    0.000000] +++++++++++++
    [    0.000000] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
    [    0.000000] Mem abort info:
    [    0.000000]   ESR = 0x0000000096000004
    [    0.000000]   EC = 0x25: DABT (current EL), IL = 32 bits
    [    0.000000]   SET = 0, FnV = 0
    [    0.000000]   EA = 0, S1PTW = 0
    [    0.000000]   FSC = 0x04: level 0 translation fault
    [    0.000000] Data abort info:
    [    0.000000]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
    [    0.000000]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
    [    0.000000]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
    [    0.000000] [0000000000000000] user address but active_mm is swapper
    [    0.000000] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
    [    0.000000] Modules linked in:
    [    0.000000] CPU: 0 PID: 0 Comm: swapper Tainted: G        W          6.6.32 #57
    [    0.000000] Hardware name: Texas Instruments J722S EVM (DT)
    [    0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [    0.000000] pc : readl+0x0/0x18
    [    0.000000] lr : start_kernel+0xc4/0x6f0
    [    0.000000] sp : ffff8000812a3e40
    [    0.000000] x29: ffff8000812a3e40 x28: 00000000810360ac x27: 0000000000000000
    [    0.000000] x26: 0000000000000000 x25: 0000000000000000 x24: ffff8000813df000
    [    0.000000] x23: 0068000000000f13 x22: ffff8000812a9940 x21: 0068000000000713
    [    0.000000] x20: 0000000000000e12 x19: 0000000000000000 x18: 0000000000000006
    [    0.000000] x17: 000000000000002f x16: 00000000fdc612e0 x15: ffff8000812a3870
    [    0.000000] x14: 0000000000000000 x13: ffff8000812bea50 x12: 0000000000000126
    [    0.000000] x11: 0000000000000062 x10: ffff800081316a50 x9 : ffff8000812bea50
    [    0.000000] x8 : 00000000ffffefff x7 : ffff800081316a50 x6 : 80000000fffff000
    [    0.000000] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
    [    0.000000] x2 : 0000000000000000 x1 : ffff8000812b2b40 x0 : 0000000000000000
    [    0.000000] Call trace:
    [    0.000000]  readl+0x0/0x18
    [    0.000000]  __primary_switched+0xbc/0xc4
    [    0.000000] Code: d53cd040 d53cd040 d53cd040 d53cd040 (b9400000) 
    [    0.000000] ---[ end trace 0000000000000000 ]---
    [    0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
    [    0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---

    The strange thing is that I compiled that code into a module using insmod to load the module and no panic occurs, what is the reason for that?

    Best Regards,

    Bing