Presented by: © 2015 Jacob Beningo All Rights Reserved Writing Portable and Robust Firmware in C September 4, 2015 Jacob Beningo, CSDP Class 5: Robust.

Slides:



Advertisements
Similar presentations
State Machines An approach to assembler coding. Intro State Machines are an integral part of software programming. State machines make code more efficient,
Advertisements

1/1/ / faculty of Electrical Engineering eindhoven university of technology Speeding it up Part 3: Out-Of-Order and SuperScalar execution dr.ir. A.C. Verschueren.
OBP Research Oy for simpler creation of embedded systems.
19.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 19: Security The Security Problem Authentication Program Threats.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
2008EECS Embedded Network Programming nesC, TinyOS, Networking, Microcontrollers Jonathan Hui University of California, Berkeley.
Figure 1.1 Interaction between applications and the operating system.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Hardware Interface Design Patterns Ahmet Selman Bozkır – Hacettepe Univ.
June 5, 2013 XenClient Enterprise 5.0 Engine VNC Remote Access.
Evolution of Microcontroller Firmware Development David Benjamin.
CE-2800: Embedded Systems Software I Watchdog Timers 1 The Watchdog timer.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
USART interrupt.
Instructore: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Concurrent and.
Dan Parish Program Manager Microsoft Session Code: OFC 304.
Hands-On Microsoft Windows Server 2003 Administration Chapter 2 Managing Windows Server 2003 Hardware and Software.
15-740/ Oct. 17, 2012 Stefan Muller.  Problem: Software is buggy!  More specific problem: Want to make sure software doesn’t have bad property.
M Semiconductor Products Sector Computer Operating Properly Module Detail Slide #1 of 7 Tutorial Introduction PURPOSE -To explain how to configure and.
Computer Security and Penetration Testing
1 Run-Time Methods for Making Embedded Systems Robust.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Virtual EEPROM and Flash API for.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Implementing Bootloaders on Renesas MCUs.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
ATLAS DCS ATLAS DCS ELMB PRR, 4 Mar 2002, H.Boterenbrood 1 Software for the ELMB Henk Boterenbrood ATLAS DCS.
25 April 2000 SEESCOASEESCOA STWW - Programma Evaluation of on-chip debugging techniques Deliverable D5.1 Michiel Ronsse.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
Data Link and Flow Control Networks and Protocols Prepared by: TGK First Prepared on: Last Modified on: Quality checked by: Copyright 2009 Asia Pacific.
6.5 Implementing a State Machine Language. State Machine in game AI The most used software pattern Simple to program Easy to comprehend Easy to debug.
Conclusion Speech. Content Organization Pronunciation Handwriting.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the serial communication.
System Integration Module MTT Motoola SYSTEM INTEGRATION MODULE (SIM)
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course explains how to use section setting and memory.
High Assurance Products in IT Security Rayford B. Vaughn, Mississippi State University Presented by: Nithin Premachandran.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course describes Coverage, a utility that is used.
Presented by: © 2015 Jacob Beningo All Rights Reserved Writing Portable and Robust Firmware in C September 2, 2015 Jacob Beningo, CSDP Class 3: Uart Driver.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
Computer Operating Properly Module MTT COMPUTER OPERATING PROPERLY MODULE (COP)
Tiva C TM4C123GH6PM UART Embedded Systems ECE 4437 Fall 2015 Team 2:
WAVECOM©2005. All rights reserved 1 PROTECTIONS Embedded Software Architecture AT commands Parser Customer Application written in Standard ANSI C Wavecom.
Basic Concepts Microinstructions The control unit seems a reasonably simple device. Nevertheless, to implement a control unit as an interconnection of.
Bootloaders Many embedded processors have flash memory. This allows us to alter a product even though it is in the users hands: -fix bugs -upgrade or enhance.
Embedded System Design Techniques™:
Homework Reading Machine Projects Labs
Bootloaders Many embedded processors have flash memory. This allows us to alter a product even though it is in the users hands: -fix bugs -upgrade or.
Microprocessor and Microcontroller Fundamentals
Embedded Software Development with Python and the Raspberry Pi
Data Watch Presenter Information Jason Puncher and François Tétreault
Embedded Software Development with Python and the Raspberry Pi
RX Watchdog Timer (WDT)
An Introduction to Embedded Software Architecture and Design
Baremetal C Programming for Embedded Systems
Embedded Software Development with Python and the Raspberry Pi
An Introduction to Embedded Software Architecture and Design
Writing Portable and Robust Firmware in C
Writing Portable and Robust Firmware in C
February 26, 2015 Jacob Beningo, CSDP
Baremetal C Programming for Embedded Systems
NetSilicon & Digi Confidential
Baremetal C Programming for Embedded Systems
An Introduction to Embedded Software Architecture and Design
An Introduction to Embedded Software Architecture and Design
4/28/2019 6:13 PM HW-889P Advanced driver code analysis techniques Tips and tricks to develop more secure & reliable drivers Dave Sielaff Principal Software.
An Introduction to Embedded Software Architecture and Design
Embedded System Design Techniques™:
February 24, 2015 Jacob Beningo, CSDP
Operating System Concepts
MCU – Microcontroller Unit – 2
Presentation transcript:

