<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115276/unable-to-mount-fat-fs-using-external-partition-manager-using-pm_static-yml-file</link><description>Hi, 
 I am trying to mount Fat FS using pm_static.yml instead of devicetree overlay fixed partition. I can generate a memory report, but when I try to mount file system I get the following mount errors. 
 Errors: 
 
 
 Prj.Conf 
 
 overlay file: 
 
 pm_static</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Oct 2024 09:14:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115276/unable-to-mount-fat-fs-using-external-partition-manager-using-pm_static-yml-file" /><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/507292?ContentTypeID=1</link><pubDate>Tue, 22 Oct 2024 09:14:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e41ba823-8030-449d-ad23-59070bf994fc</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;No worries, glad to be of help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/507229?ContentTypeID=1</link><pubDate>Tue, 22 Oct 2024 00:24:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0f012cc-0010-49ac-bba8-9078acab9328</guid><dc:creator>Barsa</dc:creator><description>&lt;p&gt;Hi BrianW,&lt;/p&gt;
&lt;p&gt;I really appreciate your help. I am finally able to mount fat FS into my storage. I removed the MCU boot part, since I am just storing sensor data for now into my storage. Thank you again!&lt;br /&gt;&lt;br /&gt;Regards,&lt;/p&gt;
&lt;p&gt;Barsha&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/506427?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2024 07:54:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa08e20b-027f-4d54-889b-36419d9431f7</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;It looks like your prj.conf has commented out the critical mcuboot keys?&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;# CONFIG_BOOTLOADER_MCUBOOT=y&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;if you make a partition map with mcuboot at 0x0, you need to build an image with mcuboot in there...&lt;/p&gt;
&lt;div&gt;in prj.conf:&lt;br /&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_BOOTLOADER_MCUBOOT=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;# put slot2 in external flash&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_WITHOUT_SCRATCH=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And then you need to put a &amp;#39;mcuboot.conf&amp;#39; file in the directory &amp;#39;child_image&amp;#39; containing:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_MCUBOOT_SERIAL=n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_BOOT_MAX_IMG_SECTORS=256&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_FPROTECT=n&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_BOOTLOADER_MCUBOOT=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;(this is also where you put the config for image signing keys files etc).&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;My proj.conf (but this is still a work in progress especially as I&amp;#39;m fighting with the wifi stuff right now..)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
#debug core dump : TODO change to use flash partition
CONFIG_DEBUG_COREDUMP=n
CONFIG_DEBUG_COREDUMP_BACKEND_LOGGING=n
CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=n

# debug/memory/thread/stack check analysis : 
# TODO remove for runtime
CONFIG_DEBUG=n
CONFIG_DEBUG_INFO=n

CONFIG_THREAD_NAME=y
# TODO remove for runtime
CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_USE_PRINTK=n
CONFIG_THREAD_ANALYZER_AUTO=n
#CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=60
#CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y

CONFIG_SYS_HEAP_RUNTIME_STATS=y
CONFIG_INIT_STACKS=y

# TODO remove for runtime
CONFIG_ASSERT=y
CONFIG_ASSERT_VERBOSE=y
CONFIG_ASSERT_NO_COND_INFO=n
CONFIG_ASSERT_NO_MSG_INFO=n
CONFIG_STACK_SENTINEL=y
# system HALT on error (useful for debugger?)
# TODO remove for runtime
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_REBOOT=y

#CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_PRINTK=n
# warning : if shell enabled this caused fatal crash at boot...
CONFIG_SHELL=n
CONFIG_SHELL_MINIMAL=n
CONFIG_SHELL_LOG_BACKEND=n

# cannot access binary says ninja, also the info is not available to the source code
#CONFIG_BINDESC=y
#CONFIG_BINDESC_DEFINE=y
#CONFIG_BINDESC_DEFINE_BUILD_TIME=y
#CONFIG_BINDESC_BUILD_DATE_TIME_STRING=y
#CONFIG_BINDESC_BUILD_DATE_TIME_STRING_FORMAT=&amp;quot;%Y-%m-%dT%H:%M&amp;quot;

CONFIG_GPIO=y
CONFIG_GPIO_MCP230XX=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_LINE_CTRL=y

CONFIG_I2C=y
CONFIG_I2C_CALLBACK=y
CONFIG_I2C_NRFX=y
#CONFIG_I2C_NRFX_TWIM=y
#CONFIG_NRFX_TXI_ENABLED=y

CONFIG_SPI=y
CONFIG_SPI_ASYNC=y

# Using AEF event system for inter-module comm and sync
CONFIG_APP_EVENT_MANAGER=y
CONFIG_APP_EVENT_MANAGER_POSTINIT_HOOK=y
CONFIG_CAF=y
CONFIG_CAF_PM_EVENTS=y
CONFIG_CAF_POWER_MANAGER=n
#CONFIG_CAF_BUTTONS=y
#CONFIG_CAF_BUTTONS_DEF_PATH=&amp;quot;cc1_med_buttons_def.h&amp;quot;
CONFIG_CAF_BUTTON_EVENTS=y
#CONFIG_CAF_BUTTONS_PM_EVENTS=y
# button polarity inverse on DK board... tbd on real hw
#CONFIG_CAF_BUTTONS_POLARITY_INVERSED=y
#CONFIG_CAF_BUTTONS_PM_KEEP_ALIVE=n
CONFIG_CAF_CLICK_DETECTOR=y
CONFIG_CAF_CLICK_DETECTOR_LONG_CLICK_MSEC=2000
CONFIG_CAF_CLICK_DETECTOR_PM_EVENTS=y
CONFIG_CAF_CLICK_DETECTOR_DEF_PATH=&amp;quot;cc1_med_buttons_click_def.h&amp;quot;
CONFIG_LED=y
CONFIG_LED_GPIO=y

# libaries
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_COMMON_LIBC_CALLOC=y
CONFIG_COMMON_LIBC_REALLOCARRAY=y
# use malloc that maps to k_malloc(), and allocate all remaing RAM to heap (-1)
CONFIG_COMMON_LIBC_MALLOC=y
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=180000
CONFIG_HEAP_MEM_POOL_SIZE=50000

