INTRODUZIONE A
MICRO FRAMEWORK
Smart Personal Objects Technology (SPOT)
Dario Airoldi
Developer & Platform Evangelism Italy
[email protected]
http://blogs.msdn.com/darioa
http://blogs.msdn.com/darioait
TEAM DEVELOPER & PLATFORM
Mission
Favorire
la conoscenza e la diffusione delle tecnologie innovative,
creare casi di utilizzo che rendano evidente il valore della piattaforma
Microsoft.

Iniziative e attività:




La redazione dei contenuti sul sito MSDN Italy.
Newsletter e Webcast registrati
Seminari e conferenze
Incontri presso le aziende
http://www.microsoft.com/italy/msdn/contattaci/default.mspx
LA VISION DI MICRO FRAMEWORK

Piccoli dispositivi elettronici controllati da
microprocessori sono sempre più diffusi ma:
 Pochi
tool ne supportano lo sviluppo
 Richiedono forti skill per fare cose semplici
 Sono realizzati con codice unmanaged

Microframework si propone per il mondo
embedded come VB6 per lo sviluppo delle
vecchie applicazioni desktop.
POSIZIONAMENTO DI MICRO FRAMEWORK
MF è un .Net Runtime piccolo per processori
embedded 32bit, economici e a basso consuno






Ha Memory footprint ridotto (~256K RAM)
Non richiede Memory Management Unit
Permette lo sviluppo embedded con Visual Studio 2005
L’ambiente Include un emulatore completo e funzionale
Permette lo sviluppo con linguaggio C# e .Net framework
Esegue codice managed controllato e sicuro
LE PIATTAFORME EMBEDDED DI MICROSOFT
.NET Micro Framework
Windows CE
Windows XP Embedded
Pocket PC Phone
Wearable Devices
Auxiliary Displays
Windows Mobile Smartphone
Windows
Automotive
Retail Point-of-Sale
Windows-based
Terminals
Health Monitoring
Portable Media Center
VoIP phones
Remote Controls
Medical devices
Set-top boxes
Sensor Networks
Mobile handhelds
Gateways
Entertainment devices
LE PIATTAFORME EMBEDDED A CONFRONTO
.NET Micro Framework
Windows CE
Windows XPe
Example Devices
Sensor Nodes, Aux displays,
Health Monitoring, Remote
Controls, Robotics
GPS Handhelds, PDAs,
Automotive, Set Top Boxes
Thin Clients, ATMs, Kiosks
Features
Connected, Small, Wearable,
Graphical UI
Connected, Graphical UI,
Server, Browser, RAS, DirectX
PCclass performance,
PC networking
Footprint
250-500KB managed code
Full featured
300KB+ without managed
code
12MB with managed code
40MB + Depending on
features
Power
Very low power
Low power
Mains power
CPU
ARM7, ARM9, No MMU
X86, MIPS, SH4, ARM,
with MMU
X86
Real-time
Not Real-time
Hard Real-time
Real-time capable through 3rd
party extensions
Managed vs. Native
Code
Managed via .NET Micro
Framework,
native code through interop
only.
Supports both,
Supports both, managed code
managed code requires .NET
requires .NET Framework
Compact Framework
UN PO’ DI STORIA
CARATTERISTICHE DI MICRO FRAMEWORK
Microframework è:
 Bootable



Safe


Utilizza assemblies firmati
Extensible


L’accesso alle risorse avviene tramite oggetti
Secure


Può eseguire boot autonomamente
Può essere ospitato su sistemi operativi esistenti
A livello software ed Hardware
Portable

Il Porting Kit permette di portarlo su HW non supportato
RUNTIME FEATURES

Runtime grafico Windows Presentation Foundation (WPF):





Runtime engine:




Graphics primitives
BMP and JPG image support
Text manipulation
Unified Programming model covering All devices
Thread support
Garbage collection
Globalized language support
Funzioni di interazione con l’hardware





Managed drivers for LCDs
Universal Asynchronous Receiver/Transmitter (USART)
I2C™
General-purpose I/O (GPIO)
Pulse-Width modulation (PWM)
TOOL DI SVILUPPO

Microsoft Visual Studio 2005





Device Emulator
Personalizzabile per simulare la
configurazione delle periferiche


Project System/templates
PostBuild processing
Intellisense support
Deployment to device (seriale, usb o emulatore)
Debugging interattivo dall’IDE (Breakpoints, tracing,
variable inspection)
SCHEMA ARCHITETTURALE
PIATTAFORME SUPPORTATE

Come bootable runtime supporta:







ARM7TDMI @ 27MHz (384K RAM, 1M Flash)
ARM7TDMI @ 50MHz (4M RAM, 2M Flash)
ARM920T @ 96MHz (4M RAM, 2M Flash)
ARM Cortex M3
Motorola 68K (implementazioni custom)
…
Come hosted runtime supporta:

Dual ARM7TDMI @100Mhz (32M RAM, 1G Flash)


Intel x86



NetOS/ThreadX per CONNECTME , WinCE
Windows XP
…
Il Porting a nuovi devices:


