CCS:Type region `APP_CODE_MEM' overflowed by 641240 b

遇到问题

随着代码的不断增加,突然有一天编译出错却并不是语法错误:
这里写图片描述

分析问题

看起来像是代码段空间不足造成的,之前编译成功后生成的.out文件大小在1.5M左右,这次新增加了两个开源库lwIP和mbedtls就出现预分配空间不足的问题了,但是我找遍了CCS所有配置都没有找到APP_CODE_MEM在哪里赋值的。
于是我查看了CCS生成的.cmd文件:

MEMORY
{
    SRAM_LO (RWX) : org = 0x402f0000, len = 0x400
    SRAM_HI (RWX) : org = 0x402f0400, len = 0xfc00
    OCMC_SRAM (RWX) : org = 0x40300000, len = 0x10000
    APP_CODE_MEM : org = 0x80001000, len = 0x1ff000
    APP_CACHED_DATA_MEM : org = 0x80200000, len = 0x1400000
    APP_UNCACHED_DATA_BLK3_MEM : org = 0xa0000000, len = 0x200000
    APP_CACHED_DATA_BLK1_MEM : org = 0x81600000, len = 0xf400000
    APP_CACHED_DATA_BLK2_MEM : org = 0x90a00000, len = 0x8000000
}

len = 0x1ff000就2M的空间了,可以断定是这个预分配空间不够了,可以通过修改len = 0x2ff000使得编译通过,但是这是CCS自动生成的文件会被覆盖掉,要找到源头修改才行,于是查找了CCS的XDCTools配置:
这里写图片描述
可以看到它引用了一个编译配置文件:

/*
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* *  Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
* *  Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
*
* *  Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
 *  ======== config_am335x_a8.bld ========
 *  Build configuration script for BSP drivers
 */
/* load the required modules for the configuration */
var A8     = xdc.useModule('gnu.targets.arm.A8F');
/* A8 compiler directory path                    */
A8.rootDir        = java.lang.System.getenv("CGTOOLS_A8");

/* Read the current board */
var CurrentPlatform = java.lang.System.getenv("BOARD");

if (CurrentPlatform == null)
{
    /* The env variable is probably not set while running inside CCS */
    CurrentPlatform = java.lang.System.getProperty("BOARD");
}

/*add bspLib to support SemiHosting to enable system_printf on A8*/
/* GCC bare metal targets */
var gccArmTargets = xdc.loadPackage('gnu.targets.arm');
gccArmTargets.A8F.bspLib = "rdimon";


/*
Memory map

DDR: 0x80000000 (Ist 512MB - Cached)

NOTE: APP_CACHED_DATA_BLK1_MEM is used to route sections which needs to be in a
separate section preferably at the end of 512 MB memory.
For example:
Frame buffer memory can be less at runtime depending on boards with lesser DDR (as in TDA 12x12 POP boards).
If the same is routed to APP_CACHED_DATA_MEM section then the linker will
place the frame buffer before other data section and the other data will fall into
region outside the DDR in the board. Hence separate section is used!!

+-----------------------------+
| APP_CODE_MEM                | 2MB
+-----------------------------+
| APP_CACHED_DATA_MEM         | 20MB
+-----------------------------+
| APP_CACHED_DATA_BLK1_MEM    | 244MB
+-----------------------------+
| APP_CACHED_DATA_BLK2_MEM    | 128MB
+-----------------------------+
| NOT USED                    | Remaining MB
+-----------------------------+

DDR: 0xA0000000 (2nd 512MB - Non-Cached)
+-----------------------------+
|                             |
| APP_UNCACHED_DATA_BLK3_MEM  | 2MB
+-----------------------------+
|     NOT USED                | Remaining MB
+-----------------------------+

*/

var KB=1024;
var MB=KB*KB;

var DDR3_ADDR_0;
var DDR3_ADDR_1;

var APP_CODE_ADDR;
var APP_CODE_SIZE;

var APP_CACHED_DATA_ADDR;
var APP_CACHED_DATA_SIZE;

var APP_UNCACHED_DATA_BLK3_ADDR;
var APP_UNCACHED_DATA_BLK3_SIZE;

var APP_CACHED_DATA_BLK1_ADDR;
var APP_CACHED_DATA_BLK1_SIZE;

var APP_CACHED_DATA_BLK2_ADDR;
var APP_CACHED_DATA_BLK2_SIZE;

/* First 4KB reserved for components such as SBL */
SBL_SIZE                = 4*KB;
DDR3_ADDR_0             = 0x80000000 + SBL_SIZE;
DDR3_ADDR_1             = 0xA0000000;

APP_CODE_SIZE                   = 2*MB - SBL_SIZE;
APP_CACHED_DATA_SIZE            = 20*MB;
APP_CACHED_DATA_BLK1_SIZE       = 244*MB;
APP_CACHED_DATA_BLK2_SIZE       = 128*MB;
APP_UNCACHED_DATA_BLK3_SIZE     = 2*MB;

APP_CODE_ADDR                   = DDR3_ADDR_0;
APP_CACHED_DATA_ADDR            = APP_CODE_ADDR + APP_CODE_SIZE;
APP_CACHED_DATA_BLK1_ADDR       = APP_CACHED_DATA_ADDR + APP_CACHED_DATA_SIZE;
APP_CACHED_DATA_BLK2_ADDR       = APP_CACHED_DATA_BLK1_ADDR + APP_CACHED_DATA_BLK1_SIZE;
APP_UNCACHED_DATA_BLK3_ADDR     = DDR3_ADDR_1;



myplatform = "ti.platforms.evmAM3359";


Build.platformTable[myplatform] =
{
    externalMemoryMap:
    [
        ["APP_CODE_MEM", {
            comment : "APP_CODE_MEM",
            name    : "APP_CODE_MEM",
            base    : APP_CODE_ADDR,
            len     : APP_CODE_SIZE
        }],
        ["APP_CACHED_DATA_MEM", {
            comment : "APP_CACHED_DATA_MEM",
            name    : "APP_CACHED_DATA_MEM",
            base    : APP_CACHED_DATA_ADDR,
            len     : APP_CACHED_DATA_SIZE
        }],
        ["APP_UNCACHED_DATA_BLK3_MEM", {
            comment : "APP_UNCACHED_DATA_BLK3_MEM",
            name    : "APP_UNCACHED_DATA_BLK3_MEM",
            base    : APP_UNCACHED_DATA_BLK3_ADDR,
            len     : APP_UNCACHED_DATA_BLK3_SIZE
        }],
        ["APP_CACHED_DATA_BLK1_MEM", {
            comment : "APP_CACHED_DATA_BLK1_MEM",
            name    : "APP_CACHED_DATA_BLK1_MEM",
            base    : APP_CACHED_DATA_BLK1_ADDR,
            len     : APP_CACHED_DATA_BLK1_SIZE
        }],
        ["APP_CACHED_DATA_BLK2_MEM", {
            comment : "APP_CACHED_DATA_BLK2_MEM",
            name    : "APP_CACHED_DATA_BLK2_MEM",
            base    : APP_CACHED_DATA_BLK2_ADDR,
            len     : APP_CACHED_DATA_BLK2_SIZE
        }],
    ],
    codeMemory: "APP_CODE_MEM",
    dataMemory: "APP_CACHED_DATA_MEM",
    stackMemory: "APP_CACHED_DATA_MEM"
};

解决问题

修改”${PDK_INSTALL_PATH}/ti/build/am335x/config_am335x_a8.bld”将
APP_CODE_SIZE = 2*MB - SBL_SIZE;
改为
APP_CODE_SIZE = 4*MB - SBL_SIZE;

然后在CCS上重新编译ok了
再次检查一下.cmd看看是否重新生成了。

MEMORY
{
    SRAM_LO (RWX) : org = 0x402f0000, len = 0x400
    SRAM_HI (RWX) : org = 0x402f0400, len = 0xfc00
    OCMC_SRAM (RWX) : org = 0x40300000, len = 0x10000
    APP_CODE_MEM : org = 0x80001000, len = 0x3ff000
    APP_CACHED_DATA_MEM : org = 0x80400000, len = 0x1400000
    APP_UNCACHED_DATA_BLK3_MEM : org = 0xa0000000, len = 0x200000
    APP_CACHED_DATA_BLK1_MEM : org = 0x81800000, len = 0xf400000
    APP_CACHED_DATA_BLK2_MEM : org = 0x90c00000, len = 0x8000000
}

确认ok了

另个问题

在引入TI的NDK模块后,发现可以正常运行,网络功能ok,但是奇怪的是只要打断点调试就崩溃,可以通过修改pktNumFrameBufs配置来解决:
这里写图片描述
比如将默认pktNumFrameBufs=192改大卫pktNumFrameBufs=384就ok了;
但是这个配置不能随意无限改大,因为它依赖APP_CODE_SIZE的大小,越界了同样会出现`APP_CODE_MEM’ overflowed 的问题

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

horsen_duan

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值