15.01.2012
Ethernetowy bootloader dla mikrokontrolerów Freescale Kinetis
Podsumowanie
Implementacja ethernetowego bootloadera jest możliwa dla trzech różnych scenariuszy:
- W projekcie programistycznym napisanym w środowisku IAR
- W projekcie programistycznym napisanym w środowisku CodeWarrior
- W projekcie programistycznym napisanym w środowisku CodeWarrior i wykorzystującym system operacyjny MQX.
Każdy scenariusz został przybliżony w formie opisu, w którym zawarto kroki, jakie należy wykonać, aby zintegrować w oprogramowaniu użytkownika funkcjonalność ethernetowego bootloadera. Dostępność różnych scenariuszy umożliwia projektantom wybranie spośród nich najlepszego dla swojego projektu.
Dodatek A: plik konfiguracji linkera (.icf) dla środowiska IAR
Listing 12.
/*###ICF### Section handled by ICF editor, don't touch! ****/ /*-Editor annotation file-*/ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ define symbol __ICFEDIT_intvec_start__ = 0x0000C000; /*-Memory Regions-*/ define symbol __ICFEDIT_region_ROM_start__ = 0x0000C000; define symbol __ICFEDIT_region_ROM_end__ = 0x00080000; define symbol __ICFEDIT_region_RAM_start__ = 0x1FFF0410; define symbol __ICFEDIT_region_RAM_end__ = 0x20010000; /*-Sizes-*/ define symbol __ICFEDIT_size_cstack__ = 0x1000; define symbol __ICFEDIT_size_heap__ = 0x200; /**** End of ICF editor section. ###ICF###*/ define symbol FappParams_start__= __ICFEDIT_region_ROM_end__ - (2*0x400); //FAPP define symbol FappParams_end__ = __ICFEDIT_region_ROM_end__-1; //FAPP //define symbol __region_RAM2_start__ = 0x20000000; //define symbol __region_RAM2_end__ = 0x20010000; define exported symbol __VECTOR_TABLE = 0x0000C000; define exported symbol __VECTOR_RAM = 0x1fff0000; define exported symbol __BOOT_STACK_ADDRESS = __ICFEDIT_region_RAM_end__ - 8; // 0x2000FFF8; define symbol __code_start__ = 0x0000C410; define memory mem with size = 4G; //define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; //define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__] | mem:[from __region_RAM2_start__ to __region_RAM2_end__]; define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__-1] - mem:[from FappParams_start__ to FappParams_end__]; define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__-1]; //| mem:[from __region_RAM2_start__ to __region_RAM2_end__-1]; define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; initialize manually { readwrite }; initialize manually { section .data}; initialize manually { section .textrw }; do not initialize { section .noinit }; define block CodeRelocate { section .textrw_init }; define block CodeRelocateRam { section .textrw }; place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; place at address mem:__code_start__ { readonly section .noinit }; place at address mem:FappParams_start__ { section fapp_params }; //APP place in ROM_region { readonly, block CodeRelocate}; place in RAM_region { readwrite, block CodeRelocateRam, block CSTACK, block HEAP };
Dodatek B: plik rozkazów linkera (.lcf) dla środowiska CW
Listing 13.
# Default linker command file. MEMORY { fnet_bootloader (RX) : ORIGIN = 0x00000000, LENGTH = 0x0000C000 # 48KB (Reserved for FNET Bootloader) m_interrupts (RX) : ORIGIN = 0x0000C000, LENGTH = 0x000001E0 m_text (RX) : ORIGIN = 0x0000C410, LENGTH = 0x00080000-0x0000C410 fnet_params (RW) : ORIGIN = 0x20010000,LENGTH = 0x00001000 # 4Kbytes (Last logical-block reserved for parameters) m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000 #m_cfmprotrom (RX) : ORIGIN = 0x0000C400, LENGTH = 0x00000010 } KEEP_SECTION { .vectortable } KEEP_SECTION { .cfmconfig } SECTIONS { .interrupts : { __vector_table = .; * (.vectortable) . = ALIGN (0x4); } > m_interrupts #.cfmprotect : #{ # *(.cfmconfig) # . = ALIGN (0x4); #} > m_cfmprotrom .app_text: { ALIGNALL(4); * (.init) * (.text) .= ALIGN(0x8) ; * (.rodata) .= ALIGN(0x4) ; ___ROM_AT = .; } > m_text .app_data: AT(___ROM_AT) { * (.sdata) * (.data) .= ALIGN(0x4) ; *(.ARM.extab) .= ALIGN(0x4) ; __exception_table_start__ = .; EXCEPTION __exception_table_end__ = .; .= ALIGN(0x4) ; __sinit__ = .; STATICINIT .= ALIGN(0x8) ; } > m_data .bss : { .= ALIGN(0x4) ; __START_BSS = .; * (.bss) __END_BSS = .; .= ALIGN(0x8) ; } >> m_data _romp_at = ___ROM_AT + SIZEOF(.app_data); .romp : AT(_romp_at) { __S_romp = _romp_at; WRITEW(___ROM_AT); WRITEW(ADDR(.app_data)); WRITEW(SIZEOF(.app_data)); WRITEW(0); WRITEW(0); WRITEW(0); } __SP_INIT = . + 0x00008000; __heap_addr = __SP_INIT; __heap_size = 0x00008000; }