OpenWrt is a Linux distribution for embedded systems that runs on many routers and networking devices today. In this session we'll talk about OpenWrt's origins, architecture and get down to building apps for the platform.
Along the way we will touch on some basic firmware concepts and at last present the final working OpenWrt router and its capabilities.
Anton Lerner, Architect at Sitaro, computer geek, developer and occasional maker.
Sitaro provides total cyber protection for small business and home networks. Sitaro prevents massive scale IoT cyber attacks.
Find out more information in the meetup event page - https://www.meetup.com/Tel-Aviv-Yafo-Linux-Kernel-Meetup/events/245319189/
10. Under the hood
Customized Linux kernel for embedded devices
Drivers - Wifi, Lan, chipset specific, generic
Applications - DHCP, DNS, BusyBox, LuCi
11. 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
14. 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
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
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 about chipsets
● SoC - system on chip
● NICs
● Hardware switch
19. Packages
● Over 3500 apps
○ In OPKG repository
○ Torrent client
○ Adblock
○ OpenVPN
○ Different network monitoring tools
● We can make our own packages
20. Building our own package
● 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 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
24. 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
26. 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!
27. OpenWRT platform
● Runs on multiple platforms and architectures
● Upgrade your router's capabilities
● Excellent research tool
● Many flavors, Active communities