VAR-SOM-OM37 Windows GS

From Variscite Wiki
Revision as of 07:47, 19 January 2014 by Admin (talk | contribs)

VAR-SOM-OM37 - Windows CE support

Support

Variscite supports its VAR-SOM-OM37 with Windows CE 6 R3 and Windows Embedded compact 7 BSPs.

The BSP provides support for all on-board peripherals. Your Windows CE folder on your CD contains:

  1. Ready-to-run pre-built binaries of the : NK.bin , Eboot, Xloader
  2. Sources files
  3. SDK
  4. C# wrappers for device drivers
  5. OpenGL / PowerVR demos
  6. Sample media contents for playing via the DM3730 hardware acceleration.

Resources

WindowsCE OS Update Service

overview

Variscite's Windows CE BSP includes a proprietary OS update service.

The service provides the ability to remotely update the OS run-time-image which resides on the on-board NAND-flash.

Windows embedded compact 7 releases 1.25 and forth, support EBOOT, boot configuration and screen logo update as well.

O.S. update procedure is power-fail proof.  OS image will not replace current one, until the flashing process is successfully completed and verified.

All other updates are not power fail proof, user must ensure proper power stability before procedure start.


Boot Configuration API

Boot configuration structure (BOOT_CFG) declared in file boot_args.h Two IOCTLs provided: OSU_IOCTL_READ_BOOTARGS - Reads boot configuration from flash memory into user buffer OSU_IOCTL_WRITE_BOOTARGS - Saves boot configuration from user buffer into flash memory Note that OSU_IOCTL_WRITE_BOOTARGS is not fail-safe: if for some reason (like power removal) if will fail, it may leave boot configuration in undefined state.

OS image, EBOOT and Logo update API

OS image update (like EBOOT and Logo update) uses two IOCTLs:
OSU_IOCTL_SET_FILE - Sets the file-name for consequent update operation. For OS image update file shall be of "nb0" (raw binary) type.
OSU_IOCTL_UPDATE - Initiates the OS image update procedure

Updating EBOOT also uses two IOCTLs: same OSU_IOCTL_SET_FILE followed by OSU_IOCTL_UPDATE_EBOOT. EBOOT file shall be in "nb0" (raw binary) format. Please ensure that correct file is specified, because there is no way for the driver to determine that raw binary contains EBOOT.

Updating EBOOT also uses two IOCTLs: same OSU_IOCTL_SET_FILE followed by OSU_IOCTL_UPDATE_LOGO. Logo file shall be in "bmp" (24-bit RGB) format. Make sure that supplied bitmap has exactly the size of your screen, otherwise it will not be displayed correctly by EBOOT.


Note:
The NK.nb0 and EBOOTND.nb0 files are generated as part of OS build. The files may be found in the Release directory under the corresponding project. For example, if the user builds the VAR_SOM-OM37_P BSP with VAR-SOM-OM3X_REL project, then the file will reside in the \WINCE600\Osdesign\VAR-SOM-OM3X_REL\VAR-SOM-OM3X_REL\RelDir\VAR_SOM_OM37_P_ARMV4I_Release folder.


Note:
The OS update procedure requires reboot for updated OS image activation. User should reset the system when ready.

Application may use the following command to reset the system:

SetSystemPowerState(NULL, POWER_STATE_RESET, 0);
Note:
The driver uploads full OS image file to the RAM. Therefore, for successful update operation, driver requests 32M of free RAM.

Service limitation: OS update service nk0 size limit:

Windows CE6: 40MB

Windows embedded compact 7:  VAR-SOM-AM35   -  80MB, VAR-SOM-OM37 - 62MB

Sample application - all O.S. update features

Note that preprocessor variable DYNAMIC_OS_BOOT must be defined (in project properties)
// OSUpdate.cpp : Defines the entry point for the console application.
//
#pragma warning(push)
#pragma warning(disable : 4115 6067)
#include <windows.h>
#include "oalex.h"
#include "boot_args.h"

void RetailPrint(wchar_t *pszFormat, ...);
//extern int	CreateArgvArgc(TCHAR *pProgName, TCHAR *argv[20], TCHAR *pCmdLine);

#define OSU_IOCTL_BASE				0x35300000
#define OSU_IOCTL_SET_FILE			((OSU_IOCTL_BASE)+0)
#define OSU_IOCTL_UPDATE			((OSU_IOCTL_BASE)+1)
#define OSU_IOCTL_UPDATE_EBOOT		((OSU_IOCTL_BASE)+2)
#define OSU_IOCTL_UPDATE_LOGO		((OSU_IOCTL_BASE)+3)
#define OSU_IOCTL_READ_BOOTARGS		((OSU_IOCTL_BASE)+4)
#define OSU_IOCTL_WRITE_BOOTARGS	((OSU_IOCTL_BASE)+5)