CONFIG_FLASH=y
CONFIG_I2S=y
CONFIG_I2S_NRFX=y
CONFIG_NRFX_PDM=y
CONFIG_PWM=y
CONFIG_SYS_HASH_MAP=y
# using cJSON
CONFIG_CJSON_LIB=y
CONFIG_JSON_LIBRARY=n
CONFIG_BASE64=y
CONFIG_UTF8=y
CONFIG_CHARACTER_FRAMEBUFFER=y
# using NVS system for blobmgr. NVS partition defined in pm_static.yml
CONFIG_NVS=y

CONFIG_STDOUT_CONSOLE=y

# turn on Partition manager (must be on) to use partitions from pm_static.yml
CONFIG_PM_SINGLE_IMAGE=y

#USB related configs
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;Infrafon CC2-WDD&amp;quot;
# USB VID is MCS electronics, who sell individual PIDs. 0x138F is for CC2 purchases 25/08/2024
CONFIG_USB_DEVICE_VID=0x16D0
CONFIG_USB_DEVICE_PID=0x138F
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y

CONFIG_USB_DEVICE_HID=y
CONFIG_USB_HID_DEVICE_COUNT=2

CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_NORDIC_QSPI_NOR=y

# flash disk config
# The mx25 erase page size
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_DISK_DRIVERS=y
CONFIG_DISK_DRIVER_FLASH=y
# use ELM FATFS with long file names (not 8.3)
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_MOUNT_MKFS=y
CONFIG_FS_FATFS_LFN=y
CONFIG_FS_FATFS_EXFAT=n

CONFIG_MASS_STORAGE_DISK_NAME=&amp;quot;NAND&amp;quot;
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y

# BT/BLE config
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME=&amp;quot;CC2-WDD-2&amp;quot;
CONFIG_BT_DEVICE_APPEARANCE=512
CONFIG_BT_DEVICE_NAME_DYNAMIC=y

CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2

CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=y
CONFIG_BT_DIS_MANUF=&amp;quot;Infrafon&amp;quot;
CONFIG_BT_DIS_PNP_VID_SRC=2
CONFIG_BT_DIS_PNP_VID=0x1915
CONFIG_BT_DIS_PNP_PID=0xEEF1
CONFIG_BT_DIS_PNP_VER=0x0100

CONFIG_BT_OBSERVER=y
CONFIG_BT_SCAN=y
CONFIG_BT_NUS=y

# WIFI config
CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y
CONFIG_NRF_WIFI_PATCHES_BUILTIN=y
#CONFIG_NRF700X_RADIO_COEX=y
CONFIG_NRF_WIFI_LOW_POWER=y
CONFIG_NRF_WIFI_IF_AUTO_START=y

CONFIG_NRF700X_AP_MODE=n
CONFIG_NRF700X_P2P_MODE=n
CONFIG_NRF700X_STA_MODE=y

# WPA supplicant
CONFIG_WPA_SUPP=y
#CONFIG_WPA_SUPP_LOG_LEVEL_INF=y
#CONFIG_WIFI_NM=y
#CONFIG_WIFI_NM_LOG_LEVEL_INF=y

# No, follwing is experimental bad code
#CONFIG_WIFI_NM_WPA_SUPPLICANT=y
#CONFIG_WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_INF=y
#CONFIG_NO_WPA=n

CONFIG_NET_L2_ETHERNET=y
#CONFIG_NET_L2_WIFI_MGMT=y

# Networking layers
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_LOG=y
CONFIG_NET_IPV4=y
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_DHCPV4=y
#CONFIG_DNS_RESOLVER=y
#CONFIG_HTTP_CLIENT=y
#CONFIG_MQTT_LIB=y

CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
CONFIG_NET_MAX_CONTEXTS=5
CONFIG_NET_CONTEXT_SYNC_RECV=y
#Note that sockets are used by WPA suppliant code
CONFIG_NET_SOCKETS_POLL_MAX=10

# net_config is only for testing to set IP address directly
CONFIG_NET_CONFIG_SETTINGS=n
#CONFIG_NET_CONFIG_SETTINGS=y
#CONFIG_NET_CONFIG_INIT_TIMEOUT=0
# Must call net_config_init() explicitly
#CONFIG_NET_CONFIG_AUTO_INIT=n
#CONFIG_NET_CONFIG_MY_IPV4_ADDR=&amp;quot;192.168.1.99&amp;quot;
#CONFIG_NET_CONFIG_MY_IPV4_NETMASK=&amp;quot;255.255.255.0&amp;quot;
#CONFIG_NET_CONFIG_MY_IPV4_GW=&amp;quot;192.168.1.1&amp;quot;

# Memory usage
CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_RX_STACK_SIZE=4096
CONFIG_WPA_SUPP_WQ_STACK_SIZE=4096
CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096

# Optimized networking settings for memory usage (STA MODE IOT DEVICES profile)
# https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/wifi/stack_configuration.html
CONFIG_NRF700X_MAX_TX_TOKENS=5
CONFIG_NRF700X_MAX_TX_AGGREGATION=1
CONFIG_NRF700X_RX_NUM_BUFS=6

CONFIG_NET_TC_TX_COUNT=1
CONFIG_NET_PKT_RX_COUNT=6
CONFIG_NET_PKT_TX_COUNT=6

CONFIG_NET_BUF_RX_COUNT=6
CONFIG_NET_BUF_TX_COUNT=12
# can take BUF_DATAT_SIZE down to 500
CONFIG_NET_BUF_DATA_SIZE=800

# NFC config
CONFIG_NFC_T2T_NRFXLIB=y
CONFIG_NFC_T4T_NRFXLIB=y
CONFIG_NFC_T4T_ISODEP=y

CONFIG_NFC_NDEF=y
CONFIG_NFC_NDEF_MSG=y
CONFIG_NFC_NDEF_RECORD=y
CONFIG_NFC_NDEF_URI_REC=y
CONFIG_NFC_NDEF_URI_MSG=y

