2017年11月17日 星期五

BeagleBone ramdisk booting

此為將filesystem 壓縮存到硬碟,開機時再解壓縮到RAM使用的開機方式,開機後RFS是 唯讀
目前RFS使用toybox建置的版本:zImage 及 uImage各為5.4MB、ramdisk.gz 43.81 MB ,最後SD卡 總和55MB 低於64 MB
實際進入系統後,RFS佔了128 MB的RAM

總結:原本系統需要128 MB級別的硬體儲存,改用ramdisk後,可用64 MB級別的硬體儲存,並用128 MB的RAM 實際開機使用
壓縮比大約55%
解壓縮時間大約4 秒

簡易心得:覺得網路上的資料零散,各篇照做都不行,結果各自吸收部分內容,拼湊起來就可以成功!?

ramdisk介紹
kernel 設置
ramdisk 步驟相關

Linux kernel 設置

先確認目前的kernel設置,如果有修改的話再重新build
  • CONFIG_BLK_DEV_INITRD 確認ramdisk功能開啟
  • CONFIG_RD_XXX 確認ramdisk允許的格式
  • CONFIG_INITRAMFS_COMPRESSION_NONE 之後用mkimage包uboot header時 就不再壓縮一次
  • CONFIG_BLK_DEV_RAM_SIZE 確認ramdisk 大小,這裡是16 MB
    • beaglebone RAM有512 MB,其中另一半256 MB給了shm (這256 MB不確定能不能調整)
    • CONFIG_BLK_DEV_RAM_COUNT = 16 => 16*16MB = 256 MB
    • 進去beaglebone看到/dev/ram有16個裝置,所以要調大的話必須維持總和256 MB,比如COUNT 4,size 64 MB 
  • CONFIG_INITRAMFS_SOURCE 本來是可以指向RFS的路徑,然後make kernel會產生一個cpio檔案及System.map,但還不知道如何使用
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_RD_GZIP=y
CONFIG_RD_BZIP2=y
CONFIG_RD_LZMA=y
CONFIG_RD_XZ=y
CONFIG_RD_LZO=y
CONFIG_INITRAMFS_COMPRESSION_NONE=y
# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set
# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set
# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
# CONFIG_INITRAMFS_COMPRESSION_XZ is not set
# CONFIG_INITRAMFS_COMPRESSION_LZO is not set
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=16384

製作RFS

因考慮POC的方便性,先用busybox製作RFS
並且要設定static library,就不用另外裝glibc
最後整個busybox 不到4MB,才能符合 小於等於16MB的要求 
PS :
  • 需要開機的/etc/inittab 再自行新增
  • linux kernel module 自行copy進去
  • RFS內不用再放kernel image 到/boot 及 /etc/fstab 不用再mount root路徑
mkdir /root/busybox
cd /root/busybox
mkdir bin sbin lib etc var opt proc sys mnt media root home run
ROOT=$PWD USE="make-symlinks static" armv7a-hardfloat-linux-gnueabihf-emerge --usepkgonly --oneshot sys-apps/busybox
# copy other files you need
tar cvzpf ../busybox.$(date +%Y%m%d).tar.gz .

製作ramdisk

  • 確保RFS 最大16 MB (與kernel config 有關)
  • 使用tarball 搬移RFS (保護symbolic link)
  • 要用mkimage 將uboot的header 也加入壓縮檔
    • 選擇不要壓縮 (與kernel config 有關)
    • 位址 0x88080000 (與uboot rdaddr參數有關)
dd if=/dev/zero of=/root/ramrfs bs=1M count=16
mke2fs -F ramrfs
mount -o loop ramrfs /mnt/ramrfs
tar zxvf busybox.$(date +%Y%m%d).tar.gz -C /mnt/ramrfs
umount /mnt/ramdisk/
gzip -9 ramrfs
mkimage -A arm -O linux -T ramdisk -C none -a 0x88080000 -n "ramdisk" -d ramrfs.gz ramdisk.gz

製作SD卡

