1. 程式人生 > >[Linux驅動煉成記] 05-儲存eMMC配置

[Linux驅動煉成記] 05-儲存eMMC配置

嵌入式開發環境

  • 主控晶片: Amlogic A113X
  • Linux Kernel : 4.9
  • eMMc : 金士頓 4GB
    lADPDgQ9qSqDpHLNCADNBvY_1782_20482.jpg
  1. A113X主控晶片
  2. 金士頓的4GB eMMC
  3. 海力士256M DDR
  4. 博通WIFI模組 AP6212

支援eMMC

現有專案儲存需要由Nand Flash換成eMMC

eMMC介紹

eMMC (Embedded Multi Media Card) 為MMC協會所訂立的,eMMC 相當於 NandFlash+主控IC ,對外的介面協議與SD、TF卡一樣,主要是針對手機或平板電腦等產品的內嵌式儲存器標準規格。eMMC的一個明顯優勢是在封裝中集成了一個控制器,它提供標準介面並管理快閃記憶體,使得手機廠商就能專注於產品開發的其它部分,並縮短向市場推出產品的時間。這些特點對於希望通過縮小光刻尺寸和降低成本的NAND供應商來說,同樣的重要。1

原廠補丁介紹

原廠主要提供3個補丁: uboot,kernel,rootfs

  • kernel改動如下
    • 禁用nand flash
    • 使能eMMC
+++ b/arch/arm64/boot/dts/amlogic/xxx.dts
@@ -60,7 +60,7 @@
 	mtd_nand {
 		compatible = "amlogic, aml_mtd_nand";
 		dev_name = "mtdnand";
-		status = "okay";
+		status = "disable";
 		reg = <0x0 0xFFE07800 0x0 0x200>;
 		interrupts = <	0 34 1 >;
 		pinctrl-names = "nand_rb_mod","nand_norb_mod", "nand_cs_only";
@@ -465,7 +465,7 @@
 		};
 	};
 	sd_emmc_c: 
