<?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>Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121738/manually-control-usb-msc-initialization-timing</link><description>In my project (SDK 2.9.1), I have configured a USB Mass Storage (MSC) device that uses a QSPI flash, like the one on the 52840DK board. 
 
 My system goes into sleep mode when a button is pressed, but before that it powers down some peripherals to reduce</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Jun 2025 08:46:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121738/manually-control-usb-msc-initialization-timing" /><item><title>RE: Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/thread/537800?ContentTypeID=1</link><pubDate>Tue, 03 Jun 2025 08:46:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92997ff9-8862-41a1-836a-85b0d4efe4d4</guid><dc:creator>Andrea Verdecchia</dc:creator><description>[quote userid="2111" url="~/f/nordic-q-a/121738/manually-control-usb-msc-initialization-timing/537715"]Else you need to add an&amp;nbsp;SYS_INIT() [/quote]
&lt;p&gt;You&amp;#39;re right, I hadn&amp;#39;t thought of that. Thank you so much &amp;mdash; I tried it and now it seems to be working fine. Thanks a lot for the tip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/thread/537715?ContentTypeID=1</link><pubDate>Mon, 02 Jun 2025 15:48:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dffa5f5a-8039-4fef-99f2-3c9941d4fadd</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hmm.. I guess you can possible modify flashdisk.c to power up the flash memory in the disk_flash_init():&lt;br /&gt;\zephyr\drivers\disk\flashdisk.c&lt;/p&gt;
&lt;p&gt;Else you need to add an&amp;nbsp;SYS_INIT() that is called prior to CONFIG_KERNEL_INIT_PRIORITY_DEFAULT to power it up. That might be easiest, since you avoid changing the above file.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/thread/537502?ContentTypeID=1</link><pubDate>Fri, 30 May 2025 10:17:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2e8c25c-75a7-46ad-bf6a-17cb941afba0</guid><dc:creator>Andrea Verdecchia</dc:creator><description>&lt;p data-start="55" data-end="597"&gt;Sorry for the late reply. Let me try to better explain my problem. My application runs on custom hardware. The nRF52840 I&amp;#39;m using has a pin that enables power to some peripherals that I want to completely turn off when going to sleep and reactivate when waking up. As a result, this signal that powers the peripherals is activated during the initialization of my main thread, which is called &lt;code data-start="447" data-end="459"&gt;App_Thread&lt;/code&gt;. Until that moment, the peripherals I turned off remain powered down. Among these peripherals is also the Flash memory I&amp;rsquo;m using for MSC.&lt;/p&gt;
&lt;p data-start="599" data-end="807"&gt;The issue is that, during startup, it seems the MSC is being initialized &lt;em data-start="672" data-end="680"&gt;before&lt;/em&gt; the &lt;code data-start="685" data-end="697"&gt;App_Thread&lt;/code&gt;&amp;nbsp;starts and thus before the Flash memory is powered. In fact, during boot, the nRF52840 outputs the following:&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;err&amp;gt; qspi_nor: JEDEC id [ff ff ff] expect [20 bb 20]
*** Booting My Application v0.0.1-3822453fa6ec ***
*** Using nRF Connect SDK v2.9.1-60d0d6c8d42d ***
*** Using Zephyr OS v3.7.99-ca954a6216c9 ***
&amp;lt;err&amp;gt; flashdisk: Flash area 0 open error -19
&amp;lt;err&amp;gt; usb_msc: Storage init ERROR !!!! - Aborting USB init
&lt;/pre&gt;&lt;/p&gt;
&lt;p data-start="1122" data-end="1251"&gt;Mybe I&amp;#39;m worng but the first line suggests that before my code runs, MSC initialization is attempted and fails because the Flash is still unpowered.&lt;/p&gt;
&lt;p data-start="1253" data-end="1416"&gt;So, my question is whether it is possible to control the MSC initialization manually &amp;mdash; that is, to initialize it &lt;em data-start="1366" data-end="1389"&gt;only when I choose to&lt;/em&gt;, after powering the Flash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/thread/536885?ContentTypeID=1</link><pubDate>Mon, 26 May 2025 08:37:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0e1dc58-b378-499a-ac00-933951965235</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;But then it seems you already have control over this, and can add appropriate delays&amp;nbsp;if needed? What am I missing here?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/thread/536762?ContentTypeID=1</link><pubDate>Fri, 23 May 2025 11:33:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a38bf737-64ce-4f29-be38-4306709dfdce</guid><dc:creator>Andrea Verdecchia</dc:creator><description>&lt;p&gt;No, I&amp;rsquo;ve already enabled that configuration and I&amp;rsquo;m calling &lt;code data-start="97" data-end="111"&gt;usb_enable()&lt;/code&gt; only at the end of my initialization.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
################################################
### SYSTEM CONFIGURATION #######################
################################################
CONFIG_LOG=y
CONFIG_LOG_BUFFER_SIZE=2048
CONFIG_LOG_MAX_LEVEL=2
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_RING_BUFFER=y
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_REBOOT=y
CONFIG_KERNEL_BIN_NAME=&amp;quot;XXXXX&amp;quot;
# CONFIG_DISABLE_FLASH_PATCH=y
CONFIG_POWEROFF=y
CONFIG_PM_DEVICE=y
CONFIG_THREAD_NAME=y
# CONFIG_THREAD_ANALYZER=y
# CONFIG_THREAD_ANALYZER_AUTO=y

