Skip to content

Why compile with GCC V4.6

NicolasG3 edited this page Jun 7, 2013 · 2 revisions

NETMF for STM32F4 need THUMB mode compilation. Experience shows that GCC version 4.7 does not compile in thumb mode

Looking at FirstEntry.s, you can see how the start is signed and the expected machine code:

 @ The first word has several functions:
 @ - It is the entry point of the application
 @ - it contains a signature word used to identify application blocks
 @ - out of reset it contains the initial stack pointer value
 @ - it is the first entry of the initial exception handler table
 @ The actual word used is 0x2000E00C
 
    b         Start         @ 0xE00C
    .hword    0x2000        @ Booter signature is 0x2000E00C
    .word     Start         @ Reset
...

After compilation, the assembly result is available in tinyclr.axfdump (c:\MicroFrameworkPK_v4_x\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin)

Here is the correct Booter signature:

Disassembly of section ER_FLASH:

 08010000 <EntryPoint>:
 8010000:	e00c      	b.n	801001c <Start>
 8010002:	2000      	.short	0x2000
 8010004:	...

and now the result for GCC 4.7

Disassembly of section ER_FLASH:

 08010000 <EntryPoint>:
 8010000:	f000 b80d 	b.w	801001e <Start>
 8010004:	001f2000 	.word	0x001f2000
 8010008:	...

As you can see, the thumb directive is not honored in GCC 4.7: the code size is larger and even if the compilation is completed the Booter signature is broken.