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.

[参考译文] TMS320F28027:分配内存扇区问题

Guru**** 2794745 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1070936/tms320f28027-allocation-memory-sector-problem

部件号:TMS320F28027

大家好。

在.cmd 链接器文件中,我定义 了一个名为 eeprom_sect 的 EEPROM 仿真的内存区域

MEMORY
{
PAGE 0:    /* Program Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
   progRAM	   : origin = 0x008000, length = 0x000300	/* serve per routine settaggio flash speed che deve girare in RAM */
   OTP         : origin = 0x3D7800, length = 0x000400     /* on-chip OTP */

/* DEFINIZIONE DEI SETTORI IN USO AL BOOTLOADER */
	/* FLASH SETTORE D */
   FLASHA      : origin = 0x3F0000, length = 0x005FFA     /* on-chip FLASH */

   BOOT_VECT   : origin = 0x3F5FFA, length = 0x000002
   BOOT_VERS   : origin = 0x3F5FFC, length = 0x000002
   BOOT_CRC    : origin = 0x3F5FFF, length = 0x000001

   /* FLASH SETTORE A */
   BOOT_UID    : origin = 0x3F6000, length = 0x000001
   EEPROM_SECT : origin = 0x3F6001, length = 0x000FFF
   BOOT_IMAGE  : origin = 0x3F7000, length = 0x000F80


   CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */
   BEGIN       : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */
   CSM_PWL_PROG: origin = 0x3F7FF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */

   IQTABLES    : origin = 0x3FE000, length = 0x000B50     /* IQ Math Tables in Boot ROM */
   IQTABLES2   : origin = 0x3FEB50, length = 0x00008C     /* IQ Math Tables in Boot ROM */
   IQTABLES3   : origin = 0x3FEBDC, length = 0x0000AA      /* IQ Math Tables in Boot ROM */

   ROM         : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */
   RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */

PAGE 1 :   /* Data Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
           /* Registers remain on PAGE1                                                  */

   BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */
   RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */
   dataRAM	   : origin = 0x008300, length = 0x000D00	  /* Ram da usare come Ram */

}

我创建了一个想要 放入 eepro_sect 的扇区标准 EepromFlashSector

SECTIONS
{

   /* Allocate program areas: */
   .cinit              : > FLASHA           PAGE = 0
   .pinit              : > FLASHA,          PAGE = 0
   .text               : > FLASHA 		    PAGE = 0
   codestart           : > BEGIN            PAGE = 0
   ramfuncs            : LOAD = FLASHA,
                         RUN = progRAM,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_SIZE(_RamfuncsLoadSize),
                         RUN_START(_RamfuncsRunStart),
                         PAGE = 0

   csmpasswds          : > CSM_PWL_PROG PAGE = 0
   csm_rsvd            : > CSM_RSVD     PAGE = 0

   /* Allocate uninitalized data sections: */
   .stack              : > RAMM0        PAGE = 1
   .ebss               : > dataRAM,  /* DRAML0, */
                         START(_RamUninitializedStart),
                         SIZE(_RamUninitializedSize),
                         PAGE = 1

   .esysmem            : > dataRAM       PAGE = 1
  /* .sysmem             : > DRAML0       PAGE = 1
   .cio                : >> RAMM0 | RAMM1 | DRAML0       PAGE = 1
*/
   /* Initalized sections go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHA       PAGE = 0
   .switch             : > FLASHA       PAGE = 0

   /* Allocate IQ math areas: */
   IQmath              : > FLASHA       PAGE = 0            /* Math Code */
   IQmathTables        : > IQTABLES,    PAGE = 0, TYPE = NOLOAD

   /* Uncomment the section below if calling the IQNexp() or IQexp()
      functions from the IQMath.lib library in order to utilize the
      relevant IQ Math table in Boot ROM (This saves space and Boot ROM
      is 1 wait-state). If this section is not uncommented, IQmathTables2
      will be loaded into other memory (SARAM, Flash, etc.) and will take
      up space, but 0 wait-state is possible.
   */
   /*
   IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
   {

              IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)

   }
   */
   /* Uncomment the section below if calling the IQNasin() or IQasin()
      functions from the IQMath.lib library in order to utilize the
      relevant IQ Math table in Boot ROM (This saves space and Boot ROM
      is 1 wait-state). If this section is not uncommented, IQmathTables2
      will be loaded into other memory (SARAM, Flash, etc.) and will take
      up space, but 0 wait-state is possible.
   */
   /*
   IQmathTables3    : > IQTABLES3, PAGE = 0, TYPE = NOLOAD
   {

              IQmath.lib<IQNasinTable.obj> (IQmathTablesRam)

   }
   */
   /* EEPROM SECTOR */
   EepromFlashSector   : > EEPROM_SECT PAGE = 0            /* EEPROM FILE */

   /* .reset is a standard section used by the compiler.  It contains the */
   /* the address of the start of _c_int00 for C Code.   /*
   /* When using the boot ROM this section and the CPU vector */
   /* table is not needed.  Thus the default type is set here to  */
   /* DSECT  */
   .reset              : > RESET,      PAGE = 0, TYPE = DSECT
   vectors             : > VECTORS     PAGE = 0, TYPE = DSECT

}

