4.1 移植第一步

  前面已经分析过了 .config 的过程,可以知道移植需要用到的文件:

  • .config 文件
  • arch/arm/cpu 下的文件
  • board 目录

  .config 文件是根据后面两个文件生成的,所以我们重点需要配置后面两个目录

4.1.2 移植 board 目录

  JZ2440 是基于 S3C2440 的,为三星架构,我们可以从其他支持 2440 的 uboot 版本中进行移植。

  u-boot自v2014.10版本开始引入KBuild系统,所以我们在 2014.10之后不久的版本中查询版本,这样尽量减少移植时候的差异性

  下载 u-boot 2015.01 版本代码:git clone git://git.denx.de/u-boot.git u-boot

  切换版本:

  git status

  git tag

  git checkout v2015.01

  git diff v2018.03(对比源码,可以不做)

  拷贝board/samsung/smdk2410 到 下面的目录中去

1 cp -R smdk2410/ ../../../../../uboot/u-boot-2018.03/board/samsung/jz2440

  修改文件:

  cd u-boot-2018.03/board/samsung/jz2440

  mv smdk2410.c jz2440.c

  修改 makefile:

1 obj-y    := jz2440.o
2 obj-y    += lowlevel_init.o

  jz2440.c 文件修改:

1     /* arch number of JZ2440-Board */
2     gd->bd->bi_arch_number = MACH_TYPE_JZ2440;

  注意:修改这里的类型还必须在另一个地方进行添加这个模块:

  

  直接将 SMDK2440 改为 JZ2440 即可

1 #define MACH_TYPE_SMDK2460             1007
2 #define MACH_TYPE_JZ2440               1008
3 #define MACH_TYPE_SMDK2412             1009

  Kconfig 修改:

 1 if TARGET_JZ2440
 2
 3 config SYS_BOARD
 4     default "jz2440"
 5
 6 config SYS_VENDOR
 7     default "samsung"
 8
 9 config SYS_SOC
10     default "s3c24x0"
11
12 config SYS_CONFIG_NAME
13     default "jz2440"
14
15 endif

  当前目录修改完毕

4.1.3 arch/arm/cpu/arm920t 目录修改

  uboot2015.01/u-boot$ cd arch/arm/cpu/arm920t/

  u-boot/arch/arm/cpu/arm920t$ cp -R s3c24x0/ ../../../../../../../uboot/u-boot-2018.03/arch/arm/cpu/arm920t/

(1)u-boot-2018.03/arch/arm/cpu/arm920t/Makefile 修改

 1 extra-y    = start.o
 2
 3 obj-y    += cpu.o
 4
 5 obj-$(CONFIG_EP93XX) += ep93xx/
 6 obj-$(CONFIG_IMX) += imx/
 7 obj-$(CONFIG_S3C24X0) += s3c24x0/
 8
 9 # some files can only build in ARM mode
10
11 ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD
12 CFLAGS_cpu.o := -marm
13 endif

(2)头文件添加

  查看 s3c24x0.h 文件,发现都包含了一个头文件: asm/arch/s3c24x0_cpu.h ,添加此头文件。

  在 uboot2015.01 根目录下找到此文件:find . -name s3c24x0_cpu.h

  ./arch/arm/include/asm/arch-s3c24x0/s3c24x0_cpu.h

  由找到的结果可知,需要添加 arch-s3c24x0 目录

  cp -R arch/arm/include/asm/arch-s3c24x0/ ../../u-boot-2018.03/arch/arm/include/asm/

  添加进去就可以了 不需要做其他设置

(3)arch/arm/Kconfig 中添加

  第1323行添加

1 source "board/samsung/jz2440/Kconfig"

  在第 339 行,就是  menuconfig  中目标板的选择项,这这个选项中我们可以添加自己的板子,使其在 menuconfig 中可见

  

  569~573 行添加:

