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
Linker problem with Kinetis demos
Moderator: utzig
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Linker problem with Kinetis demos
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:
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?
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?
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Linker problem with Kinetis demos
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...
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...
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Linker problem with Kinetis demos
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
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
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Linker problem with Kinetis demos
Hi,
The vectors address must be aligned to 128, the size not necessarily. It is a restriction of the base register.
Giovanni
The vectors address must be aligned to 128, the size not necessarily. It is a restriction of the base register.
Giovanni
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Linker problem with Kinetis demos
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
Cheers,
Fabio Utzig
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Linker problem with Kinetis demos
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
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
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Linker problem with Kinetis demos
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.
Who is online
Users browsing this forum: No registered users and 33 guests