WEC-2013-Logo

1      Introduction

This article discusses the important tips for Compact 2013 BSP porting.

2      Things that are changed in Compact 2013

  • Compiler is updated to new version.
  • C Runtime library is updated to latest version.
  • Assembler uses ARM thumb 2 instruction set.
  • Removal of old ARM SOC code in platform\common.

3      Things that are not changed in Compact 2013

  • BSP Structure – Directory structure is same as WEC 7
  • Build System – Directory structure of resulting sysgen’ed files is at same location as windows embedded compact 7.
  • OAL Interface – Almost all functions/variables in OAL interface are unchanged.
  • Kernel Memory and Organization – Same memory mode and multiprocessor support as WEC 7

4      New Features in Compact 2013

In this section let’s see new features which are newly added in Compact 2013

  • You can develop applications and OS for compact 2013 using latest visual studio versions 2012 and 2013. Latest visual studio has updated IDE UI and few more additional features.
  • ARM compiler is updated to new version and C runtime libraries also updated to the latest version.
  • WEC 2013 networking stack performance is improved and network miniport driver performance also improved.
  • Compact 2013 catalog items are all aligned properly. Few catalog items are merged together and some new items are all added.
    • Some catalog items are removed in compact 2013. Most highlighted feature which is removed are Internet Explorer, Remote desktop protocol (RDP), Active Sync and Windows 95 default shell.
  • For Native application development, C runtime library’s like Active Template Library (ATL), Standard Template Library (STL) and Microsoft Foundation Class (MFC) are updated to support latest version.
  • For Managed application development, .NET framework is updated to version 3.9 from 3.5.
  • Compact 2013 supports only THUMB2 mode instruction set. To generate thumb2 assembly code compiler updated to version C++ and assembler supports new version of ARM Embedded- Application Binary Interface (EABI).
  • Compact 2013 has snapshot boot feature. It significantly reduces the time that is required for your device to boot by saving the state of your device to persistent storage and then restoring that state when the device reboots
  • It support XAML and Expression blend feature to develop rich UI based application

5      Compact 7 to Compact 2013 Porting

Make sure your target BSP is built successfully without any errors in WEC7. You have to copy your target BSP from WINCE700\Platform\<BSP Name> folder to WINCE800\Platform\<BSP Name> location.

 

The following sections explains what should be taken care while porting Compact 2013 BSP from Compact 7 BSP.

5.1     C Runtime Libraries

The first step in porting WEC7 BSP to WEC2013, need do following changes in WEC2013 BSP.

 

  • h renamed to CeTypes.h – simple approach to address this changes is to create Types.h file under {bsp}\SRC\INC and include the CeTypes.h in that file.
  • lib renamed to bootcrt.lib – Have to use new lib name in boot loader and OALEXE sources file.
  • lib splits into two lib’s “coredll.lib” and “msvcrt.lib”.It now contains the C runtime API’s

Standard library functions are now updated to secure functionIt means function argument require size field for destination buffers.

5.2     ARM Data Alignment

In WEC 2013 ARM code, we may encounter data alignment error (i.e. alignment fault error).The ARM compiler assumes unaligned access handled in hardware but this is not the case for uncached memory access.

 

Alignment error will not encounter generally because /QRunaligned -flag is set when compile OS and it will generate code for accessing unaligned memory. The memcpy and memory handle unaligned access.

 

Example for alignment error: CPU generates data alignment fault for the below give code even when unaligned access enabled.

Porting-1

To avoid data alignment fault, developer should take care of alignment of structure when writing code.
Unaligned access in Boot loader:
o If MMU is not activated, all the memory access is treated as uncached.
o In Boot loader code MMU is not enabled and kernel is not used. Unaligned data access should be taken care by developer. Otherwise often will face data alignment fault exception
o Need to enable unaligned support in boot loader startup code to avoid data fault error.
o Enable unaligned support
 Clearing A bit, bit 1 of CP15 register 1.
 Setting U bit, bit 22 of CP15 register 1
