An Open Source Embedded Controller. Bill Richardson 2016 coreboot conference

Similar documents
Verified Boot: Surviving in the Internet of Insecure Things. Randall Spangler Chrome OS Firmware Lead

Using STM32 discovery kits with open source tools. STLINK development team

Digging Into The Core of Boot

Embedded Programming with ARM Cortex-M3 Basic Experiments 1

SiFive HiFive1 Getting Started Guide. c SiFive, Inc.

Hands-On with STM32 MCU Francesco Conti

Raspberry PI 'How-To' Series

ECE 598 Advanced Operating Systems Lecture 14

CIS c. University of Pennsylvania Zachary Goldberg. Notes

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

AN4749 Application note

QUICKSTART CODE COMPOSER STUDIO Stellaris Development and Evaluation Kits for Code Composer Studio

External memory code execution on STM32F7x0 Value line and STM32H750 Value line MCUs

Gooligum Electronics 2015

Adafruit Feather nrf52840 Express

E. Annex. Rules and conventions used for the project. v The µkos package

ECE 471 Embedded Systems Lecture 12

Bluegiga Wi-Fi Software 9/19/2013 1

SiFive Freedom E310 Arty FPGA Dev Kit Getting Started Guide. c SiFive, Inc.

Zephyr Kernel Installation & Setup Manual

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

STM32F7 series ARM Cortex -M7 powered Releasing your creativity

Unlocking the Potential of Your Microcontroller

WAVETEK BLE-WT51822AA/AB. Revision History. Bluetooth low energy Module WT51822AA (256k) /AB (128k) (Bluetooth Low Energy BT4.0) PRODUCT SPECIFICATION

HARDWARE REFERENCE IMM-NRF51822

Building a reference IoT product with Zephyr. Ricardo Salveti Michael Scott Tyler Baker

How Often Should I Shutdown My Macbook Air

STM32 Cortex-M3 STM32F STM32L STM32W

ECE 471 Embedded Systems Lecture 15

Cycle Approximate Simulation of RISC-V Processors

Designing with STM32F2x & STM32F4

Shedding too much Light on a Microcontroller s Firmware Protection. Johannes Obermaier, Stefan Tatschner, August 15, 2017

Administrative Details. CS 140 Final Review Session. Pre-Midterm. Plan For Today. Disks + I/O. Pre-Midterm, cont.

ArduCAM CC3200 UNO board

Your Own Virtual Playground. CS 1585 :: Doug McGeehan

Programming Microcontrollers using OpenOCD on a Raspberry Pi

OVERDRIVE Quick Start Guide. v.1.0

BIOS. Chapter The McGraw-Hill Companies, Inc. All rights reserved. Mike Meyers CompTIA A+ Guide to Managing and Troubleshooting PCs

Development Environment Embedded Linux Primer Ch 1&2

Multi-core microcontroller design with Cortex-M processors and CoreSight SoC

Reversing FreeRTOS on embedded devices

The Next Steps in the Evolution of Embedded Processors

This is an inspection failure, not meeting the requirement of >10k Ohm between either PD battery post and chassis.

Embedded Training MakeICT Workshop

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

RA Triage Procedure. Product: DM8050 & DM8600 series. 1.0 Useful Components & Accessories

Process Time. Steven M. Bellovin January 25,

19: I/O Devices: Clocks, Power Management

Nifty Type-C Features and Optimizations

ECE 598 Advanced Operating Systems Lecture 2

Format Hard Drive Using Windows 7 Recovery Disk

Last Time. Think carefully about whether you use a heap Look carefully for stack overflow Especially when you have multiple threads

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

CompTIA Exam CompTIA A+ Version: 43.0 [ Total Questions: 772 ]

How To Reinstall Grub In Windows 7 Without Losing Data And Programs

EMBEDDED SYSTEMS WITH ROBOTICS AND SENSORS USING ERLANG

Getting Started With the Stellaris EK-LM4F120XL LaunchPad Workshop. Version 1.05

ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O

Interrupts in Zynq Systems

xpress Release Notes

Introduction to the Raspberry Pi AND LINUX FOR DUMMIES

Introduction to Scientific Computing

FPGA Adaptive Software Debug and Performance Analysis

2-Oct-13. the world s most energy friendly microcontrollers and radios

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

WHY APPLICATIONS ARE STILL DRAINING OUR BATTERIES and how we can help. Aaron Schulman & Sachin Katti

AN4838. Managing memory protection unit (MPU) in STM32 MCUs. Application note. Introduction

SPIRIT1 Development Kit Software Package

Lab 4: Interrupts and Realtime

Advanced Embedded Systems

Porting Linux to a new SoC

S32 SDK for Power Architecture Release Notes Version EAR

