Using Open Source Software to Build an Industrial Grade Embedded
Total Page:16
File Type:pdf, Size:1020Kb
Open Source Summit Japan 2019 Using Open Source Software to Build an Industrial-grade Embedded Linux Platform from Scratch SZ Lin (林上智) Embedded Linux Development Center, Software R&D Engineer 07/19, 2019 About Me SZ LIN (林上智) Software Engineer at Moxa Cybersecurity Fundamentals Specialist ISA/ IEC 62443 Debian Developer Blog - https://szlin.me 2 Industrial Embedded Linux Platforms Application Smart Smart Smart Smart Smart Smart Rail Grid Oil Field Transportation Factory Marine Edge Connectivity Industrial Computing Network Infrastructure Industrial Serial I/O Video Embedded Computers Industrial Wireless Industrial Connectivity Connectivity Connectivity Ethernet LAN Routers Device 3 Before Using Open Source Software Something You Should Know 4 Copyright Patent Copyright is a legal right, that grants A patent gives its owner the right to the creator of an original work exclude others from making, using, exclusive rights to determine whether, selling, and importing an invention and under what conditions, this for a limited period of time, usually original work may be used by others twenty years. src: https://en.wikipedia.org/wiki/Copyright src: https://en.wikipedia.org/wiki/Patent 5 Copyright Patent Identify key recommended processes It is a shared defensive patent pool for effective open source management with the mission to protect Linux [2]. [1]. 6 Processes, Tooling and Support OpenChain SPDX [3] FOSSology [4] Trust between entities in the supply chain Trust for software packages Free scanning technology The OpenChain Project builds Software Package Data Exchange FOSSology is a open source trust in open source by making (SPDX) is a file format used to license compliance software open source license document information on the system and toolkit compliance simpler and more software licenses under which a consistent given piece of computer software is distributed. 7 Industrial/ Harsh Environments Including smart rail, smart grid, intelligent transportation, factory automation, oil & gas, marine, and more 8 Target Application Longevity + Stability + Security Resource Real-time Safety Performance Limited 9 Target Application Longevity + Stability + Security Hardware Software Resource Real-time Safety Performance Limited 10 Lifecycle of Industrial-grade Embedded Linux Platform Development Phase Maintenance Phase Regular Build and Testing Update 1 2 3 4 System Long-term Preparation Test 11 Development Phase Design and development according to application 12 Root filesystem User Applications User Space GNU/ Linux Init system GNU C library System call interface Kernel Kernel Space Bootloader Architecture-dependent firmware Toolchain Hardware and peripheral devices 13 Choose Proper Bootloader 14 Bootloader behavior (A case of ARM-based architecture) Linux Linux uImage Decompressor Loading Decompress U-boot Relocate U-boot 2nd Stage ROM Load MLO 1st Stage CPU DRAM 15 Supported Category License Supported Platforms Maintainer UEFI 68k, ARM, Blackfin, MicroBlaze, MIPS, Nios, DENX Das U-Boot GPL-2+ Y Software [5] SuperH, PPC, RISC-V, Engineering x86 (on top of Coreboot) IA-32, x86-64, ARMv7, Coreboot [6] GPL-2 ARMv8, MIPS, RISC-V, Y coreboot.org POWER8 IA-32, x86-64, IA-64, GRUB GPL-3 ARM, PowerPC, MIPS Y GNU Project and SPARC GNU GPLv3, Modified BSD License (original program), x86, x86-64, or Roderick W. rEFInd [9] Y additional ARM64 Smith components released under various licenses 16 Kernel Space 17 Choose Proper Kernel Based on the application requirement 18 Linux Kernel Comparison Table Latest Category Target Application Maintainer version • Performance Linux kernel 5.2 Kernel.org • Resource Limited [12] [13] • Real-time Real Time Linux Preempt RT kernel 5.2 • Functional safety collaborative project • Resource Limited *Real-time application [14][15] 19 SoC Board Support Package Kernel • Kernel version depends on SoC vendors – Well made but not well maintained • Contain lots of in-house patches – Errata patches – Specific feature patches – … • Different SoC might use different versions of kernel • The lifetime is unsure 20 LTS: Long Term Stable Kernel [16] Extend software uptime for stable kernel • Only accept bug fixes and security fixes img: https://www.kernel.org/category/releases.html 21 LTSI: Long Term Support Initiative [17] • Linux Foundation collaborative project – Based on LTS – Add another chance to include further patches on top of LTS – Auto Test framework – Same lifetime with LTS (yearly release and 2 years life time) 22 CIP (Civil Infrastructure Platform) [19] • Linux Foundation collaborative project – Support kernel and core package – Auto Test framework – Maintenance period • 10 years and more (10-20 years) 23 img: https://wiki.linuxfoundation.org/civilinfrastructureplatform/cipconferences 24 Linux Kernel Source Comparison Table Maintenance Supported Latest Version Period Features Realtime Maintainer Version (years) kernel SoC SoC vendor BSP ? Bug fixes ? N kernel team kernel LTS • Bug fixes 2 ~ ? 4.19 N Kernel.org kernel • Security fixes • Bug fixes LTSI • Security fixes 2 ~ ? 4.14 N LTSI kernel • Specific features • New features • Bug fixes CIP • Security fixes 10 + 4.19 Y CIP kernel • Specific features • New features 25 Longevity + Stability + Security Mutually Exclusive ? Resource Real-time Safety Performance Limited 26 Multiple Kernel In Single Platform To fulfill multiple user scenarios 27 FIT (Flattened Image Tree) (A case of ARM-based architecture) • Tree data structure • Handle multiple types of image – kernel : kernel image – fdt : dtb file – ramdisk : root file system • Image hashing – md5 – sha1 • Image signing • Each node in configurations has their image configuration in booting stage 28 More info.: http://git.denx.de/?p=u- boot.git;a=blob_plain;f=doc/uImage.FIT/source_file_format.txt;hb=HEAD 29 User Space 30 ELISA: Safety-Critical Systems [20] • Linux Foundation collaborative project – Build and certify Linux-based safety-critical applications – Define and maintain a common set of tools and processes • SIL2LinuxMP [21] project and the Linux Foundation’s Real-Time Linux project – IEC 61508 31 Choose Proper C Library and Toolchain 32 C Library and Toolchain Comparison Table Target Maintainer Category License Features Application User • Stable ABI • Backward compatibility • Fully symbol versioning • Performance glibc [25] LGPL 2.1 • Stack smashing GNU protection/ heap • Security corruption detection • Profiling • No-MMU architecture • Resource uClibc-ng LGPL 2.1 support uclibc-ng.org [26] • Tiny size Limited • Stable ABI • Backward compatibility • Resource Musl [28] MIT • Stack smashing Limited musl-libc.org protection/ heap • Security corruption detection Other option [93] * Be aware of year 2038 problem [29] 33 Year 2038 Problem [92] • The time_t datatype is a data type in the ISO C library and kernel structure defined for storing system time values. • 32-bit system can represent dates from Dec 13 1901 Jan 19th 2038 • It causes integer overflowing on 03:14:08 UTC 19 January 2038 34 Init System 35 Init System Comparison Table Category License C Library User Note uClinux-ng Resource- Glibc ProteanOS busybox GPL 2.0 limited musl PiBox application uClinux-ng sysvinit GPL 2.0+ glibc Devuan musl Arch, CentOS, CoreOS, Debian, Linux only systemd LGPL 2.1+ glibc Fedora, Mint, OpenSUSE, Redhat, Ubuntu musl Gentoo openrc 2-clause BSD glibc Alpine Linux upstart GPL 2.0 glibc Chromium OS Linux only 36 Choose proper RFS (Root filesystem) Stable root filesystem 37 Root filesystem Comparison Table Maintenance Number of Security Category Period C Library CI packages Tracker (years) 300 ~ 400 • uClibc Busybox ? ? ? applets • glibc Latest release the It depends on • glibc Yocto previous two Y Y meta-* • musl releases • glibc Buildroot 1 2000+ [42] • musl Y Y • uClibc-ng 3 + • glibc Debian 2 (i386, amd64, armel, 51000+ Y Y • musl armhf and arm64) 38 System Development Tools 39 System Development Tools Comparison Table System System Development Root filesystem Toolchain Development Tools Tools License Busybox Yocto OE-Core MIT Yocto Yocto OE-Core MIT Buildroot Buildroot Buildroot GPL 2.0+ Metadata: MIT ISAR Debian toolchain Others: GPL 2.0 ELBE Debian toolchain GPL 3.0+ Debian Yocto Deby (meta- OE-Core MIT debian) Live-build Debian toolchain GPL 3.0+ 40 Why We Choose Debian [49] Stability Scalability Good system security [50] unstable → testing → stable Server, Desktop, Everything is open Laptop, Embedded devices Usually, fixed packages are uploaded within a few days Long term support Multiple architectures Incredible amounts 5 more years by Debian-LTS project alpha, amd64, armel, armhf, of software (i386, amd64, armel, armhf and arm64) aarch64, hppa, i386, ia64, mips, Debian comes with over 51000 mipsel, powerpc, s390, and spar different pieces of software with free 41 Development Phase Regular Build and Testing Update 1 2 3 4 System Long-term Preparation Test More info: Building, Deploying and Testing an Industrial Linux Platform Open Source Summit Japan 2017 [51] 42 Merge Master CI/ CD Automatic Release Pipeline Develop Pull Request Feature .. N Pass Y Fork Maintainer Approval Patches Local Y N Branch Pass Internal/ External Developers Notification 43 CI/ CD Automatic Release Pipeline Continuous Integration Code Continuous Delivery Continuous Deployment Deploying Release 1 2 3 4 Building Testing 44 CI/ CD Automatic Release Pipeline Continuous Integration Code Deploying Release 1 2 3 4 Building Testing 45 Patches Local Static Program Branch Analysis Coding style Internal/ External OWASP [52] Infer [53] Slave