Presented by: © 2015 Jacob Beningo All Rights Reserved Writing Portable and Robust Firmware in C September 4, 2015 Jacob Beningo, CSDP Class 5: Robust Firmware Concepts Embedded System Design Techniques™

Presented by: © 2015 Jacob Beningo All Rights Reserved Course Overview Portable C Concepts Doxygen and PC-Lint Uart Driver and Stm32CubeMx Assertions and printf Robust Firmware Concepts 2

Presented by: © 2015 Jacob Beningo All Rights Reserved Session Overview Watchdog Timers Watchdog API Watchdogs use Stack Monitor Cyclomatic Complexity Robust application features 3

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Overview Watchdog and subsystem being monitored should have separate clocks Watchdog refresh should be done such that the changes of run-a-way code refreshing the watchdog are minimized Run-away code should be detected quickly to prevent system damage Critical control and configuration registers should have write protection so that once set they cannot be changed Should be able to detect what has caused the time-out Task flagging for proper operation 4 Characteristics of a Good Watchdog

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Types Internal – Timer Based External – Heartbeat – Smart – Dumb 5 MCU COMMS eWatchdog HB COMMS RST "A Review of Watchdog Architectures"

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog API 6

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Firmware 7

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Firmware 8

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Firmware 9

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Firmware 10

Presented by: © 2015 Jacob Beningo All Rights Reserved Watchdog Firmware 11

Presented by: © 2015 Jacob Beningo All Rights Reserved Stack Monitor Design What is on the stack? Creating a stack monitor / guard manually – Write known pattern into the Guard area – Monitor the Guard area for changes Alternatively use the MPU 12 Calculating stack size can be difficult! GUARD_SIZE = DEFINED(__guard_size__) ? __guard_size__ : 0x ;.guard: {. = ALIGN(8); FILL(0xC0DE);. += GUARD_SIZE - 1; BYTE(0xE) } > m_data void main(void) { uint32_t * GuardPtr = (uint32_t *) GUARD_START; for(Index = 0; Index < GUARD_SIZE; Index++) { if(*GuardPtr == 0xC0DE) {//DO NOTHING} else { //flag error! Attempt recovery }

Presented by: © 2015 Jacob Beningo All Rights Reserved Cyclomatic Complexity Helps to ensure readability Bounds number of test cases Forces breaking up into smaller more manageable pieces Reduces bugs 13 Limiting Function Complexity

Presented by: © 2015 Jacob Beningo All Rights Reserved Filling ROM Buffer overrun occurs? Dereference a bad pointer? System upset occurs? What is the status of none programmed ROM? 14.fillsection : { FILL(0xAA55AA55);. = ORIGIN(m_text) + LENGTH(m_text) – 1; BYTE(0xAA) } > m_text What happens if …

Presented by: © 2015 Jacob Beningo All Rights Reserved Robust Application Features ROM Checksum and validation RAM check performed periodically Robust watchdog system 1 – 3 % code are assertions Empty ROM is filled Validating inputs/outputs and error conditions 15

Presented by: © 2015 Jacob Beningo All Rights Reserved Additional Resources Download Course Material for – Updated C Doxygen Templates (May 2015) – Example source code – Templates Microcontroller API Standard EDN Embedded Basics Articles Embedded Bytes Newsletter From underwww.beningo.com - Blog and Articles > Software Techniques > CEC Writing Portable and Robust Firmware in C 16

Presented by: © 2015 Jacob Beningo All Rights Reserved Jacob Beningo Principal Consultant P.O. Box 400 Linden, Michigan : : : Jacob_Beningo : Beningo Engineering : JacobBeningo : Embedded Basics Newsletters Embedded Bytes Training MicroPython Bootloaders Low Power Design Real-time Software C/C++ Embedded 17