/*******************************************************************************
** *
** Infineon TriCore Bootloader, CANLoader, Version 1.0 *
** *
** Id: main.c 2013-06-11 15:02:32Z chen hanshun *
** *
** DESCRIPTION : *
** -Communication with PC via BL protocol *
** -Implementation of flash functions: *
** (1)Erase flash *
** (2)Program flash *
** (3)Verify flash *
** (4)Protect flash *
** (5)Program SPRAM *
** (6)Run programmed flash user code from address 0xA0000000 *
** (7)Run programmed SPRAM user code from address 0xD4001400 *
** *
** REMARKS : *
** -Stack and CSA initialized *
** -Interrupt and Traptable not initialized *
** *
*******************************************************************************/
#include "main.h"
#pragma noclear
BYTE HeaderBlock[HEADER_BLOCK_SIZE];
BYTE DataBlock[PAGE_SIZE+16];
BYTE Dflash_flag;
DWORD Mcu_PFlash_End_Address;
DWORD Mcu_DFlash_End_Address;
DWORD Mcu_Pflash_Size;
DWORD Mcu_Pflash_P0_End;
DWORD Mcu_Pflash_P1_End;
DWORD Mcu_Pflash_P2_End;
DWORD Mcu_Pflash_P3_End;
DWORD Mcu_Dflash_Size;
DWORD Mcu_Dflash_Logic_Size;
//BYTE Mcu_Type;
BYTE Mcu_Chip_Family;
BYTE Mcu_Chip_Rev;
BYTE Mcu_Emulation_Ext;
BYTE Mcu_Fsize;
BYTE Mcu_Sec;
BYTE Mcu_Chip_Id;
BYTE SectorAddressValid;
//******************************************************************************
// Function void InitClkSystem(void)
//
//------------------------------------------------------------------------------
// Description re-initialize clock system
//
//------------------------------------------------------------------------------
// Return value None
//
//------------------------------------------------------------------------------
// Parameters None
//
//------------------------------------------------------------------------------
// Date 2011-7-4
//
//******************************************************************************
void InitClkSystem(void)
{
//unsigned int uTemp;
_endinit_clear();
_safety_endinit_clear();
while (SCU_CCUCON0.B.LCK != 0U) /*Wait till ccucon0 lock is set */
{
}
SCU_CCUCON0.B.CLKSEL = 1; /*Select the EVR as fOSC for the clock distribution */
SCU_CCUCON0.B.UP = 1; /*Update the ccucon0 register */
while (SCU_CCUCON0.B.LCK != 0U) /*Wait till ccucon0 lock is set */
{
}
_safety_endinit_set();
_endinit_set();
}
//******************************************************************************
// Function void SendCANMessage(DWORD data)
//
//------------------------------------------------------------------------------
// Description send CAN message
//
//------------------------------------------------------------------------------
// Return value None
//
//------------------------------------------------------------------------------
// Parameters data : the data to be sent out
//
//------------------------------------------------------------------------------
// Date 2011-7-4
//
//******************************************************************************
void SendCANMessage(DWORD data)
{
CAN_MODATAL1.U = data;
CAN_MOFCR1.U = 0x04000000;
CAN_MOCTR1.U = 0x0F200000;
}
//******************************************************************************
// Function void Sector_Start_Address_Check(DWORD Flash_Start_Address,
// DWORD dwSectorAddr)
//
//------------------------------------------------------------------------------
// Description This function will check that the address is or not the start
// address of sector
//
//------------------------------------------------------------------------------
// Return value None
//
//------------------------------------------------------------------------------
// Parameters Flash_Start_Address: the start address of the sector in PFLASH
// dwSectorAddr : the start address to be erased
// dwSize : size of sector
//------------------------------------------------------------------------------
// Date 2011-7-4
//
//******************************************************************************
BYTE Sector_Start_Address_Check(DWORD Flash_Start_Address,DWORD dwSectorAddr,DWORD dwSize)
{
if(dwSectorAddr < Flash_Start_Address+ 0x0020000) //16k
{
if(!(dwSectorAddr & PFLASH_MASK1))
{
if(dwSize != 0x4000)
{
SendCANMessage(BSL_SIZE_ERROR);
return 0;
}
SectorAddressValid = 1;
}
}
else if(dwSectorAddr< Flash_Start_Address + 0x00060000) //32k
{
if(!(dwSectorAddr & PFLASH_MASK2))
{
if(dwSize != 0x8000)
{
SendCANMessage(BSL_SIZE_ERROR);
return 0;
}
SectorAddressValid = 1;
}
}
else if(dwSectorAddr< Flash_Start_Address + 0x000A0000) //64k
{
if(!(dwSectorAddr & PFLASH_MASK3))
{
if(dwSize != 0x10000)
{
SendCANMessage(BSL_SIZE_ERROR);
return 0;
}
SectorAddressValid = 1;
}
}
else if(dwSectorAddr< Flash_Start_Address + 0x00100000) //128k
{
if(!(dwSectorAddr & PFLASH_MASK4))
{
if(dwSize != 0x20000)
{
SendCANMessage(BSL_SIZE_ERROR);
return 0;
}
SectorAddressValid = 1;
}
}
else //256k
{
if(!(dwSectorAddr & PFLASH_MASK5))
{
if(dwSize != 0x40000)
{
SendCANMessage(BSL_SIZE_ERROR);
return 0;
}
SectorAddressValid = 1;
}
}
return 1;
}
//******************************************************************************
// Function void EraseSector(DWORD dwSectorAddr, DWORD dwSize)
//
//------------------------------------------------------------------------------
// Description This function will erase one sector of PFLASH
//
//------------------------------------------------------------------------------
// Return value None
//
//------------------------------------------------------------------------------
// Parameters dwSectorAddr: the start address of the sector in PFLASH
// dwSize : the size of sector
//------------------------------------------------------------------------------
// Date 2011-7-4
//
//******************************************************************************
void EraseSector(DWORD dwSectorAddr, DWORD dwSize)
{
//_Bool SectorAddressValid = 0;
_Bool PFlash = 1;
//_Bool UCB_Flag = 0;
int uvResult;
int index=0;
//DWORD uvTemp = 0xA0000000;
//DWORD dwAddr = dwSectorAddr;
//UINT* PFLASH_Addr = (UINT*) (dwSectorAddr);
//UINT FLASH_SIZE_DIV_4 = 0;
DWORD size = dwSize;
UINT vMulti_Sector_number =0;
//***************** check if the sector address is valid *******************
//***************** check if the sector size is valid **********************
SectorAddressValid = 0;
if((dwSectorAddr >= CLIB_FLASH_P_START) && (dwSectorAddr < Mcu_PFlash_End_Address))
{
switch(Mcu_Chip_Id&0xf0)
{
case 0x10:
if(dwSectorAddr < Mcu_Pflash_P0_End)
{
if(Sector_Start_Address_Check(TC21x_CLIB_FLASH_P0_START,dwSectorAddr,dwSize) == 0)
{
return;
}
}
else
{
SendCANMessage(BSL_ADDRESS_ERROR);
return;
}
break;
case 0x
没有合适的资源?快使用搜索试试~ 我知道了~
英飞凌 aurix bootloader AURIX.zip
共169个文件
opt:19个
d:19个
c:17个
需积分: 49 158 下载量 44 浏览量
2021-01-21
16:12:24
上传
评论 15
收藏 3.85MB ZIP 举报
温馨提示
infineon AURIX can bootloader
资源详情
资源评论
资源推荐
收起资源包目录
英飞凌 aurix bootloader AURIX.zip (169个子文件)
main.c 53KB
main.c 52KB
main.c 52KB
main.c 52KB
cstart.c 51KB
cstart.c 51KB
cstart.c 51KB
cstart.c 51KB
clib_flash.c 24KB
clib_flash.c 24KB
clib_flash.c 24KB
clib_flash.c 24KB
sync_on_halt.c 13KB
sync_on_halt.c 13KB
sync_on_halt.c 13KB
can.c 10KB
Loader2.c 5KB
.cproject 13KB
.cproject 12KB
.cproject 12KB
.cproject 12KB
.cproject 12KB
.ASC_on_CAN_Loader3_1k.elf.d 1KB
.ASC_on_CAN_Loader3.elf.d 1KB
.CANLoader.elf.d 1KB
.Loader3.elf.d 1KB
.Loader2.elf.d 1KB
.cstart.o.d 680B
.cstart.o.d 680B
.cstart.o.d 680B
.cstart.o.d 680B
.clib_flash.o.d 410B
.clib_flash.o.d 410B
.clib_flash.o.d 410B
.clib_flash.o.d 410B
.main.o.d 407B
.main.o.d 407B
.main.o.d 407B
.main.o.d 407B
.can.o.d 400B
.Loader2.o.d 202B
DConfig 0B
DConfig 0B
DConfig 0B
DConfig 0B
DConfig 0B
CANLoader.elf 74KB
ASC_on_CAN_Loader3_1k.elf 70KB
ASC_on_CAN_Loader3.elf 69KB
Loader3.elf 69KB
Loader2.elf 4KB
clib_flash.h 28KB
clib_flash.h 28KB
clib_flash.h 28KB
clib_flash.h 27KB
cstart.h 12KB
cstart.h 12KB
cstart.h 12KB
cstart.h 12KB
main.h 5KB
main.h 5KB
main.h 5KB
main.h 5KB
can.h 1KB
CANLoader.hex 9KB
ASC_on_CAN_Loader3.hex 9KB
ASC_on_CAN_Loader3_1k.hex 9KB
Loader3.hex 9KB
Loader2.hex 355B
CANLoader.launch 4KB
ASC_on_CAN_Loader3_1k.launch 3KB
ASC_on_CAN_Loader3.launch 3KB
Loader3.launch 3KB
Loader2.launch 3KB
llng208d 56KB
console.log 884B
console.log 878B
console.log 877B
console.log 856B
console.log 571B
CANLoader.lsl 12KB
ASC_on_CAN_Loader3_1k.lsl 12KB
Loader3.lsl 12KB
ASC_on_CAN_Loader3.lsl 12KB
Loader2.lsl 10KB
main.lst 2.64MB
clib_flash.lst 2.27MB
cstart.lst 2.21MB
can.lst 1.99MB
makefile 2KB
makefile 2KB
makefile 2KB
makefile 2KB
makefile 2KB
CANLoader.map 93KB
CANLoader.mapxml 50KB
ASC_on_CAN_Loader3_1k.mapxml 47KB
ASC_on_CAN_Loader3.mapxml 47KB
Loader3.mapxml 47KB
Loader2.mapxml 8KB
共 169 条
- 1
- 2
lllaoliu
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0