查看: 1521|回复: 0

[S12] 尝试编写S12P64的bootloader参考官方例程

[复制链接]

该用户从未签到

13

主题

34

帖子

0

注册会员

Rank: 2

积分
149
最后登录
2022-6-14
发表于 2016-9-9 16:05:42 | 显示全部楼层 |阅读模式
各位大神好!
       最近正在尝试为S12P64编写一个基于XCPCAN通讯的bootloader,但是尝试了近一个礼拜进展甚微,对于BOOTLOADER的原理理解不深入,有点迷茫,有没有相关经验的出来讨论讨论。参考官网的AN4258SW修改自己的程序。
对PRM定义修改RAM、ROM,和相应的PLACEMENT :
SEGMENTS
/* RAM */
      RAM           = READ_WRITE    0x3000 TO   0x35FF;   //1.5K
/* D-Flash */
      DFLASH        = READ_ONLY   0x010400 TO 0x0113FF;

/* non-paged FLASHs */
      ROM_APP       = READ_ONLY     0xC000 TO   0xF4FF;
      BOOT_RAM      = READ_ONLY     0xF500 TO   0xFEFF RELOCATE_TO 0x3600;
END

PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */

      _PRESTART,              /* Used in HIWARE format: jump to _Startup at the code start */
      STARTUP,                /* startup data structures */
      ROM_VAR,                /* constant variables */
      STRINGS,                /* string literals */
      VIRTUAL_TABLE_SEGMENT,  /* C++ virtual table segment */
    //.ostext,                /* OSEK */
   
      DEFAULT_ROM,
      NON_BANKED             /* runtime routines which must not be banked */
    //  COPY                    /* copy down information: how to initialize variables */
                              /* in case you want to use ROM_4000 here as well, make sure
                                 that all files (incl. library files) are compiled with the
                                 option: -OnB=b */
                        INTO  ROM_APP /*, ROM_1400, ROM_4000*/;

    //DEFAULT_ROM       INTO  PAGE_0E   /* PAGE_0C_B000, PAGE_0E */                 ;

    //.stackstart,            /* eventually used for OSEK kernel awareness: Main-Stack Start */
    // SSTACK,                 /* allocate stack first to avoid overwriting variables on overflow */
    //.stackend,              /* eventually used for OSEK kernel awareness: Main-Stack End */
      DEFAULT_RAM       INTO  RAM;
      RAM_CODE          INTO  BOOT_RAM;
      
  //.vectors            INTO  OSVECTORS; /* OSEK */

END

ENTRIES /* keep the following unreferenced variables */
    /* OSEK: always allocate the vector table and all dependent objects */
  //_vectab OsBuildNumber _OsOrtiStackStart _OsOrtiStart
END

STACKSIZE 0x100

VECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */
//VECTOR 0 Entry  /* reset vector: this is the default entry point for an Assembly application. */
//INIT Entry      /* for assembly applications: that this is as well the initialization entry point */

在main函数中如下编写:
void main(void) {

  /* put your own code here */
  
  INT8U delays = 0;
  INT8U cc;
  
  PLL_Init();   //bus 32MHz
  FCLKDIV = 0x1f;  //参考手册 设置为0x1f
  CopyCodeToRAM();
  //PortInit();
  Can_Init();
    EnableInterrupts;
  for(;;)
  {}
}

但是执行后发现无法实现代码复制到RAM中,还请有经验的人士指点迷津。

我知道答案 目前已有0人回答
回复

使用道具 举报

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

本版积分规则

关闭

站长推荐上一条 /4 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2024-5-10 01:00 , Processed in 0.108290 second(s), 20 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表