1 config TARGET_JZ2440
2     bool "Samsung S3C24X0"
3     select CPU_ARM920T
4     help
5         The S3C24X0 is deperated,but I want to use it.

4.2 生成 .config 文件

  我们通过 make menuconfig 进行配置我们的开发板。或者可以用 uboot 2015 版本中的 smdk2410_defconfig进行配置,可以拷贝进去。

  cp configs/smdk2410_defconfig ../../u-boot-2018.03/configs/jz2440_defconfig

  执行命令 make  jz2440_defconfig

  再执行 make menuconfig 查看配置。适量修改下,编译肯定会出错,出错后再进行修改。

4.3 编译

4.3.1 .config:138:warning: symbol value '' invalid for SYS_TEXT_BASE

  在 .config 中我们没有配置代码段的基地址。先找找这个在原先的 uboot 中配置在哪里。在 include/configs/smdk2410.h 中

  拷贝这个文件进入我们的工程中:cp include/configs/smdk2410.h ../../u-boot-2018.03/include/configs/jz2440.h

  查找下包含文件,进行修改,然后查看 include/configs/jz2440.h 文件,进行 make menuconfig  配置

  将 CONFIG_SYS_TEXT_BASE 在menuconfig  中修改为 0x0

4.3.2 include/configs/jz2440.h:78:32: fatal error: config_cmd_default.h: No such file or directory

  没有这个文件了。注释掉编译

4.3.3 重复定义项

  (1)include/configs/jz2440.h:84:0: warning: "CONFIG_CMD_ELF" redefined

  (2)include/configs/jz2440.h:91:0: warning: "CONFIG_CMDLINE_EDITING" redefined

  (3)include/configs/jz2440.h:110:0: warning: "CONFIG_SYS_LONGHELP" redefined

  (4)include/configs/jz2440.h:111:0: warning: "CONFIG_SYS_PROMPT" redefined

  (5)include/configs/jz2440.h:119:0: warning: "CONFIG_DISPLAY_CPUINFO" redefined

  (6)include/configs/jz2440.h:129:0: warning: "CONFIG_LZMA" redefined

  注释掉代码中的那几行即可

4.3.4 时钟函数未找到

  (1)arch/arm/cpu/arm920t/s3c24x0/cpu_info.c:15:2: error: ‘get_FCLK’ undeclared here (not in a function); did you mean ‘get_dacr’?

  (2)arch/arm/cpu/arm920t/s3c24x0/cpu_info.c:16:2: error: ‘get_HCLK’ undeclared here (not in a function); did you mean ‘get_FCLK’?

  (3)arch/arm/cpu/arm920t/s3c24x0/cpu_info.c:17:2: error: ‘get_PCLK’ undeclared here (not in a function); did you mean ‘get_HCLK’?

  通过文件对比可以知道,这三个函数被定义在 arch/arm/cpu/arm920t/s3c24x0/speed.c 中,但是当前工程版本中未包含这几个函数,在头文件中进行申明添加。

  505-510 行加入

 1 /* $(CPU)/speed.c */
 2 int    get_clocks (void);
 3 ulong    get_bus_freq  (ulong);
 4 int get_serial_clock(void);
 5 #if defined(CONFIG_S3C24X0)6 ulong get_FCLK(void);7 ulong get_HCLK(void);8 ulong get_PCLK(void);9 ulong get_UCLK(void);
10 #endif

4.3.5 板子适配问题

  board/samsung/jz2440/jz2440.c:100:27: error: ‘MACH_TYPE_JZ2440’ undeclared (first use in this function)

  对比2015版本的代码可以知道是因为 machine_arch_type 没有定义,所以在arch/arm/include/asm/mach-types.h中定义此变量

  文件头加上如下代码:

