X-003 FriendlyARM tiny4412 uboot移植之添加相应目录文件
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
开发环境: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 添加board/samsung/tiny4412/tiny4412.c
diff --git a/board/samsung/tiny4412/tiny4412.c b/board/samsung/tiny4412/tiny4412.c new file mode 100644 index 0000000..547dd45 --- /dev/null +++ b/board/samsung/tiny4412/tiny4412.c @@ -0,0 +1,40 @@ +/* + * 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.2 添加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 100644 index 0000000..c3a3e29 --- /dev/null +++ b/board/samsung/tiny4412/tools/mktiny4412spl.c @@ -0,0 +1,104 @@ +/* + * 2016 + * Author AP0904225 <ap0904225@qq.com> + * + * 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 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; + unsigned int count = 0; + + 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 (ofd < 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); + + count = (len < IMG_SIZE )? len : IMG_SIZE; //14K-4 + + if (read(ifd, buffer, 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;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\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.3 添加include/configs/tiny4412.h
diff --git a/include/configs/tiny4412.h b/include/configs/tiny4412.h new file mode 100644 index 0000000..36af8b1 --- /dev/null +++ b/include/configs/tiny4412.h @@ -0,0 +1,115 @@ +/* + * 2016 + * Author AP0904225 <ap0904225@qq.com> + * + * Configuration settings for the FriendlyARM TINY4412 (EXYNOS4412) 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 /* 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_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 0x02023400 +#define CONFIG_SPL_STACK 0x02060000 + +#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.4 添加configs/tiny4412_defconfig
diff --git a/configs/tiny4412_defconfig b/configs/tiny4412_defconfig new file mode 100644 index 0000000..93917b9 --- /dev/null +++ b/configs/tiny4412_defconfig @@ -0,0 +1,34 @@ +# +# U-Boot 2016.11 Configuration for FriendlyARM tiny4412 +# +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_MMC=y +CONFIG_CMD_MII=y +CONFIG_CMD_CACHE=y +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 + +# +#NOTE:do not delete this: +# +# CONFIG_CMD_IMLS is not set +# CONFIG_CMD_XIMG is not set +# CONFIG_CMD_MISC is not set +# CONFIG_CMD_FPGA is not set +# CONFIG_CMD_NET is not set +# CONFIG_CMD_NFS is not set |
3.5 添加board/samsung/tiny4412/MAINTAINERS
diff --git a/board/samsung/tiny4412/MAINTAINERS b/board/samsung/tiny4412/MAINTAINERS new file mode 100644 index 0000000..ee5ad1a9 --- /dev/null +++ b/board/samsung/tiny4412/MAINTAINERS @@ -0,0 +1,6 @@ +TINY4412 BOARD +M: AP0904225 <ap0904225@qq.com> +S: Author AP0904225 +F: board/samsung/tiny4412/ +F: include/configs/tiny4412.h +F: configs/tiny4412_defconfig |
3.6 修改 board/samsung/tiny4412/Kconfig
diff --git a/board/samsung/tiny4412/Kconfig b/board/samsung/tiny4412/Kconfig new file mode 100644 index 0000000..954c391 --- /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.7 修改board/samsung/tiny4412/Makefile
diff --git a/board/samsung/tiny4412/Makefile b/board/samsung/tiny4412/Makefile new file mode 100644 index 0000000..55301d5 --- /dev/null +++ b/board/samsung/tiny4412/Makefile @@ -0,0 +1,23 @@ +# +# 2016 +# Author AP0904225 <ap0904225@qq.com> +# +# 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/mktiny4412spl.c and delete the following work-around +$(obj)/tools/mktiny4412spl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS)) +else +obj-y += tiny4412.o +endif |
3.8 修改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..c8bb811 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -56,6 +56,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 @@ -145,6 +154,7 @@ source "board/samsung/universal_c210/Kconfig" source "board/samsung/origen/Kconfig" source "board/samsung/trats2/Kconfig" source "board/samsung/odroid/Kconfig" +source "board/samsung/tiny4412/Kconfig" source "board/samsung/arndale/Kconfig" source "board/samsung/smdk5250/Kconfig" source "board/samsung/smdk5420/Kconfig" |
3.9 修改 arch/arm/mach-exynos/Makefile,
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile index 0cc6c32..ac47ab2 100644 --- 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.10 修改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..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 |
3.11、修改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..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 |
3.12、修改arch/arm/dts/Makefile,用于编译tiny4412设备树
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 836a8c4..a654d74 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 |
3.13 添加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 100644 index 0000000..8822d52 --- /dev/null +++ b/arch/arm/dts/exynos4412-tiny4412.dts @@ -0,0 +1,86 @@ +/* + * FriendlyARM 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"; + + aliases { + i2c0 = "/i2c@13860000"; + i2c1 = "/i2c@13870000"; + i2c2 = "/i2c@13880000"; + i2c3 = "/i2c@13890000"; + i2c4 = "/i2c@138a0000"; + i2c5 = "/i2c@138b0000"; + i2c6 = "/i2c@138c0000"; + i2c7 = "/i2c@138d0000"; + serial0 = "/serial@13800000"; + console = "/serial@13810000"; + mmc2 = "/sdhci@12530000"; + mmc4 = "/dwmmc@12550000"; + }; + + i2c@13860000 { + samsung,i2c-sda-delay = <100>; + samsung,i2c-slave-addr = <0x10>; + samsung,i2c-max-bus-freq = <100000>; + status = "okay"; + }; + + serial@13810000 { + status = "okay"; + }; + + sdhci@12510000 { + status = "disabled"; + }; + + sdhci@12520000 { + status = "disabled"; + }; + + sdhci@12530000 { + samsung,bus-width = <4>; + samsung,timing = <1 2 3>; + cd-gpios = <&gpk2 2 0>; + }; + + sdhci@12540000 { + 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>; + }; + + ehci@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开发板上,需进一步修改代码。
到这里第一阶段的添加相关代码目录文件的工作就告一段落了。
参考
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