Do we have any example for use flash as usb mass storage on Zephyr?

I am trying to use Xiao BLE Sence QSPI flash as a storage, but got error like this
Any one can help?

/home/wols/Documents/Wols/zephyrproject/zephyr/samples/subsys/usb/mass/src/main.c:36:2: error: #error No supported disk driver enabled
   36 | #error No supported disk driver enabled
      |  ^~~~~
[17/106] Building C object zephyr/lib/libc/common/CMakeFiles/lib__libc__common.dir/source/stdlib/malloc.c.obj
ninja: build stopped: subcommand failed.

Here is build cmd

west build -b xiao_ble/nrf52840/sense zephyr/samples/subsys/usb/mass -DCONFIG_APP_MSC_STORAGE_FLASH_FATFS=y

Here is overlay

/delete-node/ &storage_partition;
/ {
    chosen {
        zephyr,ieee802154 = &ieee802154;
    };

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

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

Hi there,

So which Toolchain are you using, and Did you run the Kconfig,to enable the driver. for QSPI look into that.

HTH
GL :slight_smile: PJ :v:

Hi PJ_Glasso
Here is build info

$ west build -p always --pristine -b xiao_ble/nrf52840/sense zephyr/samples/subsys/usb/mass 
-- west build: making build dir /home/wols/Documents/Wols/zephyrproject/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/wols/Documents/Wols/zephyrproject/zephyr/samples/subsys/usb/mass
-- CMake version: 3.20.5
-- Found Python3: /home/wols/Documents/Wols/zephyrproject/.venv/bin/python3 (found suitable version "3.10.12", minimum required is "3.10") found components: Interpreter 
-- Cache files will be written to: /home/wols/.cache/zephyr
-- Zephyr version: 4.1.0-rc2 (/home/wols/Documents/Wols/zephyrproject/zephyr)
-- Found west (found suitable version "1.3.0", minimum required is "0.14.0")
-- Board: xiao_ble, qualifiers: nrf52840/sense
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.17.0 (/home/wols/zephyr-sdk-0.17.0)
-- Found toolchain: zephyr 0.17.0 (/home/wols/zephyr-sdk-0.17.0)
-- Found Dtc: /home/wols/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/wols/Documents/Wols/zephyrproject/zephyr/boards/seeed/xiao_ble/xiao_ble_nrf52840_sense.dts
-- Generated zephyr.dts: /home/wols/Documents/Wols/zephyrproject/build/zephyr/zephyr.dts
-- Generated pickled edt: /home/wols/Documents/Wols/zephyrproject/build/zephyr/edt.pickle
-- Generated devicetree_generated.h: /home/wols/Documents/Wols/zephyrproject/build/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/wols/Documents/Wols/zephyrproject/build/zephyr/dts.cmake

warning: DISK_DRIVER_FLASH (defined at drivers/disk/Kconfig.flash:4) was assigned the value 'y' but
got the value 'n'. Check these unsatisfied dependencies: DT_HAS_ZEPHYR_FLASH_DISK_ENABLED (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_DISK_DRIVER_FLASH and/or look up
DISK_DRIVER_FLASH in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.

And folder tree

$ tree zephyr/samples/subsys/usb/mass 
zephyr/samples/subsys/usb/mass
β”œβ”€β”€ boards
β”‚   β”œβ”€β”€ adafruit_feather_nrf52840_sense.overlay
β”‚   β”œβ”€β”€ nrf52840dk_nrf52840.overlay
β”‚   β”œβ”€β”€ nrf5340dk_nrf5340_cpuapp.overlay
β”‚   β”œβ”€β”€ rpi_pico.overlay
β”‚   β”œβ”€β”€ sensortile_box_pro.conf
β”‚   β”œβ”€β”€ stm32l562e_dk_stm32l562xx_ns.conf
β”‚   β”œβ”€β”€ xiao_ble_nrf25840_sence.conf
β”‚   └── xiao_ble_nrf25840_sence.overlay
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ Kconfig
β”œβ”€β”€ prj.conf
β”œβ”€β”€ ramdisk.overlay
β”œβ”€β”€ README.rst
β”œβ”€β”€ src
β”‚   └── main.c
└── usbd_next_prj.conf

2 directories, 15 files

xiao_ble_nrf25840_sence.conf

CONFIG_MAIN_STACK_SIZE=2048
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8192

CONFIG_DISK_ACCESS=y
CONFIG_DISK_DRIVERS=y

CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_DISK_DRIVER_FLASH=y

Hi there,

So , You would benefit from watching the Webinars on the Dev academy training , It’s free. Number 8 shows what you are stuck at.
The message at the bottom(warning) telling you the issue, DID you open the Kconfig menu? Did you navigate to Drivers, and select the QSPI for the flash ? Probably NOT?
Your closer though, Keep going. I see this was a pristine build so that a start. You’ll need a build that includes the boot loader and the QSPI flash drivers too. Did you make a Partition manager . yaml file for the build ? Looks like your short a few steps.
hit this link and See where it went sideways…

HTH
GL :slight_smile: PJ :v: