Openwrt
And 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 - FS
Kernel
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 - FS
Kernel
Write to /etc/anton
Copy 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

OpenWrt From Top to Bottom

  • 1.
  • 2.
    About me ● AntonLerner ● Architect at Sitaro
  • 3.
    Agenda ● Introduction toOpenWRT ● FW & cross compiling basics ● OpenWRT FW Memory layout ● Building an Openwrt Package
  • 4.
    What is Openwrt ●Embedded Firmware ● Open source ● Linux based ● Run mainly on routers ● Many apps and tweaks!
  • 5.
    Openwrt for theWIN! $ $$$ !!
  • 6.
    Basic image foropenwrt ● Busybox ● Luci ● Command line configuration ● Firewall ● Opkg - package manager
  • 7.
  • 8.
  • 9.
  • 10.
    Under the hood CustomizedLinux kernel for embedded devices Drivers - Wifi, Lan, chipset specific, generic Applications - DHCP, DNS, BusyBox, LuCi
  • 11.
    Conventional firmware keyconcepts ● 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
  • 12.
    Firmware and boot Bootloader Unzipped kernel Drivers Applications Boot Decompressor Filesystem
  • 13.
    OpenWRT vs conventionalFW ● 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
  • 14.
    Openwrt FW andflash 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 - FS Kernel FW Header LZMA decompressor Zipped kernel NvramSquash fs chk JFFS2
  • 15.
    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 - FS Kernel Write to /etc/anton Copy on write
  • 16.
    A lot ofvendors, Different Chipsets
  • 17.
    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
  • 18.
    A bit aboutchipsets ● SoC - system on chip ● NICs ● Hardware switch
  • 19.
    Packages ● Over 3500apps ○ In OPKG repository ○ Torrent client ○ Adblock ○ OpenVPN ○ Different network monitoring tools ● We can make our own packages
  • 20.
    Building our ownpackage ● Build SDK ○ Toolchain + cross-compiler ○ OpenWRT makefile framework ○ Buildroot
  • 21.
    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
  • 22.
    OpenWRT build infra ●On top of buildroot ● Custom makefile structure ● Part of openwrt package build process ● Custom keywords for package creation and install
  • 23.
    A word aboutbuildroot ● 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
  • 24.
    Buildroot + OpenWRTmakefile 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
  • 25.
  • 26.
    Build Package- TutorialChecklist ● 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!
  • 27.
    OpenWRT platform ● Runson multiple platforms and architectures ● Upgrade your router's capabilities ● Excellent research tool ● Many flavors, Active communities
  • 28.