这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » vxworks code error,thanks

共2条 1/1 1 跳转至

vxworks code error,thanks

菜鸟
2007-12-13 09:21:13     打赏

LOCAL AT91S_MciDeviceFeatures   MCI_Device_Features;
LOCAL  AT91S_MciDeviceDesc   MCI_Device_Desc;
LOCAL AT91S_MciDevice *    pMCI_Device=0;

/*-----------------------------------------------*/
/* SDCard Device Descriptor Structure Definition */
/*-----------------------------------------------*/
typedef struct _AT91S_MciDeviceDesc
{
    volatile unsigned int state;
 unsigned int   SDCard_bus_width;

} AT91S_MciDeviceDesc, *AT91PS_MciDeviceDesc;

/*---------------------------------------------*/
/* MMC & SDCard Structure Device Features    */
/*---------------------------------------------*/
typedef struct _AT91S_MciDeviceFeatures
{
    unsigned int Card_Inserted;    /* (0=AT91C_CARD_REMOVED) (1=AT91C_MMC_CARD_INSERTED) (2=AT91C_SD_CARD_INSERTED)*/
    unsigned int  Relative_Card_Address;  /* RCA*/
 unsigned int  Max_Read_DataBlock_Length; /* 2^(READ_BL_LEN) in CSD */
 unsigned int  Max_Write_DataBlock_Length; /* 2^(WRITE_BL_LEN) in CSD*/
 unsigned int Read_Partial;    /* READ_BL_PARTIAL*/
 unsigned int Write_Partial;    /* WRITE_BL_PARTIAL*/
 unsigned int Erase_Block_Enable;   /* ERASE_BLK_EN*/
 unsigned int Read_Block_Misalignment; /* READ_BLK_MISALIGN*/
 unsigned int Write_Block_Misalignment; /* WRITE_BLK_MISALIGN*/
 unsigned int Sector_Size;    /* SECTOR_SIZE*/
 unsigned int Memory_Capacity;   /* Size in bits of the device*/
 
} AT91S_MciDeviceFeatures, *AT91PS_MciDeviceFeatures ;

/*---------------------------------------------*/
/* MCI Device Structure Definition       */
/*---------------------------------------------*/
typedef struct _AT91S_MciDevice
{
 BLK_DEV blkDev;
 int drive;
        int blkOffset ;
 AT91PS_MciDeviceDesc    pMCI_DeviceDesc; /* MCI device descriptor*/
 AT91PS_MciDeviceFeatures  pMCI_DeviceFeatures;/* Pointer on a MCI device features array  */
}AT91S_MciDevice, *AT91PS_MciDevice;

void AT91F_CfgDevice(AT91PS_MciDevice pmmcDev)
{
 /* Init Device Structure*/

 MCI_Device_Features.Relative_Card_Address   = 0;
 MCI_Device_Features.Card_Inserted     = AT91C_CARD_REMOVED;
 MCI_Device_Features.Max_Read_DataBlock_Length = 0;
 MCI_Device_Features.Max_Write_DataBlock_Length  = 0;
 MCI_Device_Features.Read_Partial     = 0;
 MCI_Device_Features.Write_Partial     = 0;
 MCI_Device_Features.Erase_Block_Enable    = 0;
 MCI_Device_Features.Sector_Size     = 0;
 MCI_Device_Features.Memory_Capacity    = 0;
 
 MCI_Device_Desc.state       = AT91C_MCI_IDLE;
 MCI_Device_Desc.SDCard_bus_width    = AT91C_MCI_SCDBUS;
 
 /* Init AT91S_DataFlash Global Structure, by default AT45DB choosen !!!*/
 pmmcDev->pMCI_DeviceDesc   = &MCI_Device_Desc;
 pmmcDev->pMCI_DeviceFeatures  = &MCI_Device_Features;

}


void mmcDevCreate(void)
{
 AT91PS_MciDevice pmmcDev;
  
    if ((pmmcDev = (AT91PS_MciDevice )calloc(sizeof (AT91PS_MciDevice), 1)) == NULL)
 return (NULL);
     pMCI_Device = pmmcDev; 
     AT91F_CfgDevice(pmmcDev);
    
}


上面代码中,执行到
 pmmcDev->pMCI_DeviceDesc   = &MCI_Device_Desc;
 pmmcDev->pMCI_DeviceFeatures  = &MCI_Device_Features;
系统出错,提示信息如下:
Data abort
Exception address: 0x20013fe8
Current Processor Status Register: 0x20000013

trcStack aborted: error in top frame
shell restarted.


请问,这边可以直接给指针赋值?谢谢!




关键词: vxworks     error     thanks     AT91    

菜鸟
2007-12-24 16:17:08     打赏
2楼
从报出的异常信息(数据访问错误 )来看,出错应该是这样来由的:程序指令中要求向一个地址发起某种传输(不同位宽的读、写),结果CPU无法完成此操作,于是产生内部异常,PC指针被移到数据异常处理入口,数据异常处理程序于是打印出该信息 
你的代码没有细看,但是,从现象来说,产生数据异常最有可能的情况有两种。
1. 你程序中的数据访问方式不合法(CPU无法发起给定位宽向给定地址的读/写传输)。
2. 访问地址不合法(地址不存在或者是MMU表中无法寻找到,如果有MMU的话)。

但可能性大的,应该是第一种,通常由由对齐问题引起,在大端模式的CPU下容易出线此错误,而同样的程序在小端模式的CPU比如x86下则不会出线此错误。因为大端模式的CPU有自然对齐的要求,如果向一个非4的倍数的地址发起32位宽的数据读写传输,则会产生数据错误。如果是这个原因引起,要查的话,就看程序中是否存在强制类型转换和指针强制类型转换,特别是指针。


共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]