获取u-boot-2017.11
本博客的版本是
u-boot-2017.11.tar.bz2.
注:
关于u-boot的启动流程及原理,本博客就不详细说明,网上教程也是一大堆,想要了解的各位可以自行搜索学习
官网下载地址:
ftp://ftp.denx.de/pub/u-boot/u-boot-2017.11.tar.bz2
开始移植
(一)创建板级目录
mkdir board/samsung/itop4412
mkdir board/samsung/itop4412/tools
(二)添加板级文件
touch board/samsung/itop4412/itop4412.c
touch board/samsung/itop4412/Kconfig
touch board/samsung/itop4412/Makefile
touch board/samsung/itop4412/MAINTAINERS
touch board/samsung/itop4412/tools/mkitop4412spl.c
(三)编辑文件内容
(1)itop4412.c
/*
* Copyright (C) 2011 Samsung Electronics
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include
#include
#include
#include
#include
#include
#include
#include
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
(2)Kconfig
if TARGET_ITOP4412
config SYS_BOARD
default "itop4412"
config SYS_VENDOR
default "samsung"
config SYS_CONFIG_NAME
default "itop4412"
endif
(3)Makefile
#
# 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/mkitop4412spl
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/mkitop4412spl.c and delete the following work-around
$(obj)/tools/mkitop4412spl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))
else
obj-y += itop4412.o
endif
(4)MAINTAINERS
ITOP4412 BOARD
M: Chander Kashyap
S: Maintained
F: board/samsung/itop4412/
F: include/configs/itop4412.h
F: configs/itop4412_defconfig
(5)mkitop4412spl.c
/*
* Copyright (C) 2011 Samsung Electronics
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include
#include
#include
#include
#include
#include
#include
#define BUFSIZE (16*1024)
#define IMG_SIZE (14*1024) //16*1024
#define SPL_HEADER_SIZE 0 //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
", 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);
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
",
argv[0], argv[1], strerror(errno));
if (ifd)
close(ifd);
if (ofd)
close(ofd);
exit(EXIT_FAILURE);
}
#if 0
for (i = 0; i < IMG_SIZE - SPL_HEADER_SIZE; i++)
checksum += buffer[i+16];
*(unsigned long *)buffer ^= 0x1f;
*(unsigned long *)(buffer+4) ^= checksum;
for (i = 1; i < SPL_HEADER_SIZE; i++)
buffer[i] ^= buffer[i-1];
#endif
for (i = 0; i < IMG_SIZE - 4; 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;
}
(四) 修改文件
修改arch/arm/mach-exynos/Kconfig
vim arch/arm/mach-exynos/Kconfig
+config TARGET_ITOP4412
+ bool "Exynos4412 iTop-4412 board"
+ select SUPPORT_SPL
+source "board/samsung/itop4412/Kconfig"
(五) 修改顶级目录下的Makefile
vim Makefile
CROSS_COMPILE := arm-linux-gnueabi-
(五) 配置 .config 编译选项
make menuconfig
(1)进入配置页面

(2)选择 Architecture select(平台类型)

(3)选择ARM architecture(ARM平台类型)

(4)选择芯片版本

(5)选择刚刚我们添加的itop4412板级类型

(6)选择Boot media引导媒介

(7)选该引导延时 5s(不是她别重要)

(8)选择控制台选项配置(不是特别重要)

(10)选择SPL/TPL
配置链接脚本的路径

配置支持GPIO

配置支持串口

(11)选择Command line interface(命令行接口)
配置Use hush shell

配置Shell prompt

(12)选择Partition Types(分区类型)

(13)选择Device Tree Control(设备树配置)

(14)选择Device Drivers(设备驱动)
配置Support block devices

配置Serial drivers串口驱动(
重要)

配置MMC Host controller Support (
重要)

(15)选择File systems(文件系统)

make menuconfig基本配置就是这些,由于写不完,留着下一节写。
下一节
iTop-4412精英版的u-boot-2017.11移植教程(二)