Design Examples and Case Studies of Program Modeling

  • Slides: 57
Download presentation
Design Examples and Case Studies of Program Modeling and Programming with RTOS-2: Lesson-3 CASE

Design Examples and Case Studies of Program Modeling and Programming with RTOS-2: Lesson-3 CASE STUDY OF AN EMBEDDED SYSTEM FOR SMART CARD 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 1

1. Smart Card System Requirements 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming

1. Smart Card System Requirements 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 2

Purpose Enabling authentication and verification of card and card holder by a host •

Purpose Enabling authentication and verification of card and card holder by a host • Enabling GUI at host machine to interact with the card holder/user for the required transactions, for example, financial transactions with a bank or credit card transactions. • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 3

Inputs • Received header and messages at IO port Port_IO from host through the

Inputs • Received header and messages at IO port Port_IO from host through the antenna 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 4

Internal Signals, Events and Notifications • • • On power up, radiation-powered chargepump supply

Internal Signals, Events and Notifications • • • On power up, radiation-powered chargepump supply of the card activated and a signal to start the system boot program at reset. Task Card start request. Header message to task_Read. Port from reset. Task Host authentication request. Start message to task_Read. Port from reset. Task to enable requests for Port_IO 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 5

Internal Signals, Events and Notifications • User. PW verification message (notification) through Port_IO from

Internal Signals, Events and Notifications • User. PW verification message (notification) through Port_IO from host • Card application close request. Appl. Close message to Port_IO 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 6

Outputs Transmitted headers and messages at Port_IO through antenna • 2008 Chapter-12 L 03:

Outputs Transmitted headers and messages at Port_IO through antenna • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 7

Control panel • No control panel is at the card. The control panel and

Control panel • No control panel is at the card. The control panel and GUIs activate at the host machine (for example, at ATM or credit card reader) 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 8

Functions of the system • • • The card inserts at a host machine.

Functions of the system • • • The card inserts at a host machine. The radiations from the host activate a charge pump at the card. The charge pump powers the So. C circuit consisting of card processor, memory, timer, interrupt handler and IO port, Port_IO. On power up, system reset signals reset. Task to start. The reset. Task sends the messages request. Header and request. Start for waiting task_Read. Port. Chapter-12 L 03: "Embedded Systems - Architecture, 2008 Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 9

Functions of the system… task_Read. Port sends requests for host identification and reads through

Functions of the system… task_Read. Port sends requests for host identification and reads through the Port_IO the hostidentification message and request for card identification. • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 10

Functions of the system… task_PW sends through Port_IO the requested card identification after system

Functions of the system… task_PW sends through Port_IO the requested card identification after system receives the host identity through Port_IO. • task_Appl then runs required API. The request. Appl. Close message closes the application. • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 11

Functions of the system… The card can now be withdrawn • All transactions between

Functions of the system… The card can now be withdrawn • All transactions between cardholder/user now takes place through GUIs using at the host control panel (screen or touch screen or LCD display panel). • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 12

Design metrics Power Source and Dissipation: Radiation powered contact less • Code size: optimum.

Design metrics Power Source and Dissipation: Radiation powered contact less • Code size: optimum. card system memory needs should not exceed 64 k. B memory. • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 13

Design metrics • Limited use of data types; multidimensional arrays, long 64 bit integer

Design metrics • Limited use of data types; multidimensional arrays, long 64 bit integer and floating points and very limited use of the error handlers, exceptions, signals, serialization, debugging and profiling. • File system(s): Three-layered file system for data. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 14

Design metrics… • File management: There is either a fixed length file management or

Design metrics… • File management: There is either a fixed length file management or a variable file length management with each file with a predefined offset. • Microcontroller hardware: Generates distinct coded physical addresses for the program and data logical addresses. Protected once writable memory space 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 15

Design metrics… • Validity: System is embedded with expiry date, after which the card

Design metrics… • Validity: System is embedded with expiry date, after which the card authorization through the hosts disables. • Extendibility: The system expiry date is extendable by transactions and authorization of master control unit (for example, bank servee). 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 16

Design metrics… • Performance: Less than 1 s for transferring control from the card

Design metrics… • Performance: Less than 1 s for transferring control from the card to host machine. • Process Deadlines: None. • User Interfaces: At host machine, graphic at LCD or touch screen display on LCD and commands for card holder (card user) transactions. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 17

Design metrics… Engineering Cost: US$ 50000 (assumed) • Manufacturing Cost: US$ 1 (assumed) •

Design metrics… Engineering Cost: US$ 50000 (assumed) • Manufacturing Cost: US$ 1 (assumed) • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 18