ECE 571 Advanced Microprocessor-Based Design Lecture 12

Introduction to Configuration. Chapter 4

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

An Incubator Project in the Apache Software Foundation. 13 July 2016

Hands-On Workshop: ARM mbed

Buried Treasure: Unlock the Processing Power of Wireless Modules

Hands-On Workshop: ARM mbed : From Rapid Prototyping to Production

Embedded Linux Day 2

A Guide to Condor. Joe Antognini. October 25, Condor is on Our Network What is an Our Network?

Tomasz Włostowski Beams Department Controls Group Hardware and Timing Section. Developing hard real-time systems using FPGAs and soft CPU cores

STM32 F-2 series High-performance Cortex-M3 MCUs

How to Implement USB Suspend/Resume Feature with MCUXpresso SDK USB Stack

============================================================================

Usb Port On Manually Create Bootable Windows Xp Install Driver

Atmel 328-Processor for RaspberryPi

Titan silicon root of trust for Google Cloud

BIOS Update Release Notes

AN4311 Application note

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Instructions Board Game For Windows 7 32 Bit Laptop >>>CLICK HERE<<<

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

Establishing Trust in Disconnected Environments, page 1

Intel Active Management Technology Overview

Linux in the connected car platform

CPSC 213. Introduction to Computer Systems. I/O Devices, Interrupts and DMA. Unit 2a Mar 12 and 14. Winter Session 2017, Term 2

STM32F3 Hands-On Workshop

ECE 471 Embedded Systems Lecture 2

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

Transcription:

An Open Source Embedded Controller Bill Richardson 2016 coreboot conference

Chrome OS firmware engineer since 2009 Verified Boot Developer Mode Embedded Controller Case-closed debugging Some other stuff I can t talk about (yet)

What s an Embedded Controller anyway? A tiny SoC that manages battery charging, fans, keyboard, LEDs, etc. Typically runs even when the main system processor is off We call the main system CPU the AP (for Application Processor) Most laptops have them Most Chromebooks do too Ours is open source, which is unusual

What s this have to do with coreboot? Not much, really It s used in most Chromebooks, though Stefan Reinauer thought y all might find it interesting

What s this have to do with coreboot? Not much, really It s used in most Chromebooks, though Stefan Reinauer thought y all might find it interesting So here I am

A bit of history The first three Chromebooks used a UEFI BIOS It worked, but had several drawbacks Large Slow Complicated Expensive Closed source (TianoCore is only part of it) Only builds on Windows After that, we switched to coreboot

and there was much rejoicing

But the EC was still provided by the ODM This had several drawbacks too Slow Buggy Source unavailable (and probably not worth it) Long turnaround time for every change which usually introduced new bugs Maybe we can make our own...

Primary responsibilities of the EC AP power sequencing Battery charging Thermal management Keyboard scan matrix Buttons and switches Backlights, indicator LEDs Various other board-specific peripherals

Power Sequencing Each AP family & motherboard has its own Power states Voltage regulators Controlling GPIOs (both input and output) Transition rules Timing requirements Trigger events The EC must manage and respond to all those requirements as the AP boots, sleeps, idles, or transitions between various subtle states. It must also ensure that certain peripherals are brought up and down too (USB, WiFi, etc.)

It s actually not that bad All we need is a midrange SoC With various GPIOs and peripherals Hm, there aren t a ton of choices... Oh, and we ll need an SDK or something to write the software

Texas Instruments had a nice SoC The Stellaris LM4 (now called TM4) should do fine ARM M4F core Integrated flash and RAM Lots of GPIOs for keyboard scanning ADCs for power & thermal monitoring PWM controllers for fans and backlighting Timers, counters, blah blah blah Their engineers were very helpful And we can license their SDK

Texas Instruments had a nice SoC The Stellaris LM4 (now called TM4) should do fine ARM M4F core Integrated flash and RAM Lots of GPIOs for keyboard scanning ADCs for power & thermal monitoring PWM controllers for fans and backlighting Timers, counters, blah blah blah Their engineers were very helpful And we can license their SDK #include <lawyers.h>

We now have permission to look at their SDK It s not ideal Let s think of something else...

The Chrome OS EC Firmware Randall Spangler and Vincent Palatin wrote a basic OS in about three days It does all we need A small number of independent tasks Each task has its own stack Task switching is interrupt-driven Strictly ordered list of task priorities Events, mutexes, timers, callbacks No heap (no malloc/free), so no memory leaks Modular, configurable Written in C Open source It doesn t have a clever name. It s just the EC firmware. Sorry.

I already gave a talk on it a couple years ago www.chromium.org/chromium-os/2014-firmware-summit