IIN 我的代码在 EepromFlashSector 上分配一个变量

#pragma DATA_SECTION(eepromPages, "EepromFlashSector");

EEPROMPAGE    eepromPages[EEPROM_NUM_PAGES];

我的问题是,这种变体不是从 eepro_sect 的源地址开始,而是在64字节之后开始,所以我无法使用我为 EEPROM 保留的整个空间,有人可以告诉我什么问题,这样我就可以填满整个 EEPROM 空间。

在此处的.map 文件中,您可以看到链接程序在何处分配变量  

MEMORY CONFIGURATION

         name            origin    length      used     unused   attr    fill
----------------------  --------  ---------  --------  --------  ----  --------
PAGE 0:
  RAMM1                 00000400   00000400  00000000  00000400  RWIX
  progRAM               00008000   00000300  0000008e  00000272  RWIX
  OTP                   003d7800   00000400  00000000  00000400  RWIX
  FLASHA                003f0000   00005ffa  00004a2a  000015d0  RWIX
  BOOT_VECT             003f5ffa   00000002  00000000  00000002  RWIX
  BOOT_VERS             003f5ffc   00000002  00000000  00000002  RWIX
  BOOT_CRC              003f5fff   00000001  00000000  00000001  RWIX
  BOOT_UID              003f6000   00000001  00000000  00000001  RWIX
  EEPROM_SECT           003f6001   00000fff  00000fb9  00000046  RWIX
  BOOT_IMAGE            003f7000   00000f80  00000000  00000f80  RWIX
  CSM_RSVD              003f7f80   00000076  00000000  00000076  RWIX
  BEGIN                 003f7ff6   00000002  00000002  00000000  RWIX
  CSM_PWL_PROG          003f7ff8   00000008  00000000  00000008  RWIX
  IQTABLES              003fe000   00000b50  00000b50  00000000  RWIX
  IQTABLES2             003feb50   0000008c  00000000  0000008c  RWIX
  IQTABLES3             003febdc   000000aa  00000000  000000aa  RWIX
  ROM                   003ff27c   00000d44  00000000  00000d44  RWIX
  RESET                 003fffc0   00000002  00000000  00000002  RWIX
  VECTORS               003fffc2   0000003e  00000000  0000003e  RWIX

