u-boot-2014.10移植

2024-03-14 10:32
文章标签 移植 boot 2014.10

本文主要是介绍u-boot-2014.10移植,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

最近在学习linux相关知识,下面是CSDN一篇文章,感觉有帮助,保存下来,感谢博主分享,谢谢!

原文博客地址:blog.csdn.net/girlkoo


最近移植了下u-boot-2014.10到TQ335x,如果基于am335x evm进行移植,需要修改的地方并不多。

由于TI的am335x evm开发使用了一个eeprom保存了板载配置信息,用来区分不同板子的型号的,而TQ335x没有这个eeprom,因此,需要修改eeprom相关的部分,使u-boot适应TQ335x开发板。

使用source insight查看代码,很容易发现,所有获取板载配置的部分都是通过读取eeprom获得的,因此,首选修改read_eeprom(board/ti/am335x/board.c)函数,具体的修改如下:

[cpp] view plain copy
  1. static int read_eeprom(struct am335x_baseboard_id *header)  
  2. {  
  3. #if 1  
  4.     strcpy(header->name, "TQ335x");  
  5. #else  
  6.     /* Check if baseboard eeprom is available */  
  7.     if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {  
  8.         puts("Could not probe the EEPROM; something fundamentally "  
  9.             "wrong on the I2C bus.\n");  
  10.         return -ENODEV;  
  11.     }  
  12.   
  13.     /* read the eeprom using i2c */  
  14.     if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header,  
  15.              sizeof(struct am335x_baseboard_id))) {  
  16.         puts("Could not read the EEPROM; something fundamentally"  
  17.             " wrong on the I2C bus.\n");  
  18.         return -EIO;  
  19.     }  
  20.   
  21.     if (header->magic != 0xEE3355AA) {  
  22.         /* 
  23.          * read the eeprom using i2c again, 
  24.          * but use only a 1 byte address 
  25.          */  
  26.         if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header,  
  27.                  sizeof(struct am335x_baseboard_id))) {  
  28.             puts("Could not read the EEPROM; something "  
  29.                 "fundamentally wrong on the I2C bus.\n");  
  30.             return -EIO;  
  31.         }  
  32.   
  33.         if (header->magic != 0xEE3355AA) {  
  34.             printf("Incorrect magic number (0x%x) in EEPROM\n",  
  35.                     header->magic);  
  36.             return -EINVAL;  
  37.         }  
  38.     }  
  39. #endif  
  40.   
  41.     return 0;  
  42. }  
通过上述修改,u-boot不去读取eeprom,而是直接将header的name赋值为"TQ335x",后面可以根据这一配置区分是否为TQ335x开发板。

然后是修改get_dpll_ddr_params(board/ti/am335x/board.c)函数,具体的修改内容如下:

[cpp] view plain copy
  1. const struct dpll_params *get_dpll_ddr_params(void)  
  2. {  
  3.     struct am335x_baseboard_id header;  
  4.   
  5.     enable_i2c0_pin_mux();  
  6.     i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);  
  7.     if (read_eeprom(&header) < 0)  
  8.         puts("Could not get board ID.\n");  
  9.   
  10.     if (board_is_tq335x(&header) || board_is_evm_sk(&header))  
  11.         return &dpll_ddr_evm_sk;  
  12.     else if (board_is_bone_lt(&header))  
  13.         return &dpll_ddr_bone_black;  
  14.     else if (board_is_evm_15_or_later(&header))  
  15.         return &dpll_ddr_evm_sk;  
  16.     else  
  17.         return &dpll_ddr;  
  18. }  
然后是修改sdram_init(board/ti/am335x/board.c)函数,具体的修改内容如下:
[cpp] view plain copy
  1. void sdram_init(void)  
  2. {  
  3.     __maybe_unused struct am335x_baseboard_id header;  
  4.   
  5.     if (read_eeprom(&header) < 0)  
  6.         puts("Could not get board ID.\n");  
  7.   
  8.     if (board_is_evm_sk(&header)) {  
  9.         /* 
  10.          * EVM SK 1.2A and later use gpio0_7 to enable DDR3. 
  11.          * This is safe enough to do on older revs. 
  12.          */  
  13.         gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");  
  14.         gpio_direction_output(GPIO_DDR_VTT_EN, 1);  
  15.     }  
  16.   
  17.     if (board_is_evm_sk(&header) || board_is_tq335x(&header))  
  18.         config_ddr(303, &ioregs_evmsk, &ddr3_data,  
  19.                &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);  
  20.     else if (board_is_bone_lt(&header))  
  21.         config_ddr(400, &ioregs_bonelt,  
  22.                &ddr3_beagleblack_data,  
  23.                &ddr3_beagleblack_cmd_ctrl_data,  
  24.                &ddr3_beagleblack_emif_reg_data, 0);  
  25.     else if (board_is_evm_15_or_later(&header))  
  26.         config_ddr(303, &ioregs_evm15, &ddr3_evm_data,  
  27.                &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);  
  28.     else  
  29.         config_ddr(266, &ioregs, &ddr2_data,  
  30.                &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0);  
  31. }  