Test and validation conditions Tested on different host machine versions for fail proof card-host

Test and validation conditions Tested on different host machine versions for fail proof card-host communication • 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 19

2. Classes and class diagram 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming

2. Classes and class diagram 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 20

Class diagram

Class diagram

Classes • • • Task_Card. Communication is an abstract class from which extended to

Classes • • • Task_Card. Communication is an abstract class from which extended to class (es) derive to read port and authenticate. The tasks (objects) are the instances of the classes Task_Appl, Task_Reset, Task_Read. Port and Task_PW. ISR 1_Port_IO, ISR 2_Port_IO and ISR 3_Port_IO are interfaces to the tasks 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 22

Other Classes • Classes for the network, sockets, connections, datagrams, character-input output and streams,

Other Classes • Classes for the network, sockets, connections, datagrams, character-input output and streams, security management, digital-certification, symmetric and asymmetric keys-based cryptography and digital signatures 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 23

3. Hardware Architecture 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design"

3. Hardware Architecture 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 24

Smart card hardware

Smart card hardware

Smart Card Hardware • A plastic card in ISO standard dimensions, 85. 60 mm

Smart Card Hardware • A plastic card in ISO standard dimensions, 85. 60 mm x 53. 98 x 0. 80 mm. It is an embedded So. C (System-On- Chip). [ISO standards - ISO 7816 (1 to 4) for host-machine contact based card and ISO 14443 (Part A or B) for the contact- less cards. ] 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 26

Smart Card Hardware … • Microcontroller MC 68 HC 11 D 0 or PIC

Smart Card Hardware … • Microcontroller MC 68 HC 11 D 0 or PIC 16 C 84 or a smart card processor Philips Smart XA or an ASIP Processor. Needs 8 k. B+ internal RAM and 32 k. B EPROM and 2/3 wire protected memory. • CPU special features, for example, a security lock 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 27

Smart Card Hardware … • CPU locks certain section of memory protect 1 k.

Smart Card Hardware … • CPU locks certain section of memory protect 1 k. B or more data from modification and access by any external source or instruction outside that memory • Other way of protecting - CPU access through the physical addresses, which are different from logical address used in the program. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 28

Smart Card Hardware … • Standard ROM 8 k. B for usual or 64

Smart Card Hardware … • Standard ROM 8 k. B for usual or 64 k. B when using advanced cryptographic features • Full or part of ROM bus activates take place after a security check only. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 29

Smart Card Hardware … ROM Contains: i. Fabrication key and Personalisation key (after insertion

Smart Card Hardware … ROM Contains: i. Fabrication key and Personalisation key (after insertion of this key, RTOS and application use only the logical addresses) ii. RTOS codes iii. Application codes iv. Utilisation lock 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 30

Smart Card Hardware … • EEPROM or Flash scalable – only needed part unlocks

Smart Card Hardware … • EEPROM or Flash scalable – only needed part unlocks when storing P. I. N. , unlocking P. I. N. , access condition, card-user data, post activation application run generated non-volatile data, invalidation lock to invalidate card after the expiry date or server instruction 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 31

Smart Card Hardware … • RAM – run time temporary variables • Chip-supply system

Smart Card Hardware … • RAM – run time temporary variables • Chip-supply system using charge pump • I/O system 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 32

4. Software Architecture 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design"

4. Software Architecture 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 33

Smart Card Software • Needs cryptographic software, needs special features in its operating system

Smart Card Software • Needs cryptographic software, needs special features in its operating system over and above the MS DOS or UNIX system features. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 34

Smart Card Software … • Protected environment -OS stored in the protected part of

Smart Card Software … • Protected environment -OS stored in the protected part of ROM. • A restricted run-time environment. • OS, every method, class and run time library should be scalable. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 35

Smart Card Software … • Optimum Code-size • Limited use of data types; multidimensional

Smart Card Software … • Optimum Code-size • Limited use of data types; multidimensional arrays, long 64 -bit integer and floating points and very limited use of the error handlers, exceptions, signals, serialisation, debugging and profiling 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 36

Smart Card Software … • Three-layered file system for the data • master file

Smart Card Software … • Three-layered file system for the data • master file to store all file headers (file status, access conditions and the file lock) 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 37

Smart Card Software … • A header means file status, access conditions and the

Smart Card Software … • A header means file status, access conditions and the file lock. • Dedicated file─ second file to hold a file grouping and headers of the immediate successor • Elementary file ─ third file to hold the file header and its file data. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 38

Smart Card Software … • Either a fixed length file management or a variable

Smart Card Software … • Either a fixed length file management or a variable file length management with each file with a predefined offset. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 39

Smart Card Software in Java • Java Card. TM, Embedded. Java or J 2

Smart Card Software in Java • Java Card. TM, Embedded. Java or J 2 ME (Java 2 Micro Edition) JVM has thread scheduler built in. • Java provides the features to support (i) security using class java. lang. Security. Manager), (ii) cryptographic needs (package java. security*). 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 40

