<?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 Using Keil to load binary into external SPI Flash in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Using-Keil-to-load-binary-into-external-SPI-Flash/m-p/2055025#M57806</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm wondering if there's a way to load a random binary file into external SPI flash using Keil. The binary file will pass through the LPC54102 (OM13077 EVK board). I know some ISEs for FPGAs allow you to do this, curious if this is possible with the LPC54102 using Keil.&lt;/P&gt;&lt;P&gt;Obviously Keil will need to know what SPI flash is connected to the LPC, along with other details like, SPI port, clk speed, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know is Keil can do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 746px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326563i4F7768C970592B51/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 03 Mar 2025 22:19:50 GMT</pubDate>
    <dc:creator>rhsalced</dc:creator>
    <dc:date>2025-03-03T22:19:50Z</dc:date>
    <item>
      <title>Using Keil to load binary into external SPI Flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Using-Keil-to-load-binary-into-external-SPI-Flash/m-p/2055025#M57806</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm wondering if there's a way to load a random binary file into external SPI flash using Keil. The binary file will pass through the LPC54102 (OM13077 EVK board). I know some ISEs for FPGAs allow you to do this, curious if this is possible with the LPC54102 using Keil.&lt;/P&gt;&lt;P&gt;Obviously Keil will need to know what SPI flash is connected to the LPC, along with other details like, SPI port, clk speed, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know is Keil can do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 746px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326563i4F7768C970592B51/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2025 22:19:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Using-Keil-to-load-binary-into-external-SPI-Flash/m-p/2055025#M57806</guid>
      <dc:creator>rhsalced</dc:creator>
      <dc:date>2025-03-03T22:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using Keil to load binary into external SPI Flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Using-Keil-to-load-binary-into-external-SPI-Flash/m-p/2056047#M57829</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/229179"&gt;@rhsalced&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- You can refer to this thread:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers/LPC54018JxM-debugging-internal-flash-example-for-Keil-MDK-ARM/td-p/1352169" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers/LPC54018JxM-debugging-internal-flash-example-for-Keil-MDK-ARM/td-p/1352169&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It introduces lpc54018 + QSPI flash + KEIL.。&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-&amp;nbsp; 1.&amp;nbsp;&lt;/SPAN&gt;If the default selected Flash download algorithm file is not applicable to your board, then you need to provide a suitable algorithm file (.FLM) yourself and place it in the MDK installation directory (\Keil_v5\ARM\Flash). Then, reopen the project options, and the newly added algorithm will be automatically refreshed into the list of selectable algorithms.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.jpg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326795i837F0A3B9BD74A12/image-size/medium?v=v2&amp;amp;px=400" role="button" title="1.jpg" alt="1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;2. After obtaining the appropriate download algorithm file, you finally need to check two address ranges. One is the actual mapped address space corresponding to the Flash, and the other is the running RAM address space of the download algorithm file.&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.jpg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326796i0ADCC1BD269C7453/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2.jpg" alt="2.jpg" /&gt;&lt;/span&gt;
