<?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 flashx example Help in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211182#M5205</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;

  write_buffer = allocate_buffer(read_write_size, k, "write");
  old_buffer = allocate_buffer(read_write_size, k, "old");
    
     /* fill data to write buffer */
     for ( i = 0; i &amp;lt; read_write_size; i++ ) { 
        write_buffer[i] = i;
     } /* Endfor */


     seek_location = 0x0007E000;

     /*read*/
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     i = read(flash_hdl, old_buffer, read_write_size);
     size_compare(flash_hdl, i, read_write_size);
    
     /*erase*/        
     printf("\nTesting _io_ioctl erase_sector: %d (0x%x)", seek_location, seek_location);
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     error_code = _io_ioctl(flash_hdl, FLASH_IOCTL_ERASE_SECTOR, NULL);
     if (error_code != MQX_OK) {
        printf("\nFLASH_IOCTL_ERASE_SECTOR failed.");
        _task_block();
     }   

     /*write*/
     printf("\nSeek to sector and modify (may take a while)");
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     i = write(flash_hdl, write_buffer, read_write_size );
     size_compare(flash_hdl, i, read_write_size);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write and read a "sector" in M52259, but I dont know how to do it. I tried using the code above which comes with the flashx example but it doesnt work. Question is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what doest seek_location means and how to relate that number with an address?&lt;/P&gt;&lt;P&gt;How many bytes does a sector contain?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone can help me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Aug 2009 05:47:47 GMT</pubDate>
    <dc:creator>MQXuser</dc:creator>
    <dc:date>2009-08-28T05:47:47Z</dc:date>
    <item>
      <title>flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211182#M5205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;

  write_buffer = allocate_buffer(read_write_size, k, "write");
  old_buffer = allocate_buffer(read_write_size, k, "old");
    
     /* fill data to write buffer */
     for ( i = 0; i &amp;lt; read_write_size; i++ ) { 
        write_buffer[i] = i;
     } /* Endfor */


     seek_location = 0x0007E000;

     /*read*/
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     i = read(flash_hdl, old_buffer, read_write_size);
     size_compare(flash_hdl, i, read_write_size);
    
     /*erase*/        
     printf("\nTesting _io_ioctl erase_sector: %d (0x%x)", seek_location, seek_location);
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     error_code = _io_ioctl(flash_hdl, FLASH_IOCTL_ERASE_SECTOR, NULL);
     if (error_code != MQX_OK) {
        printf("\nFLASH_IOCTL_ERASE_SECTOR failed.");
        _task_block();
     }   

     /*write*/
     printf("\nSeek to sector and modify (may take a while)");
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     i = write(flash_hdl, write_buffer, read_write_size );
     size_compare(flash_hdl, i, read_write_size);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write and read a "sector" in M52259, but I dont know how to do it. I tried using the code above which comes with the flashx example but it doesnt work. Question is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what doest seek_location means and how to relate that number with an address?&lt;/P&gt;&lt;P&gt;How many bytes does a sector contain?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone can help me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2009 05:47:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211182#M5205</guid>
      <dc:creator>MQXuser</dc:creator>
      <dc:date>2009-08-28T05:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211183#M5206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm really having a hard time getting writing to flash to work...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also trying my own functions without the MQX driver but my application crashes in this function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
volatile int CFM_page_erase (unsigned int address)
{  
    /* Allocate space on stack to run flash command out of SRAM */
 char buf[100];
 int (*RunOnStack)(void) = (int(*)(void))buf;
 volatile CFM_REG_STRUCT_PTR  cfm_reg_ptr;
  
 memcpy(buf, (void*)SpSub, (char*)SpSubEnd - (char*)SpSub);
   
    cfm_reg_ptr = (pointer)(&amp;amp;((VMCF5225_STRUCT_PTR)_PSP_GET_IPSBAR())-&amp;gt;CFM);
    
    (*(volatile vuint32 *)(FLASH_START_ADDRESS+address)) =  -1;

 cfm_reg_ptr-&amp;gt;CFMCMD = MCF_CFM_CFMCMD_PAGE_ERASE;
 RunOnStack();

 /* Check for Errors */
 if (cfm_reg_ptr-&amp;gt;CFMUSTAT &amp;amp; MCF_CFM_CFMUSTAT_ACCERR) {return 0;}
 if (cfm_reg_ptr-&amp;gt;CFMUSTAT &amp;amp; MCF_CFM_CFMUSTAT_PVIOL)  {return 0;}
 return(1);

}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;When I make continous calls to this function an error shows in code warrior ( Exception vector name: Address Error ).&lt;/P&gt;&lt;P&gt;The error not always shows, I am making more tests, but what I would like to know is if I am missing something in the function I show above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If somebody know about my question in the first post, please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MQXuser on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-08-28&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;02:39 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2009 08:34:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211183#M5206</guid>
      <dc:creator>MQXuser</dc:creator>
      <dc:date>2009-08-28T08:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211184#M5207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;seek_location mean the address in&amp;nbsp;flashx space.&lt;/P&gt;&lt;P&gt;I suppose you used the internal flash target. In this demo is internal flash separated into two parts - code and flashx space. The flashx size is depend on code size, flashxsize = total flash size - code size, the size is counted in function _mcf52259_internal_flash_install. Definitions like FLASHX_SECT_SIZE, FLASHX_START_ADDR are defined in intflash.lcf file. See details in that file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case is the sector size 0x1000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is possible, in your example, the&amp;nbsp;flashx size is smaller than 0x0007E000, and you are out of the range.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2009 16:06:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211184#M5207</guid>
      <dc:creator>PavelM</dc:creator>
      <dc:date>2009-08-28T16:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211185#M5208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Thanks for your answer. I am not sure I completely understand, in intflash.lcf file I read&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
    ___FLASHX_START_ADDR = (_flashx_start + 0xfff) / 0x1000 * 0x1000;
    ___FLASHX_END_ADDR = ___INTERNAL_FLASH_BASE + ___INTERNAL_FLASH_SIZE;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
    ___INTERNAL_FLASH_BASE = 0x00000000;
    ___INTERNAL_FLASH_SIZE = 0x00080000;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; thus, the flashx end is at 0x00080000 and I am not trying to write in locations greater than that&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (in my example I try at 0x0007E000).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then, I found&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;
        _flashx_start = __COPY_OF_DATA + SIZEOF(.main_application_data) +
                SIZEOF(.romp);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I figured this is the size of the program code, and although I dont know the actual number,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am almost sure the code program does not use memory after 0x0007E000(because the program is small).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Then, what could be causing the error?, How come I never see flash changing when debugging(even without changing the example to 0x0007E000. If the examples writes at 0x2400 I go to that address with the view memory option and I dont see anything changing.)?&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;I also found this definition at BSP libraries:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;PRE&gt;
 BSPCFG_FLASHX_SIZE = 0x4000&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why do I have to define that if it is already defined in intflash.lcf file?&lt;BR /&gt;&lt;BR /&gt;Hope you can help me. Regards.&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2009 21:56:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211185#M5208</guid>
      <dc:creator>MQXuser</dc:creator>
      <dc:date>2009-08-28T21:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211186#M5209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The actual FLASHX_START_ADDR addres you can find in the project *.xMAP file. In internal flashx example you can find in intflash_d.elf.xMAP file followed lines:&lt;/P&gt;&lt;PRE&gt;
