tiny4412 -1312 __Uboot移植

Posted chu-yi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tiny4412 -1312 __Uboot移植相关的知识,希望对你有一定的参考价值。

开发环境:win10 64位 + VMware12 + Ubuntu14.04 32位

工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi

要移植的u-boot版本:u-boot-2016-11

Tiny4412开发板硬件版本为

  底板:  Tiny4412SDK 1312B

  核心板:Tiny4412 - 1306

 

1.获取U-BOOT源码

  • 从FTP站点下载: ftp://ftp.denx.de/pub/u-boot
  • uboot-2016-09.tar.bz2

2.交叉编译工具链

3.解压裁剪

  •  

 4.初步移植(拷贝模板)

  u-boot/board/samsung目录下基于exynos4412的开发板有:origen、odroid、trats、trats2,但是只有origen支spl配置,根据exynos4412芯片启动的特点,选择origen作为参考比较合适。

   cp -r origen/ tiny4412

  1)修改 ./board/samsung/tiny4412/tiny4412.c

     直接修改文件名即可;

  2)修改 ./board/samsung/tiny4412/Kconfig

[email protected]:/home/arm/u-boot-2016.11# git diff 6a31271 board/samsung/tiny4412/Kconfig 
diff --git a/board/samsung/tiny4412/Kconfig b/board/samsung/tiny4412/Kcon
new file mode 100644
index 0000000..e7e759c
--- /dev/null
+++ b/board/samsung/tiny4412/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_TINY4412
+
+config SYS_BOARD
+       default "tiny4412"
+
+config SYS_VENDOR
+       default "samsung"
+
+config SYS_CONFIG_NAME
+       default "tiny4412"
+
+config EXYNOS4412
+    bool
+
+endif

  3)修改 ./board/samsung/tiny4412/MAINTAINERS

diff --git a/board/samsung/tiny4412/MAINTAINERS b/board/samsung/tiny4412/
new file mode 100644
index 0000000..fdcd79e
--- /dev/null
+++ b/board/samsung/tiny4412/MAINTAINERS
@@ -0,0 +1,6 @@
+TINY4412 BOARD
+M:     Chander 123 <34777829@qq.com>
+S:     Maintained
+F:     board/samsung/tiny4412/
+F:     include/configs/tiny4412.h
+F:     configs/tiny4412_defconfig

  4)修改 ./board/samsung/tiny4412/tools/mktiny4412spl.c

diff --git a/board/samsung/tiny4412/tools/mktiny4412spl.c b/board/samsung
new file mode 100644
index 0000000..c0d0453
--- /dev/null
+++ b/board/samsung/tiny4412/tools/mktiny4412spl.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#define BUFSIZE                        (16*1024)
+#define IMG_SIZE               ((14*1024)-4)
+#define FILE_PERM              (S_IRUSR | S_IWUSR | S_IRGRP +                               | S_IWGRP | S_IROTH | S_IWOTH)
+/*
+* Requirement:
+* IROM code reads first 14K bytes from boot device.
+* It then calculates the checksum of 14K-4 bytes and compare with data a
+* 14K-4 offset.
+*
+* This function takes two filenames:
+* IN  "u-boot-spl.bin" and
+* OUT "$(BOARD)-spl.bin as filenames.
+* It reads the "u-boot-spl.bin" in 16K buffer.
+* It calculates checksum of 14K-4 Bytes and stores at 14K-4 offset in bu
+* It writes the buffer to "$(BOARD)-spl.bin" file.
+*/
+
+int main(int argc, char **argv)
+{
+       int i, len;
+       unsigned char buffer[BUFSIZE] = {0};
+       int ifd, ofd;
+       unsigned int checksum = 0;
+    unsigned int count = 0;
+
+       if (argc != 3) {
+               printf(" %d Wrong number of arguments
", argc);
+               exit(EXIT_FAILURE);
+       }
+
+       ifd = open(argv[1], O_RDONLY);
+       if (ifd < 0) {
+               fprintf(stderr, "%s: Can‘t open %s: %s
",
+                       argv[0], argv[1], strerror(errno));
+               exit(EXIT_FAILURE);
+       }
+
+       ofd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, FILE_PERM);
+       if (ofd < 0) {
+               fprintf(stderr, "%s: Can‘t open %s: %s
",
+                       argv[0], argv[2], strerror(errno));
+               if (ifd)
+                       close(ifd);
+               exit(EXIT_FAILURE);
+       }
+
+       len = lseek(ifd, 0, SEEK_END);
+       lseek(ifd, 0, SEEK_SET);
+
+       if (read(ifd, buffer , count) != count) {
+               fprintf(stderr, "%s: Can‘t read %s: %s
",
+                       argv[0], argv[1], strerror(errno));
+
+               if (ifd)
+                       close(ifd);
+               if (ofd)
+                       close(ofd);
+
+               exit(EXIT_FAILURE);
+       }
+
+       for (i = 0; i < IMG_SIZE ; i++)
+    {
+               checksum += (unsigned char)(buffer[i]);
+    }
+
+       *(unsigned int *)(buffer+i) = checksum;
+
+       if (write(ofd, buffer, BUFSIZE) != BUFSIZE) {
+               fprintf(stderr, "%s: Can‘t write %s: %s
",
+                       argv[0], argv[2], strerror(errno));
+
+               if (ifd)
+                       close(ifd);
+               if (ofd)
+                       close(ofd);
+
+               exit(EXIT_FAILURE);
+       }
+
+       if (ifd)
+               close(ifd);
+       if (ofd)
+               close(ofd);
+
+       return EXIT_SUCCESS;
+}

  5)修改 ./board/samsung/tiny4412/Makefile