CONFIG_MAIN_STACK_SIZE=4096
# need big stack for system workqueue thread, as this is where we execute pretty much all real operations
#CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=32796
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

CONFIG_BOOTLOADER_MCUBOOT=y
# put slot2 in external flash
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_WITHOUT_SCRATCH=y
CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE=y
#CONFIG_MCUBOOT_BOOTUTIL_LIB=n
#CONFIG_MCUBOOT_IMG_MANAGER=n
CONFIG_MCUBOOT_SHELL=n
#CONFIG_MCUBOOT_USB_SUPPORT=n
#CONFIG_MCUBOOT_UTIL_LOG_LEVEL_ERR=n

# sign with our own key
CONFIG_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE=y
#CONFIG_BOOT_SIGNATURE_KEY_FILE=&amp;quot;/work/dev/if-device-nrf53/keys/bootloader_priv-ecdsa256.pem&amp;quot;
#CONFIG_MCUBOOT_SIGNATURE_KEY_FILE=&amp;quot;/work/dev/if-device-nrf53/keys/bootloader_priv-ecdsa256.pem&amp;quot;
# not using 2 stage bootloader
#CONFIG_SECURE_BOOT=y
#CONFIG_SB_SIGNING_KEY_FILE=&amp;quot;/work/dev/if-device-nrf53/keys/bootloader_priv-ecdsa256.pem&amp;quot;
#CONFIG_SB_SIGNING_OPENSSL=y
# want bin and hexes
CONFIG_BUILD_OUTPUT_BIN=y
CONFIG_BUILD_OUTPUT_HEX=y

# to allow net CPU update (complex &amp;amp; hard...)
#CONFIG_UPDATEABLE_IMAGE_NUMBER=2
#CONFIG_PCD_APP=y
#CONFIG_FLASH_SIMULATOR=y
#CONFIG_NRF53_MULTI_IMAGE_UPDATE=n
#CONFIG_USE_NRF53_MULTI_IMAGE_WITHOUT_UPGRADE_ONLY=n

# Enable DFU target for application image, this lets us write an image downloaded from whereever into the secondary slot for update by mcuboot
CONFIG_DFU_TARGET=y
CONFIG_STREAM_FLASH=y
CONFIG_STREAM_FLASH_ERASE=y
CONFIG_DFU_TARGET_STREAM=y
CONFIG_IMG_MANAGER=y
CONFIG_DFU_TARGET_MCUBOOT=y&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;and child_image/mcuboot.conf&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_MCUBOOT_SERIAL=n
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_FPROTECT=n

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
CONFIG_BOOT_SIGNATURE_KEY_FILE=&amp;quot;/work/dev/if-device-nrf53/keys/bootloader_priv-ecdsa256.pem&amp;quot;
#CONFIG_MCUBOOT_SIGNATURE_KEY_FILE=&amp;quot;/work/dev/if-device-nrf53/keys/bootloader_priv-ecdsa256.pem&amp;quot;

&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I don&amp;#39;t use an overlay, just a single DTS file as my board is custom. And my flash chip is different (only 8Mb...)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/506397?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2024 05:08:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fe21f48-3b8c-468b-9825-3c10a5066254</guid><dc:creator>Barsa</dc:creator><description>&lt;p&gt;If its possible can you share your prj.conf and overlay file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/506396?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2024 05:07:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b19f635-7376-4740-9c75-537325c09a88</guid><dc:creator>Barsa</dc:creator><description>&lt;p&gt;Hi Simonr,&lt;/p&gt;
&lt;p&gt;I added it and its still the same.&lt;br /&gt;&lt;br /&gt;Regards,&lt;/p&gt;
&lt;p&gt;Barsha&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/506394?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2024 05:06:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36462804-3d3e-49a3-9cef-0ac67740c8a7</guid><dc:creator>Barsa</dc:creator><description>&lt;p&gt;Hi BrianW,&lt;/p&gt;
&lt;p&gt;Thank you so much for your response.&lt;/p&gt;
&lt;p&gt;I tried following your suggestion and now my code looks like this:&lt;br /&gt;main.c&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2016 Intel Corporation.
 * Copyright (c) 2019-2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;sample_usbd.h&amp;gt;

#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
#include &amp;lt;zephyr/usb/usb_device.h&amp;gt;
#include &amp;lt;zephyr/usb/usbd.h&amp;gt;
#include &amp;lt;zephyr/usb/class/usbd_msc.h&amp;gt;
#include &amp;lt;zephyr/fs/fs.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

LOG_MODULE_REGISTER(main);

#include &amp;lt;zephyr/storage/flash_map.h&amp;gt;
#include &amp;lt;ff.h&amp;gt;

#if CONFIG_FILE_SYSTEM_LITTLEFS
#include &amp;lt;zephyr/fs/littlefs.h&amp;gt;
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
#endif

#define STORAGE_PARTITION fatfs_storage
#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION)

static struct fs_mount_t _fs_mnt;

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
static struct usbd_context *sample_usbd;

#if CONFIG_DISK_DRIVER_RAM
USBD_DEFINE_MSC_LUN(RAM, &amp;quot;Zephyr&amp;quot;, &amp;quot;RAMDisk&amp;quot;, &amp;quot;0.00&amp;quot;);
#endif

USBD_DEFINE_MSC_LUN(NAND, &amp;quot;Zephyr&amp;quot;, &amp;quot;FlashDisk&amp;quot;, &amp;quot;0.00&amp;quot;);

#if CONFIG_DISK_DRIVER_SDMMC
USBD_DEFINE_MSC_LUN(SD, &amp;quot;Zephyr&amp;quot;, &amp;quot;SD&amp;quot;, &amp;quot;0.00&amp;quot;);
#endif

