28
Openwrt And some embedded FW building

OpenWrt From Top to Bottom

Embed Size (px)

Citation preview

Page 1: OpenWrt From Top to Bottom

OpenwrtAnd some embedded FW building

Page 2: OpenWrt From Top to Bottom

About me● Anton Lerner● Architect at Sitaro

Page 3: OpenWrt From Top to Bottom

Agenda● Introduction to OpenWRT● FW & cross compiling basics● OpenWRT FW Memory layout● Building an Openwrt Package

Page 4: OpenWrt From Top to Bottom

What is Openwrt

● Embedded Firmware● Open source● Linux based● Run mainly on routers● Many apps and tweaks!

Page 5: OpenWrt From Top to Bottom

Openwrt for the WIN!

$ $$$ !!

Page 6: OpenWrt From Top to Bottom

Basic image for openwrt

● Busybox● Luci● Command line configuration● Firewall● Opkg - package manager

Page 7: OpenWrt From Top to Bottom

Short feature presentation

Page 8: OpenWrt From Top to Bottom

OpenWRTs origins● Linksys WRT54G

Page 9: OpenWrt From Top to Bottom

Other versions

DD-WRT

Gargoyle

LEDE

Deb-WRT

Tomato Roofnet

Page 10: OpenWrt From Top to Bottom

Under the hood

Customized Linux kernel for embedded devices

Drivers - Wifi, Lan, chipset specific, generic

Applications - DHCP, DNS, BusyBox, LuCi

Page 11: OpenWrt From Top to Bottom

Conventional firmware key concepts● Reliable firmware

○ Checksum, custom headers○ Read only filesystem - avoid corruption of data

● Small size○ Flash size is small, we want to get the most of it!

● Filesystem is read only - cannot tweak after the image is built○ NVRAM is used for persistent configuration modifications

FW Header LZMA decompressor Zipped kernel NvramSquash fs chk

Page 12: OpenWrt From Top to Bottom

Firmware and boot

Boot loader

Unzipped kernel

Drivers Applications

Boot Decompressor

Filesystem

Page 13: OpenWrt From Top to Bottom

OpenWRT vs conventional FW● Static image● Squashfs + Ram FS

SquashFS - read only FS Temp-fs runtime cfg. NVRAM - persistent config

FW Header LZMA decompressor Zipped kernel NvramSquash fs chk

Kernel

Page 14: OpenWrt From Top to Bottom

Openwrt FW and flash layout

● Applications can be installed and uninstalled in run time● Fully Writable Filesystem!

○ Copy on write using JFFS2

SquashFS - read only FS - ROM JFFS2 - Writable

Overlay - FSKernel

FW Header

LZMA decompressor Zipped kernel NvramSquash fs chk JFFS2

Page 15: OpenWrt From Top to Bottom

Copy on write● FS Have /rom for squashFS and /overlay for JFFS2 mounts● / mounted with overlay_fs● Great success!

SquashFS - read only FS - ROM JFFS2 - Writable

Overlay - FSKernel

Write to /etc/antonCopy on write

Page 16: OpenWrt From Top to Bottom

A lot of vendors, Different Chipsets

Page 17: OpenWrt From Top to Bottom

OpenWRT 4 all● Openwrt is available on different chipsets

○ Table of hardware

● Each Openwrt version for a specific router contains*○ OpenWRT pre built image○ SDK and cross compiling tools

● Porting packages into router is (relatively) quick and easy

Page 18: OpenWrt From Top to Bottom

A bit about chipsets

● SoC - system on chip● NICs● Hardware switch

Page 19: OpenWrt From Top to Bottom

Packages

● Over 3500 apps○ In OPKG repository○ Torrent client○ Adblock○ OpenVPN○ Different network monitoring tools

● We can make our own packages

Page 20: OpenWrt From Top to Bottom

Building our own package

● Build SDK○ Toolchain + cross-compiler○ OpenWRT makefile framework○ Buildroot

Page 21: OpenWrt From Top to Bottom

Cross compiling toolchains● A set of compilers and compiling tools ● Custom made for a specific Chipset / Processor● Released with hardware by vendor● Usually supports c/c++● Contains custom libs for libc / libc++ and other utilities

○ Smaller size

Page 22: OpenWrt From Top to Bottom

OpenWRT build infra

● On top of buildroot● Custom makefile structure● Part of openwrt package build process● Custom keywords for package creation and install

Page 23: OpenWrt From Top to Bottom

A word about buildroot

● Framework containing scripts and makefiles● Enables to build a linux image from scratch● Used when compiling embedded FW

○ Cross compiling friendly!

● In openwrt, used with scripts that connect to OpenWRT app feeds

Page 24: OpenWrt From Top to Bottom

Buildroot + OpenWRT makefile infra● Download open source code of included packages● Compile downloaded packages with cross compiler tools● Download and compile dependencies● Compile any custom packages● Build the kernel according to our specifications● Create a rootFS filesystem● Copy package content into rootFS● Zip FS and create loadable image

Page 25: OpenWrt From Top to Bottom

Demo - Building Package

Page 26: OpenWrt From Top to Bottom

Build Package- Tutorial Checklist● Check for OpenWRT support!● Choose correct SDK / OpenWRT code branch

○ Download SDK from site or compile one using buildroot

● Create custom makefile● Compile using buildroot + correct cross compiler● Locate Package● Copy to router● Opkg install● Have fun!

Page 27: OpenWrt From Top to Bottom

OpenWRT platform

● Runs on multiple platforms and architectures● Upgrade your router's capabilities● Excellent research tool● Many flavors, Active communities

Page 28: OpenWrt From Top to Bottom

Questions