Building an

Embedded Ecosystem for

My Past Self 

Matt Knight

Overview

  • Goals
  • Status Quo
  • Fundamentals
  • Zig Embedded Group

HOW

TO

MAKE

SENSE

OF ANY

MESS

by Abby Covert

Inspiration

Prerequisites

  • CPU architecture
  • Function calls
  • Addressable memory

Goals

Collaboration

  • Reproducible
  • Discoverable
  • Hackable

Hardware Freedom

  • Fit hardware to spec
  • obselesence
  • supply chain disruption
  • education

Custom boards

  • some applications are size limited
  • making custom board is gratifying
    • art/creativity
  • dev boards are lacking sometimes
  • custom power electronics for application

Leverage Hardware

  • Do more with less
  • reduce cost
  • room to grow

Challenges with the Status Quo

What's an embedded system?

  • Not a PC
  • Not a server
  • (Probably) not a phone
  • Usually dealing with physical phenomena

Yo what distro you running?

Microcontrollers

CPU

Flash

RAM

Peripherals

ALU

SP

PC

registers

Architectures

  • ARM
  • AVR (Arduino)
  • MSP430 (Texas Instruments)
  • RISC-V
  • ESP32
  • MIPS
  • PIC

 

  • 8, 16, 32-bit
  • Harvard and Von Neumann

Peripherals

  • GPIO
  • Digital communication
  • Analog-to-Digital Converter (ADC)
  • Digital-to-Analog Converter (DAC)
  • DMA
  • and more

Programming Tools

  • Arduino IDE
  • TI: Code Composer Studio
  • TI: Energia
  • ST: STM32CubeIDE
  • ST: SW4SM32
  • ST: TrueSTUDIO
  • Microchip Studio for AVR and SAM Devices
  • Microchip: MPLAB X
  • NXP: MCUXpresso
  • Silicon Labs: Simplicity Studio
  • Keil: IAR Embedded Workbench
  • SEGGER Embedded IDE
  • Crossworks
  • Espressif
    • esp-idf (Just a toolchain!!!)
  • Nordic
    • also just an sdk/toolchain

Things hidden from you

  • Makefiles
  • Linker Scripts
  • what a compiler is
  • how interrupts work
  • how your code gets onto the MCU

Fundamentals

Microcontrollers

CPU

Flash

RAM

Peripherals

ALU

SP

PC

registers

Memory Mapped Input Output

  • Specific addresses have special meaning
  • Reading/Writing bitfields affects hardware

GPIO

0x0000

0xffff

Transmitting over a serial line

Hardware Interrupts

  • Statically sized table mapping events to functions
  • Usually every peripheral gets an interrupt

Hardware Interrupts

Interrupt Table

ISR

main

Hardware Interrupts

Interrupt Table

ISR

main

Hardware Interrupts

Interrupt Table

ISR

main

Hardware Interrupts

Interrupt Table

ISR

main

*Interrupt triggered

Hardware Interrupts

Interrupt Table

ISR

main

Hardware Interrupts

Interrupt Table

ISR

main

Hardware Interrupts

Interrupt Table

ISR

main

Transmitting with interrupts

  1. Set UART ISR at compile or runtime
  2. Set up buffer
  3. Enable UART interrupts

 

  • Once the transfer is complete, the interrupt can be disabled

That's it

Zig Embedded Group

Why Zig?

  • Toolchain
    • cross compilation: Zig/C/C++
    • build.zig
  • Language itself
    • can fit it in my head
    • don't need a separate standard library
    • explicit error handling
    • comptime
  • Build script library
  • CPU startup code
  • Linkerscript generation
  • Interrupt declaration
  • Standard interfaces
  • Unstable at the moment

MMIO

Interrupts

./src/modules/cpus/cortex-m/cortex-m.zig:96:21: error: There is no such interrupt as 'blarg' it must be one of:
    nmi
    hard_fault
    mpu_fault
    bus_fault
    usage_fault
    secure_fault
    svc
    debugmon
    pendsv
    systick

                    @compileError(msg);
                    ^

Software You Can Love 2022

Questions

and maybe answers

Photography by Preston Thompson

Made with Slides.com