<?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>Kinetis Software Development Kit中的主题 Re: fsl_sdcard malloc return NULL pointer</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493896#M4512</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Iva,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for late response. No I didn't try to increase stack size. I checked the MKL25Z128 linker flash file and found exactly what you showed me. But I don't like the idea of editing these sources files because it's also using by many other projects (I guess ?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Processor Expert, so I have found that the heap size default value was 0x0000 into &lt;EM&gt;Cpu component -&amp;gt; Build option.&lt;/EM&gt; So, I simply set it to the same value of stack size (0x0400) for a test and it solve my problem ! &lt;SPAN style="font-family: andale mono,times;"&gt;&lt;EM&gt;Calloc()&lt;/EM&gt;&lt;/SPAN&gt; function do not return a NULL pointer any more. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3334ca; font-size: 10pt;"&gt;&lt;SPAN style="font-family: andale mono,times;"&gt; &lt;/SPAN&gt;&lt;EM style="font-family: andale mono,times;"&gt; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture d’écran 2016-03-31 à 14.32.41.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26615i86AF129119625C1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2016-03-31 à 14.32.41.png" alt="Capture d’écran 2016-03-31 à 14.32.41.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thank you for your response, you lead me to the good way :smileyhappy:.&lt;/P&gt;&lt;P&gt;Even I can't still use fsl_sdcard component correctly (didn't find any good code example)&amp;nbsp; but I can read/write to my sd card with fsl_spi component. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Mar 2016 12:53:29 GMT</pubDate>
    <dc:creator>mr_max</dc:creator>
    <dc:date>2016-03-31T12:53:29Z</dc:date>
    <item>
      <title>fsl_sdcard malloc return NULL pointer</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493894#M4510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am face with a problem with &lt;SPAN style="font-family: andale mono,times;"&gt;fsl_sdcard&lt;/SPAN&gt; component in KSDK v1.3 + PEx. I would like to read a block of my micro SDHC card with &lt;SPAN style="font-family: andale mono,times; font-size: 10pt;"&gt;SDSPI_DRV_ReadBlocks() &lt;/SPAN&gt;function driver. But it seem that it doesn't work because that function always returning &lt;SPAN style="; color: #3334ca; font-size: 10pt;"&gt;&lt;EM&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;kStatus_SDSPI_OutOfMemory.&lt;/SPAN&gt; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhere, &lt;SPAN style="font-family: andale mono,times; font-size: 10pt;"&gt;SDSPI_DRV_ReadBlocks()&lt;/SPAN&gt; call &lt;SPAN style="font-family: andale mono,times; font-size: 10pt;"&gt;calloc()&lt;/SPAN&gt;&amp;nbsp; function (see more bellow) and this is cause the problem.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using FRDM-KL25Z board.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code :&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void run_sdcard(void) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t buffer[512] = {0}; &amp;nbsp;&amp;nbsp;&amp;nbsp; SDSPI_DRV_ReadBlocks(&amp;amp;memoryCard1_spi_state,&amp;amp;memoryCard1_state,buffer,0,1); &amp;nbsp;&amp;nbsp;&amp;nbsp; while(1);&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source of &lt;SPAN style="font-family: andale mono,times;"&gt;&lt;STRONG&gt;&lt;EM&gt;fsl_sdcard_spi.c&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;sdspi_status_t SDSPI_DRV_ReadBlocks(sdspi_spi_t *spi, sdspi_card_t *card, uint8_t *buffer, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t startBlock, uint32_t blockCount) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t offset, i; &amp;nbsp;&amp;nbsp;&amp;nbsp; sdspi_request_t *req; &amp;nbsp;&amp;nbsp;&amp;nbsp; assert(spi); &amp;nbsp;&amp;nbsp;&amp;nbsp; assert(card); &amp;nbsp;&amp;nbsp;&amp;nbsp; assert(buffer); &amp;nbsp;&amp;nbsp;&amp;nbsp; assert(blockCount);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; req = (sdspi_request_t *)OSA_MemAllocZero(sizeof(sdspi_request_t)); &amp;nbsp;&amp;nbsp;&amp;nbsp; if (req == NULL) &amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return kStatus_SDSPI_OutOfMemory; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; offset = startBlock; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (!IS_BLOCK_ACCESS(card)) &amp;nbsp;&amp;nbsp;&amp;nbsp; { ....&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source of &lt;SPAN style="font-family: andale mono,times;"&gt;&lt;STRONG&gt;fsl_os_abstraction_bm.c. &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;You can see the&lt;/SPAN&gt; calloc() &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;/*FUNCTION**********************************************************************&amp;nbsp; *&amp;nbsp; * Function Name : OSA_MemAllocZero&amp;nbsp; * Description&amp;nbsp;&amp;nbsp; : This function is used to allocate amount of memory in bytes&amp;nbsp; * and initializes it to 0.&amp;nbsp; * Return the pointer to the memory if success, otherwise return NULL;&amp;nbsp; *&amp;nbsp; *END**************************************************************************/ void * OSA_MemAllocZero(size_t size) { &amp;nbsp;&amp;nbsp;&amp;nbsp; return calloc(1, size); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why memories allocations failed like that ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:23:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493894#M4510</guid>
      <dc:creator>mr_max</dc:creator>
      <dc:date>2016-03-21T14:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: fsl_sdcard malloc return NULL pointer</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493895#M4511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maxime,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please, have you tried to increase stack size in MKL25Z128xxx4_flash.ld file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14586533055044775 jive_text_macro" data-renderedposition="112_8_1192_48" jivemacro_uid="_14586533055044775"&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;HEAP_SIZE&amp;nbsp; = DEFINED(__heap_size__)&amp;nbsp; ? __heap_size__&amp;nbsp; : 0x0400;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0100 : 0x0;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will find it under &lt;EM&gt;C:\Freescale\KSDK_1.3.0\platform\devices\MKL25Z4\linker\gcc&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this article also helps you. &lt;A href="http://mcuoneclipse.com/2014/06/15/tutorial-diy-kinetis-sdk-project-with-eclipse-startup/" rel="nofollow noopener noreferrer" title="http://mcuoneclipse.com/2014/06/15/tutorial-diy-kinetis-sdk-project-with-eclipse-startup/" target="_blank"&gt;Tutorial: DIY Kinetis SDK Project with Eclipse – Startup | MCU on Eclipse&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Iva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2016 13:35:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493895#M4511</guid>
      <dc:creator>ivadorazinova</dc:creator>
      <dc:date>2016-03-22T13:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: fsl_sdcard malloc return NULL pointer</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493896#M4512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Iva,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for late response. No I didn't try to increase stack size. I checked the MKL25Z128 linker flash file and found exactly what you showed me. But I don't like the idea of editing these sources files because it's also using by many other projects (I guess ?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Processor Expert, so I have found that the heap size default value was 0x0000 into &lt;EM&gt;Cpu component -&amp;gt; Build option.&lt;/EM&gt; So, I simply set it to the same value of stack size (0x0400) for a test and it solve my problem ! &lt;SPAN style="font-family: andale mono,times;"&gt;&lt;EM&gt;Calloc()&lt;/EM&gt;&lt;/SPAN&gt; function do not return a NULL pointer any more. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3334ca; font-size: 10pt;"&gt;&lt;SPAN style="font-family: andale mono,times;"&gt; &lt;/SPAN&gt;&lt;EM style="font-family: andale mono,times;"&gt; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture d’écran 2016-03-31 à 14.32.41.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26615i86AF129119625C1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2016-03-31 à 14.32.41.png" alt="Capture d’écran 2016-03-31 à 14.32.41.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thank you for your response, you lead me to the good way :smileyhappy:.&lt;/P&gt;&lt;P&gt;Even I can't still use fsl_sdcard component correctly (didn't find any good code example)&amp;nbsp; but I can read/write to my sd card with fsl_spi component. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 12:53:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493896#M4512</guid>
      <dc:creator>mr_max</dc:creator>
      <dc:date>2016-03-31T12:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: fsl_sdcard malloc return NULL pointer</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493897#M4513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i am still facing the same issue ....i am trying to implement usb host hid(for keyboard) for k66 based on processor expert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2016 09:40:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493897#M4513</guid>
      <dc:creator>rimidhanjal</dc:creator>
      <dc:date>2016-04-28T09:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: fsl_sdcard malloc return NULL pointer</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493898#M4514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also found the same problem as Rimi trying to implement a USB MSD host. Did you manage to solve it yet?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2016 14:15:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/fsl-sdcard-malloc-return-NULL-pointer/m-p/493898#M4514</guid>
      <dc:creator>danielcaetano</dc:creator>
      <dc:date>2016-10-14T14:15:41Z</dc:date>
    </item>
  </channel>
</rss>