diff --git a/board/samsung/tiny4412/Makefile b/board/samsung/tiny4412/Mak
new file mode 100644
index 0000000..0beabeb
--- /dev/null
+++ b/board/samsung/tiny4412/Makefile
@@ -0,0 +1,22 @@
+#
+# Copyright (C) 2011 Samsung Electronics
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+ifdef CONFIG_SPL_BUILD
+# necessary to create built-in.o
+obj- := __dummy__.o
+
+hostprogs-y := tools/mktiny4412spl
+always := $(hostprogs-y)
+
+# omit -O2 option to suppress
+#   warning: dereferencing type-punned pointer will break strict-aliasin
+#
+# TODO:
+# Fix the root cause in tools/mkorigenspl.c and delete the following wor
+$(obj)/tools/mktiny4412spl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))
+else
+obj-y  += tiny4412.o
+endif
(END)

 

  6)添加include/configs/tiny4412.h

  cp   include/configs/origen.h   include/configs/tiny4412.h 

 

diff --git a/include/configs/tiny4412.h b/include/configs/tiny4412.h
new file mode 100644
index 0000000..fef910f
--- /dev/null
+++ b/include/configs/tiny4412.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * Configuration settings for the SAMSUNG ORIGEN (EXYNOS4210) board.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __CONFIG_TINY4412_H
+#define __CONFIG_TINY4412_H
+
+#include <configs/exynos4-common.h>
+
+/*TIZEN THOR downloader support*/
+#undef CONFIG_CMD_THOR_DOWNLOAD
+#undef CONFIG_USB_FUNCTION_THOR
+
+/* High Level Configuration Options */
+#define TINY4412         1
+
+#define CONFIG_SYS_DCACHE_OFF          1
+
+/* ORIGEN has 4 bank of DRAM */
+#define CONFIG_NR_DRAM_BANKS           4
+#define CONFIG_SYS_SDRAM_BASE          0x40000000
+#define PHYS_SDRAM_1                   CONFIG_SYS_SDRAM_BASE
+#define SDRAM_BANK_SIZE                        (256 << 20)     /* 256 MB
+
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START       CONFIG_SYS_SDRAM_BASE
+#define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x600000
+#define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x3E0000
+
+#define CONFIG_SYS_TEXT_BASE           0x43E00000
+
+#define CONFIG_MACH_TYPE               MACH_TYPE_TINY4412
+
+/* select serial console configuration */
+#define CONFIG_SERIAL2
+#define CONFIG_BAUDRATE                        115200
+
+/* Console configuration */
+#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8"
+
+#define CONFIG_SYS_MEM_TOP_HIDE        (1 << 20)       /* ram console */
+
+#define CONFIG_SYS_MONITOR_BASE        0x00000000
+
+/* Power Down Modes */
+#define S5P_CHECK_SLEEP                        0x00000BAD
+#define S5P_CHECK_DIDLE                        0xBAD00000
+#define S5P_CHECK_LPA                  0xABAD0000
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+/* MMC SPL */
+#define COPY_BL2_FNPTR_ADDR    0x02020030
+#define CONFIG_SPL_TEXT_BASE   0x02023400
+#define CONFIG_SPL_STACK        0x02060000
+
+
+#define CONFIG_EXTRA_ENV_SETTINGS +       "loadaddr=0x40007000" +       "rdaddr=0x48000000" +       "kerneladdr=0x40007000" +       "ramdiskaddr=0x48000000" +       "console=ttySAC2,115200n8" +       "mmcdev=0" +       "bootenv=uEnv.txt" +       "loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}" +       "importbootenv=echo Importing environment from mmc ...; " +               "env import -t $loadaddr $filesize" +        "loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr" +        "bootscript=echo Running bootscript from mmc${mmcdev} ...; " +                "source ${loadaddr}"
+#define CONFIG_BOOTCOMMAND +       "if mmc rescan; then " +               "echo SD/MMC found on device ${mmcdev};" +               "if run loadbootenv; then " +                       "echo Loaded environment from ${bootenv};" +                       "run importbootenv;" +               "fi;" +               "if test -n $uenvcmd; then " +                       "echo Running uenvcmd ...;" +                       "run uenvcmd;" +               "fi;" +               "if run loadbootscript; then " +                       "run bootscript; " +               "fi; " +       "fi;" +       "load mmc ${mmcdev} ${loadaddr} uImage; bootm ${loadaddr} "
+
+#define CONFIG_CLK_1000_400_200
+
+/* MIU (Memory Interleaving Unit) */
+#define CONFIG_MIU_2BIT_21_7_INTERLEAVED
+
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         0
+#define CONFIG_ENV_SIZE                        (16 << 10)      /* 16 KB 
+#define RESERVE_BLOCK_SIZE             (512)
+#define BL1_SIZE                       (16 << 10) /*16 K reserved for BL
+#define CONFIG_ENV_OFFSET              (RESERVE_BLOCK_SIZE + BL1_SIZE)
+
+#define CONFIG_SPL_LDSCRIPT    "board/samsung/common/exynos-uboot-spl.ld
+#define CONFIG_SPL_MAX_FOOTPRINT       (14 * 1024)
+
+#define CONFIG_SYS_INIT_SP_ADDR                0x02040000
+
+/* U-Boot copy size from boot Media to DRAM.*/
+#define COPY_BL2_SIZE          0x80000
+#define BL2_START_OFFSET       ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/51
+#define BL2_SIZE_BLOC_COUNT    (COPY_BL2_SIZE/512)
+
+#endif /* __CONFIG_H */

 

  7)修改 configs/tiny4412_defconfig

   cp  /configs/origin_defconfig  /configs/tiny4412_defconfig

 