# printf floats support
CONFIG_CBPRINTF_LIBC_SUBSTS=y
CONFIG_CBPRINTF_FP_SUPPORT=y

# time library support
CONFIG_NEWLIB_LIBC=y
CONFIG_POSIX_API=y

################################################
### SOC&amp;#39;S PERIPHERALS CONFIGURATION ############
################################################
CONFIG_GPIO=y
CONFIG_PWM=y
CONFIG_LED=y
CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_NRFX_SPIM2=y
# CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_GPIOTE0=y
CONFIG_NRFX_GPIOTE1=y
CONFIG_NRFX_PPI=y
CONFIG_NRFX_QSPI=y                                  
CONFIG_NORDIC_QSPI_NOR=y                            
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096  
CONFIG_USB_DEVICE_MANUFACTURER=&amp;quot;XXXXX&amp;quot;
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;XXXXX&amp;quot;
CONFIG_USB_DEVICE_SN=&amp;quot;XXXXX&amp;quot;
CONFIG_USB_DEVICE_PID=0x0002
CONFIG_USB_DEVICE_VID=0xAD5A

################################################
### NVS MEMORY CONFIGURATION ###################
################################################
CONFIG_NVS=y

################################################
### FLASH MEMORY SUPPORT CONFIGURATION #########
################################################
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FLASH_MAP=y

################################################
### BLE CONFIGURATION ##########################
################################################
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME=&amp;quot;XXXXX&amp;quot;
# CONFIG_BT_SMP=y
CONFIG_BT_DEVICE_APPEARANCE=1345
CONFIG_BT_MAX_CONN=1
CONFIG_BT_LL_SOFTDEVICE=y
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_ATT_PREPARE_COUNT=2
# CONFIG_BT_L2CAP_TX_BUF_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=498
# CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_CTLR_RX_BUFFERS=2
CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_CONN_RSSI=y

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=80
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

CONFIG_BT_ATT_TX_COUNT=10
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_BUF_EVT_RX_COUNT=11

################################################
### MASS STORAGE CONFIGURATION #################
################################################
CONFIG_USB_MASS_STORAGE=y
CONFIG_MASS_STORAGE_DISK_NAME=&amp;quot;NAND&amp;quot;

################################################
### FILE SYSTEMFS CONFIGURATION ################
################################################
CONFIG_DISK_DRIVER_FLASH=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_LFN=y

################################################
### DFU CONFIGURATION ##########################
################################################
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y
CONFIG_MCUMGR=y
CONFIG_STREAM_FLASH=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_THREAD_MONITOR=y
CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
CONFIG_STATS=y
CONFIG_STATS_NAMES=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_STAT=y
CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
CONFIG_CONSOLE=y
CONFIG_MCUMGR_TRANSPORT_UART=y
CONFIG_BASE64=y&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manually control USB MSC initialization timing</title><link>https://devzone.nordicsemi.com/thread/536760?ContentTypeID=1</link><pubDate>Fri, 23 May 2025 11:26:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d5fb4e1-e283-45db-98b3-f2b0aaf62893</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Does using&amp;nbsp;CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n help?&lt;/p&gt;
&lt;p&gt;With this configuration, you can call the USB initialization functions (such as usb_enable()) at the appropriate time in your application, after ensuring the flash is active and ready for use by the MSC class.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>