Tizen Bootup
Xiaoli Gong [email protected] Nankai University, China Tizen logical layers
OSP(Open Services Platform, C++ APIs) Tizen physical partitions
Storage partitions Tizen filesystems File system is a user interface
5 Mount point
6 Write file system into partitions Write file system into partitions Write file system into partitions How system know file systems
In u-boot source code, root file system type is specified: include/configs/tizen.h
10 Root file system mounted by kernel
Call stack init/main.c kernel_init_freeable init/do_mounts.c prepare_namespace init/do_mounts.c mount_root_block In this function, the argument “root”, “rootfstype” are recognized,and call do_mount_root to mount the root Create the first process
Kernel source : init/main.c kernel_init
12 User space—prepare for init
The first process with task id 1 Root of the process tree Take over the orphan process Power off the system …… What’s in /sbin/init
14 systemd What is systemd?
• Sysvinit – userspace launch (PID 1) – Only one process at a time running – Simply starting the system and then going to sleep until the next reboot • Systemd – Default init in Fedora 15 and later Leonard Poettering (2009) – improve the software framework for expressing dependencies – allow more processing to be done concurrently or in parallel during system booting – reduce the computational overhead of the shell. Platform bootup
https://wiki.tizen.org/wiki/Porting_Guide
.target vs .service • .target; service grouping • .service; process run Parsing unit file – example (8/8)
• User awareness unit name = “System Initialization” • If emergency is running, wait • Run with local-fs.target, swap.target, sysinit.target.wants • Run after local-fs.target, swap.target, emergency.service, emergency.target • User can control service start and stop local-fs.target
/usr/lib/systemd/system/local-fs.target.wants opt.mount [Mount] What=/dev/mmcblk0p6 Where=/opt Type=ext4 Options=defaults Systemd other features
Demo What is systemd?
Systemd in Tizen System and service manager for tizen systemd Ver. 43 (download http://www.freedesktop.org/software/systemd/) Parallelizes service execution Socket and D-Bus activation for starting services and daemon on-demand starting of daemons Managing the service processes as a group using Linux cgroup Supporting automount points Snapshotting and restoring of services systemd architecture systemd architecture
• systemd Utility – monitoring and controlling systemd itself and its services – 'systemctl' developers can query or send control commend to the systemd service manager – 'systemd-journalctl' utility to see log message • systemd target – Tizen boot-up process is split up in various discrete steps and each step are grouped its unit using 'Target' unit to synchronize point – The boot-up process is highly parallelized in each target so that the order in which specific target units are reached in not deterministic • systemd daemon – system and service manager for Tizen platform – acts as init system – 'systemd' daemonruns as user session with '--user' option – 'systemd-journald' is a system service that collects and stores log data from the Kernel, from user processes via syslog or STDOUT/STDERR systemd architecture
systemd core manages all units such as service, socket, mount and so on, stores all log data. controlled by using systemd utility like 'systemctl' systemd library & Linux Kernel systemd requires to enable 'cgroup' and 'autofs' option in Kernel configuration It also depends on dbus and some libraries such as libnotify, libudev Platform bootup – sysinit.target
Early boot-up scripts Most of file system are mounted and systemd related daemons are launched
Kernel
dev-hugepages.mount local-fs.target sysinit.target dev-mqueue.mount -.mount proc-sys-fs- boot.mount binfmt_misc.automount csa.mount basic.target sys-fs-fuse-connections.mount fsck-root.service sys-kernel-config.mount media.mount opt-usr.mount bootmode.target sys-kernel-debug.mount sys-kernel-security.mount opt.mount systemd-ask-password- remount-rootfs.service multi-user.target console.path resize2fs-root.service systemd-binfmt.service systemd-remount-api-vfs.service systemd-journald.service var-run.mount graphical.target systemd-modules-load.service systemd-random-seed- socket.target load.service dbus.socket systemd-readahead-collect.service systemd-initctl.socket systemd-readahead-replay.service systemd-journald.socket systemd-sysctl.service systemd-shutdownd.socket systemd-tmpfiles-setup.service telnetd.socket udev-control.socket swap.target udev-kernel.socket Platform bootup – basic.target
Basic boot-up All necessary initialization for general purpose daemons are completed
Kernel
sysinit.target
basic.target opt-var-kdb-db-libsqlfs.service opt-var-kdb-db-smack-labels.service bootmode.target smack-default-labeling.service multi-user.target systemd-tmpfiles-clean.timer tizen-debug-level.service graphical.target udev-trigger.service udev.service vconf-setup.service Platform bootup – bootmote.target
Select boot mode If kernel boot parameter has ‘charger_detect_boot’, the platform boots up as charging mode Kernel
sysinit.target
basic.target
bootmode.target
multi-user.target bootmode-charging.service bootmode-graphical.service graphical.target Platform bootup – multi-user.target
Setup a multi-user system which is non-graphical support Launching platform infrastructure daemons (such as dbus, power manager, gps manager, telephony daemon, WRT security daemon, media server, systemd-related daemons) Kernel alarm-server.service avsystem.service sysinit.target bluetooth-address.service bluetooth-frwk-service.service basic.target bluetooth.service dbus.service dlog-main.service bootmode.target dlog-radio.service getty.target gps-manager.service multi-user.target media-server.service nfc-manager.service graphical.target power-manager.service pulseaudio.service secure-storage.service sensor-framework.service system-server.service systemd-ask-password-wall.path systemd-logind.service systemd-user-sessions.service telephony.service Platform bootup – graphical.target
Setup a graphical environment System user session for app privilege daemons such as Enlightenment (window manager) Special target for middleware & mobile service Kernel ac.service sysinit.target [email protected] [email protected] [email protected] basic.target xorg.target tizen-mobile-session.target bootmode.target xorg.service wrt-preinstall-widgets.service
multi-user.target core-efl.target boot-animation.service graphical.target cbhm.service tizen-middleware.target e17.service indicator.service calendar.service osp-app-service.service contacts-service.service quickpanel.service download-provider.service scim.service email.service starter.path msg-service.service xmodmap.service pushd.service xrdb.service sound-server.service Systemd parsing Platform bootup
systemd Control is moved from initramfs to systemd of Tizen platform Run hardware init and fs mount, etc services Bootup process run several units (.target) Different target can be run in parallel Many linux distributions adopt systemd as default Red Hat Enterprise Linux, CentOS, Fedora, Arch Linux, openSUSE Do not use daemon control script (/sbin/init, /etc/init.d/*, /etc/rc*.d) /usr/lib/systemd unit files: service, target, socket, device, mount, automount, path, snapshot, swap, timer systemd utilities: systemctl, notify, analyze, cgis, cgtop, logictl, journalctl, nspawn Parsing unit file – example (1/8) /usr/lib/systemd/system
target to parse
cat sysinit.target Parsing unit file – example (2/8)
Website http://www.freedesktop.org/wiki/software/systemd/ systemd download http://www.freedesktop.org/software/systemd/
manpage Parsing unit file – example (3/8)
Can search all function and unit, configuration of systemd
enter target index Parsing unit file – example (4/8)
target unit file Parsing unit file – example (5/8)
Description on unit file option Parsing unit file – example (6/8) Parsing unit file – example (7/8) Parsing unit file – example (8/8)
• User awareness unit name = “System Initialization” • If emergency is running, wait • Run with local-fs.target, swap.target, sysinit.target.wants • Run after local-fs.target, swap.target, emergency.service, emergency.target • User can control service start and stop Different Sessions
[Unit], [Service], [Install], [Socket], [Swap], [Mount], … example; telephony.service [Unit]; general options unit name = Telephony daemon Run after modem.service [Service]; process options Run telephony-daemon as main process [Install]; actual work of unit excute Create telephony.service symlink at multi-user.target.wants References
systemd official Site http://www.freedesktop.org/wiki/Software/systemd/ systemd FAQ (written by developer) http://0pointer.de/blog/projects/the-biggest-myths Homework
Finish porting Tizen to Odroid-U3 Submit a report about your porting procedure Reference http://nyx.skku.ac.kr/?page_id=201 for troubleshooting Acknowledgement
This project is partially sponsored by Tianjin Samsung Electronics Co., Ltd. Special thanks to SKKU Embedded Software Laboratory. This material is based on the lecture provided by them, and the credit goes to the original authors.