标签:ddr vendor bank info copy mon prompt 编译 storage
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
开发环境:win7 64位 + VMware12 + Ubuntu14.04 64位
工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi
要移植的u-boot版本:u-boot-2016-11
Tiny4412开发板硬件版本为:
底板: Tiny4412/Super4412SDK 1506
核心板:Tiny4412 - 1412
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
在u-boot/board/samsung目录下基于exynos4412的开发板有:origen、odroid、trats、trats2,但是只有origen支持spl配置,根据exynos4412芯片启动的特点,选择origen作为参考比较合适。
一、参考origen在u-boot中的代码结构添加tiny4412的目录和配置文件
1、添加tiny4412 板级目录
mkdir -p board/samsung/tiny4412 mkdir -p board/samsung/tiny4412/tools |
2、添加tiny4412 配置文件
touch board/samsung/tiny4412/tiny4412.c touch board/samsung/tiny4412/Kconfig touch board/samsung/tiny4412/MAINTAINERS touch board/samsung/tiny4412/Makefile touch board/samsung/tiny4412/tools/mktiny4412spl.c touch include/configs/tiny4412.h touch configs/tiny4412_defconfig touch arch/arm/dts/exynos4412-tiny4412.dts |
3、修改、添加tiny4412 配置文件
3.1、修改arch/arm/dts/Makefile,用于编译tiny4412设备树
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index a4ab069..314aa5c 100755 --- 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
|
3.2、修改arch/arm/include/asm/mach-types.h,增加tiny4412的machine ID
diff --git a/arch/arm/include/asm/mach-types.h b/arch/arm/include/asm/mach-types.h index d51be0b..8174b50 100755 --- 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 @@ -13672,6 +13673,19 @@ extern unsigned int __machine_arch_type; # define machine_is_origen() (0) #endif
+#ifdef CONFIG_MACH_TINY4412 +# ifdef machine_arch_type +# undef machine_arch_type +# define machine_arch_type __machine_arch_type +# else +# define machine_arch_type MACH_TYPE_TINY4412 +# endif +# define machine_is_tiny4412() (machine_arch_type == MACH_TYPE_ORIGEN) +#else +# define machine_is_tiny4412() (0) +#endif + + #ifdef CONFIG_MACH_EPC10 # ifdef machine_arch_type # undef machine_arch_type
|
3.3 修改arch/arm/mach-exynos/Kconfig,在执行make menuconfig时会看到tiny4412 board选项
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index c25fcf3..65c8d36 100755 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -56,6 +56,10 @@ config TARGET_TRATS2 config TARGET_ODROID bool "Exynos4412 Odroid board"
+config TARGET_TINY4412 + bool "Exynos4412 Tiny4412 board" + select SUPPORT_SPL + select EXYNOS4412 endchoice endif
@@ -134,6 +138,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"
|
3.4 修改 board/samsung/tiny4412/Kconfig
diff --git a/board/samsung/tiny4412/Kconfig b/board/samsung/tiny4412/Kconfig new file mode 100755 index 0000000..06a7905 --- /dev/null +++ b/board/samsung/tiny4412/Kconfig @@ -0,0 +1,12 @@ +if TARGET_TINY4412 + +config SYS_BOARD + default "tiny4412" + +config SYS_VENDOR + default "samsung" + +config SYS_CONFIG_NAME + default "tiny4412" + +config EXYNOS4412 + bool +endif
|
3.5 修改board/samsung/tiny4412/Makefile
diff --git a/board/samsung/tiny4412/Makefile b/board/samsung/tiny4412/Makefile index e69de29..123f0a7 100755 --- a/board/samsung/tiny4412/Makefile +++ b/board/samsung/tiny4412/Makefile @@ -0,0 +1,22 @@ +# +# Copyright (C) 2016 AP0904225 +# +# 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-aliasing rules +# +# TODO: +# Fix the root cause in tools/mkorigenspl.c and delete the following work-around +$(obj)/tools/mktiny4412spl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS)) +else +obj-y += tiny4412.o +endif |
3.7 修改 arch/arm/mach-exynos/Makefile,
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile index 0cc6c32..ac47ab2 100755 --- a/arch/arm/mach-exynos/Makefile +++ b/arch/arm/mach-exynos/Makefile @@ -15,6 +15,7 @@ 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 |
3.8 修改include/configs/tiny4412.h
diff --git a/include/configs/tiny4412.h b/include/configs/tiny4412.h new file mode 100755 index 0000000..a6ca631 --- /dev/null +++ b/include/configs/tiny4412.h @@ -0,0 +1,116 @@ +/* + * 2016 + * Author AP0904225 <ap0904225@qq.com> + * Configuration settings for the SAMSUNG TINY4412 (EXYNOS4412) board. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __CONFIG_TINY4412_H +#define __CONFIG_TINY4412_H + +#include <configs/exynos4-common.h> + +/* High Level Configuration Options */ +#define TINY4412 1 /* working with TINY4412*/ + +#define CONFIG_SYS_DCACHE_OFF 1 + +/* TINY4412 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 + 0x6000000) +#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + 0x3E00000) + +#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_SYS_CONSOLE_INFO_QUIET +#define CONFIG_SYS_CONSOLE_IS_IN_ENV +#define CONFIG_DEFAULT_CONSOLE "console=ttySAC1,115200n8\0" + +#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 0x02021410 + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "loadaddr=0x40007000\0" \ + "rdaddr=0x48000000\0" \ + "kerneladdr=0x40007000\0" \ + "ramdiskaddr=0x48000000\0" \ + "console=ttySAC2,115200n8\0" \ + "mmcdev=0\0" \ + "bootenv=uEnv.txt\0" \ + "loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \ + "importbootenv=echo Importing environment from mmc ...; " \ + "env import -t $loadaddr $filesize\0" \ + "loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr\0" \ + "bootscript=echo Running bootscript from mmc${mmcdev} ...; " \ + "source ${loadaddr}\0" +#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 BL1*/ +#define CONFIG_ENV_OFFSET (RESERVE_BLOCK_SIZE + BL1_SIZE) + +#define CONFIG_SPL_LDSCRIPT "board/samsung/common/exynos-uboot-spl.lds" +#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)/512) +#define BL2_SIZE_BLOC_COUNT (COPY_BL2_SIZE/512) + + + +#endif /* __CONFIG_H */ |
3.9 修改configs/tiny4412_defconfig
diff --git a/configs/tiny4412_defconfig b/configs/tiny4412_defconfig new file mode 100755 index 0000000..f8cb2a4 --- /dev/null +++ b/configs/tiny4412_defconfig @@ -0,0 +1,36 @@ +CONFIG_ARM=y +CONFIG_ARCH_EXYNOS=y +CONFIG_ARCH_EXYNOS4=y +CONFIG_TARGET_TINY4412=y #define CONFIG_IDENT_STRING " for TINY4412" +CONFIG_DEFAULT_DEVICE_TREE="exynos4412-tiny4412" +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_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 |
3.10 添加board/samsung/tiny4412/tiny4412.c
diff --git a/board/samsung/tiny4412/tiny4412.c b/board/samsung/tiny4412/tiny4412.c new file mode 100755 index 0000000..a549621 --- /dev/null +++ b/board/samsung/tiny4412/tiny4412.c @@ -0,0 +1,39 @@ +/* + * 2016 + * Author AP0904225 <ap0904225@qq.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <asm/io.h> +#include <asm/gpio.h> +#include <asm/arch/cpu.h> +#include <asm/arch/mmc.h> +#include <asm/arch/periph.h> +#include <asm/arch/pinmux.h> +#include <usb.h> + +DECLARE_GLOBAL_DATA_PTR; + +u32 get_board_rev(void) +{ + return 0; +} + +int exynos_init(void) +{ + return 0; +} + +int board_usb_init(int index, enum usb_init_type init) +{ + return 0; +} + +#ifdef CONFIG_BOARD_EARLY_INIT_F +int exynos_early_init_f(void) +{ + return 0; +} +#endif
|
3.11 添加board/samsung/tiny4412/tools/mktiny4412spl.c
diff --git a/board/samsung/tiny4412/tools/mktiny4412spl.c b/board/samsung/tiny4412/tools/mktiny4412spl.c new file mode 100755 index 0000000..3ed20ef --- /dev/null +++ b/board/samsung/tiny4412/tools/mktiny4412spl.c @@ -0,0 +1,110 @@ +/* + * 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 (16*1024) +#define SPL_HEADER_SIZE 16 +#define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP \ + | S_IWGRP | S_IROTH | S_IWOTH) +#define SPL_HEADER "S5PC210 HEADER " +/* +* Requirement: +* IROM code reads first 14K bytes from boot device. +* It then calculates the checksum of 14K-4 bytes and compare with data at +* 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 buffer. +* 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, count; + + if (argc != 3) { + printf(" %d Wrong number of arguments\n", argc); + exit(EXIT_FAILURE); + } + + ifd = open(argv[1], O_RDONLY); + if (ifd < 0) { + fprintf(stderr, "%s: Can‘t open %s: %s\n", + argv[0], argv[1], strerror(errno)); + exit(EXIT_FAILURE); + } + + ofd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, FILE_PERM); + if (ifd < 0) { + fprintf(stderr, "%s: Can‘t open %s: %s\n", + argv[0], argv[2], strerror(errno)); + if (ifd) + close(ifd); + exit(EXIT_FAILURE); + } + + len = lseek(ifd, 0, SEEK_END); + lseek(ifd, 0, SEEK_SET); + + memcpy(&buffer[0], SPL_HEADER, SPL_HEADER_SIZE); + + count = (len < (IMG_SIZE - SPL_HEADER_SIZE)) + ? len : (IMG_SIZE - SPL_HEADER_SIZE); + + if (read(ifd, buffer + SPL_HEADER_SIZE, count) != count) { + fprintf(stderr, "%s: Can‘t read %s: %s\n", + argv[0], argv[1], strerror(errno)); + + if (ifd) + close(ifd); + if (ofd) + close(ofd); + + exit(EXIT_FAILURE); + } + + for (i = 0; i < IMG_SIZE - SPL_HEADER_SIZE; i++) + checksum += buffer[i+16]; + + *(ulong *)buffer ^= 0x1f; + *(ulong *)(buffer+4) ^= checksum; + + for (i = 1; i < SPL_HEADER_SIZE; i++) + buffer[i] ^= buffer[i-1]; + + if (write(ofd, buffer, BUFSIZE) != BUFSIZE) { + fprintf(stderr, "%s: Can‘t write %s: %s\n", + 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; +}
|
3.12 添加arch/arm/dts/exynos4412-tiny4412.dts,使用uart0作为终端
diff --git a/arch/arm/dts/exynos4412-tiny4412.dts b/arch/arm/dts/exynos4412-tiny4412.dts new file mode 100755 index 0000000..8ae7c8d --- /dev/null +++ b/arch/arm/dts/exynos4412-tiny4412.dts @@ -0,0 +1,30 @@ +/* + * Tiny4412 board device tree source + * + * 2016 + * Author AP0904225 <ap0904225@qq.com> + * + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/dts-v1/; +#include "exynos4412.dtsi" + +/ { + model = "Tiny4412 based on Exynos4412"; + compatible = "samsung,tiny4412", "samsung,exynos4412"; + + chosen { + stdout-path = "serial0"; + }; + + aliases { + serial0 = "/serial@13800000"; + console = "/serial@13800000"; + }; + + serial0:serial@13810000 { + status = "okay"; + }; +}; |
3.13 修改arch/arm/mach-exynos/exynos4_setup.h
diff --git a/arch/arm/mach-exynos/exynos4_setup.h b/arch/arm/mach-exynos/exynos4_setup.h index 9f29d94..8339354 100755 --- a/arch/arm/mach-exynos/exynos4_setup.h +++ b/arch/arm/mach-exynos/exynos4_setup.h @@ -440,6 +440,13 @@ 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
|
3.10 添加board/samsung/tiny4412/MAINTAINERS
diff --git a/board/samsung/tiny4412/MAINTAINERS b/board/samsung/tiny4412/MAINTAINERS new file mode 100755 index 0000000..2a71892 --- /dev/null +++ b/board/samsung/tiny4412/MAINTAINERS @@ -0,0 +1,6 @@ +TINY4412 BOARD +M: AP0904225 <ap0904225@qq.com> +S: Author +F: board/samsung/tiny4412/ +F: include/configs/tiny4412.h +F: configs/tiny4412_defconfig |
添加完相关代码目录后,执行如下命令进行编译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开发板上,需进一步修改代码。
到这里第一阶段的添加相关代码目录文件的工作就告一段落了。
参考
1、友善之臂tiny4412 uboot_tiny4412-20130729.tar.gz
2、http://www.wowotech.net/x_project/bubblegum_uboot_porting.html
3、http://www.wowotech.net/u-boot/boot_flow_1.html
4、http://www.wowotech.net/u-boot/boot_flow_2.html
5、http://www.cnblogs.com/pengdonglin137/p/5080645.html
X-003 FriendlyARM tiny4412 uboot移植之添加相应目录文件
标签:ddr vendor bank info copy mon prompt 编译 storage
原文地址:http://www.cnblogs.com/AP0904225/p/6078966.html