1 #ifndef __ASSEMBLY__
2 extern unsigned int __machine_arch_type;
3 #endif

  文件尾加上如下代码:

 1 #ifdef CONFIG_ARCH_JZ2440
 2 # ifdef machine_arch_type
 3 # undef machine_arch_type
 4 # define machine_arch_type __machine_arch_type
 5 # else
 6 # define machine_arch_type MACH_TYPE_JZ2440
 7 # endif
 8 # define machine_is_jz2440()    (machine_arch_type == MACH_TYPE_JZ2440)
 9 #else
10 # define machine_is_jz2440()    (0)
11 #endif

  board/samsung/jz2440/jz2440.c 加上头文件:

#include <asm/mach-types.h>

4.3.6 无此文件和目录

  (1)cmd/reginfo.c:10:10: fatal error: asm/ppc.h: No such file or directory

    #include <asm/ppc.h>

    reginfo.c  是命令文件,打印寄存器的信息,可以在 menuconfig 中的 common line 选项中修改

    带源代码中查找 CONFIG_CMD_REGINFO:

    

    在menuconfig 中 CMD_REGINFO 依赖于 PPC=y,注释掉此项定义。

  (2)cmd/ubi.c: In function ‘display_ubi_info’:

      cmd/ubi.c:79:44: error: ‘CONFIG_MTD_UBI_WL_THRESHOLD’ undeclared (first use in this function)

      cmd/ubi.c:28:54: note: in definition of macro ‘ubi_msg’

      cmd/ubi.c:79:44: note: each undeclared identifier is reported only once for each function it appears in ubi_msg("wear-leveling threshold:    %d", CONFIG_MTD_UBI_WL_THRESHOLD);

      cmd/ubi.c:28:54: note: in definition of macro ‘ubi_msg’ #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__)

    

    README 中的解释,默认值是4096

    

    menuconfig 中没有开 MTD_UBI 则此模块可以注释掉。

    include/configs/jz2440.h 中

    

  (3)cmd/built-in.o: In function `do_fat_fsinfo':

    cmd/fat.c:85: undefined reference to `fat_set_blk_dev'

    cmd/fat.c:90: undefined reference to `file_fat_detectfs'

    追踪代码可以知道 fat_set_blk_dev 和 file_fat_detectfs 都定义在 Fat.c (fs\fat) 中,fat 文件系统我们并没有支持。在 include/configs/jz2440.h 中关闭掉这个命令宏。

    代码第 185 行注释

  (4)drivers/mtd/nand/built-in.o: In function `nand_init_chip':

    drivers/mtd/nand/nand.c:94: undefined reference to `board_nand_init'

    对比代码可以知道,drivers/mtd/nand/s3c2410_nand.c 这个文件在 2018.03 版本中没有,复制进工程中。

    drivers/mtd/nand$ cp s3c2410_nand.c ../../../../../u-boot-2018.03/drivers/mtd/nand/s3c2440_nand.c

    将 s3c2440_nand.c 中的2410 字符串改为 2440

    drivers/mtd/nand/Makefile 中59行添加:

1 obj-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o 

    drivers/mtd/nand/Kconfig 中添加:

1 config NAND_S3C2440
2     bool "Support for S3c2440 Nand Controller"
3     depends on TARGET_JZ2440
4     imply CMD_NAND
5     help
6       This enables Nand driver support for Nand flash contoller
7       found on S3C2440 Soc.

    修改完成后 需要进入 menuconfig 中添加配置。

  (5)env/built-in.o: In function `env_flash_save':

    env/flash.c:268: undefined reference to `flash_sect_protect'

    env/flash.c:276: undefined reference to `flash_sect_erase'

    env/flash.c:280: undefined reference to `flash_write'

    env/flash.c:303: undefined reference to `flash_sect_protect'

    env/flash.c:298: undefined reference to `flash_perror'

    追踪代码可以知道 CONFIG_MTD_NOR_FLASH 宏未定义,开宏即可

    

4.3.7 规则问题

  (1)make[1]: *** No rule to make target 'arch/arm/dts/unset.dts', needed by 'arch/arm/dts/unset.dtb'.

    Makefile:879: recipe for target 'dts/dt.dtb' failed

    看一下顶层的  Makefile:

    

    这里编译进了 dts ,dts  我们不支持得干掉

    make menuconfig 中,

    Device Tree Control  干掉

    Path to dtc binary for use within mkimage  的值设为空

4.3.8 宏定义问题   

    Error: You must add new CONFIG options using Kconfig
    The following new ad-hoc CONFIG options were detected:
    CONFIG_JZ2440
    CONFIG_NAND_S3C2410
    CONFIG_RTC_S3C24X0
    CONFIG_S3C2410
    CONFIG_S3C24X0
    CONFIG_S3C24X0_SERIAL
    CONFIG_SMDK2410
    CONFIG_SYS_HUSH_PARSER
    CONFIG_SYS_S3C2410_NAND_HWECC
    CONFIG_USB_OHCI_S3C24XX
    CONFIG_ZERO_BOOTDELAY_CHECK

  注释掉顶层  Makefile 中下面几句:

  

  clean 之后编译。

  编译完成,生成了 u-boot.bin.

  

  或者将这些内容直接加入到 scripts/config_whitelist.txt  当中。

  

4.3.8 驱动问题

  (1)cmd/date.c:52:12: warning: implicit declaration of function ‘I2C_GET_BUS’;

  (2)cmd/date.c:53:2: warning: implicit declaration of function ‘I2C_SET_BUS’;

  (3)cmd/date.c:53:14: error: ‘CONFIG_SYS_RTC_BUS_NUM’ undeclared

   函数问题是因为 CONFIG_DM_I2C_COMPAT 未定义,即 I2C 模块未开启,若是开启了 CONFIG_SYS_I2C 或是 CONFIG_DM_RTC 则不会走那个分支

   我们直接关掉 CONFIG_DM_I2C 模块 

  (4)drivers/spi/built-in.o: In function `dev_read_u32_default'

    DM 模块问题,关掉 DM 模块。    

  (5)rivers/serial/serial.c:379: undefined reference to `default_serial_console'

    对比代码可以知道,缺少serial_s3c24x0.c文件,拷贝进去,并修改 Makefile

    drivers/serial$ cp serial_s3c24x0.c ../../../../u-boot-2018.03/drivers/serial/

    

    修改完成,已经可以编译出完整的 u-boot.bin 文件了。后续再做代码分析和移植的时候,有些东西还需要修改

    当前的 .bin 文件是过大的,接近350K

    

    

      

  

  

  

  

  

  

转载于:https://www.cnblogs.com/kele-dad/p/8983109.html

四、移植 JZ2440 开发板相关推荐

  1. jz2440开发板移植U-boot之修改代码支持DM9000网卡

    今天我们来移植U-boot到jz2440开发板,修改代码支持DM9000网卡.查看之前写的移植记录请点击链接:点击查看之前的移植记录 现在大多数开发板都支持DM9000网卡.我们的U-boot源码里面 ...

  2. 移植u-boot-2012.04.01到jz2440开发板

    今天我给大家分享一下如何移植一个纯净的uboot到jz2440开发大版,通过记录学习分享,与大家一起进步!!! 1.首先我们在uboot官网下载u-boot-2012.04.01.tar.bz2,建立 ...

  3. 移植Linux 3.4.2内核到JZ2440开发板(超精讲)

    Linux 3.4.2内核移植到JZ2440开发板 0.开发环境 虚拟机:VMware workstation 16 pro 宿主机操作系统:Ubuntu 16.04 开发板:JZ2440 移植内核版 ...

  4. 关于修改jz2440开发板IP以及开发板与Windows互ping问题

    一.如何修改jz2440开发板IP 开头注意:在进行以下操作前必须已经跟着u-boot内核到开发板上,此外还要移植根文件系统到开发板上. 修改开发板IP有两种方式: 1.临时修改IP 2.永久修改IP ...

  5. jz2440开发板修改UBOOT支持NAND FLASH

    很多天没有看嵌入式的东西了,今天来看一下,继续之前移植uboot到jz2440开发板.今天我们来实现Uboot支持NAND FLASH. 在之前的文章里(点击连接查看之前的记录),我们为了编译通过把N ...

  6. 嵌入式Linux操作系统移植IMX6开发板之实现USB 自动挂载

    学习交流加 个人qq: 1126137994 个人微信: liu1126137994 学习交流资源分享qq群: 962535112 本篇文章讲述如何实现USB自动挂载,U盘即插即用,不用手动挂载的方法 ...

  7. JZ2440开发板与电脑通过网线直连,实现开发板、虚拟机、PC机三者互Ping,并成功挂接网络根文件系统

    声明: 本文提及的部分图片与内容属于韦东山老师的教学视频课程内容,本文提出的解决方案是基于韦老师教学视频中提及方案的扩展. 转载内容来自: [005_ARM裸机1期加强版_第006课_第006节_一句 ...

  8. EMSWIN GUIBuilder移植到开发板

    推荐: 古清生:雪天摘橙美如画 令狐冲练易筋经是骗局? 公告:请您及时更换请请请您正在使用的模版将于2周后被下线,请您及时更换 × 何其有幸遇到懂你的人 加载中- 新浪首页 登录 注册 硬汉Eric2 ...

  9. Linux系统移植:原厂 Kernel 移植到开发板

    文章目录 Linux系统移植:原厂 Kernel 移植到开发板 一.获取原厂内核并编译 二.内核启动测试 三.添加自己板子文件 3.1 板子配置文件 3.2 板子设备树 3.3 编译 四.重要配置修改 ...

最新文章

  1. php滑动换视频,php工具类之【视频变换类】
  2. Spring-AOP 通过配置文件实现 异常抛出增强
  3. 我的Java知识复习回顾笔记
  4. Cisco CCNP 笔记(一)
  5. HDU1530 最大流问题
  6. 华为云电脑和马云无影比_阿里云打造未来电脑无影,却因为5G限制,很难达到普及...
  7. Unity之git版本控制
  8. 计算机音乐刚好遇见你乐谱,刚好遇见你钢琴谱-李玉刚|因为我刚好遇见你
  9. iOS AVPlayer视频播放器
  10. 女生做产品经理好吗_谁说女生不适合做产品经理?
  11. oracle学用命令大全 笔记
  12. Java多线程概念[同步容器,并发容器](二)
  13. php基于浏览器的linux终端模拟器,shellinabox基于web浏览器的终端模拟器
  14. php 头bom_php bom头是什么
  15. OpenCV C++安装和配置
  16. openstack搭建问题
  17. python panda是什么_如何最简单、通俗地理解Python的pandas库?
  18. ValueError: Can only compute partial correlations for lags up to 50% of the sample size. The request
  19. vue项目跨域的问题(一个项目对接两个不同的域名、端口接口导致跨域,最好的办法是后端解决)
  20. 电脑加装内存条的教程

热门文章

  1. matlab中集合的表示,Matlab常用命令集合
  2. 客户成功—以客户为中心,为客户创造价值
  3. 7-3 汉诺塔 (20 分)
  4. Delphi中BPL包的使用,个人经验
  5. 【AI简报20210910期】联想发布LA2智能嵌入式控制器、单目摄像头实时感知车辆形状...
  6. 【徒手训练】来自美国特种部队的徒手三角肌训练法
  7. 如何应对面试中的常见问题?
  8. 《Adobe Photoshop CS6中文版经典教程(彩色版)》—第2课2.7节使用海绵工具调整饱和度...
  9. android diy固件,官方固件不给力?咱自己DIY!手把手教你修改固件!
  10. [转载]软件测试从零开始