1.SD卡要設置兩個磁區,p1 fat,p2 ext4
2.放置內容如下:
P1 : MLO及u-boot.img
P2 : boot 目錄底下放置dtb檔、zImage、uImage ?、及ramdisk.gz
zImage 及 uImage各為5.4MB、ramdisk.gz 1.3 MB ,最後SD卡 總和13MB 低於16 MB

uboot 指令修改

記得準備serial cap 接到beaglebone及PC才能debug
開機時用SD卡開機
1.開機時按下space 進入uboot
2.打指令printenv 確認目前uboot的設定 (如下)
因為我uboot是beaglebone 官方相關資源取得的,所以有預設許多uboot的參數
如果沒有這麼多參數預設的話,可參考http://blog.csdn.net/girlkoo/article/details/41258583 打指令
 Click here to expand...
3.經過一些嘗試及理解後,只要輸入下方3個指令去修改uboot
代表的意義分別是
  • 修改loadramdisk 讓uboot找到對的ramdisk file
  • 修改mmcboot 讓流程會去loadramdisk
  • 修改mmcloads 會去執行ramboot
setenv loadramdisk "load mmc 0:2 ${rdaddr} /boot/ramdisk.gz"
setenv mmcboot "mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};run envboot; if run loadimage; then run loadramdisk; run mmcloados; fi;fi;"
setenv mmcloados "run args_mmc; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then run ramboot; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;"
4.最後打指令boot 開機

開機畫面

switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
reading boot.scr
** Unable to read file boot.scr **
reading uEnv.txt
56 bytes read in 4 ms (13.7 KiB/s)
Loaded env from uEnv.txt
Importing environment from mmc0 ...
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
reading boot.scr
** Unable to read file boot.scr **
reading uEnv.txt
56 bytes read in 4 ms (13.7 KiB/s)
Loaded env from uEnv.txt
Importing environment from mmc0 ...
5615200 bytes read in 325 ms (16.5 MiB/s)
1347638 bytes read in 93 ms (13.8 MiB/s)
26179 bytes read in 22 ms (1.1 MiB/s)
Booting from ramdisk ...
Kernel image @ 0x82000000 [ 0x000000 - 0x55ae60 ]
## Loading init Ramdisk from Legacy Image at 88080000 ...
   Image Name:   ramdisk
   Created:      2017-11-16   1:45:31 UTC
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    1347574 Bytes = 1.3 MiB
   Load Address: 88080000
   Entry Point:  88080000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Ramdisk to 8feb7000, end 8ffffff6 ... OK
   Loading Device Tree to 8fead000, end 8feb6642 ... OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.8.13 (root@tux) (gcc version 4.9.4 (Gentoo 4.9.4p1.0, pie-0.6.4) ) #1 SMP Thu Jan 19 10:16:44 CST 2017