Always verify alignment when accessing memory typically face a problem when accessing unaligned structure passed from hardware.
5.3 ARM Stack Alignment
When working on assembly code in WEC2013 you should keep in mind about stack alignment and keep the stack aligned as four byte boundary or eight byte boundary.

Macros such as LEAF_ENTRY and LEAF_END must be matched but many arm assembly files have LEAF_ENTRY and ENTRY_END macros on assembler function.

Difference between LEAF_ and NESTED_ macros
o LEAF_ macros are used for routines that don’t call other routines
o NESTED_ macros are used for routines that call other routines
Use PROLOG_STACK_ALLOC for allocating space on stack and use PROLOG_PUSH and EPILOG_POP to save and restore registers as show in below example.

Porting-2

To know more details about the macro’s definition’s refer the link
In all the assembly files (.s) of WEC2013, you have to change ENTRY_END macro as LEAF_END macro.

Porting-3
Figure 1. Macro example

Need to add RODATAAREA macro in the OAL startup code located at SRC\OAL\OALLIB folder.

Porting-4
Figure 2. RODATAAREA macro example

5.4 ARM Thumb2 Code Changes
o Compact 2013 support only ARMV7 THUMB2 mode.
o Thumb2 mode does not support reset and exception handler.
o CPU must be in THUMB2 mode before running any WEC 2013 code.
o ARM assembly code and THUMB2 assembly code should be in separate ASM files.

For more details about ARM Thumb2 porting considerations, Please see the below article.

Windows Embedded Compact 2013 – THUMB2 Porting Considerations

PC arithmetic operation are not supported in THUMB2 mode instructions. So assembler will through an error “pre UAL syntax not allowed” frequently. Need to change few instruction to THUMB2 UAL syntax. Please see the below blog posts for more details.

Windows Embedded Compact 2013 THUMB2 porting – ARM pre UAL syntax and its equivalent UAL syntax

Windows Embedded Compact 2013 THUMB2 ARM pre UAL syntax and its equivalent UAL syntax-part 2

5.5 Fixing Start Up code of Initial Boot loaders

There are some size constrained binaries specifically pre boot loaders such as XLDR/IPL are loaded by processor boot ROM from NAND/SD card to a small size SRAM and this will load the Eboot to DDR and jump to Eboot. Entry point of the boot loader is expected to be the very first instruction for some processor or a set of predefined data that can be understandable by the boot rom of the processor is expected to be at very beginning of the boot loader. Normally STARTUPTEXT Macro is used to place the required code in the very beginning in Windows CE but there are some changes in this macro on WEC2013 due to these there are some changes has to be done in our code to keep the required instruction/data to be in the first location of the binary. Please see the below blogs for more details.

Windows Embedded Compact 2013 – Understanding STARTUPTEXT macro – Part 1

Windows Embedded Compact 2013 – Understanding STARTUPTEXT macro – Part 2

 5.6 Replace DLLENTRY MACRO as DLLMAIN

In WEC2013, DLLENTRY macro is renamed as DLLMAIN. So change the DLL entry point in driver as DLL main and in .def file DllEntry import/export as DllMain.

For example, the following change is required in sources file of drivers.

DLLENTRY=_DllMainCRTStartUp

Co-author: Suresh Madhu, Microsoft Certified Technology Specialist

2 thoughts on “Windows Embedded Compact 2013 BSP porting”
  1. No, you can’t run it.If you try to run Windows CE 7 build application in Windows CE 2013 it will throw error as “Cannot load executables built for OS version 7.00”.

    The Windwos 2013 supports only Thumb2 instructions set and the application built in Windows 2013 generate Thumb2 assembly code for executable(.exe) but application built in windows 7 generates ARM assembly code. So you have to build your application in Windows 2013 platform.

Comments are closed.