Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit e0927ef

Browse files
committed
Adding NoNet project to MCBSTM32F400
1 parent 1dd1b60 commit e0927ef

19 files changed

+883
-271
lines changed

Solutions/MCBSTM32F400/DeviceCode/Initialization/tinyhal.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void __section("SectionForBootstrapOperations") Prepare_Zero( UINT32* dst
124124
}
125125
}
126126

127-
#if !defined(PLATFORM_ARM_OS_PORT)
127+
#if !defined(PLATFORM_ARM_OS_PORT) || defined(__GNUC__)
128128
void __section("SectionForBootstrapOperations") PrepareImageRegions()
129129
{
130130
//
@@ -327,7 +327,7 @@ void HAL_Initialize()
327327
// a soft reboot.
328328
__enable_irq();
329329
#endif
330-
330+
331331
HAL_CONTINUATION::InitializeList();
332332
HAL_COMPLETION ::InitializeList();
333333

@@ -510,25 +510,28 @@ void HAL_Uninitialize()
510510
#endif
511511
}
512512

513-
#if !defined(PLATFORM_ARM_OS_PORT)
514513
extern "C"
515514
{
515+
#if defined( __GNUC__ )
516+
extern "C++" int main(void);
517+
extern void __libc_init_array();
518+
void __main()
519+
{
520+
// Copy writeable data and zero init BSS
521+
PrepareImageRegions();
516522

517-
void BootEntry()
518-
{
519-
#if (defined(GCCOP) && defined(COMPILE_THUMB))
520-
521-
// the IRQ_Handler routine generated from the compiler is incorrect, the return address LR has been decrement twice
522-
// it decrements LR at the first instruction of IRQ_handler and then before return, it decrements LR again.
523-
// temporary fix is at the ARM_Vector ( IRQ), make it jump to 2nd instruction of IRQ_handler to skip teh first subs LR, LR #4;
524-
//
525-
volatile int *ptr;
526-
ptr =(int*) 0x28;
527-
*ptr = *ptr +4;
528-
#endif
523+
// Call static constructors
524+
__libc_init_array();
529525

526+
// Call the application's entry point.
527+
main();
528+
}
529+
#endif
530530

531-
#if !defined(BUILD_RTM) && !defined(PLATFORM_ARM_OS_PORT)
531+
#if !defined(PLATFORM_ARM_OS_PORT)
532+
void BootEntry()
533+
{
534+
#if !defined(BUILD_RTM)
532535
{
533536
int marker;
534537
int* ptr = &marker - 1; // This will point to the current top of the stack.
@@ -620,10 +623,10 @@ void BootEntry()
620623
CPU_Halt();
621624
#endif
622625
}
626+
#endif
623627

624628
} // extern "C"
625629

626-
#endif
627630

628631
#if defined(PLATFORM_ARM_OS_PORT)
629632
extern "C" void STM32F4_BootstrapCode();
@@ -683,8 +686,6 @@ void lcd_printf( const char* format, ... )
683686

684687
#endif // !defined(BUILD_RTM)
685688

686-
//--//
687-
688689
#if !defined(BUILD_RTM)
689690

690691
UINT32 Checksum_RAMConstants()

Solutions/MCBSTM32F400/MCBSTM32F400.settings

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<IsSolutionWizardVisible>True</IsSolutionWizardVisible>
1414
<ENDIANNESS>le</ENDIANNESS>
1515
<NO_BOOTLOADER_COMPRESSION>true</NO_BOOTLOADER_COMPRESSION>
16-
<TCP_IP_STACK>LWIP_1_4_1_OS</TCP_IP_STACK>
1716
</PropertyGroup>
1817
<PropertyGroup>
1918
<OEMSystemInfoString>Copyright (C) Microsoft Open Technologies Inc.</OEMSystemInfoString>
@@ -24,5 +23,5 @@
2423
</ItemGroup>
2524
<Import Project="$(SPOCLIENT)\devicecode\Targets\Native\STM32F4\STM32F4.settings" />
2625
<!-- This must be imported after the native build settings as it overrides the TARGETCODEBASE and Target type-->
27-
<Import Project="$(SPOCLIENT)\devicecode\Targets\OS\CMSIS_RTOS\CMSIS_RTOS.settings" Condition="'$(reducesize)' == 'false'"/>
26+
<Import Project="$(SPOCLIENT)\devicecode\Targets\OS\CMSIS_RTOS\CMSIS_RTOS.settings" Condition="'$(reducesize)' == 'false' AND '$(TCP_IP_STACK)'=='LWIP_1_4_1_OS'"/>
2827
</Project>

Solutions/MCBSTM32F400/TinyBooter/TinyBooter.proj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
<RequiredProjects Include="$(SPOCLIENT)\DeviceCode\Cores\arm\Processors\CortexMx\GlobalLock\dotNetMF.proj" />
4444
</ItemGroup>
4545
<ItemGroup>
46-
<DriverLibs Include="MCBSTM32F400_tinyhal_loader.$(LIB_EXT)" />
47-
<RequiredProjects Include="$(SPOCLIENT)\Solutions\MCBSTM32F400\DeviceCode\TinyHal\dotNetMF_loader.proj" />
46+
<DriverLibs Include="TinyHal_loader_Cortex.$(LIB_EXT)"/>
47+
<RequiredProjects Include="$(SPOCLIENT)\DeviceCode\Cores\arm\Processors\CortexMx\TinyHal\dotnetmf_loader.proj" />
4848
</ItemGroup>
4949
<ItemGroup>
5050
<DriverLibs Include="cpu_prestackinit_stubs.$(LIB_EXT)" />
@@ -99,8 +99,8 @@
9999
<RequiredProjects Include="$(SPOCLIENT)\DeviceCode\Drivers\stubs\Processor\stubs_watchdog\dotNetMF.proj" />
100100
</ItemGroup>
101101
<ItemGroup>
102-
<DriverLibs Include="MCBSTM32F400_initialization_hal_loader.$(LIB_EXT)" />
103-
<RequiredProjects Include="$(SPOCLIENT)\Solutions\MCBSTM32F400\DeviceCode\Initialization\dotNetMF_loader.proj" />
102+
<DriverLibs Include="system_initialization_hal_loader.$(LIB_EXT)" />
103+
<RequiredProjects Include="$(SPOCLIENT)\DeviceCode\Initialization\dotNetMF_loader.proj" />
104104
</ItemGroup>
105105
<ItemGroup>
106106
<DriverLibs Include="Watchdog_pal_stubs.$(LIB_EXT)" />
@@ -246,11 +246,11 @@
246246
<DriverLibs Include="STM32F4_DA.$(LIB_EXT)" />
247247
<RequiredProjects Include="$(SPOCLIENT)\DeviceCode\Targets\Native\STM32F4\DeviceCode\STM32F4_DA\dotNetMF.proj" />
248248
</ItemGroup>
249-
<ItemGroup>
249+
<ItemGroup>
250250
<DriverLibs Include="M29W640FB_Flash.$(LIB_EXT)" />
251251
<RequiredProjects Include="$(SPOCLIENT)\Solutions\MCBSTM32F400\DeviceCode\M29W640FB_Flash\dotNetMF.proj" />
252252
</ItemGroup>
253-
<ItemGroup>
253+
<ItemGroup>
254254
<DriverLibs Include="M29W640FB_blconfig_MCBSTM32F400.$(LIB_EXT)" />
255255
<RequiredProjects Include="$(SPOCLIENT)\Solutions\MCBSTM32F400\DeviceCode\Blockstorage\M29W640FB\dotNetMF.proj" />
256256
</ItemGroup>

Solutions/MCBSTM32F400/TinyBooter/TinyBooterEntry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// boot loader doesn't use the CMSIS-RTOS kernel, so sleep goes direct
2121
// to the low level support
2222
extern void HAL_CPU_Sleep( SLEEP_LEVEL level, UINT64 wakeEvents );
23+
2324
void CPU_Sleep( SLEEP_LEVEL level, UINT64 wakeEvents )
2425
{
2526
HAL_CPU_Sleep( level, wakeEvents );

Solutions/MCBSTM32F400/TinyBooter/scatterfile_bootloader_gcc.xml

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<!-- Put Stack in CCM for high speed access, reducing overhead of stack usage -->
3737
<Set Name="Stack_Bottom" Value="%CCM_BaseAddress%"/>
3838
<Set Name="Stack_Size" Value="%CCM_Size%" />
39-
39+
4040
<!-- External SRAM -->
4141
<Set Name="Heap_BaseAddress" Value="%EXTRAM_BaseAddress%"/>
4242

@@ -53,10 +53,10 @@
5353
<Set Name="Data_BaseAddress" Value="%Config_BaseAddress% + %Config_Size%"/>
5454
<Set Name="Data_Size" Value="0x00020000"/><!-- 128KB -->
5555

56-
<!-- [Deployment fills the rest of external NOR flash..]. -->
56+
<!-- [Deployment fills the rest of external NOR flash...] -->
5757

5858
<!-- Internal FLASH -->
59-
<!-- TinyBooter sits at power on Reset vector-->
59+
<!-- TinyBooter sits at power on Reset vector -->
6060
<Set Name="BooterCode_BaseAddress" Value="%IFLASH_BaseAddress%"/>
6161
<Set Name="BooterCode_Size" Value="0x00010000"/><!-- 64KB -->
6262

@@ -92,24 +92,23 @@
9292
<If Name="Valid" Value="false">
9393
<Error Message="Configuration not recognized"/>
9494
</If>
95-
95+
9696
<EntryPoint Name="EntryPoint" />
9797

9898
<NamedGroup Name="MEMORY">
9999
<LoadRegion Name="D_CCM" Base="%CCM_BaseAddress%" Size="%CCM_Size%" />
100-
<LoadRegion Name="IRAM" Base="%IRAM_BaseAddress%" Size="%IRAM_Size%"/>
101-
<LoadRegion Name="LR_%TARGETLOCATION%" Base="%Code_BaseAddress%" Size="%Code_Size%"/>
100+
<LoadRegion Name="IRAM" Base="%IRAM_BaseAddress%" Size="%IRAM_Size%" />
101+
<LoadRegion Name="LR_%TARGETLOCATION%" Base="%Code_BaseAddress%" Size="%Code_Size%" />
102102
<LoadRegion Name="EXTRAM" Base="%EXTRAM_BaseAddress%" Size="%EXTRAM_Size%" />
103-
<LoadRegion Name="CONFIG" Base="%Config_BaseAddress%" Size="%Config_Size%"/>
104103
</NamedGroup>
105-
104+
106105
<NamedGroup Name="SECTIONS">
107106
<!-- ========= INTERNAL FLASH ============================================ -->
108107
<ExecRegion Name="ER_%TARGETLOCATION%" Options="&gt;LR_%TARGETLOCATION%">
109-
<FileMapping Name="*" Options="(i.EntryPoint)" />
108+
<FileMapping Name="KEEP" Options="(*(SectionForPowerOnReset))" />
110109
<FileMapping Name="*" Options="(SectionForBootstrapOperations)" />
110+
<FileMapping Name="*" Options="(SectionForFlashOperations)"/>
111111
<FileMapping Name="*" Options="(.text*)" />
112-
<FileMapping Name="*" Options="(i.*)" />
113112
<FileMapping Name="*" Options="(.rodata*)" />
114113
<FileMapping Name="*" Options="(rodata)" />
115114
<FileMapping Name="*" Options="(.constdata*)" />
@@ -119,65 +118,75 @@
119118
</ExecRegion>
120119

121120
<!-- ========= INTERNAL RAM ============================================= -->
122-
<ExecRegion Name="ER_RAM_RW" Align="0x10" Options="&gt;IRAM AT&gt;LR_%TARGETLOCATION%">
121+
<!-- Writeable Vector table -->
122+
<!-- NOTE:
123+
Despite what you might hope for, this CANNOT go into the CCM area as the NVIC does not
124+
have access to that space (it sees the AHB layer and below, rather than the core's D-Bus)
125+
-->
126+
<!-- Alignment for the vector table is important to allow the NVIC to decode the proper locations
127+
(See Section 4.4.4 of the ARM Cortex-M4 Generic User Guide [ ARM DUI 0553A (ID121610) ] )
128+
Since this starts the SRAM block, it's aligned just fine for any size table.
129+
-->
130+
<ExecRegion Name="ER_RAM_RW" Align="0x10" Options="&gt;IRAM AT&gt;LR_FLASH ">
131+
<FileMapping Name="*" Options="(VectorTable)"/>
123132
<FileMapping Name="*" Options="(rwdata)" />
124133
<FileMapping Name="*" Options="(.data*)" />
125134
</ExecRegion>
126135

127-
<ExecRegion Name="ER_RAM_RO" Align="0x10">
128-
<!--Flash programming from Flash is safe on STM32
129-
No need to place Flash programming code in RAM-->
136+
<ExecRegion Name="ER_RAM_RO" Align="0x10" Options="&gt;IRAM">
137+
<!-- Flash programming from Flash is safe on STM32 -->
138+
<!-- No need to place Flash programming code in RAM -->
139+
<!-- <FileMapping Name="*" Options="(SectionForFlashOperations)" /> -->
130140
</ExecRegion>
131141

132-
<ExecRegion Name=".bss" Align="0x10" Options="&gt;IRAM AT&gt;LR_%TARGETLOCATION%">
142+
<ExecRegion Name=".bss" Align="0x10" Base="(NOLOAD)" Options="&gt;IRAM">
133143
<FileMapping Name="*" Options="(.bss*)" />
134-
<FileMapping Name="*" Options="(.zidata*)" />
135144
<FileMapping Name="PROVIDE(__exidx_start = .);" />
136145
<FileMapping Name="PROVIDE(__exidx_end = .);" />
137-
<FileMapping Name="*" Options="(g_SSL_SeedData)" />
146+
<FileMapping Name="*" Options="(.zidata*)" />
147+
<FileMapping Name="*" Options="(COMMON)" />
138148
</ExecRegion>
139149

140150
<ExecRegion Name="/DISCARD/">
141151
<FileMapping Name="*" Options="(.ARM.exidx*)" />
142152
<FileMapping Name="*" Options="(.ARM.extab*)" />
143153
</ExecRegion>
144-
145-
<!--========= EXTERNAL RAM =============================================-->
154+
155+
<!--========= EXTERNAL RAM =============================================-->
146156
<ExecRegion Name="ER_HEAP_BEGIN" Options="&gt;EXTRAM">
147157
<FileMapping Name="*" Options="(SectionForHeapBegin)" />
148158
</ExecRegion>
149159

150160
<!-- everything between heapbegin and heapend will be allocated for a heap -->
151161

152-
<ExecRegion Name="ER_HEAP_END" Base="%Heap_BaseAddress% + %Heap_Size%" Options="&gt;EXTRAM" >
162+
<ExecRegion Name="ER_HEAP_END" Base="ADDR(ER_HEAP_BEGIN) + %Heap_Size%" Options="&gt;EXTRAM" >
153163
<FileMapping Name="*" Options="(SectionForHeapEnd)" />
154164
</ExecRegion>
155165

156-
<!--<ExecRegion Name="ER_CUSTOM_HEAP_BEGIN" Base="+0">
166+
<ExecRegion Name="ER_CUSTOM_HEAP_BEGIN" Options="&gt;EXTRAM" >
157167
<FileMapping Name="*" Options="(SectionForCustomHeapBegin)" />
158-
</ExecRegion>-->
168+
</ExecRegion>
159169

160-
<!-- everything between heapbegin and heapend will be allocated for the unmanaged SimpleHeap --><!--
170+
<!-- everything between heapbegin and heapend will be allocated for the unmanaged SimpleHeap -->
161171

162-
<ExecRegion Name="ER_CUSTOM_HEAP_END" Base="+%CustomHeap_Size%" Options="ABSOLUTE UNINIT" Size="">
172+
<ExecRegion Name="ER_CUSTOM_HEAP_END" Base="ADDR(ER_CUSTOM_HEAP_BEGIN) + %CustomHeap_Size%" Options="&gt;EXTRAM" >
163173
<FileMapping Name="*" Options="(SectionForCustomHeapEnd)" />
164174
</ExecRegion>
165175

166-
--><!-- ========= Internal CCM ============================================ --><!--
167-
<ExecRegion Name="ER_STACK_BOTTOM" Base="%Stack_Bottom%" Options="ABSOLUTE UNINIT" Size="">
176+
<!-- ========= Internal CCM ============================================ -->
177+
<ExecRegion Name="ER_STACK_BOTTOM" Options="&gt;D_CCM">
168178
<FileMapping Name="*" Options="(SectionForStackBottom)" />
169179
</ExecRegion>
170180

171-
--><!-- -8 for the two 32bit values in the SectionForStack* sections, This keeps the region
172-
limit from exceeding the size of physical memory.
173-
--><!--
174-
<ExecRegion Name="ER_STACK_TOP" Base="AlignExpr(+%CCM_Size% -8, 8 )" Options="ABSOLUTE UNINIT" Size="">
181+
<!--8 for the two 32bit values in the SectionForStack* sections, This keeps the region
182+
limit from exceeding the size of physical memory. -->
183+
<ExecRegion Name="ER_STACK_TOP" Base="%Stack_Bottom% + %Stack_Size% - 8" Options="&gt;D_CCM">
175184
<FileMapping Name="*" Options="(SectionForStackTop +LAST)" />
176-
</ExecRegion>-->
185+
</ExecRegion>
177186
</NamedGroup>
178187

179188
<!-- The following variables are used to simulate the ones autogenerated by ARMCC -->
180-
<GlobalVariable Name="Load$$ER_%TARGETLOCATION%$$Base" Value="ADDR(ER_%TARGETLOCATION%)"/>
189+
<GlobalVariable Name="Load$$ER_%TARGETLOCATION%$$Base" Value="LOADADDR(ER_%TARGETLOCATION%)"/>
181190
<GlobalVariable Name="Image$$ER_%TARGETLOCATION%$$Length" Value="SIZEOF(ER_%TARGETLOCATION%)"/>
182191
<GlobalVariable Name="Image$$ER_RAM_RO$$Base" Value="ADDR(ER_RAM_RO)"/>
183192
<GlobalVariable Name="Image$$ER_RAM_RO$$Length" Value="SIZEOF(ER_RAM_RO)"/>
@@ -189,3 +198,4 @@
189198
<GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Length" Value="SIZEOF(.bss)"/>
190199
<GlobalVariable Name="__use_no_semihosting_swi" Value="0"/>
191200
</ScatterFile>
201+

Solutions/MCBSTM32F400/TinyBooter/scatterfile_bootloader_mdk.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,24 @@
9595

9696
<!-- ========= INTERNAL FLASH ============================================ -->
9797
<ExecRegion Name="ER_%TARGETLOCATION%" Base="%Code_BaseAddress%" Options="FIXED" Size="">
98-
<FileMapping Name="FirstEntry.obj" Options="(+RO, +FIRST)" />
98+
<FileMapping Name="*" Options="(SectionForPowerOnReset, +FIRST)" />
9999
<FileMapping Name="*" Options="(SectionForBootstrapOperations)" />
100100
<FileMapping Name="*" Options="(+RO-CODE)" />
101101
<FileMapping Name="*" Options="(+RO-DATA)" />
102102
</ExecRegion>
103103

104104
<!-- ========= INTERNAL RAM ============================================= -->
105+
<!-- Writeable Vector table -->
106+
<!-- NOTE:
107+
Despite what you might hope for, this CANNOT go into the CCM area as the NVIC does not
108+
have access to that space (it sees the AHB layer and below, rather than the core's D-Bus)
109+
-->
110+
<!-- Alignment for the vector table is important to allow the NVIC to decode the proper locations
111+
(See Section 4.4.4 of the ARM Cortex-M4 Generic User Guide [ ARM DUI 0553A (ID121610) ] )
112+
Since this starts the SRAM block, it's aligned just fine for any size table.
113+
-->
105114
<ExecRegion Name="ER_RAM_RW" Base="%IRAM_BaseAddress%" Options="ABSOLUTE" Size="">
115+
<FileMapping Name="*" Options="(VectorTable)"/>
106116
<FileMapping Name="*" Options="(+RW-DATA, +ZI)" />
107117
</ExecRegion>
108118

Solutions/MCBSTM32F400/TinyCLR/TinyCLR.proj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<MFSettingsFile>$(SPOCLIENT)\Solutions\MCBSTM32F400\MCBSTM32F400.settings</MFSettingsFile>
1414
<IsSolutionWizardVisible>True</IsSolutionWizardVisible>
1515
<reducesize>false</reducesize>
16+
<TCP_IP_STACK>LWIP_1_4_1_OS</TCP_IP_STACK>
1617
</PropertyGroup>
1718
<Import Project="$(SPOCLIENT)\tools\targets\Microsoft.SPOT.System.Settings" />
1819
<Import Project="$(SPOCLIENT)\tools\Targets\Microsoft.SPOT.Build.Targets" />
@@ -497,7 +498,7 @@
497498
<DriverLibs Include="M29W640FB_Flash.$(LIB_EXT)" />
498499
<RequiredProjects Include="$(SPOCLIENT)\Solutions\MCBSTM32F400\DeviceCode\M29W640FB_Flash\dotNetMF.proj" />
499500
</ItemGroup>
500-
<ItemGroup>
501+
<ItemGroup>
501502
<DriverLibs Include="M29W640FB_blconfig_MCBSTM32F400.$(LIB_EXT)" />
502503
<RequiredProjects Include="$(SPOCLIENT)\Solutions\MCBSTM32F400\DeviceCode\Blockstorage\M29W640FB\dotNetMF.proj" />
503504
</ItemGroup>

0 commit comments

Comments
 (0)