[    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=50c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine: Generic AM33XX (Flattened Device Tree), model: TI AM335xBeagleBone
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] AM335X ES2.1 (l2cache sgx neon )
[    0.000000] PERCPU: Embedded 9 pages/cpu @c0d95000 s14080 r8192 d14592 u36864
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 129792
[    0.000000] Kernel command line: console=ttyO0,115200n8 capemgr.enable_partno=BB-SPIDEV0 root=/dev/ram0 rw rootfstype=ext2
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] __ex_table already sorted, skipping sort
[    0.000000] allocated 1048576 bytes of page_cgroup
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] Memory: 511MB = 511MB total
[    0.000000] Memory: 506548k/506548k available, 17740k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf800000 - 0xbfe00000   (   6 MB)
[    0.000000]       .text : 0xc0008000 - 0xc083f340   (8413 kB)
[    0.000000]       .init : 0xc0840000 - 0xc0880700   ( 258 kB)
[    0.000000]       .data : 0xc0882000 - 0xc090a900   ( 547 kB)
[    0.000000]        .bss : 0xc090a900 - 0xc0984080   ( 486 kB)
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
[    0.000000] NR_IRQS:0 nr_irqs:0 0
[    0.000000] IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrupts
[    0.000000] Total of 128 interrupts on 1 active controller
[    0.000000] OMAP clockevent source: GPTIMER1 at 24000000 Hz
[    0.000000] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956ms
[    0.000000] OMAP clocksource: GPTIMER2 at 24000000 Hz
[    0.000000] Console: colour dummy device 80x30
[    0.000225] Calibrating delay loop... 993.47 BogoMIPS (lpj=969728)
[    0.029183] pid_max: default: 32768 minimum: 301
[    0.029320] Security Framework initialized
[    0.029377] Mount-cache hash table entries: 512
[    0.035183] Initializing cgroup subsys cpuacct
[    0.035204] Initializing cgroup subsys memory
[    0.035241] Initializing cgroup subsys blkio
[    0.035326] CPU: Testing write buffer coherency: ok
[    0.035705] CPU0: thread -1, cpu 0, socket -1, mpidr 0
[    0.035763] Setting up static identity map for 0x804d9e18 - 0x804d9e64
[    0.036668] Brought up 1 CPUs
[    0.036684] SMP: Total of 1 processors activated (993.47 BogoMIPS).
[    0.037451] devtmpfs: initialized
[    0.045864] omap_hwmod: wd_timer2: _wait_target_disable failed
[    0.097998] pinctrl core: initialized pinctrl subsystem
[    0.098127] rstctl core: initialized rstctl subsystem
[    0.098403] regulator-dummy: no parameters
[    0.098712] NET: Registered protocol family 16
[    0.099206] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.104741] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
[    0.105293] platform 49000000.edma: alias fck already exists
[    0.105309] platform 49000000.edma: alias fck already exists
[    0.105323] platform 49000000.edma: alias fck already exists
[    0.106038] OMAP GPIO hardware version 0.1
[    0.108396] gpio-rctrl rstctl.4: loaded OK
[    0.111674] No ATAGs?
[    0.111690] hw-breakpoint: debug architecture 0x4 unsupported.
[    0.112916] cpsw.0: No hwaddr in dt. Using 68:c9:0b:ed:0e:ed from efuse
[    0.112934] cpsw.1: No hwaddr in dt. Using 68:c9:0b:ed:0e:ef from efuse
[    0.120881] bio: create slab <bio-0> at 0
[    0.127053] edma-dma-engine edma-dma-engine.0: TI EDMA DMA engine driver
[    0.127319] vmmcsd_fixed: 3300 mV
[    0.128830] SCSI subsystem initialized
[    0.129064] usbcore: registered new interface driver usbfs
[    0.129135] usbcore: registered new interface driver hub
[    0.129320] usbcore: registered new device driver usb
[    0.130125] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[    0.131075] input: tps65217_pwr_but as /devices/ocp.3/44e0b000.i2c/i2c-0/0-0024/input/input0
[    0.132615] DCDC1: at 1500 mV
[    0.133481] vdd_mpu: 925 <--> 1325 mV at 1325 mV
[    0.134275] vdd_core: 925 <--> 1150 mV at 1125 mV
[    0.135116] LDO1: at 1800 mV
[    0.135902] LDO2: at 3300 mV
[    0.137412] LDO3: 1800 mV
[    0.138237] LDO4: at 3300 mV
[    0.138996] tps65217 0-0024: TPS65217 ID 0xe version 1.2
[    0.139432] omap_i2c 44e0b000.i2c: unable to select pin group
[    0.139889] omap_i2c 4819c000.i2c: bus 1 rev0.11 at 100 kHz
[    0.141272] omap_i2c 4819c000.i2c: unable to select pin group
[    0.141409] media: Linux media interface: v0.10
[    0.141472] Linux video capture interface: v2.00
[    0.141552] pps_core: LinuxPPS API ver. 1 registered
[    0.141560] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.141584] PTP clock support registered
[    0.141955] Advanced Linux Sound Architecture Driver Initialized.
[    0.142629] NetLabel: Initializing
[    0.142640] NetLabel:  domain hash size = 128
[    0.142647] NetLabel:  protocols = UNLABELED CIPSOv4
[    0.142712] NetLabel:  unlabeled traffic allowed by default
[    0.142860] Switching to clocksource gp_timer
[    0.173554] NET: Registered protocol family 2
[    0.174200] TCP established hash table entries: 4096 (order: 3, 32768 bytes)
[    0.174281] TCP bind hash table entries: 4096 (order: 4, 81920 bytes)
[    0.174378] TCP: Hash tables configured (established 4096 bind 4096)
[    0.174441] TCP: reno registered
[    0.174455] UDP hash table entries: 256 (order: 1, 12288 bytes)
[    0.174480] UDP-Lite hash table entries: 256 (order: 1, 12288 bytes)
[    0.174710] NET: Registered protocol family 1
[    0.175087] RPC: Registered named UNIX socket transport module.
[    0.175096] RPC: Registered udp transport module.
[    0.175103] RPC: Registered tcp transport module.
[    0.175109] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.175326] Trying to unpack rootfs image as initramfs...
[    0.176038] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.182564] Freeing initrd memory: 1312K
[    0.182881] hw perfevents: enabled with ARMv7 Cortex-A8 PMU driver, 5 counters available
[    0.183131] CPU PMU: attempt to register multiple PMU devices!
[    0.183155] arm-pmu: probe of arm-pmu failed with error -28
[    0.183467] omap2_mbox_probe: platform not supported
[    0.334696] VFS: Disk quotas dquot_6.5.2
[    0.334823] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.335516] NFS: Registering the id_resolver key type
[    0.335587] Key type id_resolver registered
[    0.335595] Key type id_legacy registered
[    0.335867] fuse init (API version 7.20)
[    0.336317] Btrfs loaded
[    0.336416] msgmni has been set to 991
[    0.337942] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
[    0.337959] io scheduler noop registered
[    0.337966] io scheduler deadline registered
[    0.337994] io scheduler cfq registered (default)
[    0.339118] tps65217-bl tps65217-bl: no platform data provided
[    0.339141] tps65217-bl: probe of tps65217-bl failed with error -22
[    0.339637] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.340968] omap_uart 44e09000.serial: did not get pins for uart0 error: -19
[    0.341243] 44e09000.serial: ttyO0 at MMIO 0x44e09000 (irq = 72) is a OMAP UART0
[    1.102252] console [ttyO0] enabled
[    1.106528] [drm] Initialized drm 1.1.0 20060810
[    1.118427] brd: module loaded
[    1.125193] loop: module loaded
[    1.128594] at24 0-0050: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
[    1.135848] at24 1-0054: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
[    1.143093] at24 1-0055: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
[    1.150406] at24 1-0056: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
[    1.157652] at24 1-0057: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
[    1.171542] bone-capemgr bone_capemgr.9: Baseboard: 'A335BNLT,,BBG115081683'
[    1.179024] bone-capemgr bone_capemgr.9: compatible-baseboard=ti,beaglebone-green
[    1.217147] bone-capemgr bone_capemgr.9: slot #0: No cape found
[    1.254252] bone-capemgr bone_capemgr.9: slot #1: No cape found
[    1.291361] bone-capemgr bone_capemgr.9: slot #2: No cape found
[    1.328470] bone-capemgr bone_capemgr.9: slot #3: No cape found
[    1.334686] bone-capemgr bone_capemgr.9: slot #4: specific override
[    1.341255] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 4
[    1.349266] bone-capemgr bone_capemgr.9: slot #4: 'Bone-LT-eMMC-2G,00A0,TexasInstrument,BB-BONE-EMMC-2G'
[    1.359347] bone-capemgr bone_capemgr.9: enabled_partno part_number 'BB-SPIDEV0', version 'N/A', prio '0'
[    1.369351] bone-capemgr bone_capemgr.9: slot #5: generic override
[    1.375816] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 5
[    1.383825] bone-capemgr bone_capemgr.9: slot #5: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV0'
[    1.393858] bone-capemgr bone_capemgr.9: loader: before slot-4 BB-BONE-EMMC-2G:00A0 (prio 1)
[    1.402697] bone-capemgr bone_capemgr.9: loader: check slot-4 BB-BONE-EMMC-2G:00A0 (prio 1)
[    1.411449] bone-capemgr bone_capemgr.9: initialized OK.
[    1.417019] bone-capemgr bone_capemgr.9: loader: before slot-5 BB-SPIDEV0:00A0 (prio 0)
[    1.425390] bone-capemgr bone_capemgr.9: loader: check slot-5 BB-SPIDEV0:00A0 (prio 0)
[    1.435040] OneNAND driver initializing
[    1.439938] usbcore: registered new interface driver cdc_ether
[    1.446097] usbcore: registered new interface driver rndis_host
[    1.452342] bone-capemgr bone_capemgr.9: loader: check slot-4 BB-BONE-EMMC-2G:00A0 (prio 1)
[    1.461087] bone-capemgr bone_capemgr.9: loader: after slot-5 BB-SPIDEV0:00A0 (prio 0)
[    1.469428] usbcore: registered new interface driver cdc_ncm
[    1.475379] bone-capemgr bone_capemgr.9: slot #5: Requesting part number/version based 'BB-SPIDEV0-00A0.dtbo
[    1.486107] usbcore: registered new interface driver cdc_acm
[    1.492045] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[    1.500411] Initializing USB Mass Storage driver...
[    1.505528] bone-capemgr bone_capemgr.9: slot #5: Requesting firmware 'BB-SPIDEV0-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[    1.519216] usbcore: registered new interface driver usb-storage
[    1.525498] USB Mass Storage support registered.
[    1.530362] bone-capemgr bone_capemgr.9: slot #5: dtbo 'BB-SPIDEV0-00A0.dtbo' loaded; converting to live tree
[    1.540830] musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
[    1.547305] bone-capemgr bone_capemgr.9: slot #5: #2 overlays
[    1.553736] mousedev: PS/2 mouse device common for all mice
[    1.561715] edma-dma-engine edma-dma-engine.0: allocated channel for 0:19
[    1.569476] lsm303dlhc_acc accelerometer driver: init
[    1.574879] edma-dma-engine edma-dma-engine.0: allocated channel for 0:18
[    1.582072] i2c-core: driver [lsm303dlhc_acc] using legacy suspend method
[    1.589190] i2c-core: driver [lsm303dlhc_acc] using legacy resume method
[    1.596611] lsm303dlhc_mag driver: init
[    1.600899] edma-dma-engine edma-dma-engine.0: allocated channel for 0:17
[    1.608124] lsm330_acc accelerometer driver: init
[    1.613113] edma-dma-engine edma-dma-engine.0: allocated channel for 0:16
[    1.620267] i2c-core: driver [lsm330_acc] using legacy suspend method
[    1.627019] i2c-core: driver [lsm330_acc] using legacy resume method
[    1.634460] bone-capemgr bone_capemgr.9: slot #5: Applied #2 overlays.
[    1.641337] bone-capemgr bone_capemgr.9: loader: done slot-5 BB-SPIDEV0:00A0 (prio 0)
[    1.649565] bone-capemgr bone_capemgr.9: loader: check slot-4 BB-BONE-EMMC-2G:00A0 (prio 1)
[    1.658371] lsm330_gyr: gyroscope sysfs driver init
[    1.663519] bone-capemgr bone_capemgr.9: loader: after slot-4 BB-BONE-EMMC-2G:00A0 (prio 1)
[    1.672833] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc0
[    1.680269] bone-capemgr bone_capemgr.9: slot #4: Requesting firmware 'cape-bone-2g-emmc1.dtbo' for board-name 'Bone-LT-eMMC-2G', version '00A0'
[    1.694029] i2c /dev entries driver
[    1.698613] pps_ldisc: PPS line discipline registered
[    1.704008] Driver for 1-wire Dallas network protocol.
[    1.709405] bone-capemgr bone_capemgr.9: slot #4: dtbo 'cape-bone-2g-emmc1.dtbo' loaded; converting to live tree
[    1.721185] omap_wdt: OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec
[    1.728780] device-mapper: ioctl: 4.23.1-ioctl (2012-12-18) initialised: dm-devel@redhat.com
[    1.737906] bone-capemgr bone_capemgr.9: slot #4: #2 overlays
[    1.744554] bone-capemgr bone_capemgr.9: slot #4: Applied #2 overlays.
[    1.751397] bone-capemgr bone_capemgr.9: loader: done slot-4 BB-BONE-EMMC-2G:00A0 (prio 1)
[    1.760068] cpuidle: using governor ladder
[    1.764362] cpuidle: using governor menu
[    1.768793] omap_hsmmc mmc.5: of_parse_phandle_with_args of 'reset' failed
[    1.775999] omap_hsmmc mmc.5: Failed to get rstctl; not using any
[    1.782724] edma-dma-engine edma-dma-engine.0: allocated channel for 0:25
[    1.789925] edma-dma-engine edma-dma-engine.0: allocated channel for 0:24
[    1.797238] mmc.5 supply vmmc_aux not found, using dummy regulator
[    1.804029] omap_hsmmc mmc.5: pins are not configured from the driver
[    1.838464] gpio-rctrl rstctl.4: gpio_rctrl_request eMMC_RSTn
[    1.844603] omap_hsmmc mmc.11: Got rstctl (gpio:#0 name eMMC_RSTn) label:eMMC_RSTn
[    1.852560] gpio-rctrl rstctl.4: gpio_rctrl_deassert eMMC_RSTn
[    1.858877] edma-dma-engine edma-dma-engine.0: allocated channel for 0:3
[    1.865958] edma-dma-engine edma-dma-engine.0: allocated channel for 0:2
[    1.873303] mmc.11 supply vmmc_aux not found, using dummy regulator
[    1.879954] omap_hsmmc mmc.11: pins are not configured from the driver
[    1.914689] pinctrl-single 44e10800.pinmux: pin 44e10854 already requested by 44e10800.pinmux; cannot claim for gpio-leds.8
[    1.926363] pinctrl-single 44e10800.pinmux: pin-21 (gpio-leds.8) status -22
[    1.933644] pinctrl-single 44e10800.pinmux: could not request pin 21 on device pinctrl-single
[    1.942583] leds-gpio gpio-leds.8: pins are not configured from the driver
[    1.950492] ledtrig-cpu: registered to indicate activity on CPUs
[    1.957055] edma-dma-engine edma-dma-engine.0: allocated channel for 0:36
[    1.964255] omap-sham 53100000.sham: hw accel on OMAP rev 4.3
[    1.971614] omap-aes 53500000.aes: OMAP AES hw accel rev: 3.2
[    1.977829] edma-dma-engine edma-dma-engine.0: allocated channel for 0:5
[    1.984980] edma-dma-engine edma-dma-engine.0: allocated channel for 0:6
[    1.994904] usbcore: registered new interface driver usbhid
[    2.000823] usbhid: USB HID core driver
[    2.005071] mmc0: host does not support reading read-only switch. assuming write-enable.
[    2.014475] ashmem: initialized
[    2.017946] mmc0: new high speed SDHC card at address 0007
[    2.023959] logger: created 256K log 'log_main'
[    2.029132] mmcblk0: mmc0:0007 SD08G 7.42 GiB
[    2.034031] logger: created 256K log 'log_events'
[    2.039764] logger: created 256K log 'log_radio'
[    2.044734]  mmcblk0: p1 p2
[    2.048119] logger: created 256K log 'log_system'
[    2.055680] TCP: cubic registered
[    2.059302] NET: Registered protocol family 10
[    2.064741] NET: Registered protocol family 17
[    2.069688] Key type dns_resolver registered
[    2.074307] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[    2.082421] ThumbEE CPU extension supported.
[    2.086929] Registering SWP/SWPB emulation handler
[    2.092642] registered taskstats version 1
[    2.146844] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
[    2.153262] davinci_mdio 4a101000.mdio: detected phy mask fffffffe
[    2.159843] mmc1: BKOPS_EN bit is not set
[    2.164951] libphy: 4a101000.mdio: probed
[    2.169200] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver SMSC LAN8710/LAN8720
[    2.178905] Detected MACID = 68:c9:0b:ed:0e:ed
[    2.183492] cpsw 4a100000.ethernet: NAPI disabled
[    2.190269] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:01 UTC (946684801)
[    2.200310] mmc1: new high speed MMC card at address 0001
[    2.210187] ALSA device list:
[    2.213347]   No soundcards found.
[    2.216973] mmcblk1: mmc1:0001 P1XXXX 3.60 GiB
[    2.221962] mmcblk1boot0: mmc1:0001 P1XXXX partition 1 2.00 MiB
[    2.228714] mmcblk1boot1: mmc1:0001 P1XXXX partition 2 2.00 MiB
[    2.236013]  mmcblk1: p1 p2
[    2.241295]  mmcblk1boot1: unknown partition table
[    2.248209]  mmcblk1boot0: unknown partition table
[    2.253661] RAMDISK: gzip image found at block 0
[    2.550323] VFS: Mounted root (ext2 filesystem) on device 1:0.
[    2.557626] devtmpfs: mounted
[    2.561156] Freeing init memory: 256K
-----------Run rcS-------
Gentoo login: root
login[112]: root login on 'ttyO0'
# rm /etc/mtab
# ln -s /proc/mounts /etc/mtab
# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                15.5M      3.5M     11.2M  24% /
devtmpfs                247.3M         0    247.3M   0% /dev

遇過的問題

1.ramdisk invalid format
回頭看uboot訊息,應該會看到read ramdisk file failed 
再確認 loadramdisk 能不能執行,可能是ramdisk 路徑錯誤,或者要載入的位址有問題
網路上看別人都是load mmc 0 就能運作
但我不知道為甚麼要設定成load mmc 0:2才行
setenv loadramdisk "load mmc 0:2 ${rdaddr} /boot/ramdisk.gz"
2.Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
找不到filesystem
表示boot指令沒有代到ramdisk
回頭確認一下uboot指令 要執行到 bootz ${loadaddr} ${rdaddr} ${fdtaddr}
正確的uboot訊息會有
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Ramdisk to 8feb7000, end 8ffffff6 ... OK
   Loading Device Tree to 8fead000, end 8feb6642 ... OK

3.Kernel panic - not syncing: No init found 
回頭看Linux訊息,應該會看到一堆memory的錯誤訊息
代表ramdisk解壓縮有問題,可能是size 或者 檔案格式問題 (這邊就是對照前面Linux 設置的部分)

後續

增加ramdisk大小

有兩種方式,我只先試第一種
1.直接調整Linux Kernel config 的 CONFIG_BLK_DEV_RAM_COUNT 及 CONFIG_BLK_DEV_RAM_SIZE ,重新build kernel即可換成更大的ramdisk
注意 CONFIG_BLK_DEV_RAM_COUNT * CONFIG_BLK_DEV_RAM_SIZE 小於等於 beaglebone total RAM 256 MB
不一定要2的指數倍率
2.修改uboot內核啟動參數ramdisk_size
Gentoo login: root
login[97]: root login on 'ttyO0'
# ls
# rm /etc/mtab
# ln -s /proc/mounts /etc/mtab
# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                59.1M      4.6M     51.5M   8% /
devtmpfs                247.3M         0    247.3M   0% /dev

CONFIG_BLK_DEV_RAM_COUNT
CONFIG_BLK_DEV_RAM_SIZE
1616384
832768
465536
2131072
1262144

修改uEnv.txt

將剛剛手動修改的uboot參數改成uEnv.txt 餵進去,就不用每次都要進去uboot改
當然也可以用saveenv 覆蓋舊的uboot參數,但是怕改爛
uEnv.txt放到SD卡的p1磁區 ( 跟 MLO 和uboot img一起)
loadramdisk=load mmc 0:2 ${rdaddr} /boot/ramdisk.gz
mmcboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};run envboot; if run loadimage; then run loadramdisk; run mmcloados; fi;fi;
mmcloados=run args_mmc; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then run ramboot; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fifielse bootz; fi;

