nrf53 USB as mass storage with SDCARD enable ok but doesn't work

Hello,

I am here, again! I am trying to use the USB of nfr5340dk or my custom board as mass storage with SDCard.

I am sure the SDCard works... in the same project I can read and write files without problems, but when I enable the usb, the USB_enable() function returns that there is not a problem, but from the PC I can't see the device, and no enumeration too.

The first question is: How does USB bind with SDCard? I saw that for internal flash, the overlay file contains these rows that I don't have:

/delete-node/ &storage_partition;

&mx25r64 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		storage_partition: partition@0 {
			label = "storage";
			reg = <0x00000000 0x00020000>;
		};
	};
};

/ {
	msc_disk0 {
		compatible = "zephyr,flash-disk";
		partition = <&storage_partition>;
		disk-name = "NAND";
		cache-size = <4096>;
	};
};

second question: The application must exit from the main to works like in this other post?

Thank

Marco

Parents
  • A small update.

    After some tries with both dk and custom board, with DK now the PC start the enumeration but in a terminal I can read a fault message and the board reset.

    *** Booting Zephyr OS build v3.1.99-ncs1-1
    Mount /SD:: 0
    /SD:: bsize = 512 ; frsize = 32768 ; blocks = 238304 ; bfree = 236871
    /SD: opendir: 0
      D 0 EXAMPLE
    End of files
    [00:00:02.259,338] <inf> sd: Detected SD card
    [00:00:02.278,381] <inf> sd: Maximum SD clock is under 25MHz, using clock of 2000000Hz
    [00:00:02.364,013] <inf> main: The device is put in USB mass storage mode.
    
    [00:00:03.770,263] <err> os: ***** USAGE FAULT *****
    [00:00:03.770,294] <err> os:   Stack overflow (context area not valid)
    [00:00:03.770,294] <err> os: r0/a1:  0xfbd35e65  r1/a2:  0x247882c0  r2/a3:  0x0000a2d0
    [00:00:03.770,294] <err> os: r3/a4:  0x61000000 r12/ip:  0x20000224 r14/lr:  0x00000009
    [00:00:03.770,324] <err> os:  xpsr:  0x00000000
    [00:00:03.770,324] <err> os: Faulting instruction address (r15/pc): 0x20000224
    [00:00:03.770,355] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
    [00:00:03.770,355] <err> os: Current thread: 0x200009b0 (unknown)
    [00:00:03.828,186] <err> fatal_error: Resetting system

    It is the mass storage example and I don't touch anything! I just added the SPI configuration for the sd card.

    Best

    Marco

Reply
  • A small update.

    After some tries with both dk and custom board, with DK now the PC start the enumeration but in a terminal I can read a fault message and the board reset.

    *** Booting Zephyr OS build v3.1.99-ncs1-1
    Mount /SD:: 0
    /SD:: bsize = 512 ; frsize = 32768 ; blocks = 238304 ; bfree = 236871
    /SD: opendir: 0
      D 0 EXAMPLE
    End of files
    [00:00:02.259,338] <inf> sd: Detected SD card
    [00:00:02.278,381] <inf> sd: Maximum SD clock is under 25MHz, using clock of 2000000Hz
    [00:00:02.364,013] <inf> main: The device is put in USB mass storage mode.
    
    [00:00:03.770,263] <err> os: ***** USAGE FAULT *****
    [00:00:03.770,294] <err> os:   Stack overflow (context area not valid)
    [00:00:03.770,294] <err> os: r0/a1:  0xfbd35e65  r1/a2:  0x247882c0  r2/a3:  0x0000a2d0
    [00:00:03.770,294] <err> os: r3/a4:  0x61000000 r12/ip:  0x20000224 r14/lr:  0x00000009
    [00:00:03.770,324] <err> os:  xpsr:  0x00000000
    [00:00:03.770,324] <err> os: Faulting instruction address (r15/pc): 0x20000224
    [00:00:03.770,355] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
    [00:00:03.770,355] <err> os: Current thread: 0x200009b0 (unknown)
    [00:00:03.828,186] <err> fatal_error: Resetting system

    It is the mass storage example and I don't touch anything! I just added the SPI configuration for the sd card.

    Best

    Marco

Children
Related