【TINY4412】U-BOOT移植笔记:(8)SD卡驱动
宿主机 : 虚拟机 Ubuntu 16.04 LTS / X64
目标板[底板]: Tiny4412SDK - 1506
目标板[核心板]: Tiny4412 - 1412
U-BOOT版本: 2017.03
交叉编译器: gcc-arm-none-eabi-5_4-2016q3
日期: 2017-5-13 22:31:52
作者: SY
修改内容
git diff 304c30 807828
diff --git a/arch/arm/dts/exynos4412-tiny4412.dts b/arch/arm/dts/exynos4412-tiny4412.dts
index 2595016..96ec2c2 100644
--- a/arch/arm/dts/exynos4412-tiny4412.dts
+++ b/arch/arm/dts/exynos4412-tiny4412.dts
@@ -15,13 +15,72 @@
compatible = "samsung,tiny4412", "samsung,exynos4412";
chosen {
+ bootargs = "";
stdout-path = "serial0";
};
aliases {
serial0 = "/serial@13800000";
console = "/serial@13800000";
+
+ mmc0 = "/sdhci@12530000";
+ mmc1 = "/dwmmc@12550000";
};
+ serial@13800000 {
+ compatible = "samsung,exynos4210-uart";
+ status = "okay";
+ };
+
+ serial@13810000 {
+ compatible = "samsung,exynos4210-uart";
+ status = "disabled";
+ };
+
+ serial@13820000 {
+ compatible = "samsung,exynos4210-uart";
+ status = "disabled";
+ };
+
+ serial@13830000 {
+ compatible = "samsung,exynos4210-uart";
+ status = "disabled";
+ };
+
+ serial@13840000 {
+ compatible = "samsung,exynos4210-uart";
+ status = "disabled";
+ };
+ sdhci@12510000 {
+ compatible = "samsung,exynos4412-sdhci";
+ status = "disabled";
+ };
+
+ sdhci@12520000 {
+ compatible = "samsung,exynos4412-sdhci";
+ status = "disabled";
+ };
+
+ sdhci@12530000 {
+ compatible = "samsung,exynos4412-sdhci";
+ samsung,bus-width = <4>;
+ samsung,timing = <1 2 3>;
+ cd-gpios = <&gpk2 2 0>;
+ };
+
+ sdhci@12540000 {
+ compatible = "samsung,exynos4412-sdhci";
+ status = "disabled";
+ };
+
+ dwmmc@12550000 {
+ samsung,bus-width = <8>;
+ samsung,timing = <2 1 0>;
+ samsung,removable = <0>;
+ fifoth_val = <0x203f0040>;
+ bus_hz = <400000000>;
+ div = <0x3>;
+ index = <4>;
+ };
};
diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index 2cb27a2..886cf13 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -172,6 +172,7 @@ clbss_l:cmp r0, r1 /* while not at end of BSS */
#if ! defined(CONFIG_SPL_BUILD)
bl coloured_LED_init
bl red_led_on
+ bl led_on_2
#endif
/* call board_init_r(gd_t *id, ulong dest_addr) */
mov r0, r9 /* gd_t */
diff --git a/arch/arm/mach-exynos/dmc_init_exynos4412.c b/arch/arm/mach-exynos/dmc_init_exynos4412.c
index 938348a..361eb3a 100644
--- a/arch/arm/mach-exynos/dmc_init_exynos4412.c
+++ b/arch/arm/mach-exynos/dmc_init_exynos4412.c
@@ -213,6 +213,7 @@ void mem_ctrl_init(int reset)
#endif
#endif
+#ifdef CONFIG_DEBUG_UART
printascii("[SPL] DDR3 SDRAM配置:\n");
printascii("timingref "); printhex8(mem.timingref); printascii("\n");
printascii("timingrow "); printhex8(mem.timingrow); printascii("\n");
@@ -229,6 +230,7 @@ void mem_ctrl_init(int reset)
printascii("memconfig1 "); printhex8(mem.memconfig1); printascii("\n");
printascii("dll_resync "); printhex8(mem.dll_resync); printascii("\n");
printascii("dll_on "); printhex8(mem.dll_on); printascii("\n");
+#endif
/* DMC0 */
dmc = (struct exynos4_dmc *)samsung_get_base_dmc_ctrl();
@@ -238,7 +240,8 @@ void mem_ctrl_init(int reset)
dmc = (struct exynos4_dmc *)(samsung_get_base_dmc_ctrl()
+ DMC_OFFSET);
dmc_init(dmc);
-
+
+#ifdef CONFIG_DEBUG_UART
{
printascii("[SPL] DDR3 SDRAM测试:\n");
@@ -265,6 +268,8 @@ void mem_ctrl_init(int reset)
printascii("测试结束\n");
}
+#endif
+
}
void Test_SDRAM(unsigned long addr, unsigned long value)
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index ba928e0..531c800 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -126,7 +126,6 @@ static int board_uart_init(void)
{
#ifndef CONFIG_PINCTRL_EXYNOS
int err, uart_id, ret = 0;
-
for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) {
err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE);
if (err) {
diff --git a/include/configs/tiny4412.h b/include/configs/tiny4412.h
index 420e718..6ed0b16 100644
--- a/include/configs/tiny4412.h
+++ b/include/configs/tiny4412.h
@@ -17,10 +17,13 @@
/* DEBUG UART */
#if ! defined(CONFIG_SPL_BUILD)
- /* U-BOOT阶段调试输出 */
- #define DEBUG
+#if 0
+ /* U-BOOT DEBUG */
+ #define DEBUG
+#endif
#else
- /* SPL阶段调试输出 */
+#if 0
+ /* SPL DEBUG */
#define CONFIG_DEBUG_UART 1
#define CONFIG_SPL_SERIAL_SUPPORT 1
#define CONFIG_SPL_GPIO_SUPPORT 1
@@ -28,6 +31,10 @@
#define CONFIG_DEBUG_UART_BASE 0x13800000
#define CONFIG_DEBUG_UART_CLOCK (100000000)
#endif
+#endif
+
+/* MMC CONFIG */
+#define CONFIG_BLK 1
#define CONFIG_SYS_DCACHE_OFF 1
@@ -134,4 +141,3 @@
#endif /* __CONFIG_H */
-
diff --git a/sd_fuse/tiny4412/auto_fuse.sh b/sd_fuse/tiny4412/auto_fuse.sh
index 0c3da1a..7a024f5 100755
--- a/sd_fuse/tiny4412/auto_fuse.sh
+++ b/sd_fuse/tiny4412/auto_fuse.sh
@@ -1,6 +1,7 @@
#!/bin/bash
-EXEC="sd_fusing.sh"
+#EXEC="sd_fusing.sh"
+EXEC="fast_fusing.sh"
SD_PATH="/dev/sdb"
FUSE_PATH="./${EXEC}"
diff --git a/sd_fuse/tiny4412/fast_fuse.sh b/sd_fuse/tiny4412/fast_fuse.sh
deleted file mode 100644
index 21bd649..0000000
--- a/sd_fuse/tiny4412/fast_fuse.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#
-# Copyright (C) 2011 Samsung Electronics Co., Ltd.
-# http://www.samsung.com/
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-####################################
-
-if [ -z $1 ]
-then
- echo "usage: ./sd_fusing.sh <SD Reader's device file>"
- exit 0
-fi
-
-if [ -b $1 ]
-then
- echo "$1 reader is identified."
-else
- echo "$1 is NOT identified."
- exit 0
-fi
-
-####################################
-#<verify device>
-
-BDEV_NAME=`basename $1`
-BDEV_SIZE=`cat /sys/block/${BDEV_NAME}/size`
-
-if [ ${BDEV_SIZE} -le 0 ]; then
- echo "Error: NO media found in card reader."
- exit 1
-fi
-
-if [ ${BDEV_SIZE} -gt 32000000 ]; then
- echo "Error: Block device size (${BDEV_SIZE}) is too large"
- exit 1
-fi
-
-####################################
-# check files
-
-E4412_UBOOT=../../u-boot.bin
-MKBL2=../mkbl2
-
-if [ ! -f ${E4412_UBOOT} ]; then
- echo "Error: u-boot.bin NOT found, please build it & try again."
- exit -1
-fi
-
-if [ ! -f ${MKBL2} ]; then
- echo "Error: can not find host tool - mkbl2, stop."
- exit -1
-fi
-
-#<make bl2>
-${MKBL2} ${E4412_UBOOT} bl2.bin 14336
-
-####################################
-# fusing images
-
-bl2_position=17
-uboot_position=49
-
-#<BL2 fusing>
-echo "---------------------------------------"
-echo "BL2 fusing"
-dd iflag=dsync oflag=dsync if=./bl2.bin of=$1 seek=$bl2_position
-
-#<u-boot fusing>
-echo "---------------------------------------"
-echo "u-boot fusing"
-dd iflag=dsync oflag=dsync if=${E4412_UBOOT} of=$1 seek=$uboot_position
-
-#<flush to disk>
-sync
-
-####################################
-#<Message Display>
-echo "---------------------------------------"
-echo "U-boot image is fused (at `date +%T`) successfully."
-echo "Eject SD card and insert it again."
-
diff --git a/sd_fuse/tiny4412/fast_fuse.sh.bkp b/sd_fuse/tiny4412/fast_fuse.sh.bkp
new file mode 100644
index 0000000..21bd649
--- /dev/null
+++ b/sd_fuse/tiny4412/fast_fuse.sh.bkp
@@ -0,0 +1,84 @@
+#
+# Copyright (C) 2011 Samsung Electronics Co., Ltd.
+# http://www.samsung.com/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+####################################
+
+if [ -z $1 ]
+then
+ echo "usage: ./sd_fusing.sh <SD Reader's device file>"
+ exit 0
+fi
+
+if [ -b $1 ]
+then
+ echo "$1 reader is identified."
+else
+ echo "$1 is NOT identified."
+ exit 0
+fi
+
+####################################
+#<verify device>
+
+BDEV_NAME=`basename $1`
+BDEV_SIZE=`cat /sys/block/${BDEV_NAME}/size`
+
+if [ ${BDEV_SIZE} -le 0 ]; then
+ echo "Error: NO media found in card reader."
+ exit 1
+fi
+
+if [ ${BDEV_SIZE} -gt 32000000 ]; then
+ echo "Error: Block device size (${BDEV_SIZE}) is too large"
+ exit 1
+fi
+
+####################################
+# check files
+
+E4412_UBOOT=../../u-boot.bin
+MKBL2=../mkbl2
+
+if [ ! -f ${E4412_UBOOT} ]; then
+ echo "Error: u-boot.bin NOT found, please build it & try again."
+ exit -1
+fi
+
+if [ ! -f ${MKBL2} ]; then
+ echo "Error: can not find host tool - mkbl2, stop."
+ exit -1
+fi
+
+#<make bl2>
+${MKBL2} ${E4412_UBOOT} bl2.bin 14336
+
+####################################
+# fusing images
+
+bl2_position=17
+uboot_position=49
+
+#<BL2 fusing>
+echo "---------------------------------------"
+echo "BL2 fusing"
+dd iflag=dsync oflag=dsync if=./bl2.bin of=$1 seek=$bl2_position
+
+#<u-boot fusing>
+echo "---------------------------------------"
+echo "u-boot fusing"
+dd iflag=dsync oflag=dsync if=${E4412_UBOOT} of=$1 seek=$uboot_position
+
+#<flush to disk>
+sync
+
+####################################
+#<Message Display>
+echo "---------------------------------------"
+echo "U-boot image is fused (at `date +%T`) successfully."
+echo "Eject SD card and insert it again."
+
diff --git a/sd_fuse/tiny4412/fast_fusing.sh b/sd_fuse/tiny4412/fast_fusing.sh
new file mode 100755
index 0000000..cac3d03
--- /dev/null
+++ b/sd_fuse/tiny4412/fast_fusing.sh
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2011 Samsung Electronics Co., Ltd.
+# http://www.samsung.com/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+####################################
+
+if [ -z $1 ]
+then
+ echo "usage: ./sd_fusing.sh <SD Reader's device file>"
+ exit 0
+fi
+
+if [ -b $1 ]
+then
+ echo "$1 reader is identified."
+else
+ echo "$1 is NOT identified."
+ exit 0
+fi
+
+####################################
+#<verify device>
+
+BDEV_NAME=`basename $1`
+BDEV_SIZE=`cat /sys/block/${BDEV_NAME}/size`
+
+if [ ${BDEV_SIZE} -le 0 ]; then
+ echo "Error: NO media found in card reader."
+ exit 1
+fi
+
+if [ ${BDEV_SIZE} -gt 32000000 ]; then
+ echo "Error: Block device size (${BDEV_SIZE}) is too large"
+ exit 1
+fi
+
+####################################
+# check files
+
+E4412_UBOOT=../../u-boot.bin
+MKBL2=../mkbl2
+
+if [ ! -f ${E4412_UBOOT} ]; then
+ echo "Error: u-boot.bin NOT found, please build it & try again."
+ exit -1
+fi
+
+if [ ! -f ${MKBL2} ]; then
+ echo "Error: can not find host tool - mkbl2, stop."
+ exit -1
+fi
+
+#<make bl2>
+${MKBL2} ${E4412_UBOOT} bl2.bin 14336
+
+####################################
+# fusing images
+
+signed_bl1_position=1
+bl2_position=17
+uboot_position=81
+tzsw_position=1105
+
+#<BL1 fusing>
+#echo "---------------------------------------"
+#echo "BL1 fusing"
+#dd iflag=dsync oflag=dsync if=./E4412_N.bl1.bin of=$1 seek=$signed_bl1_position
+
+#<BL2 fusing>
+echo "---------------------------------------"
+echo "BL2 fusing"
+dd iflag=dsync oflag=dsync if=../../spl/tiny4412-spl.bin of=$1 seek=$bl2_position
+
+#<u-boot fusing>
+echo "---------------------------------------"
+echo "u-boot fusing"
+dd iflag=dsync oflag=dsync if=${E4412_UBOOT} of=$1 seek=$uboot_position
+
+#<TrustZone S/W fusing>
+#echo "---------------------------------------"
+#echo "TrustZone S/W fusing"
+#dd iflag=dsync oflag=dsync if=./E4412_tzsw.bin of=$1 seek=$tzsw_position
+
+#<flush to disk>
+sync
+
+####################################
+#<Message Display>
+echo "---------------------------------------"
+echo "U-boot image is fused successfully."
+echo "Eject SD card and insert it again."
+
(END)
测试
U-Boot 2017.03-g807828f-dirty (May 13 2017 - 07:51:54 -0700) for TINY4412
CPU: Exynos4412 @ 1.4 GHz
Model: Tiny4412 based on Exynos4412
Board: Tiny4412 based on Exynos4412
DRAM: 1 GiB
WARNING: Caches not enabled
MMC: SAMSUNG SDHCI: 0
Hit any key to stop autoboot: 0
SD/MMC found on device 0
reading uEnv.txt
** Unable to read file uEnv.txt **
reading boot.scr
** Unable to read file boot.scr **
reading uImage
** Unable to read file uImage **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
TINY4412#
TINY4412# mmcinfo
Device: SAMSUNG SDHCI
Manufacturer ID: 27
OEM: 5048
Name: SD16G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.5 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
TINY4412#