1 /*###ICF### Section handled by ICF editor, don't touch! ****/ 2 /*-Editor annotation file-*/ 3 /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */ 4 /*-Memory Regions-*/ 5 define symbol __ICFEDIT_region_ROM_start__ = 0x00000000; 6 define symbol __ICFEDIT_region_ROM_end__ = 0x0000FFFF; 7 define symbol __ICFEDIT_region_RAM_start__ = 0x00010000; 8 define symbol __ICFEDIT_region_RAM_end__ = 0x0001FFFF; 9 /*-Sizes-*/ 10 define symbol __ICFEDIT_size_cstack__ = 0x2000; 11 define symbol __ICFEDIT_size_heap__ = 0x8000; 12 /**** End of ICF editor section. ###ICF###*/ 13 14 15 define memory mem with size = 4G; 16 define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; 17 define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; 18 19 define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; 20 define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; 21 22 initialize by copy { readwrite }; 23 do not initialize { section .noinit }; 24 25 // Project > Options > Build Actions > Post-build command line 26 // 27 // ielftool --checksum __checksum:4,crc32,0x0;__checksum_first_dword-__checksum_last_dword+3 --verbose "$TARGET_PATH$" "$TARGET_PATH$" 28 29 define block RAM_CONTENT with fixed order 30 { 31 readwrite, 32 block HEAP, 33 block CSTACK 34 }; 35 36 //define block ROM_CONTENT with fixed order 37 //{ 38 // readonly section read_only_start, 39 // readonly, 40 // readonly section read_only_end 41 //}; 42 //place in ROM_region { block ROM_CONTENT }; 43 44 place at address mem:__ICFEDIT_region_ROM_start__ { readonly section read_only_start }; 45 46 //define block read_only_start { readonly section read_only_start }; 47 //place in ROM_region { first block read_only_start }; 48 49 place in ROM_region { readonly }; 50 51 define block read_only_end { readonly section read_only_end }; 52 place in ROM_region { last block read_only_end }; 53 54 place in RAM_region { block RAM_CONTENT };
1 MODULE startup 2 3 EXTERN main 4 5 PUBLIC __read_only_size 6 PUBLIC __iar_program_start 7 PUBLIC __checksum_first_dword 8 PUBLIC __checksum_last_dword 9 PUBLIC __checksum 10 11 SECTION read_only_end:CODE:ROOT(2) 12 CODE32 13 __checksum_last_dword 14 DCD 0x55AA55AA ; magic dword 15 __checksum 16 DCD 0x00000000 ; will be filled ielftool 17 __read_only_end 18 19 ; Forward declaration of sections. 20 SECTION CSTACK:DATA:NOROOT(3) 21 SECTION read_only_start:CODE:ROOT(2) 22 CODE32 23 24 __read_only_start 25 __checksum_first_dword 26 RST B __iar_program_start ; 0x00000000 27 UND B __iar_program_start ; 0x00000004 28 SWI B __iar_program_start ; 0x00000008 29 IABT B __iar_program_start ; 0x0000000C 30 DABT B __iar_program_start ; 0x00000010 31 __read_only_size 32 SIZ DCD __read_only_end-__read_only_start ; 0x00000014 33 IRQ B __iar_program_start ; 0x00000018 34 FIQ B __iar_program_start ; 0x0000001C 35 36 ;------------------------------------------------------------------------------- 37 __iar_program_start 38 ;------------------------------------------------------------------------------- 39 MSR CPSR_c, #0x1F ; Change to User mode, Enable IRQ/FIQ 40 ldr sp,=SFE(CSTACK) ; End of CSTACK(user) 41 B main ; Note : use B not BL, because an 42 ; application will never return 43 44 END
1 int main(void) 2 { 3 for (;;); 4 }