TCHAR	strOsImage[MAX_PATH] = L"\\Hard Disk\\NK.nb0";
TCHAR	strOsEboot[MAX_PATH] = L"\\Hard Disk\\Eboot.nb0";
TCHAR	strOsLogo[MAX_PATH] = L"\\Hard Disk\\logo.bmp";
BOOT_CFG BootArgs;

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpCmdLine, int nCmShow)
{
	HANDLE		hDrvContext;
	DWORD		dwErr=1;
	DWORD		dwRet;
    
    UNREFERENCED_PARAMETER(hInst);
    UNREFERENCED_PARAMETER(hPrevInst);
    UNREFERENCED_PARAMETER(nCmShow);

	// Open OSU driver
	hDrvContext = 
        CreateFile(L"OSU0:", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);

	if (hDrvContext == INVALID_HANDLE_VALUE) {
		RETAILMSG(1, (TEXT("ERROR: Can't open OSU driver\r\n")));
		return -1;
	}	

	RETAILMSG(1, (TEXT("Reading boot config\r\n")));
	if (!DeviceIoControl(hDrvContext, OSU_IOCTL_READ_BOOTARGS, NULL, 0, &BootArgs, sizeof(BootArgs), &dwRet, NULL))
	{
		RETAILMSG(1, (L"ERROR: can't read Boot_CFG, err = %d\r\n", GetLastError()));
	}
	RETAILMSG(1, (L"Boot Args ver %d signature %x\r\n", BootArgs.version, BootArgs.signature));

	if (!DeviceIoControl(hDrvContext, OSU_IOCTL_WRITE_BOOTARGS, &BootArgs, sizeof(BootArgs), NULL, 0, &dwRet, NULL))
	{
		RETAILMSG(1, (L"ERROR: can't write Boot_CFG, err = %d\r\n", GetLastError()));
	}
	
        RetailPrint(TEXT("Updating Eboot from %s\n"), strOsEboot);
	DeviceIoControl(hDrvContext, OSU_IOCTL_SET_FILE, strOsEboot, _tcslen(strOsEboot)*sizeof(TCHAR), NULL, 0, NULL, NULL);	

	// start update process
	if (!DeviceIoControl(hDrvContext, OSU_IOCTL_UPDATE_EBOOT, NULL, 0, NULL, 0, NULL, NULL))
	{		
		LPVOID lpMsgBuf = NULL;
		DWORD dw = GetLastError(); 

		// REQUIRES SYSGEN_FMTMSG AND SYSGEN_FMTRES
		dwErr = FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | 
			FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL,
			dw,
			0,
			(LPTSTR) &lpMsgBuf,
			512, NULL );

		// Display the error message		
		RETAILMSG(1, (L"ERROR: can't update Logo, err = %d/%d, %s\r\n", dw, dwErr, lpMsgBuf));		
	}

	RetailPrint(TEXT("Updating Logo from %s\n"), strOsLogo);

	DeviceIoControl(hDrvContext, OSU_IOCTL_SET_FILE, strOsLogo, _tcslen(strOsLogo)*sizeof(TCHAR), NULL, 0, NULL, NULL);	

	// start update process
	if (!DeviceIoControl(hDrvContext, OSU_IOCTL_UPDATE_LOGO, NULL, 0, NULL, 0, NULL, NULL))
	{		
		LPVOID lpMsgBuf = NULL;
		DWORD dw = GetLastError(); 

		// REQUIRES SYSGEN_FMTMSG AND SYSGEN_FMTRES
		dwErr = FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | 
			FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL,
			dw,
			0,
			(LPTSTR) &lpMsgBuf,
			512, NULL );

		// Display the error message		
		RETAILMSG(1, (L"ERROR: can't update Logo, err = %d/%d, %s\r\n", dw, dwErr, lpMsgBuf));		
	}

	RetailPrint(TEXT("Updating NK image from %s\n"), strOsImage);
	// set file name holding new OS image
	DeviceIoControl(hDrvContext, OSU_IOCTL_SET_FILE, strOsImage, _tcslen(strOsImage)*sizeof(TCHAR), NULL, 0, NULL, NULL);
	// start update process
	if (!DeviceIoControl(hDrvContext, OSU_IOCTL_UPDATE, NULL, 0, NULL, 0, NULL, NULL))
	{		
		LPVOID lpMsgBuf = NULL;
		DWORD dw = GetLastError(); 

		// REQUIRES SYSGEN_FMTMSG AND SYSGEN_FMTRES
		dwErr = FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | 
			FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL,
			dw,
			0,
			(LPTSTR) &lpMsgBuf,
			512, NULL );

		// Display the error message		
		RETAILMSG(1, (L"ERROR: can't update OS, err = %d/%d, %s\r\n", dw, dwErr, lpMsgBuf));		
	}

    return 0;
}

