Introduction to Hardware and Firmware

  • Upload
    shanrei

  • View
    36

  • Download
    4

Embed Size (px)

DESCRIPTION

Intro to Embedded Systems

Citation preview

  • Presented by:Jan Ray C. RulidaINTRODUCTION TO HARDWARE/FIRMWARE INTERFACE DESIGN

  • 'If acluttered deskis a sign of a cluttered mind, of what, then, is an empty desk a sign?-Albert EinsteinQuote:

  • My Desk:

  • INTRODUCTION TO FIRMWARE

  • Origin of firmwareThe word firmware was coined by Ascher Opler in 1967In electronics systems and computing, this is now referred to as the combination of persistent memory and program code and data stored in it. Firmware existed on the boundary between hardware and softwarePopular usage extended the word firmware to anything that resides in ROM, include processor machine-instructions for BIOS and bootloadersWHAT IS FIRMWARE?

  • Also called embedded softwareNon-volatile, this means that firmware is installed on ROM (ROM, PROM, EPROM) or FLASH chips.Enables the device(e.g., embedded system, etc.) to render its features and capabilities functionalUsually written in C, C++, Java, Javascript, or Lua.

    WHAT IS FIRMWARE?

  • Commonly developed for embedded systems.Found in smartphones routers, digital watches, digital cameras, and pretty much anything digital and runs on microcontrollers. WHAT IS FIRMWARE?

  • From now on, let us make firmware refer to any piece of code that is written and loaded into hardware device to make that hardware device work.Let us also define firmware as any piece of code that runs on hardware.WHAT IS FIRMWARE?

  • Upgradable:Firmware, nowadays, are stored in flash memory making them easily updatable and upgradable.

    Portable:Loading the firmware from the host system is cheaper and more flexible. The loading of firmware is done using device drivers.TRENDS IN FIRMWARE

  • A bootloader is a piece of code that runs before any operating system is running.A bootloader is highly processor and board specific as it is the first software to run after powerup or reset.Bootloaders also usually starts from ROM or flash.Bootloader code is moved to RAM for actual execution.A bootloader decides which OS kernel image to use.FIRMWARE vs BOOTLOADER

  • The bootloader removes the need for special hardware to program and load firmware.Bootloaders can also be classified as firmware, in the sense that it is code embedded in hardwareFIRMWARE vs BOOTLOADER

  • When you upload a sketch(firmware), you're using the Arduinobootloader. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the on-board (pin 13) LED when it starts (i.e. when the board resets).ARDUINO FIRMWARE AND BOOTLOADER

  • The bootloader removes the need for special hardware to program and load firmware.Bootloaders can also be classified as firmware, in the sense that it is code embedded in hardwareFIRMWARE vs BOOTLOADER

  • FIRMWARE DEVELOPMENT

  • Writing and developing firmware is closely related to software engineering principles.When developing firmware, one must know the target device (8-bit, 16-bit, or 32-bit MCUs or full-blown processors).FIRMWARE DEVELOPMENT

  • Development tools should also be considered, whether commercial or free (IAR, Keil, GCC)Choosing a hardware and software debugger.The choice of programming language should also be taken into account (C/C++, Java, Assembler, etc).Licensing can also be an issue. (Commercial, free, open-source, share-alike, etc.)Version control: Github, Mercurial, SubversionBare-metal programming or use RTOSFIRMWARE DEVELOPMENT

  • Requirements gatheringSystem architecture designFirmware design (Hardware Design)Firmware development (Hardware Development)Software and Hardware integrationDebugging and TestingValidationDeploymentMaintenanceFIRMWARE DEVELOPMENT CYCLE

  • According to William Y. Arms, there is a Fundamental Assumption for software processes:Good processes lead to good softwareGood processes reduce riskGood processes enhance visibilityGood processes enable teamworkFIRMWARE SOFTWARE PROCESSSOURCE: Steps in the software development process by William Y. Arms. CS5150.Cornell University Computing and Information Science. Fall 2013. http://www.cs.cornell.edu/Courses/cs5150/2013fa/slides/B2-processes.pdf

  • #include "stm32f4xx_conf.h"void TIM2_IRQHandler(void) {if (TIM2->SR & TIM_SR_UIF) GPIOD->ODR ^= (1 SR = 0x0; // reset the status register}int main(void){RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; GPIOD->MODER = (1 ISER[0] |= 1PSC = 0x0;TIM2->DIER |= TIM_DIER_UIE;TIM2->ARR = 0x01; TIM2->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN;TIM2->EGR = 1;while (1);}

    EXAMPLE 32-BIT ARM CODE

  • intled=13; voidsetup(){ pinMode(led,OUTPUT); } voidloop(){ digitalWrite(led,HIGH);delay(1000); digitalWrite(led,LOW); delay(1000); }EXAMPLE ARDUINO CODE

  • FIRMWARE AND EMBEDDED SYSTEMS

  • Firmware is an integral part of embedded systemsFIRMWARE & EMBEDDED SYSTEMSTypical embedded system components.Figure from Software Engineering for Embedded Systems by Robert Oshana.

  • Firmware is everywhereOver 95% of software systems are actually embeddedEmbedded systems permeate everyday life, but are mostly taken for granted

    EMBEDDED SYSTEMS

  • Firmware should be safe, robust and reliableCoding and quality standards must be implemented and adhered to especially for firmware used in mission and life-critical embedded systems (e.g., MISRA C/C++ for the automotive industry)Good code could save a life, bad code could kill a person. (e.g. Bookout v Toyota Motor Corp.)Be careful of stack overflowSAFE AND RELIABLE FIRMWARE IN EMBEDDED SYSTEMS

  • Internet of ThingsWearable electronics and technologySensor networksDigital Signal ProcessingToysLower cost to entry for hardware designFUTURE TRENDS IN FIRMWARE DEV

  • The Internet of Things (IoT) is a scenario in which objects, animals or people are provided withunique identifiersand the ability to automatically transfer data over a network without requiring human-to-human or human-to-computer interaction.INTERNET OF THINGSSOURCE: http://whatis.techtarget.com/definition/Internet-of-Things

  • WEARABLE TECHNOLOGYImage URL: http://static.dezeen.com/uploads/2013/03/Wearable-Technology-on-Dezeen.jpg

  • WEARABLE TECHNOLOGYImage URL: http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2012/7/18/1342629671354/Google-Glass-008.jpg

  • SENSOR NETWORKSSOURCE: http://searchdatacenter.techtarget.com/definition/sensor-networkA sensor network is a group of specializedtransducers with a communications infrastructure intended to monitor and record conditions at diverse locations. Commonly monitored parameters are temperature, humidity, pressure, wind direction and speed, illumination intensity, vibration intensity, sound intensity, power-line voltage, chemical concentrations, pollutant levels and vital body functions.

  • FIRMWARE DESIGN AND IMPLEMENTATION

  • THINGS TO REMEMBERMake your code efficient, stable, and easy to read.Document your code. Always. I mean it. Seriously.Use a version control system. Again, seriously.Make yourself familiar with DMA (direct memory access) and interruptsUse timers.Use coding standards, stick to it and be consistentMake use of pointers and buffers to avoid needlessly copying dataRemember that your system is typically connected to real hardware; software errors can have dramatic and expensive results.

  • Roughly determine the purpose of your firmware.Determine the challenges that your are facing with regard to your firmwares purposePlan how to deal with these challenges. Do you have a strategy to follow?Make detailed plan for the firmware architecture. Tesla might not approve, but making drawings when planning your architecture cant hurt.Start documenting.

    FIRST STEPS: FIRMWARE DESIGN

  • This largely depends on your target microcontroller or system but the following should be more or less generic.Set up the framework. These will include empty header and source files.Set up the clock of the microcontroller.Create the main() function.FIRMWARE IMPLEMENTATION

  • Set the pins of your microcontroller accordingly and properly.Set up your timer correctly. You will need it.Work some blinkenlights to check your GPIOs, clock and timer!You may set up a UART for some extra debugging and then try sending and receiving data using the UART.Start implementing the specific functions of your firmwar.Always commit your work to your version control system.

    FIRMWARE IMPLEMENTATION

  • C/C++ ProgrammingKnowledge of assembly language (not really).When doing bare-metal programming, knowledge of target microcontroller/microprocessor architecture is important.A particular set of skills is needed for firmware and embedded systems developers according to specifications of the client.Knows how to RTFM.READY TO GET STARTED?

  • THANK YOU!