static int enable_usb_device_next(void)
{
	int err;

	sample_usbd = sample_usbd_init_device(NULL);
	if (sample_usbd == NULL)
	{
		LOG_ERR(&amp;quot;Failed to initialize USB device&amp;quot;);
		return -ENODEV;
	}

	err = usbd_enable(sample_usbd);
	if (err)
	{
		LOG_ERR(&amp;quot;Failed to enable device support&amp;quot;);
		return err;
	}

	LOG_DBG(&amp;quot;USB device support enabled&amp;quot;);

	return 0;
}
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK_NEXT) */

static int _erase_flash(unsigned int id)
{
	const struct flash_area *pfa;
	int rc = -1;

	rc = flash_area_open(id, &amp;amp;pfa);
	if (rc &amp;lt; 0)
	{
		LOG_ERR(&amp;quot;Erasing flash area ... failed to open it (%d)&amp;quot;, rc);
		return rc;
	}
	LOG_ERR(&amp;quot;Opened flash area (%d) -&amp;gt; trying to erase it....&amp;quot;, rc);
	rc = flash_area_erase(pfa, 0, pfa-&amp;gt;fa_size);
	if (rc &amp;lt; 0)
	{
		LOG_ERR(&amp;quot;Erasing flash area ... failed! (%d)&amp;quot;, rc);
	}
	else
	{
		LOG_ERR(&amp;quot;Erased flash area OK.&amp;quot;);
	}
	flash_area_close(pfa);
	return rc;
}

static int _setup_flash(unsigned int id, struct fs_mount_t *mnt)
{
	int rc = -1;
#if CONFIG_DISK_DRIVER_FLASH
	const struct flash_area *pfa;

	mnt-&amp;gt;storage_dev = (void *)id;
	rc = flash_area_open(id, &amp;amp;pfa);
	if (rc &amp;lt; 0)
	{
		LOG_ERR(&amp;quot;Failed to open flash area (%d) -&amp;gt; trying to erase it....&amp;quot;, rc);
		rc = flash_area_erase(pfa, 0, pfa-&amp;gt;fa_size);
		if (rc &amp;lt; 0)
		{
			LOG_ERR(&amp;quot;Erasing flash area ... failed! (%d)&amp;quot;, rc);
			flash_area_close(pfa);
			return rc;
		}
		LOG_ERR(&amp;quot;Erased flash area OK.&amp;quot;);
		rc = flash_area_open(id, &amp;amp;pfa);
		if (rc &amp;lt; 0)
		{
			LOG_ERR(&amp;quot;Erasing flash area ... didn&amp;#39;t help, still can&amp;#39;t open it! (%d)&amp;quot;, rc);
			flash_area_close(pfa);
			return rc;
		}
	}
	LOG_ERR(&amp;quot;Flash USB mass storage opened : area %u at 0x%x on %s for %u bytes\n&amp;quot;,
			id, (unsigned int)pfa-&amp;gt;fa_off, pfa-&amp;gt;fa_dev-&amp;gt;name,
			(unsigned int)pfa-&amp;gt;fa_size);
#endif
	return pfa-&amp;gt;fa_size;
}

static int _mount_app_fs(struct fs_mount_t *mnt, char *mnt_point)
{
	int rc;

#if CONFIG_FAT_FILESYSTEM_ELM
	static FATFS fat_fs;

	mnt-&amp;gt;type = FS_FATFS;
	mnt-&amp;gt;fs_data = &amp;amp;fat_fs;
	mnt-&amp;gt;mnt_point = mnt_point;
#else
	LOG_ERR(&amp;quot;no file system type defined in firmware build, no FS mount available.&amp;quot;);
	return -1;
#endif
	rc = fs_mount(mnt);

	return rc;
}

static bool _setup_disk(struct fs_mount_t *mp, char *mnt_point)
{
	int rc;
	int flash_partition_size = 0;
	if (IS_ENABLED(CONFIG_DISK_DRIVER_FLASH))
	{
		// _erase_flash(STORAGE_PARTITION_ID);		// Only do this if created a FATFS on partition of wrong size initially...
		flash_partition_size = _setup_flash(STORAGE_PARTITION_ID, mp);
		if (flash_partition_size &amp;lt; 0)
		{
			LOG_ERR(&amp;quot;Failed to setup flash area&amp;quot;);
			return false;
		}
	}
	else
	{
		LOG_ERR(&amp;quot;No flash driver enabled&amp;quot;);
		return false;
	}

	if (!IS_ENABLED(CONFIG_FAT_FILESYSTEM_ELM))
	{
		LOG_ERR(&amp;quot;No file system enabled&amp;quot;);
		return false;
	}

	rc = _mount_app_fs(mp, mnt_point);
	if (rc &amp;lt; 0)
	{
		LOG_ERR(&amp;quot;Failed to mount filesystem on %s&amp;quot;, mnt_point);
		return false;
	}
	// If fatfs size is not the partition size, then we need to erase the partition and start again
	struct fs_statvfs fvol;
	rc = fs_statvfs(mnt_point, &amp;amp;fvol);
	LOG_INF(&amp;quot;statvfs says block size %d, total blocks %d -&amp;gt; %u bytes volume size&amp;quot;, fvol.f_blocks, fvol.f_frsize, fvol.f_blocks * fvol.f_frsize);
	if (abs((fvol.f_blocks * fvol.f_frsize) - flash_partition_size) &amp;gt; 100000)
	{ // approx
		LOG_ERR(&amp;quot;File system size (%u) not equal to flash zone size (%u) -&amp;gt; wiping and reformatting&amp;quot;, (fvol.f_blocks * fvol.f_frsize), flash_partition_size);
		_erase_flash(STORAGE_PARTITION_ID); // Only do this if created a FATFS on partition of wrong size initially...
		// And redo?
		// Need to close parition, unmountfs?
		fs_unmount(mp);
		flash_partition_size = _setup_flash(STORAGE_PARTITION_ID, mp);
		rc = _mount_app_fs(mp, mnt_point);
		if (rc &amp;lt; 0)
		{
			LOG_ERR(&amp;quot;Failed to mount filesystem on %s&amp;quot;, mnt_point);
			return false;
		}
	}
	/* Allow log messages to flush to avoid interleaved output */
	k_sleep(K_MSEC(50));

	return true;
}

int main(void)
{
	int ret;

	if (_setup_disk(&amp;amp;_fs_mnt, &amp;quot;/NAND:&amp;quot;))
	{
		LOG_INF(&amp;quot;USB mass storage mode enabled.\n&amp;quot;);
	}
	else
	{
		LOG_ERR(&amp;quot;USB mass storage mode FS failed!&amp;quot;);
	}

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
	ret = enable_usb_device_next();
#else
	ret = usb_enable(NULL);
#endif
	if (ret != 0)
	{
		LOG_ERR(&amp;quot;Failed to enable USB&amp;quot;);
		return 0;
	}

	LOG_INF(&amp;quot;The device is put in USB mass storage mode.\n&amp;quot;);
	return 0;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is my complete pm_static.yml file that I used:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcuboot:
    address: 0x0
    end_address: 0xe000
    region: flash_primary
    size: 0xe000

mcuboot_pad:
    address: 0xe000
    end_address: 0xe200
    region: flash_primary
    size: 0x200

app:
    address: 0xe200
    end_address: 0x100000
    region: flash_primary
    size: 0xf1e00

mcuboot_primary_app:
    address: 0xe200
    end_address: 0x100000
    region: flash_primary
    size: 0xf1e00
    span: [app]

mcuboot_primary:
    address: 0xe000
    end_address: 0x100000
    region: flash_primary
    size: 0xf2000
    span: [mcuboot_pad, mcuboot_primary_app]

# define partition for fatfs disk, on the external flash storage (probably the device defined by nordic,pm-ext-flash in the DTS)
fatfs_storage:
    region: external_flash
    affiliation: 
        - disk
    extra_params: {
        disk_name: &amp;quot;NAND&amp;quot;,
        disk_cache_size: 4096,
        disk_sector_size: 512,
        disk_read_only: 0
    }
    # 6Mb size, external flash is 8Mb total
    address: 0x0
    size: 0x600000

nvs_storage:
    region: external_flash
    affiliation: 
        - nvs
    # 64kB size, its just for small stuff
    address: 0x600000
    size: 0x10000

mcuboot_secondary_1:
    region: external_flash
    affiliation: 
        - mcuboot
    # 256kb size, its for netcore flash image
    address: 0x610000
    size: 0x40000

mcuboot_secondary:
    region: external_flash
    affiliation: 
        - mcuboot
    address: 0x650000
    # MUST be same size as the primary application slot size, and share_size does not appear to work
    size: 0xf1e00
    #share_size: [mcuboot_primary_app]

# internal cuisine
otp:
    address: 0xff8100
    end_address: 0xff83fc
    region: otp
    size: 0x2fc
pcd_sram:
    address: 0x20000000
    end_address: 0x20002000
    #placement:
    #    after:
    #    - start
    region: sram_primary
    size: 0x2000
rpmsg_nrf53_sram:
    address: 0x20070000
    end_address: 0x20080000
    #placement:
    #    before:
    #    - end
    region: sram_primary
    size: 0x10000
sram_primary:
    address: 0x20002000
    end_address: 0x20070000
    region: sram_primary
    size: 0x6e000

# TODO need fake flash ram flash partition to do cpunet DFU...
#mcuboot_primary_1:
#  address: 0x0
#  device: nordic_ram_flash_controller
#  end_address: 0x40000
#  region: ram_flash
#  size: 0x40000
#
#ram_flash:
#  address: 0x40000
#  end_address: 0x40000
#  region: ram_flash
#  size: 0x0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is my overlay:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
	chosen {
		nordic,pm-ext-flash = &amp;amp;winbond;
	};
};




&amp;amp;button2 {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;button3 {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;gpio_fwd {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;uicr {nfct-pins-as-gpios; };

&amp;amp;pinctrl {
	spi_master_default: spi_master_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 2)&amp;gt;,   // SCLK
			&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 9)&amp;gt;,  // MOSI
			&amp;lt;NRF_PSEL(SPIM_MISO, 0, 3)&amp;gt;;  // MISO
		};
	};

	spi_master_sleep: spi_master_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 2)&amp;gt;,   // SCLK
			&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 9)&amp;gt;,  // MOSI
			&amp;lt;NRF_PSEL(SPIM_MISO, 0, 3)&amp;gt;;  // MISO
			low-power-enable;
		};
	};
};


