OpenWrt From Top to Bottom

  • View
    248

  • Download
    11

  • Category

    Software

Preview:

Citation preview

OpenwrtAnd some embedded FW building

About me● Anton Lerner● Architect at Sitaro

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

What is Openwrt

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

Openwrt for the WIN!

$ $$$ !!

Basic image for openwrt

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

Short feature presentation

OpenWRTs origins● Linksys WRT54G

Other versions

DD-WRT

Gargoyle

LEDE

Deb-WRT

Tomato Roofnet

Under the hood

Customized Linux kernel for embedded devices

Drivers - Wifi, Lan, chipset specific, generic

Applications - DHCP, DNS, BusyBox, LuCi

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

Firmware and boot

Boot loader

Unzipped kernel

Drivers Applications

Boot Decompressor

Filesystem

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

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

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

A lot of vendors, Different Chipsets

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

A bit about chipsets

● SoC - system on chip● NICs● Hardware switch

Packages

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

● We can make our own packages

Building our own package

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

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

OpenWRT build infra

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

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

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

Demo - Building Package

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!

OpenWRT platform

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

Questions

Recommended