&lt;P&gt; &lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;3. NOR Flash Download Algorithm Design&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;The Flash download algorithm under Keil MDK is open-source and comes with relatively detailed documentation. The documentation can be found on the GitHub homepage of arm-software. Based on these documents, we can basically understand the design details of its download algorithm.&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;Algorithm Homepage:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&lt;A href="https://arm-software.github.io/CMSIS_5/Pack/html/flashAlgorithm.html" rel="nofollow" target="_blank"&gt;https://arm-software.github.io/CMSIS_5/Pack/html/flashAlgorithm.html&lt;/A&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;3.1 Download Algorithm Template Project&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;Keil MDK provides a basic template project for the Flash download algorithm. The project is located at \Keil_v5\ARM\Flash_Template\NewDevice.uvprojx. This project can only be compiled using MDK (not supported by MDK-Lite). In addition to the project settings, this template project only contains four files:&lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;\Keil_v5\ARM\Flash\FlashOS.h&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;\Keil_v5\ARM\Flash_Template\FlashDev.c&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;\Keil_v5\ARM\Flash_Template\FlashPrg.c&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;\Keil_v5\ARM\Flash_Template\Target.lin&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;After obtaining the basic template project, we need to change the default ARMCM0 core in the project options according to the type of the target MCU core. Then, we need to implement all the algorithm API functions in FlashDev.c and FlashPrg.c (they are empty by default). Finally, compile the project to generate the.FLM file, which is the algorithm file we need (in fact, the final.FLM file is obtained by directly renaming the.axf file through the script command in After Build. The.FLM file is essentially an axf format file).&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4444.jpg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326797iD91AC1F3197FFE03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="4444.jpg" alt="4444.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;3.2 Download Algorithm Structure Design&lt;BR class="container-utlnW2 wrapper-d0Cc1k undefined" /&gt;The structure of the algorithm itself is actually very simple. In the FlashDev.c file, there is a constant structure named FlashDevice, and its prototype is defined in FlashOS.h. This structure mainly provides the necessary Flash information for the IDE, and its values must be filled in correctly according to the actual situation of the board.&lt;/DIV&gt;
&lt;DIV class="relative w-fit custom-code-block-canvas-wrapper w-full"&gt;
&lt;DIV class="code-block-element-naRNnJ light custom-code-block-container--c hide-indicator disable-theme-style custom-code-block-container"&gt;
&lt;DIV class="code-area-RgeUH7 code-area" dir="ltr"&gt;
&lt;DIV class="header-dBhZw9"&gt;
&lt;DIV class="action-UHHINY"&gt;
&lt;DIV class="hoverable-fZ6eZQ" tabindex="0" aria-describedby="el33mjn" data-popupid="el33mjn"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="content-_tUZzR light-scrollbar-yKKsFX"&gt;
&lt;PRE class="light-scrollbar-WEp2KJ language-c"&gt;&lt;CODE&gt;struct FlashDevice const FlashDevice  =  {
   FLASH_DRV_VERS,             // Driver Version, do not modify!
   "New Device 256kB Flash",   // Device Name 
   ONCHIP,                     // Device Type
   0x00000000,                 // Device Start Address
   0x00040000,                 // Device Size in Bytes (256kB)
   1024,                       // Programming Page Size
   0,                          // Reserved, must be 0
   0xFF,                       // Initial Content of Erased Memory
   100,                        // Program Page Timeout 100 mSec
   3000,                       // Erase Sector Timeout 3000 mSec

// Specify Size and Address of Sectors
   0x002000, 0x000000,         // Sector Size  8kB (8 Sectors)
   0x010000, 0x010000,         // Sector Size 64kB (2 Sectors) 
   0x002000, 0x030000,         // Sector Size  8kB (8 Sectors)
   SECTOR_END
};
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;In addition to FlashDevice, the most core part is of course the seven API functions in FlashPrg.c. These API functions provide the actual functions of Flash erasing, programming, and verification. The IDE will automatically call these APIs as needed to achieve online downloading. The prototypes of these APIs are fixed, but the specific function implementations vary depending on the board.&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="55555.jpg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326798iFB03C5D5098BF482/image-size/medium?v=v2&amp;amp;px=400" role="button" title="55555.jpg" alt="55555.jpg" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;There is also a design of the algorithm project that has to be mentioned, that is, both Read-Only Position Independent and Read-Write Position Independent are checked under the project options C/C++ (including Asm). This indicates that the download algorithm itself is not linked using a fixed address, but is a position-independent link (also called a relative address link). The machine code of the algorithm code can be executed at any address, which is why you can specify the RAM for Algorithm in the example options.&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="66666.jpg" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/326799i456D26BE46E11CC2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="66666.jpg" alt="66666.jpg" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;(The&amp;nbsp; above steps on how to develop a suitable download algorithm file are from a Chinese article &lt;A href="https://blog.csdn.net/Henjay724/article/details/109153585" target="_blank"&gt;https://blog.csdn.net/Henjay724/article/details/109153585&lt;/A&gt; . It is based on I.MX RT, and I just&amp;nbsp; translated it into English. )&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;BR&lt;/DIV&gt;
&lt;DIV class="auto-hide-last-sibling-br paragraph-JOTKXA paragraph-element br-paragraph-space"&gt;Alice&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 07:16:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Using-Keil-to-load-binary-into-external-SPI-Flash/m-p/2056047#M57829</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2025-03-05T07:16:16Z</dc:date>
    </item>
  </channel>
</rss>

