<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Mass Storage FRDM-MCXN947 With SD Card in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1974398#M1778</link>
    <description>Hi XuZhang,&lt;BR /&gt;thank you for your reply and great support from NXP. I am developing device on FreeRTOS that has two task and each of them uses SD card. When I move the initialization to the main (to not initialize SD card twice), there is probably still issue that SD_Init() function still has a connection to FreeRTOS task resources, and program ends up in hard-fault, is that possible?</description>
    <pubDate>Tue, 15 Oct 2024 15:14:19 GMT</pubDate>
    <dc:creator>Doly02</dc:creator>
    <dc:date>2024-10-15T15:14:19Z</dc:date>
    <item>
      <title>Mass Storage FRDM-MCXN947 With SD Card</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1972672#M1764</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am currently trying to run a Mass Storage Device example on FRDM-MCXN974 with SD card support and FreeRTOS. I managed to get the standard example to run fine. The code contains two tasks APP_task and USB_DeviceTask, I am trying to reduce this code to only one task, which I have designed as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;int main(void)
{
    /* Initialize board hardware. */
    APP_InitBoard();

    USB_DeviceApplicationInit();
    usb_echo("Available heap size before task creation: %d bytes\r\n", xPortGetFreeHeapSize());
    if (g_msc.deviceHandle)
    {
        if (xTaskCreate(USB_DeviceTask,                  /* pointer to the task */
                        (char const *)"usb device task", /* task name for kernel awareness debugging */
                        9000L / sizeof(portSTACK_TYPE),  /* task stack size */
                        g_msc.deviceHandle,              /* optional task startup argument */
                        4,                               /* initial priority */
                        &amp;amp;g_msc.device_task_handle        /* optional task handle to create */
                        ) != pdPASS)
        {
            usb_echo("usb device task create failed!\r\n");
            return 1;
        }
    }
    vTaskStartScheduler();
    while (1)
    {
    	;
    }
    return 1;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But It always end with fard-fault in USB_DeviceApplicationInit() as in the attached picture.&lt;/P&gt;&lt;P&gt;The original code looked like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;int main(void)
{
    /* board initialization... */

    /* task... */
    if (xTaskCreate(APP_task,                       /* pointer to the task */
                    (char const *)"app task",       /* task name for kernel awareness debugging */
                    5000L / sizeof(portSTACK_TYPE), /* task stack size */
                    &amp;amp;g_msc,                         /* optional task startup argument */
                    3,                              /* initial priority */
                    &amp;amp;g_msc.application_task_handle  /* optional task handle to create */
                    ) != pdPASS)
    {
        usb_echo("app task create failed!\r\n");
    }
    vTaskStartScheduler();
    return 1;
}
void USB_DeviceTask(void *handle)
{
    while (1U)
    {
        USB_DeviceTaskFn(handle);
    }
}
void APP_task(void *handle)
{
    USB_DeviceApplicationInit();

#if USB_DEVICE_CONFIG_USE_TASK
    if (g_msc.deviceHandle)
    {
        if (xTaskCreate(USB_DeviceTask,                  /* pointer to the task */
                        (char const *)"usb device task", /* task name for kernel awareness debugging */
                        5000L / sizeof(portSTACK_TYPE),  /* task stack size */
                        g_msc.deviceHandle,              /* optional task startup argument */
                        5,                               /* initial priority */
                        &amp;amp;g_msc.device_task_handle        /* optional task handle to create */
                        ) != pdPASS)
        {
            usb_echo("usb device task create failed!\r\n");
            return;
        }
    }
    while (1)
    {
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did I miss anything? Can I somehow reduce the code just to one task?&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2024 18:44:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1972672#M1764</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-10-12T18:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Mass Storage FRDM-MCXN947 With SD Card</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1972673#M1765</link>
      <description />
      <pubDate>Sat, 12 Oct 2024 18:47:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1972673#M1765</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-10-12T18:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Mass Storage FRDM-MCXN947 With SD Card</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1973252#M1771</link>
      <description>&lt;P&gt;hi，&lt;A id="link_6" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/235054" target="_self" aria-label="View Profile of Doly02"&gt;&lt;SPAN class=""&gt;Doly02&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your interest in NXP Semiconductor products and the opportunity to serve you, I will gladly help you with this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You can try to modify the frdmmcxn947_dev_msc_disk_freertos demo program in the way shown in the picture.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XuZhang_0-1728899840169.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/304529i0437FAF26F2006F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XuZhang_0-1728899840169.png" alt="XuZhang_0-1728899840169.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XuZhang_1-1728899848333.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/304530i67F49BC47703088D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XuZhang_1-1728899848333.png" alt="XuZhang_1-1728899848333.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Wish it helps you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you still have question about it,please kindly let me know.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Zhang Xu&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 09:58:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1973252#M1771</guid>
      <dc:creator>Joey_z</dc:creator>
      <dc:date>2024-10-14T09:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Mass Storage FRDM-MCXN947 With SD Card</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1974398#M1778</link>
      <description>Hi XuZhang,&lt;BR /&gt;thank you for your reply and great support from NXP. I am developing device on FreeRTOS that has two task and each of them uses SD card. When I move the initialization to the main (to not initialize SD card twice), there is probably still issue that SD_Init() function still has a connection to FreeRTOS task resources, and program ends up in hard-fault, is that possible?</description>
      <pubDate>Tue, 15 Oct 2024 15:14:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1974398#M1778</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-10-15T15:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Mass Storage FRDM-MCXN947 With SD Card</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1974764#M1780</link>
      <description>&lt;P&gt;hi,&lt;SPAN&gt;Doly02&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I don't think it's possible that the SD_Init () function is still connected to the FreeRTOS task resource, and the program ends up with a hard failure, and SD card initialization is done in the USB_DeviceApplicationInit() function. You can refer to the frdmmcxn947_dev_msc_disk_bm demo program where the USB_DeviceApplicationInit() function is initialized in main.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XuZhang_0-1729048195303.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/304908iAE6A2E0E90684DA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XuZhang_0-1729048195303.png" alt="XuZhang_0-1729048195303.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If you use SD cards in Freertos, ensure that the tasks have enough stack space and do not conflict with other tasks, ensure that the initialization and use of the SD card is thread-safe, and you can use the Mutex provided by FreeRTOS to prevent problems caused by multiple tasks accessing the SD card at the same time. If the SD card initialization is done in one task, and other tasks need to wait for the initialization to complete before using the SD card, then Semaphore or other synchronization mechanism should be used to coordinate the tasks.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Xu Zhang&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 03:10:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1974764#M1780</guid>
      <dc:creator>Joey_z</dc:creator>
      <dc:date>2024-10-16T03:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Mass Storage FRDM-MCXN947 With SD Card</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1983908#M1859</link>
      <description>Thank you, so the best way is to use as a baseline bare-metal example for my project&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Oct 2024 14:15:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Mass-Storage-FRDM-MCXN947-With-SD-Card/m-p/1983908#M1859</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-10-29T14:15:45Z</dc:date>
    </item>
  </channel>
</rss>