diff --git a/configs/tiny4412_defconfig b/configs/tiny4412_defconfig
new file mode 100644
index 0000000..ccc9fab
--- /dev/null
+++ b/configs/tiny4412_defconfig
@@ -0,0 +1,39 @@
+CONFIG_ARM=y
+CONFIG_ARCH_EXYNOS=y
+CONFIG_ARCH_EXYNOS4=y
+CONFIG_TARGET_TINY4412=y
+CONFIG_IDENT_STRING=" for TINY4412"
+CONFIG_DEFAULT_DEVICE_TREE="exynos4412-tiny4412"
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_SPL=y
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="TINY4412 # "
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_XIMG is not set
+CONFIG_CMD_MMC=y
+# CONFIG_CMD_DFU=y
+# CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_FPGA is not set
+# CONFIG_CMD_NET is not set
+# CONFIG_CMD_DHCP=y
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_MII=y
+CONFIG_CMD_CACHE=y
+# CONFIG_CMD_MISC is not set
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_CONTROL=y
+#CONFIG_DFU_MMC=y
+#CONFIG_USB=y
+#CONFIG_DM_USB=y
+#CONFIG_USB_GADGET=y
+#CONFIG_USB_GADGET_DWC2_OTG=y
+#CONFIG_USB_GADGET_DOWNLOAD=y
+#CONFIG_G_DNL_MANUFACTURER="Samsung"
+#CONFIG_G_DNL_VENDOR_NUM=0x04e8
+#CONFIG_G_DNL_PRODUCT_NUM=0x6601

 

  8)修改arch/arm/mach-exynos/Makefile

diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefil
index 0cc6c32..5f8b6ba 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -15,6 +15,8 @@ ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_EXYNOS5)  += clock_init_exynos5.o
 obj-$(CONFIG_EXYNOS5)  += dmc_common.o dmc_init_ddr3.o
 obj-$(CONFIG_EXYNOS4210)+= dmc_init_exynos4.o clock_init_exynos4.o
+obj-$(CONFIG_EXYNOS4412)+= dmc_init_exynos4.o clock_init_exynos4.o
+
 obj-y  += spl_boot.o tzpc.o
 obj-y  += lowlevel_init.o
 endif

  9) 修改arch/arm/mach-exynos/Kconfig,在执行make menuconfig时会看到tiny4412 board选项

diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index ce2a16f..473fef0 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -55,6 +55,15 @@ config TARGET_TRATS2
 
 config TARGET_ODROID
        bool "Exynos4412 Odroid board"
+config TARGET_TINY4412
+    bool "Exynos4412 FriendlyARM Tiny4412 board"
+    select SUPPORT_SPL
+    select SPL
+    select EXYNOS4412
+        help
+        Support FriendlyARM Tiny4412 board based on Samsung exynos4412
+        CPU: S5PC220[Samsung SOC on SMP Platform Base on ARM CortexA9
+]
 
 endchoice
 endif
@@ -143,6 +152,7 @@ source "board/samsung/smdkv310/Kconfig"
 source "board/samsung/trats/Kconfig"
 source "board/samsung/universal_c210/Kconfig"
 source "board/samsung/origen/Kconfig"
+source "board/samsung/tiny4412/Kconfig"
 source "board/samsung/trats2/Kconfig"
 source "board/samsung/odroid/Kconfig"
 source "board/samsung/arndale/Kconfig"

  10)修改arch/arm/mach-exynos/exynos4_setup.h

diff --git a/arch/arm/mach-exynos/exynos4_setup.h b/arch/arm/mach-exynos/
index 9f29d94..838e02c 100644
--- a/arch/arm/mach-exynos/exynos4_setup.h
+++ b/arch/arm/mach-exynos/exynos4_setup.h
@@ -440,6 +440,12 @@ struct mem_timings {
 #define APB_SFR_ARBRITATION_CONF_VAL   0x00000001
 #endif
 
+#ifdef TINY4412
+/* Interleave: 2Bit, Interleave_bit1: 0x15, Interleave_bit0: 0x7 */
+#define APB_SFR_INTERLEAVE_CONF_VAL    0x20001507
+#define APB_SFR_ARBRITATION_CONF_VAL   0x00000001
+#endif
+
 #define INTERLEAVE_ADDR_MAP_START_ADDR 0x40000000
 #define INTERLEAVE_ADDR_MAP_END_ADDR   0xbfffffff
 #define INTERLEAVE_ADDR_MAP_EN         0x00000001

  11)修改arch/arm/include/asm/mach-types.h,增加tiny4412machine ID

diff --git a/arch/arm/include/asm/mach-types.h b/arch/arm/include/asm/mac
index d51be0b..297f1c3 100644
--- a/arch/arm/include/asm/mach-types.h
+++ b/arch/arm/include/asm/mach-types.h
@@ -1107,6 +1107,7 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_COLIBRI_T30          4493
 #define MACH_TYPE_APALIS_T30           4513
 #define MACH_TYPE_OMAPL138_LCDK        2495
+#define MACH_TYPE_TINY4412             4608
 
 #ifdef CONFIG_ARCH_EBSA110
 # ifdef machine_arch_type

  12) 修改arch/arm/dts/Makefile,用于编译tiny4412设备树

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 836a8c4..771e713 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -14,6 +14,7 @@ dtb-$(CONFIG_EXYNOS4) += exynos4210-origen.dtb         exynos4210-universal_c210.dtb         exynos4210-trats.dtb         exynos4412-trats2.dtb +    exynos4412-tiny4412.dtb         exynos4412-odroid.dtb
 
 dtb-$(CONFIG_TARGET_HIKEY) += hi6220-hikey.dtb

  13) 添加arch/arm/dts/exynos4412-tiny4412.dts,使用uart0作为终端

