iTop-4412精英版的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
 
 
  • 1
  • 2

(二)添加板级文件

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
  • 2
  • 3
  • 4
  • 5

(三)编辑文件内容
(1)itop4412.c

/*
 * Copyright (C) 2011 Samsung Electronics
 *
 * 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
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

(2)Kconfig

if TARGET_ITOP4412

config SYS_BOARD
    default "itop4412"

config SYS_VENDOR
    default "samsung"

config SYS_CONFIG_NAME
    default "itop4412"

endif
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

(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
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

(4)MAINTAINERS

ITOP4412 BOARD
M:  Chander Kashyap <k.chander@samsung.com>
S:  Maintained
F:  board/samsung/itop4412/
F:  include/configs/itop4412.h
F:  configs/itop4412_defconfig
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

(5)mkitop4412spl.c

/*
 * 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) //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\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);

    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);
    }

#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\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;
}
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117

(四) 修改文件
修改arch/arm/mach-exynos/Kconfig

vim arch/arm/mach-exynos/Kconfig
 
 
  • 1
+config TARGET_ITOP4412
+   bool "Exynos4412 iTop-4412 board"
+   select SUPPORT_SPL
 
 
  • 1
  • 2
  • 3

这里写图片描述

+source "board/samsung/itop4412/Kconfig"
 
 
  • 1

这里写图片描述

(五) 修改顶级目录下的Makefile

vim Makefile
 
 
  • 1
CROSS_COMPILE := arm-linux-gnueabi-
 
 
  • 1

这里写图片描述

(五) 配置 .config 编译选项

make menuconfig
 
 
  • 1

(1)进入配置页面
这里写图片描述

(2)选择 Architecture select(平台类型)
这里写图片描述
(3)选择ARM architecture(ARM平台类型)
这里写图片描述
(4)选择芯片版本
这里写图片描述
(5)选择刚刚我们添加的itop4412板级类型
这里写图片描述
(6)选择Boot media引导媒介
这里写图片描述
(7)选该引导延时 5s(不是她别重要)
这里写图片描述
(8)选择控制台选项配置(不是特别重要)
这里写图片描述
(10)选择SPL/TPL
配置链接脚本的路径
配置链接脚本的路径
配置支持GPIO
配置支持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串口驱动(重要
这里写图片描述
(15)选择File systems(文件系统)
这里写图片描述

make menuconfig基本配置就是这些,由于写不完,留着下一节写。

下一节
iTop-4412精英版的u-boot-2017.11移植教程(二)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值