This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

请教大数组的访问问题:

各位专家,目前用ccs5.3开发C5534,烧Flash的时候发现对于bin文件导入后的 Uint16 bootImage[64000]数组,只能访问0~32767地址,访问32768时得到错误值,很像越界了,百思不得其解,代码如下,求助!

//源代码

#pragma DATA_SECTION(bootImage, ".buffer1")
Uint16 bootImage[64000];

1.直接用 temp = bootImage[32768];访问都得不到正确数值

2.进入调试环境观察expression的方式看到  bootImage[32768]内容正确

3. map文件中 _bootImage的 Word address为0x00010000  

cmd文件===========================================================================

/******************************************************************************/

-stack 0x2000 /* Primary stack size */
-sysstack 0x1000 /* Secondary stack size */
-heap 0x2000 /* Heap area size */

-c /* Use C linking conventions: auto-init vars at runtime */
-u _Reset /* Force load of reset interrupt handler */

/* SPECIFY THE SYSTEM MEMORY MAP */

MEMORY
{
PAGE 0: /* ---- Unified Program/Data Address Space ---- */

MMR (RWIX): origin = 0x000000, length = 0x0000c0 /* MMRs */
DARAM0 (RWIX): origin = 0x0000c0, length = 0x00ff40 /* 64KB - MMRs */
SARAM0 (RWIX): origin = 0x010000, length = 0x010000 /* 64KB */
SARAM1 (RWIX): origin = 0x020000, length = 0x01FE00 /* 128KB -512B*/
VECS (RWIX): origin = 0x03FE00, length = 0x000200 /* 512B */
PDROM (RIX): origin = 0xff8000, length = 0x008000 /* 32KB */

PAGE 2: /* -------- 64K-word I/O Address Space -------- */

IOPORT (RWI) : origin = 0x000000, length = 0x020000
}

/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */

SECTIONS
{
.text >> SARAM0 /* Code */

/* Both stacks must be on same physical memory page */
.stack > DARAM0 /* Primary system stack */
.sysstack > DARAM0 /* Secondary system stack */

.data >> DARAM0|SARAM0 /* Initialized vars */
.bss >> DARAM0|SARAM0 /* Global & static vars */
.const >> DARAM0|SARAM0 /* Constant data */
.sysmem > DARAM0|SARAM0 /* Dynamic memory (malloc) */
.switch > SARAM0 /* Switch statement tables */
.cinit > SARAM0 /* Auto-initialization tables */
.pinit > SARAM0 /* Initialization fn tables */
.cio > SARAM0 /* C I/O buffers */
.args > SARAM0 /* Arguments to main() */

vectors > VECS /* Interrupt vectors */
.buffer1 > SARAM1
.ioport > IOPORT PAGE 2 /* Global & static ioport vars */
}

  • 这是DSP内核的限制。

    http://processors.wiki.ti.com/index.php?title=C5000_DSP_FAQ#Why_can_I_not_correctly_move_data_that_spans_a_64K-word_boundary.3F

  • 非常感谢,有几个问题请教一下:

    1.目前的问题是无法访问 大于32kWord的地址,而不是文中所说的64kWord

    2.链接中说section不能超过64kWord,而上面给出的cmd文件中  buffer1所在的SARAM1起始地址和大小完全满足该要求,origin = 0x020000, length = 0x01FE00

    3.按照解决方案2给出的代码,改写了memcpy函数如下,没有效果

    void copy(Uint32 dst, Uint32 src, Uint32 cnt)
    {
    Uint32 x = 0;
    for(x = 0; x < cnt; x++)
             *(Uint16*)dst++ = *(Uint16*)src++;
    }

    请问是不是我对链接的描述什么地方理解的不对?

    谢谢

  • 仿真器调试时能访问大数组吗?还是只是在烧写进flash后才出现这个问题?

  • 仿真器就不能

    因为我的场景就是用仿真器去烧Flash,用的M25P16,跟5535开发板上的Flash兼容,每个page 256B,写入后再读出做校验的时候发现从128页开始校验错误,这样一步步反推才发现是写入的内容就不对,进一步验证 temp =  = bootImage[32768];的数据就是错误的。

    后来尝试直接访问绝对地址memcpy(spi_buf,  (Uint32*)(0x18000), 256);能得到正确的结果(_bootImage的绝对地址是00010000h)

    当然也有折衷的办法就是把bin文件的两个byte拼成1个Word,这样可以使总数据量减半,因为之前fread读入的时候是把1个byte直接扩展成了1个Word。但是这样总归是没有找到问题的根源,烦请帮忙分析一下,多谢