We ve made some improvements since then Code cleanup & refactoring More chip vendors It83xx, lm4, mec1322, npcx, nrf51, stm32 More CPU cores cortex-m, cortex-m0, nds32 Many more Chromebooks More use cases Original EC functions USB-PD controllers Case-closed debug controller USB Type-C power brick More sensors and peripherals

EC Software Sync It is important that the AP firmware (BIOS) and the EC firmware remain compatible through upgrades. At every* cold boot/reset of the EC 1. The EC boots its RO firmware, and powers on the AP. 2. The AP boots its RO firmware. 3. The AP verifies its RW firmware and jumps to it. 4. The EC computes a hash of its RW firmware. 5. The AP RW firmware contains a copy of the EC s RW firmware. The AP compares its hash with the EC s hash. 6. If they differ, the AP gives the EC the correct RW firmware, which the EC writes to its flash. 7. The EC jumps to its RW firmware. There also are a few other tricks to ensure the EC isn t lying about its hash *Normal mode, anyway. In recovery mode both AP and EC stay in their RO firmware

Standalone configuration Verified Boot requires some time-consuming cryptographic calculations Software Sync is an optimization to avoid doing this on the EC Removable devices like USB Type-C power bricks have no choice They use the same sort of vboot implementation as the AP Can be configured for RO / RW, or RO / RW_A / RW_B No TPM, so preventing rollback is a little different No dev-mode in USB power bricks, duh It can take a second or two after power on before they re ready for use

If you want to play around with it We support two boards from STMicroelectronics (www.st.com) 32F072BDISCOVERY STM32L476G-EVAL Others will probably work without much trouble You ll need GNU make version 4.1 (or a minor edit to the Makefiles) openocd version 0.9.0 or newer (building from source is easy) ARM cross-compiler (gcc-arm-none-eabi)

If you want to fiddle with the EC in your Chromebook Be very careful Use the Chrome OS build environment www.chromium.org/chromium-os/developer-guide Use the correct release branch chrome://system -> ec_info -> Expand Or take apart the recovery image for your device www.chromium.org/chromium-os/how-tos-and-troubleshooting/working-on-a-branch flashrom can be used to program the EC from the AP flashrom -p ec --fast-verify -w ec.bin

Really, be very careful This is a warranty-voiding process Disable EC software sync Only update the RW half flashrom has options to do this Accessing the serial port may require soldering Other than the Pixel lightbar, there s very little that s interesting and you can drive that from the AP If you mess up the power sequencing, the AP may no longer boot Ever

Ongoing work More use cases Reduce size, simplify code Get partners more involved This is actually going very well Support more SoCs, cores, etc. Maybe someday Major refactoring Improved security???

Example build sudo apt-get install gcc-arm-none-eabi git clone https://chromium.googlesource.com/chromiumos/platform/ec cd ec make BOARD=discovery-stm32f072

Makefile.rules:243: *** multiple target patterns. Stop. You need to edit Makefile.rules as follows: @@ -240,12 +240,12 @@ $(out)/$(project).hex: $(out)/$(project).bin $(call quiet,bin_to_hex,objcopy) $(out)/rw/%.elf: override BLD:=RW -$(out)/rw/%.elf: private objs := $(rw-objs) +$(out)/rw/%.elf: objs := $(rw-objs) $(out)/rw/%.elf: $(out)/rw/%.lds $(rw-objs) $(libsharedobjs_elf-y) $(call quiet,elf,ld ) $(out)/ro/%.elf: override BLD:=RO -$(out)/ro/%.elf: private objs := $(ro-objs) +$(out)/ro/%.elf: objs := $(ro-objs) $(out)/ro/%.elf: $(out)/ro/%.lds $(ro-objs) $(libsharedobjs_elf-y) $(call quiet,elf,ld )

Build and install openocd sudo apt-get install libtool autoconf libusb-1.0-0-dev git clone git://git.code.sf.net/p/openocd/code openocd-code cd openocd-code/./bootstrap./configure --enable-stlink make sudo make install sudo cp /usr/local/share/openocd/contrib/99-openocd.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules

Program the board cd ec make BOARD=discovery-stm32f072

The EC firmware will export a console over USB > version Chip: stm stm32f07x Board: 0 RO: discovery-stm32f072_v1.1.4751-1 RW: discovery-stm32f072_v1.1.4751-1 Build: discovery-stm32f072_v1.1.4751-1ab69e7 2016-06-12 17:50:26> > help Known commands: chan gpioget md sysinfo usart_info crash gpioset panicinfo sysjump version flashinfo help reboot syslock waitms flashwp hibernate rw taskinfo gettime history shmem timerinfo HELP LIST = more info; HELP CMD = help on CMD. >