3387|2

965

帖子

0

TA的资源

纯净的硅(高级)

楼主
 

TMS570学习2-bootload跳转实验 [复制链接]

本帖最后由 石玉 于 2019-8-16 14:57 编辑

QQ:971586331

软件环境:

操作系统:windows 10

IDE:CCS7.4

代码生成工具:HALCoGen 04.07.01

烧写工具:CCS UniFlash

硬件环境:

目标板:TMDS570LS31HDK

本文内容:详细描述了TMS570系统处理器bootload跳转原理,编写2份程序,一个是bootload,一个是应用程序,在bootload中,使LED D5(HET1[00])闪烁5次后跳转到0x00180000处开始执行应用程序,应用程序中使LED D4(HET1[31])闪烁5次后软复位,再次执行bootload,如此往复。

 

1.编写bootload程序

按TMS570学习1中的流程新建工程boot_test,在hal下的sys_main.c中的编写主程序

  • /* USER CODE BEGIN (0) */
  • #include "sys_common.h"
  • #include "gio.h"
  • #include "delay.h"
  • #include "het.h"
  • #include "pinmux.h"
  • #include "F021.h"
  • /* USER CODE END */
  • /* Include Files */
  • /* USER CODE BEGIN (1) */
  • #define APP1_START_ADDRESS (0x00180000)
  • #define APP2_START_ADDRESS (0x00040000)
  • #define APP3_START_ADDRESS (0x00060000)
  • #define APP4_START_ADDRESS (0x00080000)
  • /* USER CODE END */
  • /** @fn void main(void)
  • * @brief Application main function
  • * @note This function is empty by default.
  • *
  • * This function is called after startup.
  • * The user can use this function to implement the application.
  • */
  • /* USER CODE BEGIN (2) */
  • uint32 g_ulTransferAddress;
  • /* USER CODE END */
  • uint8 emacAddress[6U] = {0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU};
  • uint32 emacPhyAddress = 1U;
  • int main(void)
  • {
  • /* USER CODE BEGIN (3) */
  • int i = 0;
  • gioInit();
  • muxInit();
  • /* Set high end timer GIO port hetPort pin direction to all output */
  • gioSetDirection(hetPORT1, 0xFFFFFFFF);
  • for( i=0; i<10; i++)
  • {
  • gioSetPort(hetPORT1, gioGetPort(hetPORT1) ^ (1<<0));
  • my_delay(1000);
  • }
  • g_ulTransferAddress = (uint32_t)APP1_START_ADDRESS;
  • ((void (*)(void))g_ulTransferAddress)(); //跳转程序指针
  • while(1)
  • {
  • }
  • /* USER CODE END */
  • return 0;
  • }
  • /* USER CODE BEGIN (4) */
  • /* USER CODE END */

在主程序中,我们先初始化IO,让HET1[00]闪烁5次,然后让程序指针跳转到0x00180000处开始运行,因为要下载2个程序,为了把程序下载到指定地址和防止程序地址空间冲突,修改cmd文件。

  • /* */
  • /*----------------------------------------------------------------------------*/
  • /* USER CODE BEGIN (0) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Linker Settings */
  • --retain="*(.intvecs)"
  • /* USER CODE BEGIN (1) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Memory Map */
  • MEMORY
  • {
  • VECTORS (X) : origin=0x00000000 length=0x00000020
  • FLASH0 (RX) : origin=0x00000020 length=0x0017FFE0
  • //FLASH1 (RX) : origin=0x00180000 length=0x00180000
  • STACKS (RW) : origin=0x08000000 length=0x00001500
  • RAM (RW) : origin=0x08001500 length=0x0003EB00
  • /* USER CODE BEGIN (2) */
  • /* USER CODE END */
  • }
  • /* USER CODE BEGIN (3) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Section Configuration */
  • SECTIONS
  • {
  • .intvecs : {} > VECTORS
  • //.text : {} > FLASH0 | FLASH1
  • //.const : {} > FLASH0 | FLASH1
  • //.cinit : {} > FLASH0 | FLASH1
  • //.pinit : {} > FLASH0 | FLASH1
  • .text : {} > FLASH0
  • .const : {} > FLASH0
  • .cinit : {} > FLASH0
  • .pinit : {} > FLASH0
  • .bss : {} > RAM
  • .data : {} > RAM
  • .sysmem : {} > RAM
  • /* USER CODE BEGIN (4) */
  • /* USER CODE END */
  • }
  • /* USER CODE BEGIN (5) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Misc */
  • /* USER CODE BEGIN (6) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/

因为bootload程序上电启动,所以从0x00000000开始,FLASH1段的位置正好是我们放应用程序的位置,所以屏蔽掉,SECTIONS中的text等段就只能放在FLASH0中,编译下载,可以看到板上的HET1[00]灯闪烁5次后熄灭,因为0x00180000处没有代码可以执行,程序跑飞。

2.编写应用程序

按TMS570学习1中的流程新建工程test,在hal下的sys_main.c中的编写主程序

  • /* USER CODE BEGIN (0) */
  • /* USER CODE END */
  • /* Include Files */
  • #include "sys_common.h"
  • /* USER CODE BEGIN (1) */
  • #include "rti.h"
  • #include "het.h"
  • #include "gio.h"
  • #include "emif.h"
  • #include "pinmux.h"
  • #include "sci.h"
  • #include "delay.h"
  • #include <stdio.h>
  • #include <reg_system.h>
  • /* USER CODE END */
  • /** @fn void main(void)
  • * @brief Application main function
  • * @note This function is empty by default.
  • *
  • * This function is called after startup.
  • * The user can use this function to implement the application.
  • */
  • /* USER CODE BEGIN (2) */
  • /* USER CODE END */
  • uint8 emacAddress[6U] = {0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU};
  • uint32 emacPhyAddress = 0U;
  • int main(void)
  • {
  • /* USER CODE BEGIN (3) */
  • int i=0;
  • int ret;
  • int buff;
  • /* Initialize RTI driver */
  • gioInit();
  • rtiInit();
  • muxInit();
  • sciInit();
  • sciEnableNotification(sciREG, SCI_RX_INT);
  • /* Set high end timer GIO port hetPort pin direction to all output */
  • gioSetDirection(hetPORT1, 0xFFFFFFFF);
  • /* Enable RTI Compare 0 interrupt notification */
  • rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
  • /* Enable IRQ - Clear I flag in CPS register */
  • /* Note: This is usually done by the OS or in an svc dispatcher */
  • _enable_IRQ();
  • /* Start RTI Counter Block 0 */
  • rtiStartCounter(rtiCOUNTER_BLOCK0);
  • //让HET1[31]闪烁5次
  • for( i=0; i<10; i++)
  • {
  • gioSetPort(hetPORT1, gioGetPort(hetPORT1) ^ (1<<31));
  • my_delay(1000);
  • }
  • systemREG1->SYSECR = 0x8000; //软件复位
  • /* Run forever */
  • while(1)
  • {
  • //gioSetPort(hetPORT1, gioGetPort(hetPORT1) ^ (1<<0));
  • my_delay(1000);
  • }
  • /* USER CODE END */
  • return 0;
  • }
  • /* USER CODE BEGIN (4) */
  • /* Note-You need to remove rtiNotification from notification.c to avoid redefinition */
  • void rtiNotification(uint32_t notification)
  • {
  • /* enter user code between the USER CODE BEGIN and USER CODE END. */
  • /* Toggle HET pin 0 */
  • gioSetPort(hetPORT1, gioGetPort(hetPORT1) ^ (1<<17));
  • }
  • /* USER CODE END */