替換掉busybox

剛剛照著流程換成toybox建置的RFS是可以套這個流程的
用free可以看到,memory已經被吃了約1/4用來開機
(none) login: root
login[1199]: root logged in on /dev/ttyO0
# df -h
Filesystem     Size  Used Avail Use% Mounted on
/dev/root      124M  117M  6.7M  95% /
devtmpfs        10M     0   10M   0% /dev
tmpfs           50M  152K   49M   1% /run
shm            248M     0  248M   0% /dev/shm
cgroup_root     10M     0   10M   0% /sys/fs/cgroup
/dev/mmcblk0p2 7.0G   58M  7.0G   1% /boot
# toybox free
                total        used        free      shared     buffers
Mem:        520310784   154796032   365514752           0      528384
-/+ buffers/cache:      154267648   366043136
Swap:               0           0           0

Copy to eMMC

  1. 參考 之前的文章 format /dev/mmcblk1
  2. mount sd卡 ( 因為ramdisk開機 預設沒有去mount sd卡的磁區)
  3. mount emmc
  4. copy檔案
mount /dev/mmcblk0p2 /boot
mount /dev/mmcblk0p1 /boot/boot/uboot
mount /dev/mmcblk1p2 /mnt
mkdir -p /mnt/boot/uboot
mount /dev/mmcblk1p1 /mnt/boot/uboot
cd /boot
cp -a boot /mnt
sync
umount /dev/mmcblk1*
重開機時,遇到不能開機成功
發現uboot 參數不太一樣..
手動測試之後發現修改兩個,就可以開機成功了,也可以改到uEnv.txt內
setenv loadimage "load mmc ${bootpart} ${loadaddr} ${bootdir}/zImage"
setenv loadramdisk "load mmc ${bootpart} ${rdaddr} /boot/ramdisk.gz"
用df檢查磁區
可以看到 /dev/mmcblk0p2,3.5GB 內只用了12.2MB 放ramdisk.gz 及zImage 等等的檔案
Gentoo login: root
login[96]: root login on 'ttyO0'
# rm /etc/mtab
# ln -s /proc/mounts /etc/mtab
# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                62.0M      4.6M     54.2M   8% /
devtmpfs                247.3M         0    247.3M   0% /dev
# mount /dev/mmcblk0p2 /mnt
# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                62.0M      4.6M     54.2M   8% /
devtmpfs                247.3M         0    247.3M   0% /dev
/dev/mmcblk0p2            3.5G     12.2M      3.3G   0% /mnt
PS: 這邊因為toybox 少了一些指令,copy過程沒辦法順利完成,改回用busybox測試
換回toybox後
(none) login: root
login[1194]: root logged in on /dev/ttyO0
# df -h
Filesystem     Size  Used Avail Use% Mounted on
/dev/root      124M  106M   18M  86% /
devtmpfs        10M     0   10M   0% /dev
tmpfs           50M  140K   49M   1% /run
shm            248M     0  248M   0% /dev/shm
cgroup_root     10M     0   10M   0% /sys/fs/cgroup
# mount /dev/mmcblk0p2 /mnt
# df -h
Filesystem     Size  Used Avail Use% Mounted on
/dev/root      124M  106M   18M  86% /
devtmpfs        10M     0   10M   0% /dev
tmpfs           50M  144K   49M   1% /run
shm            248M     0  248M   0% /dev/shm
cgroup_root     10M     0   10M   0% /sys/fs/cgroup
/dev/mmcblk0p2 3.4G   55M  3.3G   2% /mnt

沒有留言:

張貼留言

NoSQL Redis intro

Redis是一個使用ANSI C編寫的開源、支援網路、基於記憶體、可選永續性的鍵值對儲存資料庫。 支援rdb 及aof 兩種儲存方式 From  https://zh.wikipedia.org/wiki/Redis Redis 目前擁有兩種資料...