Linux Boot on Raspberry Pi Seminar on Linux

Linux Boot on Raspberry Pi Seminar on Linux based Embedded Systems Comnet – Aalto University Jonne Soininen Final Seminar – 13. 12. 2013

Objectives and Achievements • Objectives – Perform a hands-on study on Raspberry – • • Methods – Literature studies – Practical experiments with Raspberry Pi Performed experiments 1. Bare metal programming and printing 2. • Pi boot to Linux Describe the results in the seminar paper of ATAGs JTAG and GDB single-step debugging of the kernel boot Planned – but not carried out – Compilation and installation of Barebox bootloader • Achievements – One broken mouse • Yes, and innocent mouse was harmed – One broken USB-to-serial cable – My Raspberry Pi has seen the world • Multiple airport security guys examined it • “What do you mean this is a computer”? • I didn’t dare to take the cables as carry on… – But it didn’t see that much action – In the end, my family does not talk to me anymore…

Generic Embedded Boot Process • Setup – Every embedded So. C is different – Linux tries to be generic Ø Hardware has to be configured for Linux before boot • Generic boot sequence 1. 2. 3. • Hardware power-on/boot Bootloader Linux boot Linux expectations from hardware configuration (ARM) – Set registers • Register r 0 is zero • Register r 1 contains MACH_TYPE • Register r 2 contains ATAGs physical location – Configure hardware (memory/MMU, cpu speed, console port, …)

Raspberry Pi Boot Sequence - HW

Boot parameters Generic ARM Parameters • Registers • • • r 0 is zero r 1 contains MACH_TYPE r 2 contains ATAGs physical location • ATAGs • • Raspberry Pi Parameters Registers – r 0 is zero – r 1 is 3138 – r 2 is 0 x 100 ATAGs – ATAG_CORE • – ATAG_MEM • • ATAG Value ATAG CORE 0 x 54410001 ATAG_NONE 0 x 0000 ATAG_MEM 0 x 54410002 ATAG_RAMDISK 0 x 54410004 ATAG INITRD 2 0 x 54420005 ATAG CMDLINE 0 x 54410009 – All fields zero Start: 0 x 0 Size: 0 x 1 C 000000 ATAG_CMDLINE dmachans=0 x 7 f 35 bcm 2708_fb. fbwidth=656 bcm 2708_fb. fbheight=416 bcm 2708. board rev=0 xf bcm 2708. serial=0 xd 22 bc 7 d 3 smsc 95 xx. macaddr=B 8: 27: EB: 2 B: C 7: D 3 sdhci-bcm 27 08. emmc_clock_freq=10000 vc_mem. mem_base=0 x 1 ec 00000 vc_mem. mem_size=0 x 20000000 dwc_otg. lpm_enable=0 console=tty. AMA 0, 115200 kgdboc=tty. AMA 0, 115200 console=tty 1 root=/dev/mmcblk 0 p 2 rootfstype=ext 4 elevator=deadline rootwait – ATAG_NONE

Linux boot sequence

Early boot • Prints stuff like Uncompressing Linux. . . done, booting the kernel. [ 0. 000000] Booting Linux on physical CPU 0 [ 0. 000000] Initializing cgroup subsys cpu [ 0. 000000] Linux version 3. 6. 11 (jso@jso-Virtual. Box) (gcc version 4. 6. 3 (Ubuntu/Linaro 4. 6. 3 -1 ubuntu 5) ) #1 PREEMPT Sun Nov 10 21: 41: 09 3 [ 0. 000000] CPU: ARMv 6 -compatible processor [410 fb 767] revision 7 (ARMv 7), cr=00 c 5387 d [ 0. 000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache [ 0. 000000] Machine: BCM 2708

do_basic_setup / do_initcalls • do_basic_setup initializes built-in kernel module • • – Statically linked modules • The things that print: [ 0. 984766] NET: Registered protocol family 2 [ 0. 990016] TCP established hash table entries: 16384 (order: 5, 131072 bytes) do_initcalls does most of the work Calls the module initiators – The things are called sysctl_core_init (net/core/sysctl_net_core. c) inet_init (net/ipv 4/af_inet. c) af_unix_init (net/unix/af_unix. c) [ 0. 997746] TCP bind hash table entries: 16384 (order: 4, 65536 bytes) init_sunrpc (net/sunrpc_syms. c) [ 1. 004534] TCP: Hash tables configured (established 16384 bind 16384) default_rootfs (init/noinitramfs. c) sched_clock_syscore_init (arch/arm/kernel/sched_clock. c) [ 1. 011137] TCP: reno registered [ 1. 014389] UDP hash table entries: 256 (order: 0, 4096 bytes) timer_init_syscore_ops (arch/arm/kernel/time. c) [ 1. 020287] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) register_pmu_driver (arch/arm/kernel/perf_event. c) [ 1. 026946] NET: Registered protocol family 1 bcm_dmaman_drv_init (arch/arm/mach-bcm 2708/dma. c) [ 1. 031833] RPC: Registered named UNIX socket transport module. [ 1. 037878] RPC: Registered udp transport module. [ 1. 042602] RPC: Registered tcp transport module. [ 1. 047348] RPC: Registered tcp NFSv 4. 1 backchannel transport module. [ 1. 054422] bcm 2708_dma: DMA manager at f 2007000 • There are over 260 of these!
![init takes over • Last print outs [ [ 10. 671377] 12. 190930] 22. init takes over • Last print outs [ [ 10. 671377] 12. 190930] 22.](http://slidetodoc.com/presentation_image_h2/d4464282ed7cfcfc9f2670f6994e7820/image-9.jpg)
init takes over • Last print outs [ [ 10. 671377] 12. 190930] 22. 920568] 24. 077001] Freeing init memory: udevd[155]: starting EXT 4 -fs (mmcblk 0 p 2): 128 K version 175 re-mounted. Opts: (null) Raspbian GNU/Linux 7 raspberrypi tty. AMA 0 raspberrypi login:

Linux boot sequence

What was actually learned?

Thank you…
- Slides: 12