Linker file
Linker file
BTW.
Can you read / understand / modify the MK22 linker files
The firmware now takes 99.9% of the program ROM space in the MK22, making it impossible to make any more changes to the firmware, but I checked the MCU ROM backup and there is 11k of empty space after the codec_bin_section2
I checked the ROM length and it is correct, because the last 4 of ROM can't be used , because there are some hardware lock bytes in that area which the bootloader reads, and if the bytes do not match the unique CPU ID then the bootloader will not load the firmware ever again.
But I don't understand why the linker is not using this area.
possibly there needs to be another linker section added, which starts at after the end of the codec_bin_section2 but I tried adding another text section, but it did not make any difference
However, I don't know anything about linker files, so I'm just guessing about how to make the linker use this section of the ROM
Can you read / understand / modify the MK22 linker files
The firmware now takes 99.9% of the program ROM space in the MK22, making it impossible to make any more changes to the firmware, but I checked the MCU ROM backup and there is 11k of empty space after the codec_bin_section2
I checked the ROM length and it is correct, because the last 4 of ROM can't be used , because there are some hardware lock bytes in that area which the bootloader reads, and if the bytes do not match the unique CPU ID then the bootloader will not load the firmware ever again.
But I don't understand why the linker is not using this area.
possibly there needs to be another linker section added, which starts at after the end of the codec_bin_section2 but I tried adding another text section, but it did not make any difference
However, I don't know anything about linker files, so I'm just guessing about how to make the linker use this section of the ROM
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
Roger,
you can use that empty space simply by:
add a section after .codec_bin_section2:
and modify one line at the end of firmware.ld:
and then you can move functions to this new section e.g. in main.c:
Alex
you can use that empty space simply by:
add a section after .codec_bin_section2:
Code: Select all
.codec_bin_section_2 : ALIGN(4)
{
. = ABSOLUTE(0x54000) ;
*(.codec_bin_section_2)
KEEP(*(.codec_bin_section_2))
} > PROGRAM_FLASH
.upper_text : ALIGN(4)
{
*(.text*)
*(.upper_text)
. = ALIGN(4);
} > PROGRAM_FLASH
Code: Select all
_image_end = LOADADDR(.codec_bin_section_2) + SIZEOF(.codec_bin_section_2) + SIZEOF(.upper_text);
Code: Select all
...
__attribute__((section(".upper_text"))) void mainTaskFunction(void *data)
...
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
Alex
Thanks..
I will try using those changes
I did try making similar changes, but I think I made a mistake with the .upper_text block, and I also added 0x2F2F to the _image_end, because I calculated the extra space was 0x2F2F, but using the size of the new block is better
Thanks..
I will try using those changes
I did try making similar changes, but I think I made a mistake with the .upper_text block, and I also added 0x2F2F to the _image_end, because I calculated the extra space was 0x2F2F, but using the size of the new block is better
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
Hi Alex
You changes did work, but I have some other questions, becuase the compiler / linker is not automatially using the new text section even if the other sections are full
I'll emial you
You changes did work, but I have some other questions, becuase the compiler / linker is not automatially using the new text section even if the other sections are full
I'll emial you
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
Hi! Sorry, I haven't checked the forum in a couple days. I wish I could help but I don't know much about linker files, I only changed the ROM start addresses by substracting 0x4000 addresses so the code starts at the beggining of the ROM if I don't flash a bootloader. And I haven't tested anything yet so I don't know if that'll even work. I've just seen someone already helped you.
BTW, when I was writing code for the SPI0 bit-bang to work, i had a strange linker error that wouldn't let me compile saying something like "cannot move location counter backwards". I spent hours on it as I found no errors in the code. In the end, I could solve it by using less functions to do the SPI0 communication. So I assume that was the ROM running out of space, I couldn't even add a simple function. I didn't know the space problem was that bad, I hope you can get those extra addresses.
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
OK.
I think I found the problem.
I needed to use
__attribute__((section(".upper_text")))
To force data into this block.
I had expected that the linker would automatically use any new section which is added
I think I found the problem.
I needed to use
__attribute__((section(".upper_text")))
To force data into this block.
I had expected that the linker would automatically use any new section which is added
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
Yes, that's the only way I found.
The linker by it's own does not seem to be able to handle multiple .text* section.
The linker by it's own does not seem to be able to handle multiple .text* section.
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
There is another option to move complete *.o files to the .upper_text section:
and
This moves all functions from main.c and codec.c to the upper_text section.
I don't known why the percentage is incorrect. But as long as the linker thinks it fits everything should be ok.
Code: Select all
.text_main : ALIGN(4)
{
*(EXCLUDE_FILE(*main.o *codec.o).text* )
*(.rodata .rodata.* .constdata .constdata.*)
. = ALIGN(4);
_etext = . ;
} > PROGRAM_FLASH
Code: Select all
.upper_text : ALIGN(4)
{
*codec.o (.text*)
*main.o (.text*)
*(.upper_text)
. = ALIGN(4);
} > PROGRAM_FLASH
I don't known why the percentage is incorrect. But as long as the linker thinks it fits everything should be ok.
Re: Porting to the Retevis RT50 (aka TYT MD-680D)
Ale x
What is the reason for using
(.upper_text)
Instead of
*(.rodata .rodata.* .constdata .constdata.*)
I used *(.rodata .rodata.* .constdata .constdata.*) for the upper_text and it seemed to work OK
Re: moving all functions from each file
This is clever, but I think could cause maintenance problmes, if functions were added to those .c files, because there could be space in the main .text block, but no space in upp_text
I tried to move the font data to upper_text but it is too big. I also tried moving the language strings, but they are also too big.
The biggest font will not fit in upper_text on its own, which is surprising
AFIK upper_text should be 11k
What is the reason for using
(.upper_text)
Instead of
*(.rodata .rodata.* .constdata .constdata.*)
I used *(.rodata .rodata.* .constdata .constdata.*) for the upper_text and it seemed to work OK
Re: moving all functions from each file
This is clever, but I think could cause maintenance problmes, if functions were added to those .c files, because there could be space in the main .text block, but no space in upp_text
I tried to move the font data to upper_text but it is too big. I also tried moving the language strings, but they are also too big.
The biggest font will not fit in upper_text on its own, which is surprising
AFIK upper_text should be 11k