在主程序中,先初始化IO,然后让HET1[31]闪烁5次,然后让程序软复位,因为应用程序要放到0x00180000位置,所以要修改cmd文件

  • /* */
  • /*----------------------------------------------------------------------------*/
  • /* USER CODE BEGIN (0) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Linker Settings */
  • --retain="*(.intvecs)"
  • /* USER CODE BEGIN (1) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Memory Map */
  • MEMORY
  • {
  • //VECTORS (X) : origin=0x00000000 length=0x00000020
  • VECTORS (X) : origin=0x00180000 length=0x00000020
  • //FLASH0 (RX) : origin=0x00000020 length=0x0017FFE0
  • FLASH1 (RX) : origin=0x00180020 length=0x0001FFE0
  • STACKS (RW) : origin=0x08000000 length=0x00001500
  • RAM (RW) : origin=0x08001500 length=0x0003EB00
  • /* USER CODE BEGIN (2) */
  • /* USER CODE END */
  • }
  • /* USER CODE BEGIN (3) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Section Configuration */
  • SECTIONS
  • {
  • .intvecs : {} > VECTORS
  • //.text : {} > FLASH0 | FLASH1
  • //.const : {} > FLASH0 | FLASH1
  • //.cinit : {} > FLASH0 | FLASH1
  • //.pinit : {} > FLASH0 | FLASH1
  • .text : {} > FLASH1
  • .const : {} > FLASH1
  • .cinit : {} > FLASH1
  • .pinit : {} > FLASH1
  • .bss : {} > RAM
  • .data : {} > RAM
  • .sysmem : {} > RAM
  • /* USER CODE BEGIN (4) */
  • /* USER CODE END */
  • }
  • /* USER CODE BEGIN (5) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/
  • /* Misc */
  • /* USER CODE BEGIN (6) */
  • /* USER CODE END */
  • /*----------------------------------------------------------------------------*/

因为程序要在0x00180000开始,所将起始地址改为0x00180000,屏蔽FLASH0,SECTIONS中的段放在FLASH1中,编译程序,此时不能仿真因为程序不是下载到0地址的

3.烧写引导程序和应用程序

用TI的CCS UniFlash工具一次性烧写引导和应用程序

点Add选择引导和应用程序的out文件,点击Program,按下开发板上的复位键,可以观察到HET1[0]闪烁5次后HET1[31]闪烁5次,然后重复,说明先运行了bootload程序,然后运行了应用程序,应用程序运行完后程序复位,又运行bootload程序。




此内容由EEWORLD论坛网友石玉原创,如需转载或用于商业用途需征得作者同意并注明出处

查看本帖全部内容,请登录或者注册
 
点赞 关注

回复
举报

965

帖子

0

TA的资源

纯净的硅(高级)

沙发
 

有一个地方没看明白,cmd文件中VECTORS段占用了起始的0x20个字节,是作什么用的?

点评

明白了,是异常向量表  详情 回复 发表于 2019-8-16 14:18
 
 

回复

965

帖子

0

TA的资源

纯净的硅(高级)

板凳
 
石玉 发表于 2019-8-16 14:03 有一个地方没看明白,cmd文件中VECTORS段占用了起始的0x20个字节,是作什么用的?

明白了,是异常向量表

 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

开源项目 更多>>
    随便看看
    查找数据手册?

    EEWorld Datasheet 技术支持

    相关文章 更多>>
    关闭
    站长推荐上一条 1/10 下一条
    艾睿电子& Silicon Labs 有奖直播 | 全新蓝牙信道探测:从技术创新到实际应用
    直播时间:3月12日(周三)上午10:00
    直播奖励:多功能榨汁机、蓝牙音箱、手机支架

    查看 »

     
    EEWorld订阅号

     
    EEWorld服务号

     
    汽车开发圈

    About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

    站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

    北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

    电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
    快速回复 返回顶部 返回列表