///////////////////////////////////////////////////////////////////////////////
// Used to show message serial terminal AND console window
void RetailPrint(wchar_t *pszFormat, ...)
{
    va_list al;
    wchar_t szTemp[2048];
    wchar_t szTempFormat[2048];

    va_start(al, pszFormat);
    vwprintf(pszFormat, al);
    // Show message on RETAILMSG
    swprintf(szTempFormat, L"OSUPDATE: %s\r", pszFormat);
    pszFormat = szTempFormat;
    vswprintf(szTemp, pszFormat, al);
    RETAILMSG(1, (szTemp));

    va_end(al);
}
#pragma warning(pop)

R3 Silverlight Support

This chapter describes how to enable Windows Embedded CE 6.0 R3 Silverlight support

OpenGL Support

Silverlight uses OpenGL API, therefore uses the OMAP3530 / dm3730 on-chip OpenGL HW accelerator.

In order to use the OpenGL accelerator, the PowerVR SW component should be included in the workspace.

Follow the following steps:

  • Download PowerVR latest version from Variscite FTP site. The package should reside under /OMAP/WindowsCE/Release/x.y.z/PowerVR/ folder, where "x.y.z" should be substituted with the version of latest BSP.
  • Follow the installation instructions in the _Installation.txt file, residing in the mentioned above folder
  • Open working solution in Visual Studio 2005. For example VAR_OM35xx_REL.
  • Go to the Catalog view
  • Open Third Party folder
  • Check PowerVR and open it as folder
  • Check OpenGLES 2.0 form the 3D API folder

For more details reference to OpenGL on VAR-SOM-OM35 Windows CE topic.

Enable Silverlight Components

  • Go to the Solution Explorer
  • Right click on the solution name
  • Choose Properties
  • Go to the Configuration Properties > Environment
  • Set New environment variable SYSGEN_XAML_RuntimeCreates to be 1
  • Set New environment variable BSP_XRPLUGIN_OPENGL to be 1
  • Set New environment variable SYSGEN_SAMPLEXAMLPERF to be 1. This settings optional for including Silverlight examples

Building

Perform CLEAN SYSGEN build.

Suspend Service - Graceful shutdown

Below you can find information on the Suspend service, which enables a graceful shutdown of the FAT file-system, in case of a power failure.

Power failure and file-systems

During the device's life-time, power failure may occur. These failures threaten the reliability of the FAT file-system. The use of Windows CE's TFAT (Transaction-safe FAT) / ExFAT significally reduces the risk of a file-system corruption. However, no file system is 100% fail-safe. Power failure while file-system is actively writing, might rarely cause errors, even while using TFAT. Therefore, a graceful shutdown at power failure incident, when possible, is recommended. The suspend service requires 250ms to complete the File-system shutdown, while SOMs power consumption is 1.32Watt (400ma @3.3v)

Suspend service - Graceful shutdown. Usage guidelines

Suspend service is waiting for a falling-edge event of a specific GPIO, at a high-priority task. Once such event is triggered, the Suspend-service gracefully shuts-down the FAT file-system at the highest priority.

Suspend service is available from BSP version 1.3.6 and forth.

Usage Guidelines:

  • To enable the Suspend Service, please set:
set BSP_SSP=1

in VAR_OM35xx_P.bat

  • in FILES\platform.reg you may choose the appropriate GPIO which triggers the event:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\SSP]
   "Prefix"="SSP"
   "Dll"="sspdrv.dll"
   "Index"=dword:0
   "Order"=dword:40
   "GpioId"=dword:6D ;GPIO#109

OpenGL

Introduction

TI OMAP3530 application processor includes the "PowerVR SGX" Core that provides advanced hardware accelerated support for OpenGL ES and OpenVG graphics. This topic explains how to enable the 3D graphics capabilities under Windows CE.

PowerVR Installation

  • Download the latest PowerVR package from Variscite FTP. The file resides in the OMAP/WindowsCE/Release/x.y.z/PowerVR/ folder, where x.y.z should be replaced with the current version.