&amp;amp;spi3 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi_master_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi_master_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 11 GPIO_ACTIVE_LOW&amp;gt;;    // Chip Select (CS) on Pin 11
	status = &amp;quot;okay&amp;quot;;
	winbond: winbond@0 {
		compatible = &amp;quot;jedec,spi-nor&amp;quot;;
		reg = &amp;lt;0&amp;gt;;                               // CS0
		spi-max-frequency = &amp;lt;32000000&amp;gt;;
		// SPI max frequency (32 MHz)
		jedec-id = [ ef 70 22  ];                  // JEDEC ID for W25Q02JV
		size = &amp;lt;268435456&amp;gt;;                      // 256MB NOR flash size
		has-dpd;                                 // Deep Power Down (DPD) support
	};
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And using this I get this partition report:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt; external_flash (0x10000000 - 262144kB): 
+-------------------------------------------------+
| 0x0: external_flash (0x10000000 - 262144kB)     |
| 0x0: fatfs_storage (0x600000 - 6144kB)          |
| 0x600000: nvs_storage (0x10000 - 64kB)          |
| 0x610000: mcuboot_secondary_1 (0x40000 - 256kB) |
| 0x650000: mcuboot_secondary (0xf1e00 - 967kB)   |
+-------------------------------------------------+

  flash_primary (0x100000 - 1024kB):
