[fpc-devel] Patch for uf2 support in freePascal

Michael Ring mail at michael-ring.org
Sat Jan 23 09:14:20 CET 2021


I am sorry but my last comment wasn't meant for the list, I wanted to 
send it directly to Florian but I failed miserably....

But for the main question raised in the (german) mail it makes perhaps 
sense to translate it to english...

In Cortex Startup files the relocation of the VectorTable is put inside 
an {$ifdef REMAP_VECTTAB} which makes it necessary to define this in 
virtually every controller unit to be able to use bootloaders. Question 
is why this was done in that way.

I now can already partially self-answer myself, to date It looks like 
when I did something on Cortex-M0 I used cortex-m0+ based controllers 
and for those the vtor register existed. However is an optional feature 
(Although an often implemented one for M0+).

On CortexM3 and higher chips it is always implemented. Only Cortex-M0 
seems to be the big exception to the rule. But why this relocation is 
not enabled by default in M3 and M4F Header files is still something I 
do not understand.

Michael

Am 23.01.21 um 05:17 schrieb J. Gareth Moreton via fpc-devel:
>
> I hope this isn't too much to ask, but if this IS intended for this 
> mailing list, would someone be willing to translate for me? I'm still 
> learning German (I assume it's German) and am not good enough yet to 
> make much sense of this.
>
> Gareth aka. Kit
>
> On 22/01/2021 22:37, Michael Ring via fpc-devel wrote:
>> Hi Florian, im Anhang der Path für den UF2 Support in freepascal, ich 
>> hoffe er passt so für Dich...
>>
>> Das UF2 File wird nur erzeugt wenn die Startadresse ungleich 
>> $00000000 ist da normalerweise der UF2 Bootloader ab Addresse 0 steht 
>> und es damit keinen sinnmacht ein uf2 file zu erzeugen wenn die 
>> Startaddresse auf default für Arm steht da dann der uf2 loader mit 
>> dem eigentlichen code kollidiert.
>>
>> Der Fall das eine Startadresse via -Ttext angepasst wird ist auch mit 
>> drin, habe ich noch was vergessen?
>>
>> Für den vollen Support muss auch noch das vtor Register umgeschrieben 
>> werden damit man interrupt-Handler im eigenen Code definieren kann, 
>> ich habe dazu bei mir den Startup Code for cortex M0,M3,M4F 
>> angepasst, keine Ahnung warum dieser Teil in dem {$ifdef 
>> REMAP_VECTTAB} define steht, denn dies muss dann in jeder Unit für 
>> einen Controller gesetzt werden obwohl bei den default Einstellungen 
>> der Remap korrekt ist.
>>
>> Hast Du eine Ahnung warum das so gemacht wurde?
>>
>> Ist nur ein Detail, wenn ich in der unit für den Raspi Pico den wert 
>> definiere dann wird vtor ja richtig gesetzt.
>>
>> Michael
>>
>>
>> Mein Startup Code:
>>
>>   ldr r0, .Lvtor
>>   ldr r1, .Ltext_start
>>   str r1, [r0]
>>
>>   bl PASCALMAIN
>>   b HaltProc
>>   .balign 4
>> .L_bss_start:
>>   .long _bss_start
>> .L_bss_end:
>>   .long _bss_end
>> .L_etext:
>>   .long _etext
>> .L_data:
>>   .long _data
>> .L_edata:
>>   .long _edata
>> .Lvtor:
>>   .long 0xE000ED08
>>
>>
>> statt original startup Code:
>>
>>
>> {$ifdef REMAP_VECTTAB}
>>   ldr r0, .Lvtor
>>   ldr r1, .Ltext_start
>>   str r1, [r0]
>> {$endif REMAP_VECTTAB}
>>
>>   bl PASCALMAIN
>>   b HaltProc
>>
>> .L_bss_start:
>>   .long _bss_start
>> .L_bss_end:
>>   .long _bss_end
>> .L_etext:
>>   .long _etext
>> .L_data:
>>   .long _data
>> .L_edata:
>>   .long _edata
>> {$ifdef REMAP_VECTTAB}
>> .Lvtor:
>>   .long 0xE000ED08
>>
>>
>> _______________________________________________
>> fpc-devel maillist  -fpc-devel at lists.freepascal.org
>> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 
> 	Virus-free. www.avast.com 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20210123/ee045472/attachment-0001.htm>


More information about the fpc-devel mailing list