PAGE 1:
  BOOT_RSVD             00000000   00000050  00000000  00000050  RWIX
  RAMM0                 00000050   000003b0  00000300  000000b0  RWIX
  DEV_EMU               00000880   00000105  00000004  00000101  RWIX
  SYS_PWR_CTL           00000985   00000003  00000003  00000000  RWIX
  FLASH_REGS            00000a80   00000060  00000008  00000058  RWIX
  CSM                   00000ae0   00000010  00000010  00000000  RWIX
  ADC_RESULT            00000b00   00000020  00000020  00000000  RWIX
  CPU_TIMER0            00000c00   00000008  00000008  00000000  RWIX
  CPU_TIMER1            00000c08   00000008  00000008  00000000  RWIX
  CPU_TIMER2            00000c10   00000008  00000008  00000000  RWIX
  PIE_CTRL              00000ce0   00000020  0000001a  00000006  RWIX
  PIE_VECT              00000d00   00000100  00000100  00000000  RWIX
  COMP1                 00006400   00000020  00000020  00000000  RWIX
  COMP2                 00006420   00000020  00000020  00000000  RWIX
  EPWM1                 00006800   00000040  00000040  00000000  RWIX
  EPWM2                 00006840   00000040  00000040  00000000  RWIX
  EPWM3                 00006880   00000040  00000040  00000000  RWIX
  EPWM4                 000068c0   00000040  00000040  00000000  RWIX
  ECAP1                 00006a00   00000020  00000020  00000000  RWIX
  GPIOCTRL              00006f80   00000040  00000040  00000000  RWIX
  GPIODAT               00006fc0   00000020  00000020  00000000  RWIX
  GPIOINT               00006fe0   00000020  0000000a  00000016  RWIX
  SYSTEM                00007010   00000020  0000001f  00000001  RWIX
  SPIA                  00007040   00000010  00000010  00000000  RWIX
  SCIA                  00007050   00000010  00000010  00000000  RWIX
  NMIINTRUPT            00007060   00000010  00000010  00000000  RWIX
  XINTRUPT              00007070   00000010  00000010  00000000  RWIX
  ADC                   00007100   00000080  00000051  0000002f  RWIX
  I2CA                  00007900   00000040  00000022  0000001e  RWIX
  dataRAM               00008300   00000d00  000006d2  0000062e  RWIX
  PARTID                003d7fff   00000001  00000001  00000000  RWIX
  CSM_PWL               003f7ff8   00000008  00000008  00000000  RWIX


SECTION ALLOCATION MAP

 output                                  attributes/
section   page    origin      length       input sections
--------  ----  ----------  ----------   ----------------
ramfuncs   0    003f46ab    0000008e     RUN ADDR = 00008000
                  003f46ab    0000008a     flash.obj (ramfuncs)
                  003f4735    00000004     f2802x_usdelay.obj (ramfuncs)

.cinit     0    003f4739    0000013d     
                  003f4739    00000044     subroutine.obj (.cinit)
                  003f477d    00000042     tig.obj (.cinit)
                  003f47bf    00000041     interrupt.obj (.cinit)
                  003f4800    00000030     allarmi.obj (.cinit)
                  003f4830    00000014     application.obj (.cinit)
                  003f4844    00000010     app_spi.obj (.cinit)
                  003f4854    0000000e     rts2800_ml.lib : exit.c.obj (.cinit)
                  003f4862    00000005                    : _lock.c.obj (.cinit:__lock)
                  003f4867    00000005                    : _lock.c.obj (.cinit:__unlock)
                  003f486c    00000004     mma.obj (.cinit)
                  003f4870    00000004     sci_io.obj (.cinit)
                  003f4874    00000002     --HOLE-- [fill = 0]

EepromFlashSector 
*          0    003f6040    00000fb9     UNINITIALIZED
                  003f6040    00000fb9     eeprom.obj (EepromFlashSector)

谢谢!!!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    变量的类型是什么? 这是一个结构吗?

    您使用的是 COFF/EABI 格式吗?

    此致,

    维纳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    嗨,我的输出格式是 “传统 COFF”,变量是结构  

    typedef struct _tagEepromPage{
        uint16_t    pageCode;
        EEPROM      Data;
    } EEPROMPAGE, *PEEPROMPAGE; // 6 word + 1word Checksum = 7word Totali
    
    #define EEPROM_NUM_PAGES      575
    
    //allocazione dell'eeprom in flash
    #pragma DATA_SECTION(eepromPages, "EepromFlashSector");
    
    EEPROMPAGE    eepromPages[EEPROM_NUM_PAGES];

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    我认为这是由于“数据页(DP)指针负载优化”。 有关详细信息,请参阅文档 “TMS320C28x 优化 C/C++编译器”

    此致,

    维纳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢 Veena,我理解了这个问题,所以这个问题的解决方案为变量提供了“无阻塞的数据属性”,这样编译就不使用 DP 优化,也不会使我的数据扇区从页面集(3F6040)开始,这是正确的?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    没错。 您可以使用该属性禁用阻止。 但是,这会导致周期的小幅增加。

    此致,

    维纳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢 Veena 的帮助,您已将我的问题作为中心,对我来说,问题已解决