Ver código fonte

Applied patch from Michael Ring fixing the startup code for Freescale microcontrollers.

git-svn-id: trunk@32568 -
Jeppe Johansen 9 anos atrás
pai
commit
4b1eb0e4f3

+ 7 - 1
compiler/systems/t_embed.pas

@@ -606,7 +606,13 @@ begin
          with embedded_controllers[current_settings.controllertype] do
          with embedded_controllers[current_settings.controllertype] do
           with linkres do
           with linkres do
             begin
             begin
-              Add('ENTRY(_START)');
+              if (embedded_controllers[current_settings.controllertype].controllerunitstr='MK20D5')
+              or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK20D7')
+              or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK22F51212')
+              or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK64F12') then
+                Add('ENTRY(_LOWLEVELSTART)')
+              else
+                Add('ENTRY(_START)');
               Add('MEMORY');
               Add('MEMORY');
               Add('{');
               Add('{');
               if flashsize<>0 then
               if flashsize<>0 then

+ 31 - 1
rtl/embedded/arm/mk20d5.pp

@@ -1106,13 +1106,43 @@ procedure SWI_interrupt; external name 'SWI_interrupt';
 
 
 {$i cortexm4f_start.inc}
 {$i cortexm4f_start.inc}
 
 
+procedure FlashConfiguration; assembler; nostackframe;
+label flash_conf;
+asm
+  .section ".flash_config.flash_conf"
+flash_conf:
+  .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
+
+  .text
+end;
+
+procedure LowLevelStartup; assembler; nostackframe; [public, alias: '_LOWLEVELSTART'];
+asm
+  // Unlock watchdog
+  ldr r0, .LWDOG_BASE
+  movw        r1, #50464
+  strh        r1, [r0, #0xE]
+  movw        r1, #55592
+  strh        r1, [r0, #0xE]
+  nop
+  nop
+  // Disable watchdog for now
+  movs r1, #0
+  strh r1, [r0, #0]
+
+  b Startup
+
+.LWDOG_BASE:
+  .long 0x40052000
+end;
+
 procedure Vectors; assembler; nostackframe;
 procedure Vectors; assembler; nostackframe;
 label interrupt_vectors;
 label interrupt_vectors;
 asm
 asm
   .section ".init.interrupt_vectors"
   .section ".init.interrupt_vectors"
   interrupt_vectors:
   interrupt_vectors:
   .long _stack_top
   .long _stack_top
-  .long Startup
+  .long LowLevelStartup
   .long NonMaskableInt_interrupt
   .long NonMaskableInt_interrupt
   .long 0
   .long 0
   .long MemoryManagement_interrupt
   .long MemoryManagement_interrupt

+ 31 - 1
rtl/embedded/arm/mk20d7.pp

@@ -1388,13 +1388,43 @@ procedure SWI_interrupt; external name 'SWI_interrupt';
 
 
 {$i cortexm4f_start.inc}
 {$i cortexm4f_start.inc}
 
 
+procedure FlashConfiguration; assembler; nostackframe;
+label flash_conf;
+asm
+  .section ".flash_config.flash_conf"
+flash_conf:
+  .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
+
+  .text
+end;
+
+procedure LowLevelStartup; assembler; nostackframe; [public, alias: '_LOWLEVELSTART'];
+asm
+  // Unlock watchdog
+  ldr r0, .LWDOG_BASE
+  movw        r1, #50464
+  strh        r1, [r0, #0xE]
+  movw        r1, #55592
+  strh        r1, [r0, #0xE]
+  nop
+  nop
+  // Disable watchdog for now
+  movs r1, #0
+  strh r1, [r0, #0]
+
+  b Startup
+
+.LWDOG_BASE:
+  .long 0x40052000
+end;
+
 procedure Vectors; assembler; nostackframe;
 procedure Vectors; assembler; nostackframe;
 label interrupt_vectors;
 label interrupt_vectors;
 asm
 asm
   .section ".init.interrupt_vectors"
   .section ".init.interrupt_vectors"
   interrupt_vectors:
   interrupt_vectors:
   .long _stack_top
   .long _stack_top
-  .long Startup
+  .long LowLevelStartup
   .long NonMaskableInt_interrupt
   .long NonMaskableInt_interrupt
   .long 0
   .long 0
   .long MemoryManagement_interrupt
   .long MemoryManagement_interrupt

+ 31 - 1
rtl/embedded/arm/mk22f51212.pp

@@ -1298,13 +1298,43 @@ procedure RESERVED101_interrupt; external name 'RESERVED101_interrupt';
 
 
 {$i cortexm4f_start.inc}
 {$i cortexm4f_start.inc}
 
 
+procedure FlashConfiguration; assembler; nostackframe;
+label flash_conf;
+asm
+  .section ".flash_config.flash_conf"
+flash_conf:
+  .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
+
+  .text
+end;
+
+procedure LowLevelStartup; assembler; nostackframe; [public, alias: '_LOWLEVELSTART'];
+asm
+  // Unlock watchdog
+  ldr r0, .LWDOG_BASE
+  movw        r1, #0xc520 //50464
+  strh        r1, [r0, #0xE]
+  movw        r1, #0xd928 //55592
+  strh        r1, [r0, #0xE]
+  nop
+  nop
+  // Disable watchdog for now
+  movs r1, #0x1d2
+  strh r1, [r0, #0]
+
+  b Startup
+
+.LWDOG_BASE:
+  .long 0x40052000
+end;
+
 procedure Vectors; assembler; nostackframe;
 procedure Vectors; assembler; nostackframe;
 label interrupt_vectors;
 label interrupt_vectors;
 asm
 asm
   .section ".init.interrupt_vectors"
   .section ".init.interrupt_vectors"
   interrupt_vectors:
   interrupt_vectors:
   .long _stack_top
   .long _stack_top
-  .long Startup
+  .long LowLevelStartup
   .long NonMaskableInt_interrupt
   .long NonMaskableInt_interrupt
   .long HardFault_interrupt
   .long HardFault_interrupt
   .long MemoryManagement_interrupt
   .long MemoryManagement_interrupt

+ 32 - 1
rtl/embedded/arm/mk64f12.pp

@@ -1711,13 +1711,44 @@ procedure ENET_Receive_interrupt; external name 'ENET_Receive_interrupt';
 procedure ENET_Error_interrupt; external name 'ENET_Error_interrupt';
 procedure ENET_Error_interrupt; external name 'ENET_Error_interrupt';
 
 
 {$i cortexm4f_start.inc}
 {$i cortexm4f_start.inc}
+
+procedure FlashConfiguration; assembler; nostackframe;
+label flash_conf;
+asm
+  .section ".flash_config.flash_conf"
+flash_conf:
+  .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
+
+  .text
+end;
+
+procedure LowLevelStartup; assembler; nostackframe; [public, alias: '_LOWLEVELSTART'];
+asm
+  // Unlock watchdog
+  ldr r0, .LWDOG_BASE
+  movw        r1, #50464
+  strh        r1, [r0, #0xE]
+  movw        r1, #55592
+  strh        r1, [r0, #0xE]
+  nop
+  nop
+  // Disable watchdog for now
+  movs r1, #0
+  strh r1, [r0, #0]
+
+  b Startup
+
+.LWDOG_BASE:
+  .long 0x40052000
+end;
+
 procedure Vectors; assembler; nostackframe;
 procedure Vectors; assembler; nostackframe;
 label interrupt_vectors;
 label interrupt_vectors;
 asm
 asm
   .section ".init.interrupt_vectors"
   .section ".init.interrupt_vectors"
   interrupt_vectors:
   interrupt_vectors:
   .long _stack_top
   .long _stack_top
-  .long Startup                                  // int -15
+  .long LowLevelStartup                          // int -15
   .long NonMaskableInt_interrupt                 // int -14
   .long NonMaskableInt_interrupt                 // int -14
   .long HardFault_interrupt                      // int -13
   .long HardFault_interrupt                      // int -13
   .long MemoryManagement_interrupt               // int -12
   .long MemoryManagement_interrupt               // int -12