+-------------------------------------------------+
| 0x0: mcuboot (0xe000 - 56kB)                    |
+---0xe000: mcuboot_primary (0xf2000 - 968kB)-----+
| 0xe000: mcuboot_pad (0x200 - 512B)              |
+---0xe200: mcuboot_primary_app (0xf1e00 - 967kB)-+
| 0xe200: app (0xf1e00 - 967kB)                   |
+-------------------------------------------------+

  otp (0x2fc - 764B):
+------------------------------+
| 0xff8100: otp (0x2fc - 764B) |
+------------------------------+

  sram_primary (0x80000 - 512kB):
+-----------------------------------------------+
| 0x20000000: pcd_sram (0x2000 - 8kB)           |
| 0x20002000: sram_primary (0x6e000 - 440kB)    |
| 0x20070000: rpmsg_nrf53_sram (0x10000 - 64kB) |
+-----------------------------------------------+

 CPUNET flash_primary (0x40000 - 256kB):
+--------------------------------------+
+---0x1000000: app (0x40000 - 256kB)---+
| 0x1000000: hci_ipc (0x40000 - 256kB) |
+--------------------------------------+

 CPUNET sram_primary (0x10000 - 64kB):
+-------------------------------------------+
| 0x21000000: sram_primary (0x10000 - 64kB) |
+-------------------------------------------+&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;prj.conf&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_STDOUT_CONSOLE=y

# CONFIG_LOG=y
# CONFIG_RTT_CONSOLE=y
# CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=y

CONFIG_FLASH=y

# # Enable mcumgr.
# CONFIG_MCUMGR=y

# # Enable most core commands.
# CONFIG_MCUMGR_CMD_IMG_MGMT=y
# CONFIG_MCUMGR_CMD_OS_MGMT=y

# # Ensure an MCUboot-compatible binary is generated.
# CONFIG_BOOTLOADER_MCUBOOT=y

# CONFIG_MULTITHREADING=y

# # Some command handlers require a large stack.
# CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

# CONFIG_NORDIC_QSPI_NOR=y
# CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
# CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

# CONFIG_MCUMGR_SMP_UART=y

# CONFIG_MCUBOOT_IMAGE_VERSION=&amp;quot;0.1.1+8&amp;quot;

# CONFIG_PM_PARTITION_REGION_FATFS_STORAGE_EXTERNAL=y


#USB related configs
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;Very FATFS storage&amp;quot;
CONFIG_USB_DEVICE_PID=0x0008
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_USB_CDC_ACM=n
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_APP_MSC_STORAGE_FLASH_FATFS=y
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_APP_WIPE_STORAGE=y
CONFIG_NORDIC_QSPI_NOR=n
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NRFX_SPIM3=y