#&amp;gt;0000F3A8          _flashx_start (linker command file)#&amp;gt;00010000          ___FLASHX_START_ADDR (linker command file)#&amp;gt;00080000          ___FLASHX_END_ADDR (linker command file)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you will write to address 0x0007E000, the real address is 0x0007E000 + FLASHX_START_ADDR = 0x8E000, and this is out of flash borders in this example.&lt;/P&gt;&lt;P&gt;If you use the flashx driver, you address&amp;nbsp;within the flashx driver's space, not in physical device address space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The BSPCFG_FLASHX_SIZE&amp;nbsp;&amp;nbsp;0x4000 is default value, if isn't defined in lcf file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Aug 2009 14:48:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211186#M5209</guid>
      <dc:creator>PavelM</dc:creator>
      <dc:date>2009-08-31T14:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211187#M5210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had some issues, from memory I think it just comes down to understanding the processor and MQX. For example, if you have MQX configured to store the vectors / cfm in ROM (0 - 420), when you run from MRAM, obviously CFM_PROT is not programmed and will not work as its protected depending on how flash is programmed (MQX doesnt really handle this error well either, from memory it calls an exception), so, move the vectors to ram and it will work I think! The example should not allow you to run MRAM debug if you do not have vectors running from RAM might be a good solution from MQX. I also changed the flashx from 0x00000000 to 0x00080000, and made the flash size 0x000800 them managed the memory myself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have developed our own BSP and changed much of the MQX configuration since testing the flashx example so I cannot recall exactly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by CarlFST60L on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-09-01&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;08:00 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Sep 2009 13:56:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211187#M5210</guid>
      <dc:creator>CarlFST60L</dc:creator>
      <dc:date>2009-09-01T13:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211188#M5211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to change the start address of my flashX to 0x0007E000.&lt;/P&gt;&lt;P&gt;Inintflash.lcf there is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___FLASHX_START_ADDR = (_flashx_start + 0xfff) / 0x1000 * 0x1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but as soon as I change it to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___FLASHX_START_ADDR = 0x0007E000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MQX never initialize the FlashX IO device and I can never use flash. Does anybody knows which files do I ahve to change in order to define the start of flashX ??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2009 02:28:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211188#M5211</guid>
      <dc:creator>MQXuser</dc:creator>
      <dc:date>2009-09-07T02:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211189#M5212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ensure you have in user_config.h file&lt;/P&gt;&lt;P&gt;#define BSPCFG_ENABLE_FLASHX&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;check, if you have defined the BSPCFG_FLASHX_SIZE. This value is used in flashx init function - _mcf52259_internal_flash_install which is called form init_bsp.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2009 13:33:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211189#M5212</guid>
      <dc:creator>PavelM</dc:creator>
      <dc:date>2009-09-07T13:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: flashx example Help</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211190#M5213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Pavel, I was forgetting to define the SIZE and since the default value is 0x4000, I was exceeding from the amount of total RAM. Now I set it to be 0x2000 and is working fine.&lt;/P&gt;&lt;P&gt;0x0007E000 + 0x4000 =&amp;nbsp; 0x00082000&amp;nbsp; = Outside range. &amp;nbsp;&lt;/P&gt;&lt;P&gt;0x0007E000 + 0x2000 =&amp;nbsp; 0x00080000&amp;nbsp; = Range is ok.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2009 06:50:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/flashx-example-Help/m-p/211190#M5213</guid>
      <dc:creator>MQXuser</dc:creator>
      <dc:date>2009-09-08T06:50:47Z</dc:date>
    </item>
  </channel>
</rss>