Porting to new HW richiede 80-100 APIs
Porting to new Platform richiede 20-40 APIs
ATTENDING PARTNERS
Web Site: “www.aboutnetmf.com”
Slide 13
DEMO: TRIPCOMPUTER SAMPLE
Create a new application and the graphical components
FRAMEWORK .NET
System.web
Services
•Description
•Discovery
•protocol
System.Windows.Forms
UI
•HTML Controls
•Web Controls
Design
Component Model
System.Drawing
Cache
Security
Drawing 2D
Printing
Configuration
Session State
Imaging
Text
System.Data
System.Xml
ADO.Net
SQL Client
XML Document
Serialization
Design
SQL Server CE
XslT/XPath
Reader/Writers
Collections
IO
Configuration
Security
Net
Service process
Text
Reflection
Diagnostics
Runtime
•Interop Services
•Remoting
•Serialization
Globalization
Resources
Threading
System
COMPACT FRAMEWORK
System.web
Services
•Description
•Discovery
•protocol
System.Windows.Forms
UI
•HTML Controls
•Web Controls
Design
Component Model
System.Drawing
Cache
Security
Drawing 2D
Printing
Configuration
Session State
Imaging
Text
System.Data
System.Xml
ADO.Net
SQL Client
XML Document
Serialization
Design
SQL Server CE
XslT/XPath
Reader/Writers
Collections
IO
Configuration
Security
Net
Service process
Text
Reflection
Diagnostics
Runtime
•Interop Services
•Remoting
•Serialization
Globalization
Resources
Threading
System
MICRO FRAMEWORK
System.web
Services
•Description
•Discovery
•protocol
System.Windows.Forms
UI
•HTML Controls
•Web Controls
Design
Component Model
System.Drawing
Cache
Security
Drawing 2D
Printing
Configuration
Session State
Imaging
Text
System.Data
System.Xml
ADO.Net
SQL Client
XML Document
Serialization
Design
SQL Server CE
XslT/XPath
Reader/Writers
Collections
IO
Configuration
Security
Net
Service process
Text
Reflection
Diagnostics
Runtime
•Interop Services
•Remoting
•Serialization
Globalization
Resources
Threading
System
MICRO FRAMEWORK È UNA IMPLEMENTAZIONE .NET!
Implementa un sottoinsieme delle core libraries
 Permette diversi linguaggi di programmazione

 Rispetta
Common Language Specification (CLS)
 Derivato da Common Language Infrastructure (CLI)
v1.0

Supporta Common Intermediate Language (CIL)
Execution.
NOTE SULLA IMPLEMENTAZIONE DEL RUNTIME

Serialization:



Remote Procedure Call (RPC)



Implementazione specifica per mf
60% più efficiente in spazio rispetto a .Net Framework
Implementazione specifica per mf
Permette di invocare metodi su oggetti remoti
Encryption:



Supporta RSA algorithm (Asymmetrico) tramite la classe Key_RSA.
supporta Extedned Tiny Encryption Algorithm (XTEA, symmetric) tramite la
classe Key_TinyEncryptionAlgorithm.
Permette algoritmi custom derivando dalla classe Key.

Delegates: permette programmazione ad eventi invece che per polling.

Exception handling
Reflection

RUNTIME FEATURES – DETTAGLIO
Funzioni disponibili includono:
•Numeric types, class types, value types,
arrays (one-dimensional only), delegates,
events, references, and weak references
•Synchronization, threads, and timers
•Reflection
•Serialization
•Garbage collection
•Exception handling
•Time classes, including DateTime and
TimeSpan (using INT64 arithmetic)
•Time-sliced thread management
Funzioni progettate per microframework:
•Execution constraints that limit call
durations and prevent failures.
•Strings represented internally as UTF-8
and exposed as Unicode.
•A global, shared string table for wellknown values (types, methods, and fields)
that reduces RAM and ROM and reduces
the number of cross-references among
assemblies.
•method resolution no virtual tables.
•A WeakDelegate class to handle dangling
references to delegates.
•Support for extending the hardware
chipset by programming its drivers
directly in C#, using the Managed Drivers
Framework. Hardware devices compatible
with industry communication standards —
such as GPIO, serial, SPI, or I2C — can be
added to the chipset and used by a
managed C# application.
DEMO THE TRIPCOMPUTER SAMPLE
Add the clock and other trip control features to the TripComputer
RUNTIME GRAFICO

Object model Basato su Windows
Presentation foundation (WPF)
 Supporta
routed events e context
properties
 Supporta layout system (content
sizing, text flow, nested controls)
 Supporta bitmap fonts
 Gestisce Images
 Gestisce Pens, brushes, colors
 Gestisce Vector primitives
 Gestisce Alpha blending
HARDWARE ABSTRACTION LAYER
Permette il boot del runtime
 Permette una astrazione delle risorse
 Gestisce gli interrupts
 Supporta asynchronous cooperative multi-tasking.
 È realizzato tramite queued Workitems
 È compatto (Occupa 40K inclusi i base drivers)

LOADER ED INTERPRETER

Assembly loader



