Page 1 of 2
Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 12:38 pm
by Giovanni
Hi,
I noticed that the .ld files do not use the common rules.ld, because of this there are errors caused by the updated startup files. The .ld files should be updated to export the required symbols for the extra RAM sections, please see rules.ld.
Giovanni
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 1:37 pm
by utzig
Why are all those ramX sections needed?
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 2:08 pm
by utzig
Well,
I changed locally the linker script and added -DCRT1_AREAS_NUMBER=1 to the makefile. That fixes the first problem. Now linking fails with error:
Code: Select all
arm-none-eabi/bin/ld: build/ch.elf section `.isr' will not fit in region `flash0'
arm-none-eabi/bin/ld: region `flash0' overflowed by 64 bytes
Although flash0 is 0xc0 sized and there are 32 vectors, which gives 0xc0 - 0x80 = 64 bytes free. Unless somehow the compiler is thinking vectors are 8 bytes... does that make sense?
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 2:43 pm
by utzig
Ok, fixing myself, the correct calculation for number of used vectors is 15+32 which gives 0xc0 space required! Which also must be the explanation for I using that for flash0 size in the linker script.
To fix the build I removed the aligned(128) in os/common/ports/ARMCMx/compilers/GCC/vectors.c line 438. Not sure why that's necessary. Either fix that way or change flash0 to be 0x100 sized. I will try both in the board and see if they work...
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 2:52 pm
by utzig
Ok, both solutions worked! So aligned(128) just means the it the vectors section must be a multiple of 0x80, correct? Not sure yet what's the reasoning...
Anyway I'll commit the changes I had to make (for the KL25Z demo only for now) and look into merging with the standard rules.ld script later because I'm hungry now and this thread is turning into a personal diary already...
Cheers
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 3:37 pm
by Giovanni
Hi,
The vectors address must be aligned to 128, the size not necessarily. It is a restriction of the base register.
Giovanni
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 10:41 pm
by utzig
I updated the linker scripts using rules.ld as reference. The problem of not being able to reuse rules.ld like the STM32 ports do, is that in Kinetis there's one small flash section at the beginning (flash0), then the flash protection segment, than the remaining of the flash. So I have to use 3 sections. When including rules.ld either before or after my custom declaration of the flash0 + protection, those sections or the default sections in rules.ld will not be allocated in the correct position. I would need something like ram0, ram1, ram2 equivalents for flash to make that work. Do you know of any other workaround?
Cheers,
Fabio Utzig
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 10:47 pm
by Giovanni
Hi,
Good point I think it is a good idea. Do you think we should delay the release for this or can it go in next one?
Giovanni
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 10:56 pm
by utzig
I think it is ok as it is right now. It has a lot of duplication which could be fixed later. Also there are only two linker scripts (very similar btw!) so these changes can be postponed.
Re: Linker problem with Kinetis demos
Posted: Sun Jan 03, 2016 11:12 pm
by utzig
Btw, I commited the fixes only to trunk, is that enough?