USB MASS sample and partition manager build issues

I have my application code which builds and runs on my nrf5340DK. The project files were based on the zephyr sample for multi-advertising BLE.

Right now I'm building the 'secure' app version (board target nrf5340dk_nrf5340_cpuapp)

I now want to add a file system, in the external flash, and enable USB access to it (objective is to have a way to give files to the application firmware over USB)

I took the code & dts/Kconfig from the USB 'mass' zephyr sample to use as a base for this, however the project will not compile, failing at flashdisk.c in the zephyr installation:

[11/142] Building C object zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj
FAILED: zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj
C:\ncs\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DPICOLIBC_LONG_LONG_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/work/dev/nordic_connect/zephyr/include -IC:/work/dev/if-device-nrf53/cc1-med/build/zephyr/include/generated -IC:/work/dev/nordic_connect/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/work/dev/nordic_connect/zephyr/soc/common/nordic_nrf/. -IC:/work/dev/nordic_connect/zephyr/soc/arm/nordic_nrf/common/. -IC:/work/dev/nordic_connect/zephyr/subsys/usb/device -IC:/work/dev/nordic_connect/zephyr/subsys/bluetooth -IC:/work/dev/nordic_connect/zephyr/drivers/usb/common/nrf_usbd_common/. -IC:/work/dev/nordic_connect/nrf/include -IC:/work/dev/nordic_connect/nrf/subsys/app_event_manager/. -IC:/work/dev/nordic_connect/nrf/subsys/app_event_manager_profiler_tracer/. -IC:/work/dev/nordic_connect/nrf/tests/include -IC:/work/dev/nordic_connect/modules/lib/cjson -IC:/work/dev/nordic_connect/nrf/modules/cjson/include -IC:/work/dev/nordic_connect/modules/hal/cmsis/CMSIS/Core/Include -IC:/work/dev/nordic_connect/zephyr/modules/cmsis/. -IC:/work/dev/nordic_connect/modules/hal/nordic/nrfx -IC:/work/dev/nordic_connect/modules/hal/nordic/nrfx/drivers/include -IC:/work/dev/nordic_connect/modules/hal/nordic/nrfx/mdk -IC:/work/dev/nordic_connect/zephyr/modules/hal_nordic/nrfx/. -IC:/work/dev/if-device-nrf53/cc1-med/build/modules/libmetal/libmetal/lib/include -IC:/work/dev/nordic_connect/modules/lib/open-amp/open-amp/lib/include -IC:/work/dev/nordic_connect/modules/crypto/tinycrypt/lib/include -IC:/work/dev/nordic_connect/nrfxlib/softdevice_controller/include -isystem C:/work/dev/nordic_connect/zephyr/lib/libc/common/include -isystem C:/work/dev/nordic_connect/nrfxlib/crypto/nrf_cc312_platform/include -Wshadow -fno-strict-aliasing -Os -imacros C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/work/dev/nordic_connect/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/work/dev/if-device-nrf53/cc1-med=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/work/dev/nordic_connect/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/work/dev/nordic_connect=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -MF zephyr\drivers\disk\CMakeFiles\drivers__disk.dir\flashdisk.c.obj.d -o zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -c C:/work/dev/nordic_connect/zephyr/drivers/disk/flashdisk.c
C:/work/dev/nordic_connect/zephyr/drivers/disk/flashdisk.c:484:1: error: return type defaults to 'int' [-Werror=implicit-int]
484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/work/dev/nordic_connect/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
C:/work/dev/nordic_connect/zephyr/drivers/disk/flashdisk.c:523:30: error: storage class specified for parameter 'flash_disks'
523 | static struct flashdisk_data flash_disks[] = {
| ^~~~~~~~~~~
C:/work/dev/nordic_connect/zephyr/drivers/disk/flashdisk.c:523:15: error: parameter 'flash_disks' is initialized
523 | static struct flashdisk_data flash_disks[] = {
| ^~~~~~~~~~~~~~
C:/work/dev/nordic_connect/zephyr/drivers/disk/flashdisk.c:524:39: error: 'DEFINE_FLASHDISKS_DEVICE' undeclared (first use in this function)
524 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE)
| ^~~~~~~~~~~~~~~~~~~~~~~~

etc etc as ever when one of these macros has an issue its very tricky to work out why....

Looking at the flashdisk.c code it seems to be in the USE_PARTITION_MANAGER case, so I guess its not finding some PM config to define the flash disk parameters?

Q: do I need to use the Partition Manager sub system? The DTS files appear to define the partitions required just fine...The mass example does not have a pm.yml either?

If I have to use PM (my reading implies 'yes', because the nrf5340 requires a multi-image hex due to the 2 processors?), where, how to configure its partitions if not in the DTS?

I tried to build the 'mass' sample standalone copied directly from the NCS; but it also fails to compile with this error:

CMake Error at CMakeLists.txt:10 (message):
No disk access settings detected.

Any ideas what I'm doing wrong?

Thanks

Brian

full compile output for 'mass' sample:

C:\work\dev\if-device-nrf53\mass>west build -p
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: C:/work/dev/if-device-nrf53/mass
-- CMake version: 3.21.0
-- Using NCS Toolchain 2.6.20240304.889616714482 for building. (C:/ncs/toolchains/cf2149caf2/cmake)
-- Found Python3: C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: C:/work/dev/nordic_connect/zephyr/.cache
-- Zephyr version: 3.5.99 (C:/work/dev/nordic_connect/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf5340dk_nrf5340_cpuapp
-- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: C:/work/dev/nordic_connect/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp.dts
-- Found devicetree overlay: C:/work/dev/if-device-nrf53/mass/boards/nrf5340dk_nrf5340_cpuapp.overlay
-- Generated zephyr.dts: C:/work/dev/if-device-nrf53/mass/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: C:/work/dev/if-device-nrf53/mass/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: C:/work/dev/if-device-nrf53/mass/build/zephyr/dts.cmake
Parsing C:/work/dev/if-device-nrf53/mass/Kconfig
Loaded configuration 'C:/work/dev/nordic_connect/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_defconfig'
Merged configuration 'C:/work/dev/if-device-nrf53/mass/prj.conf'
Configuration saved to 'C:/work/dev/if-device-nrf53/mass/build/zephyr/.config'
Kconfig header saved to 'C:/work/dev/if-device-nrf53/mass/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Warning at C:/work/dev/nordic_connect/zephyr/subsys/usb/device/CMakeLists.txt:22 (message):
CONFIG_USB_DEVICE_VID has default value 0x2FE3.

This value is only for testing and MUST be configured for USB products.


CMake Warning at C:/work/dev/nordic_connect/zephyr/CMakeLists.txt:862 (message):
No SOURCES given to Zephyr library: drivers__disk

Excluding target from build.


CMake Error at CMakeLists.txt:10 (message):
No disk access settings detected.


-- Configuring incomplete, errors occurred!
See also "C:/work/dev/if-device-nrf53/mass/build/CMakeFiles/CMakeOutput.log".
See also "C:/work/dev/if-device-nrf53/mass/build/CMakeFiles/CMakeError.log".
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe '-BC:\work\dev\if-device-nrf53\mass\build' -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp '-SC:\work\dev\if-device-nrf53\mass'

Related