esegue validazione al caricamento degli assemblies.
registra i tipi con il type system (in tabella globale dei tipi)
Microsoft Intermediate Language (MSIL) interpreter



Supporta TUTTE le msil instructions (tranne le istruzioni
unsafe)
È ottimizzato per minimizzare la latenza
Permette esecuzione “virtuale pura”
EXECUTION ENGINE AND GARBAGE COLLECTOR

Execution engine:





No native thread scheduler
Manages native work queues
Invokes native code
Permette non traditional interoperability
Garbage collector




Non incremental Mark and Sweep.
Colleziona 50ms per 1M, variabile a seconda del numero di oggetti
Supporto per storage non volatile.
dispone di un meccanismo di persistenza di oggetti
MICRO FRAMEWORK FOOTPRINT

ROM/Flash footprint
 Runtime:
~120K
 Runtime + framework minimale: ~250K
 Runtime + framework completo: ~500K

RAM requirements
 ~70K
system overhead
 ~256K per full-featured application
DEVICE ESTERNI

Permette di gestire da codice managed (Managed
drivers):
General-purpose I/O (GPIO) pins
 Serial peripheral interface (SPI) bus
 Serial ports
 Universal Asynchronous Receiver/Transmitter (USART)
 I2C™
 Pulse-Width modulation (PWM)


GPIO Interrupts sono dispatched alla applicazione
managed in forma di eventi.
QUALI DEVICE SI POSSONO GESTIRE?
External device
Protocol to communicate
API to control
Bottoni
GPIO
Microsft.SPOT.Hardware.InterruptPort (o Port family e
classi drivate in generale)
Potenziometri/Attuatori
GPIO
Microsft.SPOT.Hardware.InterruptPort (o Port family e
classi drivate in generale)
Accelerometri
Outputs booleani
(backlight, vibrator)
Monochrome LCD
OEM-specific (heart rate monitor,
air pressure sensor, touch screen)
Battery monitoring
(PWM non e’ disponibile al momento)
SPI o I2C
(tipicamente)
GPIO
SPI o I2C o driver nativo
(tipicamente)
SPI o I2C o Seriale
(Tipicamente, Dipende dal device)
Battery API
802.15.4
EEPROM memory
Calibrated accurate time
Microsoft.SPOT.hardware.Backlight o
Microsoft.SPT.Hardware.OutputPort
Microsft.SPOT.Hardware.SPI e
Microsft.SPOT.Hardware.I2Cdevice. LCD (display) API
(LCD_BitBlt e LCD_BitBltEx)
Microsft.SPOT.Hardware.SPI,
Microsft.SPOT.Hardware.I2Cdevice e
Microsft.SPOT.Hardware.SerialPort
Microsft.SPOT.Hardware.Battery e Battery and
Charger HAL API
Microsoft.SPOT.ExtendedWeakReferences
Microsoft.SPOT.Logging (solo per debug)
HAL FLASH API
Flash memory
Bluetooth
Microsft.SPOT.Hardware.SPI e
Microsft.SPOT.Hardware.I2CDevice
Seriale o SPI
(dipende dal controllore, vedi Promi-SD o BlueCore)
SPI
(Tipicamente, vedi Ember or Chipcon CC2420)
Unsupported Legacy
Dell’apposito codice e’ provvisto nel porting kit ma deve
essere abilitato manualmente
Microsoft.SPOT.hardware.SerialPort o
Microsoft.SPOT.Hardware.SPI
Microsoft.SPOT.Hardware.SPI
n/a
CODICE DI UN MANAGED DRIVER
using System.Threading;
using Microsoft.SPOT.Hardware;
…
InterruptPort myButton = new InterruptPort(
(Cpu.Pin)12,
true,
Port.ResistorMode.PullUp,
Port.InterruptMode.InterruptEdgeLow
);
MyButton.OnInterrupt +=
new GPIOInterruptEventHandler( this.MyInterruptHandler );
…
}
public void MyInterruptHandler(Cpu.Pin id, bool edge, TimeSpan time) {
// handle the interrupt event here
}
EMULATORE



L’emulatore è una windows
application che esegue codice
micro framework
Una collezione di classi che
permette di comporre
epersonalizzare l’emulatore
Un file di configurazione (XML)
che permette di configurare ed
inizializzare tutti i componenti
ARCHITETTURA DELL’EMULATORE



Windows application che esegue codice Micro
Framework
Una collezione di classi permette di comporre e
personalizzare i componenti da emulare
Un file di configurazione (XML) permette di
configurare ed inizializzare tutti i componenti
DEMO THE TRIPCOMPUTER SAMPLE
Customize the emulator to simulate buttons and IO on the TripComputer
MAGGIORI INFORMAZIONI




Sito microframework:
http://msdn.microsoft.com/embedded/netmf.
Sito embedded development:
http://msdn2.microsoft.com/embedded.
Sito per download
http://www.microsoft.com/downloads.
Webcasts
•
•
http://Www.microsoft.com/Webcasts
http://www.microsoft.com/italy/eventi/webcast/
Scarica

1. Introduzione a microframework rel