- 其他启动规则:
- 如何启动分区中有recovery.elf, 会优先启动recovery系统(待验证)->[2016-01-02]已更新
- 如果recovery系统已经运行,那么要进入正常系统之前,recovery系统会往/sys/module/bcm2709/parameters/reboot_part中写值,以防止系统重启后进入的还是recovery的系统(待验证)->[2016-01-02]已更新
- 从上面的代码可以看出,分区63用于关机,不能作为启动分区
- 再看看开机log(串口log), 找一根串口线(TTL电平), raspberry pi 的GPIO口: 6 – GND, 8 – TX, 10 – RX。log如下:
Uncompressing Linux... done, booting the kernel. ? Welcome to the rescue system recovery login: Uncompressing Linux... done, booting the kernel. [ 0.000000] Booting Linux on physical CPU 0xf00 [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 3.18.7-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] Machine model: Raspberry Pi 2 Model B [ 0.000000] cma: Reserved 8 MiB at 0x3c800000 [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] [bcm2709_smp_init_cpus] enter (8620->f3003010) [ 0.000000] [bcm2709_smp_init_cpus] ncores=4
从”Welcome to the rescue system”和”Recovery login”, 这时进入的时recovery的系统。同时由显示屏上显示的界面也印证了第一次开机最先进入的是recovery系统。如果这时用启没有按键盘上的shift键,一段时间后会进入正常的系统。
- 启动盘的制作
在Windows下,按照NOOBS_lite_v1.5/INSTRUCTIONS-README.txt的方法,使用SD formatter进行format,SD最开始的4MB空间会被保留,也就是说第一个分区是从4MB开始的,在Linux下使用fdisk进行分区,最开始会保留1MB的空间。
最重要的一点:第一个分区一定要标记为FAT32分区,也是就type为0xb,并且将该分区格式化成FAT32文件系统否则无法开机。
如果不想使用NOOBS作启动系统,可以将recovery.img或者recovery7.img(RPi 2B)和recovery.rfs替换掉。
Command (m for help): p Disk /dev/sdb: 7948 MB, 7948206080 bytes 245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x4187c4d3 Device Boot Start End Blocks Id System /dev/sdb1 2048 231423 114688 b W95 FAT32 /dev/sdb2 231424 460799 114688 83 Linux /dev/sdb3 460800 985087 262144 83 Linux
[2016-01-02更新] 原来并不是我想的那样,先看一下分区表:
Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes 4 heads, 16 sectors/track, 486192 cylinders, total 31116288 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00080214 Device Boot Start End Blocks Id System /dev/mmcblk0p1 8192 1679687 835748 e W95 FAT16 (LBA) /dev/mmcblk0p2 1687552 31050751 14681600 85 Linux extended /dev/mmcblk0p3 31050752 31116287 32768 83 Linux /dev/mmcblk0p5 1695744 2744319 524288 83 Linux /dev/mmcblk0p6 2752512 2875391 61440 c W95 FAT32 (LBA) /dev/mmcblk0p7 2883584 31049727 14083072 83 Linux Command (m for help):
/dev/mmcblk0p1 存放的是recovery系统启动所需要的文件:bootcode.bin, recovery.elf, recovery7.img, recovery.rfs, recovery.cmdline.
而/dev/mmcblk0p6存放的是raspbian系统启动所需的文件:bootcode.bin, config.txt, start.elf, fixup.dat, kernel7.img, cmdline.txt
所以系统第一次开机的时候进入recovery系统,recovery系统更新PM_RSTS寄存器,通知CPU重启后加载raspbian系统的boot分区。由于PM_RSTS寄存器系统重启时数据不丢失,所以在raspbian系统里面输入reboot的时候系统重启加载的是raspbian系统boot分区所在的代码。
相关的参考文档:
- https://www.raspberrypi.org/documentation/installation/noobs.md
- https://github.com/raspberrypi/noobs
- https://github.com/raspberrypi/noobs/issues/71
- https://github.com/raspberrypi/noobs/commit/acc5ec4d79de20930d1a93eda9954b108abe08f3
- https://github.com/raspberrypi/noobs/wiki
- https://github.com/raspberrypi/noobs/wiki/Standalone-partitioning-explained