CONFIG_MULTITHREADING=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
CONFIG_BT=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After doing this now, when I flash&amp;nbsp;I get nothing in the terminal, not even&amp;nbsp;&lt;br /&gt;*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***&lt;br /&gt;*** Using Zephyr OS v3.6.99-100befc70c74 ***&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/workingFlash.zip"&gt;devzone.nordicsemi.com/.../workingFlash.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have also attached the zip file, if you want to take a look. It is my first time working with storage, file system and Bluetooth together, I would really appreciate if you could provide any further suggestions here.&lt;br /&gt;&lt;br /&gt;Regards,&lt;/p&gt;
&lt;p&gt;Barsha&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/505736?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2024 12:53:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cc5506d-bcb1-4f7d-b4f4-632b5f0aad0a</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;You&amp;#39;ve set the config, yes. But as of NCS 2.5.0 this was deprecated and you will need to set the NFCT pins as GPIOs in&amp;nbsp;the .dts file with&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;amp;uicr { nfct-pins-as-gpios; };&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;for your current NCS version.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/505694?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2024 09:58:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa3f0ef7-3da8-461d-9cb5-50f87938782f</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;I have a similar setup on a custom PCB using nrf5340 with external flash chip.&lt;/p&gt;
&lt;p&gt;See&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/115046/dfu-using-usb-file-system-not-serial-emulation/504712"&gt;RE: DFU using USB file system (not serial emulation)?&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;in that thread is my pm_static.yml - btw I define staticallly all the partitions on the internal and external flash to ensure that future builds don&amp;#39;t move them, and break mcuboot DFU...&lt;/p&gt;
&lt;p&gt;For mounting the FAT FS, I use the ELM FAT subsystem also. I don&amp;#39;t actually do a mkfs at all, but it works...&lt;/p&gt;
&lt;p&gt;My init code (you&amp;#39;ll need to replace my log_X calls...also I decided to call my fatfs flash area a different name to ensure no interaction with any other random code zephyr/nrf decide to pull in...)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
#include &amp;lt;zephyr/usb/usb_device.h&amp;gt;
#include &amp;lt;zephyr/usb/usbd.h&amp;gt;
#include &amp;lt;zephyr/usb/class/usbd_msc.h&amp;gt;
#include &amp;lt;zephyr/fs/fs.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

#include &amp;quot;util/wutils.h&amp;quot;

#if CONFIG_DISK_DRIVER_FLASH
#include &amp;lt;zephyr/storage/flash_map.h&amp;gt;
#endif

#if CONFIG_FAT_FILESYSTEM_ELM
#include &amp;lt;ff.h&amp;gt;
#endif

#include &amp;quot;usb_fs.h&amp;quot;

//#define STORAGE_PARTITION		storage_partition
#define STORAGE_PARTITION		fatfs_storage
#define STORAGE_PARTITION_ID		FIXED_PARTITION_ID(STORAGE_PARTITION)

static struct fs_mount_t _fs_mnt;

static int _erase_flash(unsigned int id) {
	const struct flash_area *pfa;
	int rc = -1;

	rc = flash_area_open(id, &amp;amp;pfa);
	if (rc&amp;lt;0) {
		log_warn(&amp;quot;Erasing flash area ... failed to open it (%d)&amp;quot;,rc);
		return rc;
	}
	log_warn(&amp;quot;Opened flash area (%d) -&amp;gt; trying to erase it....&amp;quot;,rc);
	rc = flash_area_erase(pfa, 0, pfa-&amp;gt;fa_size);
	if (rc&amp;lt;0) {
		log_warn(&amp;quot;Erasing flash area ... failed! (%d)&amp;quot;,rc);
	} else {
		log_warn(&amp;quot;Erased flash area OK.&amp;quot;);
	}
	flash_area_close(pfa);
	return rc;
}
static int _setup_flash(unsigned int id, struct fs_mount_t *mnt)
{
	int rc = -1;
#if CONFIG_DISK_DRIVER_FLASH
	const struct flash_area *pfa;

	mnt-&amp;gt;storage_dev = (void *)id;
	rc = flash_area_open(id, &amp;amp;pfa);
	if (rc &amp;lt; 0) {
		log_warn(&amp;quot;Failed to open flash area (%d) -&amp;gt; trying to erase it....&amp;quot;,rc);
		rc = flash_area_erase(pfa, 0, pfa-&amp;gt;fa_size);
		if (rc&amp;lt;0) {
			log_warn(&amp;quot;Erasing flash area ... failed! (%d)&amp;quot;,rc);
			flash_area_close(pfa);
			return rc;
		} 
		log_warn(&amp;quot;Erased flash area OK.&amp;quot;);
		rc = flash_area_open(id, &amp;amp;pfa);
		if (rc&amp;lt;0) {
			log_warn(&amp;quot;Erasing flash area ... didn&amp;#39;t help, still can&amp;#39;t open it! (%d)&amp;quot;,rc);
			flash_area_close(pfa);
			return rc;
		} 
	}
	log_info(&amp;quot;Flash USB mass storage opened : area %u at 0x%x on %s for %u bytes\n&amp;quot;,
		id, (unsigned int)pfa-&amp;gt;fa_off, pfa-&amp;gt;fa_dev-&amp;gt;name,
		(unsigned int)pfa-&amp;gt;fa_size);
#endif
	return pfa-&amp;gt;fa_size;
}

static int _mount_app_fs(struct fs_mount_t *mnt, char* mnt_point)
{
	int rc;

#if CONFIG_FAT_FILESYSTEM_ELM
	static FATFS fat_fs;

	mnt-&amp;gt;type = FS_FATFS;
	mnt-&amp;gt;fs_data = &amp;amp;fat_fs;
	mnt-&amp;gt;mnt_point = mnt_point;
#else
	log_warn(&amp;quot;no file system type defined in firmware build, no FS mount available.&amp;quot;);
	return -1;
#endif
	rc = fs_mount(mnt);

	return rc;
}

static bool _setup_disk(struct fs_mount_t *mp, char* mnt_point) {
	int rc;
	int flash_partition_size = 0;
	if (IS_ENABLED(CONFIG_DISK_DRIVER_FLASH)) {
		// _erase_flash(STORAGE_PARTITION_ID);		// Only do this if created a FATFS on partition of wrong size initially...
		flash_partition_size = _setup_flash(STORAGE_PARTITION_ID, mp);
		if (flash_partition_size &amp;lt; 0) {
			log_error(&amp;quot;Failed to setup flash area&amp;quot;);
			return false;
		}
	} else {
		log_error(&amp;quot;No flash driver enabled&amp;quot;);
		return false;
	}

	if (!IS_ENABLED(CONFIG_FAT_FILESYSTEM_ELM)) {
		log_error(&amp;quot;No file system enabled&amp;quot;);
		return false;
	}

	rc = _mount_app_fs(mp, mnt_point);
	if (rc &amp;lt; 0) {
		log_error(&amp;quot;Failed to mount filesystem on %s&amp;quot;, mnt_point);
		return false;
	}
	// If fatfs size is not the partition size, then we need to erase the partition and start again
	struct fs_statvfs fvol;
	rc = fs_statvfs(mnt_point, &amp;amp;fvol);
	log_info(&amp;quot;statvfs says block size %d, total blocks %d -&amp;gt; %u bytes volume size&amp;quot;, fvol.f_blocks, fvol.f_frsize, fvol.f_blocks*fvol.f_frsize);
	if (abs((fvol.f_blocks*fvol.f_frsize)-flash_partition_size)&amp;gt;100000) {		// approx
		log_warn(&amp;quot;File system size (%u) not equal to flash zone size (%u) -&amp;gt; wiping and reformatting&amp;quot;, (fvol.f_blocks*fvol.f_frsize), flash_partition_size);
		_erase_flash(STORAGE_PARTITION_ID);		// Only do this if created a FATFS on partition of wrong size initially...
		// And redo?
		// Need to close parition, unmountfs?
		fs_unmount(mp);
		flash_partition_size = _setup_flash(STORAGE_PARTITION_ID, mp);
		rc = _mount_app_fs(mp, mnt_point);
		if (rc &amp;lt; 0) {
			log_error(&amp;quot;Failed to mount filesystem on %s&amp;quot;, mnt_point);
			return false;
		}
	}
	/* Allow log messages to flush to avoid interleaved output */
	k_sleep(K_MSEC(50));

	return true;
}

And then call during init phase:
	if (_setup_disk(&amp;amp;_fs_mnt, &amp;quot;/NAND:&amp;quot;)) {
		log_info(&amp;quot;USB mass storage mode enabled.\n&amp;quot;);
	} else {
    	log_warn(&amp;quot;USB mass storage mode FS failed!&amp;quot;);
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hopefully this will help you... it took me a while to get to this point...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/505594?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 13:40:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a3f981a-3289-4d38-8993-79dd12e69a84</guid><dc:creator>Barsa</dc:creator><description>&lt;p&gt;I have already done that, you can see it on my prj.conf. The only issues I am having is with the partitions and mounting&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/505453?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2024 06:04:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f12f532-d6cf-466d-8de1-2d0c33f0e0a6</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I see you&amp;#39;re using pins P0.02 and P0.03 for SPI pins here. These are configured as NFC pins by default, and you need to configure these as GPIOs if you want to use them as such. Depending on the SDK version you&amp;#39;re using, you need to set either &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_NFCT_PINS_AS_GPIOS"&gt;CONFIG_NFCT_PINS_AS_GPIOS &lt;/a&gt;(for older than NCS v2.5.0), or you need to set it in the .dts file with&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;amp;uicr { nfct-pins-as-gpios; };&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/505210?ContentTypeID=1</link><pubDate>Mon, 07 Oct 2024 13:47:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9d0ed39-bfe1-40b6-a489-306eb8f02072</guid><dc:creator>Barsa</dc:creator><description>&lt;p&gt;Hi Simonr,&lt;/p&gt;
&lt;p&gt;When I try to build the same code without this pm_static.yml and add fixed partition part in the overlay file I can mount the Fat FS into my winbond NOR storage and even write into it:&lt;/p&gt;
&lt;p&gt;overlay file:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt; / {
	chosen {
		nordic,pm-ext-flash = &amp;amp;winbond;
	};
};

/* Disable conflicting buttons and UART */
&amp;amp;button2 {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;button3 {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;gpio_fwd {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;pinctrl {
		spi_master_default: spi_master_default {
				group1 {
						psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 2)&amp;gt;,
										&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 9)&amp;gt;,
										&amp;lt;NRF_PSEL(SPIM_MISO, 0, 3)&amp;gt;;
				};
		};

		spi_master_sleep: spi_master_sleep {
				group1 {
						psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 2)&amp;gt;,
										&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 9)&amp;gt;,
										&amp;lt;NRF_PSEL(SPIM_MISO, 0, 3)&amp;gt;;
						low-power-enable;
				};
		};
};

&amp;amp;spi4 {
		compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
		pinctrl-0 = &amp;lt;&amp;amp;spi_master_default&amp;gt;;
		pinctrl-1 = &amp;lt;&amp;amp;spi_master_sleep&amp;gt;;
		pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
		cs-gpios = &amp;lt;&amp;amp;gpio0 11 GPIO_ACTIVE_LOW&amp;gt;;	
		status = &amp;quot;okay&amp;quot;;
		winbond:winbondw25q02@0 {
			compatible = &amp;quot;jedec,spi-nor&amp;quot;;
			reg = &amp;lt;0&amp;gt;;
	//      irq-gpios = &amp;lt;&amp;amp;gpio0 21 0&amp;gt;;
			spi-max-frequency = &amp;lt;32000000&amp;gt;;
			//label = &amp;quot;WINBOND&amp;quot;;
			jedec-id = [ ef 70 22 ];
			size = &amp;lt;0x10000000&amp;gt;;
			has-dpd;
			// sfdp-bfp = [
		 	// 	e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
		 	// 	ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
		 	// 	10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
		 	// 	30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		 	// ];
		};
};

/delete-node/ &amp;amp;storage_partition;

&amp;amp;winbond {
	partitions {
		compatible = &amp;quot;fixed-partitions&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;1&amp;gt;;

		storage_partition: partition@0 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x00000000 0x01000000&amp;gt;;
		};
	};
};

/ {
	msc_disk0 {
		compatible = &amp;quot;zephyr,flash-disk&amp;quot;;
		partition = &amp;lt;&amp;amp;storage_partition&amp;gt;;
		disk-name = &amp;quot;NAND&amp;quot;;
		cache-size = &amp;lt;65536&amp;gt;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;output terminal:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;winbondw25q02@0 SPI flash testing
==========================

Perform test on single sector
Test 1: Flash erase
*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***
Flash erase succeeded!

Test 2: Flash write
Attempting to write 4 bytes
Data read matches data written. Good!!
[00:00:00.378,845] &amp;lt;inf&amp;gt; flashdisk: Initialize device NAND
[00:00:00.378,875] &amp;lt;inf&amp;gt; flashdisk: offset 0, sector size 512, page size 4096, volume size 16777216
[00:00:00.386,016] &amp;lt;inf&amp;gt; flashdisk: Initialize device NAND
[00:00:00.386,047] &amp;lt;inf&amp;gt; flashdisk: offset 0, sector size 512, page size 4096, volume size 16777216
[00:00:01.456,390] &amp;lt;inf&amp;gt; flashdisk: Initialize device NAND
[00:00:01.456,420] &amp;lt;inf&amp;gt; flashdisk: offset 0, sector size 512, page size 4096, volume size 16777216
FATFS mounted successfully.
File write successful!
Reading file content:
Hello FATFS on SPI Flash!
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But my application also requires bluetooth functionality, and when I add CONFIG_BT=y in project config, it says &amp;quot;partition manager enabled and all partitions of devicetree will now be ignored&amp;quot; and I get the following build error:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;C:/ncs/v2.7.0/zephyr/drivers/disk/flashdisk.c:484:1: error: return type defaults to &amp;#39;int&amp;#39; [-Werror=implicit-int]&lt;br /&gt; 484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)&lt;br /&gt; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;That is why I thought pm_static.yml would fix this problem, but its still the same. However, with CONFIG_BT=n I can at least build and generate the memory report but still cant mount.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to mount fat FS using external partition manager using pm_static.yml file</title><link>https://devzone.nordicsemi.com/thread/505190?ContentTypeID=1</link><pubDate>Mon, 07 Oct 2024 12:57:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea1c3ed4-163f-4c0e-bcc5-1106cdd0a009</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;How are you powering the SD card/reader on your end. The VDD on the nRF5340 DK is too low for some SD cards, so you can try using a 3.3V external power source and see if that changes anything.&lt;/p&gt;
&lt;p&gt;Are you using any of the Filesystem samples available in Zephyr as a template here or have you developed this project yourself?&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/fs/fs.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/fs/fs.html&lt;/a&gt;&amp;nbsp;File systems documentation can also be found here:&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/file_system/index.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/file_system/index.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re not able to get anywhere, try finding out what function in your project is returning this error 5 when running. Error message 5 points to an I/O error, so my first guess would be that the power source isn&amp;#39;t suficient, if not it is likely due to how the SD card is connected to the nRF5340 or that the pins used for communicating aren&amp;#39;t set up correctly.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>