diff --git a/arch/arm/dts/exynos4412-tiny4412.dts b/arch/arm/dts/exynos44
new file mode 100644
index 0000000..4810202
--- /dev/null
+++ b/arch/arm/dts/exynos4412-tiny4412.dts
@@ -0,0 +1,87 @@
+/*
+ * Odroid-U3/X2 board device tree source
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *             http://www.samsung.com
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/dts-v1/;
+#include "exynos4412.dtsi"
+
+/ {
+       model = "Tiny4412 based on Exynos4412";
+       compatible = "samsung,tiny4412", "samsung,exynos4412";
+
+       aliases {
+               i2c0 = "/[email protected]";
+               i2c1 = "/[email protected]";
+               i2c2 = "/[email protected]";
+               i2c3 = "/[email protected]";
+               i2c4 = "/[email protected]";
+               i2c5 = "/[email protected]";
+               i2c6 = "/[email protected]";
+               i2c7 = "/[email protected]";
+               serial0 = "/[email protected]";
+               console = "/[email protected]";
+               mmc2 = "/[email protected]";
+               mmc4 = "/[email protected]";
+       };
+
+       [email protected]13860000 {
+               samsung,i2c-sda-delay = <100>;
+               samsung,i2c-slave-addr = <0x10>;
+               samsung,i2c-max-bus-freq = <100000>;
+               status = "okay";
+
+       };
+
+       [email protected]13810000 {
+               status = "okay";
+       };
+
+       [email protected]12510000 {
+               status = "disabled";
+       };
+
+       [email protected]12520000 {
+               status = "disabled";
+       };
+
+       [email protected]12530000 {
+               samsung,bus-width = <4>;
+               samsung,timing = <1 2 3>;
+               cd-gpios = <&gpk2 2 0>;
+       };
+
+       [email protected]12540000 {
+               status = "disabled";
+       };
+
+       [email protected]12550000 {
+               samsung,bus-width = <8>;
+               samsung,timing = <2 1 0>;
+               samsung,removable = <0>;
+               fifoth_val = <0x203f0040>;
+               bus_hz = <400000000>;
+               div = <0x3>;
+               index = <4>;
+       };
+
+       [email protected]12580000 {
+               compatible = "samsung,exynos-ehci";
+               reg = <0x12580000 0x100>;
+               #address-cells = <1>;
+               #size-cells = <1>;
+               phy {
+                       compatible = "samsung,exynos-usb-phy";
+                       reg = <0x125B0000 0x100>;
+               };
+       };
+
+       emmc-reset {
+               compatible = "samsung,emmc-reset";
+               reset-gpio = <&gpk1 2 0>;
+       };
+};

 

  添加完相关代码目录后,执行如下命令进行编译uboot

$ make distclean

$ make tiny4412_defconfig

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

可以顺利编译出u-boot-spl.bin u-boot.bin文件,此时这个u-boot-spl.bin u-boot.bin文件还不能直接用在tiny4412 SDK开发板上,需进一步修改代码。

 

问题:

 

编译时提示 Your dtc is too old, please upgrade to dtc 1.4 or newer

./scripts/dtc-version.sh: line 17: dtc: command not found
./scripts/dtc-version.sh: line 18: dtc: command not found
* Your dtc is too old, please upgrade to dtc 1.4 or newer

解决:

apt-get install device-tree-compiler

 

 

 

 

 




以上是关于tiny4412 -1312 __Uboot移植的主要内容,如果未能解决你的问题,请参考以下文章

X-004 FriendlyARM tiny4412 uboot移植之点亮指路灯

X-003 FriendlyARM tiny4412 uboot移植之添加相应目录文件

X-005 FriendlyARM tiny4412 uboot移植之时钟初始化

X-009 FriendlyARM tiny4412 uboot移植之SD Card用起来Kernel boot起来

Tiny4412 Uboot

tiny4412sdk-1506原生uboot卡死