5. Smart. OS RTOS used as alternative to MUCOS 2008 Chapter-12 L 03: "Embedded

5. Smart. OS RTOS used as alternative to MUCOS 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 41

Smart Card OS 2008 • Smart. OS─ assumed hypothetical OS in this example, as

Smart Card OS 2008 • Smart. OS─ assumed hypothetical OS in this example, as RTOS in the card. • Use for understanding purposes identical to MUCOS but actual Smart. OS has to be different from MUCOS. • Its file structure is different, though it has MUCOS like IPCs and ECBs. Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 42

Smart. OS. . • function unsigned char [ ] Smart. OSEncrypt (unsigned char *appl.

Smart. OS. . • function unsigned char [ ] Smart. OSEncrypt (unsigned char *appl. Str, En. Type type) encrypts as per encryption method, En. Type = "RSA" or "DES" algorithm chosen and returns the encrypted string 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 43

Smart. OS … • function unsigned char [ ] Smart. OSDecrypt (unsigned char *Str,

Smart. OS … • function unsigned char [ ] Smart. OSDecrypt (unsigned char *Str, De. Type type) encrypts as per deciphering method, De. Type = "RSA" or "DES" algorithm chosen and returns the deciphered string. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 44

Smart. OS … • Smart. OSEncrypt and Smart. OSDecrypt execute after verifying the access

Smart. OS … • Smart. OSEncrypt and Smart. OSDecrypt execute after verifying the access conditions from the data files that store the keys, PIN (Personal Identification Number) and password. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 45

6. Tasks and their priority, action and IPCs 2008 Chapter-12 L 03: "Embedded Systems

6. Tasks and their priority, action and IPCs 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 46

reset. Task • • • Priority ─ 1 Action─ Initiates system timer ticks, creates

reset. Task • • • Priority ─ 1 Action─ Initiates system timer ticks, creates tasks, sends initial messages and suspends itself. IPC pending: IPC posted: Sig. Reset, Msg. QStart String Output: request-Header; request. Start 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 47

task_Read. Port • • • Priority ─ 2 Action─ Wait for reset. Task suspension,

task_Read. Port • • • Priority ─ 2 Action─ Wait for reset. Task suspension, sends the queue messages and receives the messages. Starts the application and seeks closure permission for closing the application IPC pending: Sig. Reset, Msg. QStart, Msg. QPW, Msg. QAppl-Close IPC posted: Sem. PW Output: request-password, request-Appl, request. Appl. Close 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 48

task_PW • • • Priority ─ 3 Action─ Sends request for password on verification

task_PW • • • Priority ─ 3 Action─ Sends request for password on verification of host when Sem. PW = 1 IPC pending: Sem. PW IPC posted: Msg. QPW Input: request-Password 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 49

task_Appl • • Priority ─ 8 Action─ when Sem. PW = 1, runs the

task_Appl • • Priority ─ 8 Action─ when Sem. PW = 1, runs the application program IPC pending: Sem. Appl IPC posted: Msg. QAppl 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 50

7. Multiple tasks and their synchronization model 2008 Chapter-12 L 03: "Embedded Systems -

7. Multiple tasks and their synchronization model 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 51

tasks and their synchronization model

tasks and their synchronization model

8. Coding using Smart. OS 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming

8. Coding using Smart. OS 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 53

Coding using Vx. Works Adapted to OSEK-OS Features • Refer Example 12. 4 in

Coding using Vx. Works Adapted to OSEK-OS Features • Refer Example 12. 4 in Section 12. 4. 5 Note: At each step, explanation for the set of statements given there. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 54

Summary 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj

Summary 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 55

We learnt • Smart Card hardware and software • Code design given using the

We learnt • Smart Card hardware and software • Code design given using the a hypothetical RTOS, Smart. OS, which has MUCOS features plus the embedded system required cryptographic features and file security, access conditions and restricted access permissions during code run. 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 56

End of Lesson-3 of chapter 12 on CASE STUDY OF AN EMBEDDED SYSTEM FOR

End of Lesson-3 of chapter 12 on CASE STUDY OF AN EMBEDDED SYSTEM FOR SMART CARD 2008 Chapter-12 L 03: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs. : Mc. Graw-Hill, Inc. 57