然后添加board_is_tq335x函数的具体实现,参考其它类似函数实现即可,由于我们的read_eeprom仅读到了name,其内容是"TQ335x",故可如下实现,在board/ti/am335x/board.h中添加如下内容:
[cpp] view plain copy
  1. static inline int board_is_tq335x(struct am335x_baseboard_id *header)  
  2. {  
  3.     return !strncmp(header->name, "TQ335x", HDR_NAME_LEN);  
  4. }  
最后是修改enable_board_pin_mux(board/ti/am335x/mux.c)函数,具体的修改内容如下:
[cpp] view plain copy
  1. void enable_board_pin_mux(struct am335x_baseboard_id *header)  
  2. {  
  3.     /* Do board-specific muxes. */  
  4.     if (board_is_bone(header) || board_is_tq335x(header)) {  
  5.         /* Beaglebone pinmux */  
  6.         configure_module_pin_mux(i2c1_pin_mux);  
  7.         configure_module_pin_mux(mii1_pin_mux);  
  8.         configure_module_pin_mux(mmc0_pin_mux);  
  9. #if defined(CONFIG_NAND)  
  10.         configure_module_pin_mux(nand_pin_mux);  
  11. #elif defined(CONFIG_NOR)  
  12.         configure_module_pin_mux(bone_norcape_pin_mux);  
  13. #else  
  14.         configure_module_pin_mux(mmc1_pin_mux);  
  15. #endif  
  16.     } else if (board_is_gp_evm(header)) {  
  17.         /* General Purpose EVM */  
  18.         unsigned short profile = detect_daughter_board_profile();  
  19.         configure_module_pin_mux(rgmii1_pin_mux);  
  20.         configure_module_pin_mux(mmc0_pin_mux);  
  21.         /* In profile #2 i2c1 and spi0 conflict. */  
  22.         if (profile & ~PROFILE_2)  
  23.             configure_module_pin_mux(i2c1_pin_mux);  
  24.         /* Profiles 2 & 3 don't have NAND */  
  25. #ifdef CONFIG_NAND  
  26.         if (profile & ~(PROFILE_2 | PROFILE_3))  
  27.             configure_module_pin_mux(nand_pin_mux);  
  28. #endif  
  29.         else if (profile == PROFILE_2) {  
  30.             configure_module_pin_mux(mmc1_pin_mux);  
  31.             configure_module_pin_mux(spi0_pin_mux);  
  32.         }  
  33.     } else if (board_is_idk(header)) {  
  34.         /* Industrial Motor Control (IDK) */  
  35.         configure_module_pin_mux(mii1_pin_mux);  
  36.         configure_module_pin_mux(mmc0_no_cd_pin_mux);  
  37.     } else if (board_is_evm_sk(header)) {  
  38.         /* Starter Kit EVM */  
  39.         configure_module_pin_mux(i2c1_pin_mux);  
  40.         configure_module_pin_mux(gpio0_7_pin_mux);  
  41.         configure_module_pin_mux(rgmii1_pin_mux);  
  42.         configure_module_pin_mux(mmc0_pin_mux_sk_evm);  
  43.     } else if (board_is_bone_lt(header)) {  
  44.         /* Beaglebone LT pinmux */  
  45.         configure_module_pin_mux(i2c1_pin_mux);  
  46.         configure_module_pin_mux(mii1_pin_mux);  
  47.         configure_module_pin_mux(mmc0_pin_mux);  
  48. #if defined(CONFIG_NAND)  
  49.         configure_module_pin_mux(nand_pin_mux);  
  50. #elif defined(CONFIG_NOR)  
  51.         configure_module_pin_mux(bone_norcape_pin_mux);  
  52. #else  
  53.         configure_module_pin_mux(mmc1_pin_mux);  
  54. #endif  
  55.     } else {  
  56.         puts("Unknown board, cannot configure pinmux.");  
  57.         hang();  
  58.     }  
  59. }  

另外,这个版本的u-boot有个bug,需要修改fat_register_device(fs/fat/fat.c)函数:

[cpp] view plain copy
  1. int fat_register_device(block_dev_desc_t *dev_desc, int part_no)  
  2. {  
  3.     disk_partition_t info;  
  4.   
  5.     /* First close any currently found FAT filesystem */  
  6.     cur_dev = NULL;  
  7.   
  8.     /* Read the partition table, if present */  
  9.     if (get_partition_info(dev_desc, part_no, &info)) {  
  10.         /*if (part_no != 0) { 
  11.             printf("** Partition %d not valid on device %d **\n", 
  12.                     part_no, dev_desc->dev); 
  13.             return -1; 
  14.         }*/  
  15.   
  16.         info.start = 0;  
  17.         info.size = dev_desc->lba;  
  18.         info.blksz = dev_desc->blksz;  
  19.         info.name[0] = 0;  
  20.         info.type[0] = 0;  
  21.         info.bootable = 0;  
  22. #ifdef CONFIG_PARTITION_UUIDS  
  23.         info.uuid[0] = 0;  
  24. #endif  
  25.     }  
  26.   
  27.     return fat_set_blk_dev(dev_desc, &info);  
  28. }  
