I'm trying to understand how CODE_SEG is used.
I want to have Bootloader and Application sections of code. Does this mean I have to use the CODE_SEG pragma with every function declaration AND definition in each of those sections?
Can I use the pragma just once per file to keep my code clean?
Is it necessary for me to use the DEFAULT command to set things back to normal?
已解决! 转到解答。
In case anyone else is reviewing this...
I never figured out how to correctly use CODE_SEG. But, I did get closer to my goal using the following pragmas.
#pragma define_section text_bootloader ".text_bootloader" far_abs RX
#pragma section text_bootloader begin
I said closer because I'm now having another issue. I'll create a new post as the topic is now a bit different.
I'm still struggling with this...
I believe I have everything setup correctly to place one small function in the .text_bootloader section, but that section appears with size 0 in my xmap file. Please help!
Here is my linker configuration file:
# Akita linker command file.MEMORY { memory_map__vector_table (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0 memory_map__cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010 memory_map__bootloader (RX) : ORIGIN = 0x00000C00, LENGTH = 0x00002800 # 10kB memory_map__application (RX) : ORIGIN = 0x00003400, LENGTH = 0x00080000-0x00003400 memory_map__ram_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000 }# Keep linker from ever dead-stripping out section that may not be directly referenced.KEEP_SECTION { .vectortable, .cfmconfig }SECTIONS { # Entry point symbols to be used in code development. Note: When used in code, use one less underscore! __START__BOOTLOADER = ADDR( memory_map__bootloader ); __START__APPLICATION = ADDR( memory_map__application ); .interrupts: { __vector_table = .; * (.vectortable) . = ALIGN (0x4); } > memory_map__vector_table .cfmprotect: { *(.cfmconfig) . = ALIGN (0x4); } > memory_map__cfmprotrom .bootloader_startup: { *(.startup_bootloader) } > memory_map__bootloader .bootloader: { * (.text_bootloader) . = ALIGN (0x4); * (.data_bootloader) . = ALIGN (0x4); } >> memory_map__bootloader .application_startup: { *(.startup_application) } > memory_map__application .app_text: { ALIGNALL(4); * (.init) * (.text) .= ALIGN(0x8) ; * (.rodata) .= ALIGN(0x4) ; ___ROM_AT = .; } >> memory_map__application .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) ; } > memory_map__ram_data .bss : { .= ALIGN(0x4) ; __START_BSS = .; * (.bss) __END_BSS = .; .= ALIGN(0x8) ; } >> memory_map__ram_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); } # Heap and Stack sizes definition __SP_INIT = . + 0x00008000; __heap_addr = __SP_INIT; __heap_size = 0x00000000; }
Here is my header file that contains my pragma:
#ifndef __STARTUP__BOOTLOADER_H#define __STARTUP__BOOTLOADER_H#pragma CODE_SEG __FAR_SEG text_bootloadervoid STARTUP__bootloader ( void );#pragma CODE_SEG __FAR_SEG DEFAULT#endif /* __STARTUP__BOOTLOADER_H */
Here is my c file that contains my pragma:
#pragma CODE_SEG __FAR_SEG text_bootloader#include "STARTUP__BOOTLOADER.h"static u8 test_delete_me[1000];void STARTUP__bootloader ( void ) { u16 idx = 0; STARTUP__application(); /* Should never reach this point. */ while( !HELL_FROZEN_OVER ) { test_delete_me[++idx] = idx; if( test_delete_me[idx] = 65000 ) { break; } } //Endless loop } /* STARTUP__bootloader() */
Here is the end of my xmap file:
# Memory map: v_addr p_addr size name 00000000 00000000 000001E0 .interrupts memory_map__vector_table 00000400 00000400 00000000 .cfmprotect memory_map__cfmprotrom 00000C00 00000C00 00000000 .bootloader_startup memory_map__bootloader 00000C00 00000C00 00000000 .bootloader memory_map__bootloader 00003400 00003400 00000000 .application_startup memory_map__application 00003400 00003400 00024AB0 .app_text memory_map__application 1FFF0000 00027EB0 000044A8 .app_data memory_map__ram_data 1FFF44A8 1FFF44A8 00004558 .bss memory_map__ram_data 1FFF8A00 0002C358 00000018 .romp memory_map__ram_data
In case anyone else is reviewing this...
I never figured out how to correctly use CODE_SEG. But, I did get closer to my goal using the following pragmas.
#pragma define_section text_bootloader ".text_bootloader" far_abs RX
#pragma section text_bootloader begin
I said closer because I'm now having another issue. I'll create a new post as the topic is now a bit different.