| [6] | 1 | // ********************************************************************** | 
|---|
|  | 2 | // *                    SEGGER Microcontroller GmbH                     * | 
|---|
|  | 3 | // *                        The Embedded Experts                        * | 
|---|
|  | 4 | // ********************************************************************** | 
|---|
|  | 5 | // *                                                                    * | 
|---|
|  | 6 | // *            (c) 2014 - 2019 SEGGER Microcontroller GmbH             * | 
|---|
|  | 7 | // *            (c) 2001 - 2019 Rowley Associates Limited               * | 
|---|
|  | 8 | // *                                                                    * | 
|---|
|  | 9 | // *           www.segger.com     Support: support@segger.com           * | 
|---|
|  | 10 | // *                                                                    * | 
|---|
|  | 11 | // ********************************************************************** | 
|---|
|  | 12 | // *                                                                    * | 
|---|
|  | 13 | // * All rights reserved.                                               * | 
|---|
|  | 14 | // *                                                                    * | 
|---|
|  | 15 | // * Redistribution and use in source and binary forms, with or         * | 
|---|
|  | 16 | // * without modification, are permitted provided that the following    * | 
|---|
|  | 17 | // * conditions are met:                                                * | 
|---|
|  | 18 | // *                                                                    * | 
|---|
|  | 19 | // * - Redistributions of source code must retain the above copyright   * | 
|---|
|  | 20 | // *   notice, this list of conditions and the following disclaimer.    * | 
|---|
|  | 21 | // *                                                                    * | 
|---|
|  | 22 | // * - Neither the name of SEGGER Microcontroller GmbH                  * | 
|---|
|  | 23 | // *   nor the names of its contributors may be used to endorse or      * | 
|---|
|  | 24 | // *   promote products derived from this software without specific     * | 
|---|
|  | 25 | // *   prior written permission.                                        * | 
|---|
|  | 26 | // *                                                                    * | 
|---|
|  | 27 | // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             * | 
|---|
|  | 28 | // * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        * | 
|---|
|  | 29 | // * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           * | 
|---|
|  | 30 | // * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           * | 
|---|
|  | 31 | // * DISCLAIMED.                                                        * | 
|---|
|  | 32 | // * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        * | 
|---|
|  | 33 | // * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           * | 
|---|
|  | 34 | // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  * | 
|---|
|  | 35 | // * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    * | 
|---|
|  | 36 | // * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      * | 
|---|
|  | 37 | // * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          * | 
|---|
|  | 38 | // * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  * | 
|---|
|  | 39 | // * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   * | 
|---|
|  | 40 | // * DAMAGE.                                                            * | 
|---|
|  | 41 | // *                                                                    * | 
|---|
|  | 42 | // ********************************************************************** | 
|---|
|  | 43 |  | 
|---|
|  | 44 | define memory with size = 4G; | 
|---|
|  | 45 |  | 
|---|
|  | 46 | // | 
|---|
|  | 47 | // Combined regions per memory type | 
|---|
|  | 48 | // | 
|---|
|  | 49 | define region FLASH = FLASH1; | 
|---|
|  | 50 | define region RAM   = RAM1; | 
|---|
|  | 51 |  | 
|---|
|  | 52 | // | 
|---|
|  | 53 | // Block definitions | 
|---|
|  | 54 | // | 
|---|
|  | 55 | define block vectors                        { section .vectors };                         // Vector table section | 
|---|
|  | 56 | define block vectors_ram                    { section .vectors_ram };                     // Vector table section | 
|---|
|  | 57 | define block ctors                          { section .ctors,     section .ctors.*, block with         alphabetical order { init_array } }; | 
|---|
|  | 58 | define block dtors                          { section .dtors,     section .dtors.*, block with reverse alphabetical order { fini_array } }; | 
|---|
|  | 59 | define block exidx                          { section .ARM.exidx, section .ARM.exidx.* }; | 
|---|
|  | 60 | define block tbss                           { section .tbss,      section .tbss.*  }; | 
|---|
|  | 61 | define block tdata                          { section .tdata,     section .tdata.* }; | 
|---|
|  | 62 | define block tls                            { block tbss, block tdata }; | 
|---|
|  | 63 | define block tdata_load                     { copy of block tdata }; | 
|---|
|  | 64 | define block heap  with size = __HEAPSIZE__,  alignment = 8, /* fill =0x00, */ readwrite access { }; | 
|---|
|  | 65 | define block stack with size = __STACKSIZE__, alignment = 8, /* fill =0xCD, */ readwrite access { }; | 
|---|
|  | 66 | // | 
|---|
|  | 67 | // Explicit initialization settings for sections | 
|---|
|  | 68 | // | 
|---|
|  | 69 | do not initialize                           { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* }; | 
|---|
|  | 70 | initialize by copy /* with packing=auto */  { section .data, section .data.*, section .*.data, section .*.data.* }; | 
|---|
|  | 71 | initialize by copy /* with packing=auto */  { section .fast, section .fast.* }; | 
|---|
|  | 72 | initialize by copy /* with packing=auto */  { section .RamFunc, section .RamFunc.* }; | 
|---|
|  | 73 |  | 
|---|
|  | 74 | // | 
|---|
|  | 75 | // FLASH Placement | 
|---|
|  | 76 | // | 
|---|
|  | 77 | place at start of FLASH                     { block vectors };                         // Vector table section | 
|---|
|  | 78 | place in FLASH with minimum size order      { section .init,   section .init.*,        // Init code section | 
|---|
|  | 79 | section .init_rodata, section .init_rodata.*, // Init read-only section | 
|---|
|  | 80 | section .text,   section .text.*,        // Code section | 
|---|
|  | 81 | section .rodata, section .rodata.*,      // Read-only data section | 
|---|
|  | 82 | section .segger.*,                       // Auto-generated initialization | 
|---|
|  | 83 | block exidx,                             // ARM exception unwinding block | 
|---|
|  | 84 | block ctors,                             // Constructors block | 
|---|
|  | 85 | block dtors };                           // Destructors block | 
|---|
|  | 86 | place in FLASH                              { block tdata_load };                      // Thread-local-storage load image | 
|---|
|  | 87 | // | 
|---|
|  | 88 | // Explicit placement in FLASHn | 
|---|
|  | 89 | // | 
|---|
|  | 90 | place in FLASH1                             { section .FLASH1, section .FLASH1.* }; | 
|---|
|  | 91 |  | 
|---|
|  | 92 | // | 
|---|
|  | 93 | // RAM Placement | 
|---|
|  | 94 | // | 
|---|
|  | 95 | place at start of RAM                       { block vectors_ram }; | 
|---|
|  | 96 | place in RAM                                { section .non_init, section .non_init.*,  // No initialization section | 
|---|
|  | 97 | block tls };                             // Thread-local-storage block | 
|---|
|  | 98 | place in RAM with auto order                { section .fast, section .fast.*,          // "ramfunc" section | 
|---|
|  | 99 | section .RamFunc, section .Ramfunc.*, | 
|---|
|  | 100 | section .data, section .data.*,          // Initialized data section | 
|---|
|  | 101 | section .bss, section .bss.* | 
|---|
|  | 102 | };          // Static data section | 
|---|
|  | 103 | place in RAM                                { block heap };           // Heap reserved block | 
|---|
|  | 104 | place at end of RAM                         { block stack };          // Stack reserved block at the end | 
|---|
|  | 105 |  | 
|---|
|  | 106 | // | 
|---|
|  | 107 | // Explicit placement in RAMn | 
|---|
|  | 108 | // | 
|---|
|  | 109 | place in RAM1                               { section .RAM1, section .RAM1.* }; | 
|---|
|  | 110 |  | 
|---|
|  | 111 | // | 
|---|
|  | 112 | // CRC calculation | 
|---|
|  | 113 | // | 
|---|
|  | 114 |  | 
|---|
|  | 115 | define region CRC = [end(FLASH) - 4 size 4]; | 
|---|
|  | 116 | define region APP = FLASH - CRC; | 
|---|
|  | 117 | place in CRC                                { integrity check of APP with algorithm="CRC-32/STM32" fill=0xFF }; | 
|---|
|  | 118 | //fill APP with 0xFF; | 
|---|