至此,u-boot就已经可以启动了,但是有多余的步骤和log,不过可以去掉,修改file_fat_read_at(fs/fat/fat.c)函数:
[cpp] view plain copy
  1. long file_fat_read_at(const char *filename, unsigned long pos, void *buffer,  
  2.               unsigned long maxsize)  
  3. {  
  4.     debug("reading %s\n", filename);  
  5.     return do_fat_read_at(filename, pos, buffer, maxsize, LS_NO, 0);  
  6. }  
最后,TQ335x是MLO启动u-boot,然后u-boot去启动内核,故可以去掉配置项CONFIG_SPL_OS_BOOT,具体的修改文件include/configs/ti_armv7_common.h:
[cpp] view plain copy
  1. #if defined(CONFIG_SPL_OS_BOOT_ENABLE)  
  2. #define CONFIG_SPL_OS_BOOT  
  3. #endif  

至此,u-boot的移植工作就完成了,编译方法如下:

[cpp] view plain copy
  1. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x_evm_defconfig  
  2. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j8  

其中,arm-linux-gnueabi-需要根据自己的交叉编译工具链前缀进行修改。完成u-boot的移植工作后我们来研究如何启动内核。


源码下载地址:

u-boot-2014.10 for TQ335x/TQ3358(SD卡启动)


这篇关于u-boot-2014.10移植的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/808140

相关文章

Spring Boot 整合 Apache Flink 的详细过程

《SpringBoot整合ApacheFlink的详细过程》ApacheFlink是一个高性能的分布式流处理框架,而SpringBoot提供了快速构建企业级应用的能力,下面给大家介绍Spri... 目录Spring Boot 整合 Apache Flink 教程一、背景与目标二、环境准备三、创建项目 & 添

在Spring Boot中实现HTTPS加密通信及常见问题排查

《在SpringBoot中实现HTTPS加密通信及常见问题排查》HTTPS是HTTP的安全版本,通过SSL/TLS协议为通讯提供加密、身份验证和数据完整性保护,下面通过本文给大家介绍在SpringB... 目录一、HTTPS核心原理1.加密流程概述2.加密技术组合二、证书体系详解1、证书类型对比2. 证书获

Spring Boot中的YML配置列表及应用小结

《SpringBoot中的YML配置列表及应用小结》在SpringBoot中使用YAML进行列表的配置不仅简洁明了,还能提高代码的可读性和可维护性,:本文主要介绍SpringBoot中的YML配... 目录YAML列表的基础语法在Spring Boot中的应用从YAML读取列表列表中的复杂对象其他注意事项总

Spring Boot 整合 Redis 实现数据缓存案例详解

《SpringBoot整合Redis实现数据缓存案例详解》Springboot缓存,默认使用的是ConcurrentMap的方式来实现的,然而我们在项目中并不会这么使用,本文介绍SpringB... 目录1.添加 Maven 依赖2.配置Redis属性3.创建 redisCacheManager4.使用Sp

redis在spring boot中异常退出的问题解决方案

《redis在springboot中异常退出的问题解决方案》:本文主要介绍redis在springboot中异常退出的问题解决方案,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴... 目录问题:解决 问题根源️ 解决方案1. 异步处理 + 提前ACK(关键步骤)2. 调整Redis消费者组

Spring Boot 事务详解(事务传播行为、事务属性)

《SpringBoot事务详解(事务传播行为、事务属性)》SpringBoot提供了强大的事务管理功能,通过@Transactional注解可以方便地配置事务的传播行为和属性,本文将详细介绍Spr... 目录Spring Boot 事务详解引言声明式事务管理示例编程式事务管理示例事务传播行为1. REQUI

Spring Boot 集成 Solr 的详细示例

《SpringBoot集成Solr的详细示例》:本文主要介绍SpringBoot集成Solr的详细示例,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录环境准备添加依赖配置 Solr 连接定义实体类编写 Repository 接口创建 Service 与 Controller示例运行

Spring Boot拦截器Interceptor与过滤器Filter深度解析(区别、实现与实战指南)

《SpringBoot拦截器Interceptor与过滤器Filter深度解析(区别、实现与实战指南)》:本文主要介绍SpringBoot拦截器Interceptor与过滤器Filter深度解析... 目录Spring Boot拦截器(Interceptor)与过滤器(Filter)深度解析:区别、实现与实

Spring Boot项目打包和运行的操作方法

《SpringBoot项目打包和运行的操作方法》SpringBoot应用内嵌了Web服务器,所以基于SpringBoot开发的web应用也可以独立运行,无须部署到其他Web服务器中,下面以打包dem... 目录一、打包为JAR包并运行1.打包为可执行的 JAR 包2.运行 JAR 包二、打包为WAR包并运行

Spring Boot 常用注解整理(最全收藏版)

《SpringBoot常用注解整理(最全收藏版)》本文系统整理了常用的Spring/SpringBoot注解,按照功能分类进行介绍,每个注解都会涵盖其含义、提供来源、应用场景以及代码示例,帮助开发... 目录Spring & Spring Boot 常用注解整理一、Spring Boot 核心注解二、Spr