Note: The PowerVR version should be compatible with BSP version. Therefore customer is encouraged to upgrade to the latest BSP release. Otherwise, OpenGL and/or regular display capabilities may be corrupted!
  • Close Visual studio
  • Unzip downloaded file to the \WINCE600\PUBLIC to create in order two subdirectories - PowerVR and PowerVR-SDK.
  • Open OMAP solution in Platform Builder
  • Switch to the Catalog view
  • Check all the PowerVR components as it shown on the following picture:

Powervr.JPG

Note: Only one 3D API may be chosen for the application. Then, unnecessary components from 3D API may be removed in order to reduce OS image size.
  • Perform SYSGEN build of the solution

EBOOT

Overview

The VAR-SOM-OM37 implements the standard features set of Microsoft’s EBOOT.
The EBOOT is pre-burnt to the SBC in the factory, and is ready for customer use.
Variscite doesn’t expose its EBOOT source code, however, in order to enable customers to customize their boot phase, Variscite enables customers to implement the following functions in the Xloader / Eboot.

  • XLoader Configuration of the PAD MUX – Configures the CPU Balls’ alternate functions
  • Xloader Configuration and settings of GPIOs.
  • EBOOT LCD Splash screen support for customers’ specific LCD
  • Windows CE O.S. pre launch custom function.

EBOOT customization

XLDR

CustomPinMuxSetup()

This function configures specified pins of the DM37xx processor. The configuration of this function overloads the default configuration of Variscite.

Attention: incorrect settings of the OMAP pins may affect proper functionality of the VAR-SOM-OM-37

The function resides in

VAR_OMAP37xx_P\SRC\BOOT\XLDR\platfrom.c

Code Example:

VOID CustomPinMuxSetup()
{
    OMAP_SYSC_PADCONFS_REGS   *pConfig = OALPAtoUA(OMAP_SYSC_PADCONFS_REGS_PA);
    OMAP_SYSC_PADCONFS_WKUP_REGS *pWakeupConfig = OALPAtoUA(OMAP_SYSC_PADCONFS_WKUP_REGS_PA);

    /*SDRC*/
    OUTREG16(&pConfig->CONTROL_PADCONF_SDRC_D0, (INPUT_ENABLE | PULL_INACTIVE | MUX_MODE_4));
    OUTREG16(&pConfig->CONTROL_PADCONF_SDRC_D1, (INPUT_ENABLE | PULL_INACTIVE | MUX_MODE_4));
}
CustomGPIOConfigure()

This function configures specified pins of the OMAP35xx processor to function as General Purpose IOs. The configuration of this function overloads the default configuration of Variscite.

Attention: incorrect settings of the OMAP pins may affect proper functionality of the VAR-OM35xxSBC.

The function resides in

VAR_OMAP35xx_SBC_P\SRC\BOOT\XLDR\platfrom.c

Code Example:

VOID CustomGPIOConfigure()
{
    OMAP_GPIO_REGS* pGpio;

    // Initialize state/direction for Bank1[BIT0] configured as gpio
    pGpio = OALPAtoUA(OMAP_GPIO1_REGS_PA);
    OUTREG32(&pGpio->DATAOUT, (BIT0));
    OUTREG32(&pGpio->OE, INREG32(&pGpio->OE) & ~BIT0);
}

EBOOT

EBOOT files contain a number of functions for configuring the splash-screen for a specific LCD.
EBOOT also provides a pre-O.S. launch functions.

LCD defines

The following configurations are required in order to configure EBOOT to work with an alternate LCD.

  • LCD display size:
#define LOGO_WIDTH                  xxx
#define LOGO_HEIGHT                 yyy

Which resides in

VAR_OMAP35xx_SBC_P\SRC\BOOT\EBOOT\lcd_logo.h

Example:

#if BSP_AUO_G084SN05_800W_600H
#define LOGO_WIDTH                  800		// Logo bitmap image is RGB24 VGA Landscape bitmap
#define LOGO_HEIGHT                 600
#elif BSP_DATAIMAGE_WAG02_800W_480H
#define LOGO_WIDTH                  800		// Logo bitmap image is RGB24 VGA Landscape bitmap
#define LOGO_HEIGHT                 480
#else
#define LOGO_WIDTH                  1024	// Logo bitmap image is RGB24 VGA Landscape bitmap
#define LOGO_HEIGHT                 768
#endif

#define BYTES_PER_PIXEL             3
  • Define proper timing parameters of the LCD controller.

Example:

#elif BSP_AUO_G084SN05_800W_600H

    // 800x600 40Hz

    #define DEFAULT_PIXELTYPE   DISPC_PIXELFORMAT_RGB16
    // Note: Setting DEFAULT_PIXELTYPE to DISPC_PIXELFORMAT_RGB32 results in a 
	// dramatic drop in performance in the GDI BLTs, cause is not known.
    //#define DEFAULT_PIXELTYPE   DISPC_PIXELFORMAT_RGB32
    //#define DEFAULT_PIXELTYPE   DISPC_PIXELFORMAT_ARGB32

    #define LCD_WIDTH           800
    #define LCD_HEIGHT          600

    // Note: HWS, HFP and HBP, program desired value - 1
    #define LCD_HSW          	63          // should be 127, out of range for DISPC
    #define LCD_HFP          	39
    #define LCD_HBP          	87

    // Note: for VSW, program desired value - 1
    #define LCD_VSW          	3
    // Note: for VFP and VBP, program desired value
    #define LCD_VFP          	1
    #define LCD_VBP          	23

    // DSS1 = DPLL4/11 = 78.5Mhz, divide by 2 = 39.25MHz pixel clock
    // Note: DSS1 clock divider and pixel clock divider are set in src\inc\bsp_cfg.h
    #define LCD_LOGCLKDIV    	1
    // Minimum value for LCD_PIXCLKDIV is 2
    #define LCD_PIXCLKDIV    	BSP_LCD_PIXCLKDIV

    #define LCD_LOADMODE        0

    // positive H and V sync
    #define LCD_POLFREQ      	( DISPC_POL_FREQ_IVS | DISPC_POL_FREQ_IHS | /* DISPC_POL_FREQ_IPC |*/ DISPC_POL_FREQ_ONOFF)

    #define LCD_DEFAULT_COLOR   0x00000000
    #define LCD_TRANS_COLOR     0x00000000

    #define TV_DEFAULT_COLOR    0x00000000
    #define TV_TRANS_COLOR      0x00000000

#elif BSP_DATAIMAGE_WAG02_800W_480H

Which resides in

VAR_OMAP35xxSBC_P\SRC\DRIVERS\LCD\VGA\lcd_vga.c
PreLaunch

This function is called before launching the O.S.
The function resides in

VAR_OM37xx_P\SRC\BOOT\EBOOT\ prelaunch.c

Code Example:

void PreLaunch()
{
    OALLog(L"<>\r\n");
    OALLog(L"<> Windows CE Prelaunch code <>\r\n");
    OALLog(L"<>\r\n");
}
Startup Logo Functions

This function displays the pre-downloaded SplashScreen image until OS image is launched.
The function resides in

VAR_OM37xx_P\SRC\BOOT\EBOOT\ bsp_logo.c

Code Example:

DWORD   g_dwLogoPosX;
DWORD   g_dwLogoPosY;

DWORD   g_dwLogoWidth;
DWORD   g_dwLogoHeight;

#define BIT28   0x10000000

//------------------------------------------------------------------------------
//
//  Function:  ShowLogo
//
//  This function shows the logo splash screen
//
VOID ShowLogo(UINT32 flashAddr, UINT32 offset)
{
	/////////////////////////////////////
	// See the source file for details //
	/////////////////////////////////////
}

//------------------------------------------------------------------------------
//
//  Function:  HideLogo
//
//  This function hides the logo splash screen
//
VOID HideLogo(VOID)
{
	/////////////////////////////////////
	// See the source file for details //
	/////////////////////////////////////
}

XLDR and EBOOT images

The XLDR and EBOOT images are built and linked during regular BSP build. In addition, the build will prepare a ready to burn XLDR and EBOOT images. The image files

  • xldrnand.raw
  • ebootnand.raw

Both reside at:

VAR_OMAP35xxSBC_P\target\ARMV4I\retail\

EBOOT Burning

Installing and configuring the burning utility

In order to prepare the burning utility, customer should

  • Install EVMFlash v.1.2
  • Replace targets.xml file in the config\ folder under the root folder of EVM installation. (Typically should be C:\Program Files\Texas Instruments\EVMFlash3530_v1.2\config\)
  • Put supplied full_boot.ccf file in C:\Program Files\Texas Instruments\EVMFlash3530_v1.2\config\

Burning complete Bootloader image

The following steps are required for a complete EBOOT / XLDR burning:

  • Configure correct COM port and baud rate
  • Open full_boot.ccf file from menu File->Open
  • Choose Download option under VAR-OMAP35xxSBC target
  • Check “NAND” type of device
  • Check “Verify Download” check box
  • Set download settings as it shown on the following picture

Evmflash.JPG

  • Click “Download” button for start download
  • Press and hold “Boot Select” button on the carrier board
  • Press and release “Reset” button on the carrier board
  • Release “Boot Select” button on the carrier board