[email protected]
{ - status = "disabled"; + status = "okay"; compatible = "amlogic, meson-aml-mmc"; reg = <0x0 0xffe07000 0x0 0x2000>; interrupts = <0 218 1>; @@ -629,7 +629,7 @@ system:system { pname = "system"; - size = <0x0 0x80000000>; + size = <0x0 0x82000000>; mask = <1>; }; cache:cache -- 1.9.1
  • 記憶體大小配置
	[email protected] {
		device_type = "memory";
		linux,usable-memory = <0x0 0x000000 0x0 0x10000000>;
	};

這個很重要,記憶體大小不匹配,會造成核心崩潰,由於這點排除了將近3h

  • 檔案系統主由buildroot配置編譯,主要改動如下:
//分割槽格式又ubifs改為ext2 
-BR2_TARGET_ROOTFS_INITRAMFS_LIST="board/amlogic/common/initramfs/initramfs-49/ramfslist-32-ubi-release"
+BR2_TARGET_ROOTFS_INITRAMFS_LIST="board/amlogic/common/initramfs/initramfs-49/ramfslist-32-ext2"
-BR2_TARGET_UBOOT_AMLOGIC_BOOTARGS="root=/dev/ubi0_0 rootfstype=ubifs init=/sbin/init"
+BR2_TARGET_UBOOT_AMLOGIC_BOOTARGS="root=/dev/system rootfstype=ext4 init=/sbin/init
問題點

打完原提供的補丁之後,編譯韌體燒錄,系統進入檔案系統提示:

[    [email protected]] meson-mmc: add_emmc_partition
[    [email protected]] meson-mmc: [mmcblk0p01]           bootloader  offset 0x000000000000, size 0x000000400000 
[    [email protected]] meson-mmc: [mmcblk0p02]             reserved  offset 0x000002400000, size 0x000004000000 
[    [email protected]] meson-mmc: [mmcblk0p03]                cache  offset 0x000006c00000, size 0x000020000000 
[    [email protected]] meson-mmc: [mmcblk0p04]                  env  offset 0x000027400000, size 0x000000800000 
[    [email protected]] meson-mmc: [mmcblk0p05]                 logo  offset 0x000028400000, size 0x000002000000 
[    [email protected]] meson-mmc: [mmcblk0p06]             recovery  offset 0x00002ac00000, size 0x000002000000 
[    [email protected]] meson-mmc: [mmcblk0p07]                  rsv  offset 0x00002d400000, size 0x000000800000 
[    [email protected]] meson-mmc: [mmcblk0p08]                  tee  offset 0x00002e400000, size 0x000000800000 
[    [email protected]] meson-mmc: [mmcblk0p09]                crypt  offset 0x00002f400000, size 0x000002000000 
[    [email protected]] meson-mmc: [mmcblk0p10]                 misc  offset 0x000031c00000, size 0x000002000000 
[    [email protected]] meson-mmc: [mmcblk0p11]            instaboot  offset 0x000034400000, size 0x000000400000 
[    [email protected]] meson-mmc: [mmcblk0p12]                 boot  offset 0x000035000000, size 0x000002000000 
[    [email protected]] meson-mmc: [mmcblk0p13]               system  offset 0x000037800000, size 0x000082000000 
[    [email protected]] meson-mmc: [mmcblk0p14]                 data  offset 0x0000ba000000, size 0x000028000000 
[    [email protected]] card key: card_blk_probe.
[    [email protected]] emmc_key_init:183 emmc key lba_start:0x12020,lba_end:0x12220
[    [email protected]] emmc key: emmc_key_init:205 ok.
[    [email protected]] meson-mmc: amlmmc_dtb_init: register dtb chardev[    [email protected]] meson-mmc: amlmmc_dtb_init: register dtb chardev OK
[    [email protected]] meson-mmc: Exit aml_emmc_partition_ops OK.
[    [email protected]] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[    [email protected]] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[    [email protected]] xhci-hcd xhci-hcd.0.auto: hcc params 0x0220f664 hci version 0x100 quirks 0x02010010
[    [email protected]] xhci-hcd xhci-hcd.0.auto: irq 26, io mem 0xff500000
[    [email protected]] hub 1-0:1.0: USB hub found
[    [email protected]] hub 1-0:1.0: 1 port detected
[    [email protected]] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[    [email protected]] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2
[    [email protected]] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    [email protected]] hub 2-0:1.0: USB hub found
[    [email protected]] hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
[    [email protected]] platform ff642000.audiobus:loopback: Can't retrieve tdmin_mpll clock
[    [email protected]] if use extern loopback, pls set datalb-lane-mask-in
[    [email protected]] parse loopback:,       lb mode:0
[    [email protected]]        datain_src:4, datain_chnum:8, datain_chumask:3f
[    [email protected]]        datalb_src:2, datalb_chnum:2
[    [email protected]]        datalb_chswap:0x0,datalb_chumask:3
[    [email protected]] aml_pdm_probe
[    [email protected]] aml_pdm_dai_probe
[    [email protected]] aml_dai_set_tdm_sysclk freq(12288000), mpll/mclk(2)
[    [email protected]] aml_dai_set_tdm_slot(), txmask(0x3), rxmask(0x3)
[    [email protected]]        slots(2), slot_width(32), lanes(1)
[    [email protected]] asoc aml_dai_set_tdm_fmt, 0x4014, ffffffc00cccd118, id(0), clksel(0)
[    [email protected]] pad clk ctl value:0
[    [email protected]] sclk_ph0 (pad) clk ctl set:0
[    [email protected]] master_mode(1), binv(0), finv(0) out_skew(1), in_skew(3)
[    [email protected]] asoc-aml-card auge_sound: multicodec <-> TDM-A mapping ok
[    [email protected]] aml_dai_set_tdm_sysclk freq(12288000), mpll/mclk(2)
[    [email protected]] aml_dai_set_tdm_slot(), txmask(0x3), rxmask(0x3)
[    [email protected]]        slots(2), slot_width(32), lanes(1)
[    [email protected]] asoc aml_dai_set_tdm_fmt, 0x4001, ffffffc00cccd318, id(1), clksel(1)
[    [email protected]] pad clk ctl value:3
[    [email protected]] sclk_ph0 (pad) clk ctl set:3
[    [email protected]] master_mode(1), binv(0), finv(0) out_skew(1), in_skew(3)
[    [email protected]] asoc-aml-card auge_sound: multicodec <-> TDM-B mapping ok
[    [email protected]] aml_dai_set_tdm_sysclk freq(12288000), mpll/mclk(2)
[    [email protected]] aml_dai_set_tdm_slot(), txmask(0x3), rxmask(0x3)
[    [email protected]]        slots(2), slot_width(32), lanes(2)
[    [email protected]] tas575x_set_dai_fmt, format:0x4011
[    [email protected]] asoc aml_dai_set_tdm_fmt, 0x4011, ffffffc00cccd618, id(2), clksel(2)
[    [email protected]] pad clk ctl value:3
[    [email protected]] sclk_ph0 (pad) clk ctl set:3
[    [email protected]] master_mode(1), binv(0), finv(0) out_skew(1), in_skew(3)
[    [email protected]] asoc-aml-card auge_sound: tas575x <-> TDM-C mapping ok
[    [email protected]] aml_pdm_pcm_new dai->name: ff642000.audiobus:pdm dai->id: 0
[    [email protected]] asoc-aml-card auge_sound: dummy <-> ff642000.audiobus:pdm mapping ok
[    [email protected]] snd_card_add_kcontrols card:ffffffc00d1b9818
[    [email protected]] aml_vrtc rtc: setting system clock to 2015-01-01 00:00:05 UTC (1420070405)
[    [email protected]] dwc_otg: usb0: type: 2 speed: 0, config: 0, dma: 0, id: 0, phy: ffe09000, ctrl: 0
[    [email protected]] dwc_otg: Core Release: 3.10a
[    [email protected]] dwc_otg: Setting default values for core params
[    [email protected]] dwc_otg: curmode: 0, host_only: 0
[    [email protected]] dwc_otg: Using Buffer DMA mode
[    [email protected]] dwc_otg: OTG VER PARAM: 1, OTG VER FLAG: 1
[    [email protected]] dwc_otg: Working on port type = SLAVE
[    [email protected]] dwc_otg: Dedicated Tx FIFOs mode
[    [email protected]] cpucore_cooling_register, max_cpu_core_num:4
[    [email protected]] gxbb_pm: enter meson_pm_probe!
[    [email protected]] gxbb_pm: meson_pm_probe done
[    3.24126    [email protected]] meson_uart ff803000.serial: ttyS0 use xtal(8M) 24000000 change 115200 to 115200
[    [email protected]] Freeing unused kernel memory: 4480K
[    [email protected]] Failed to execute /init (error -2) //-2 返回值代表資料夾不存在
[    [email protected]] meson_uart ff803000.serial: ttyS0 use xtal(8M) 24000000 change 115200 to 115200
mkdir: can't create directory '/dev/pts': File exists
can't run '/etc/init.d/rcS': No such file or directory
can't open /dev/null: No such file or directory
can't open /dev/null: No such file or directory
can't open /dev/null: No such file or directory
can't open /dev/null: No such file or directory
can't open /dev/null: No such file or directory
  • 看到Failed to execute /init (error -2)參考2,可以確定返回值的含義3

  1. NorFlash、NandFlash、eMMC比較區別 ↩︎

  2. Linux init failures now easier to debug ↩︎

  3. Failed to execute /init ↩︎