请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:AM6421 主题:SysConfig 中讨论的其他器件
工具/软件:
您好!
当我被测试主函数退出时,所有与析构函数相关的函数都没有运行。
GCC 属性是__attribute__(析构函数 (x))、其中 x 表示 API 优先级编号。
B.R.
Jaxon
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.
工具/软件:
您好!
当我被测试主函数退出时,所有与析构函数相关的函数都没有运行。
GCC 属性是__attribute__(析构函数 (x))、其中 x 表示 API 优先级编号。
B.R.
Jaxon
尊敬的 Tushar:
我的本地开发环境如下:
CCS 版本: 12.7.1.00001
SDK 版本:10.0.0.20
这样的示例代码、
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"
static __attribute__((constructor(101))) system_entry(void)
{
System_init();
Drivers_open();
}
static __attribute__((constructor(102))) system_entry_2(void)
{
Debug_LogP("Enter AM64 system.\n");
}
static __attribute__((destructor(101))) system_exit(void)
{
Drivers_close();
System_deinit();
}
static __attribute__((destructor(102))) system_exit_2(void)
{
Debug_LogP("Exit AM64 system.\n");
}
int main(void)
{
Debug_LogP("running AM64 system.\n");
return 0;
}
B.R.
Jaxon
尊敬的 Jaxon:
感谢您的耐心。
请按照以下步骤操作。
1.在中定义 init 和 deinit 函数 BOOT_ARMv8.c 文件位于 MCU_PLUS_SDK_am64x_11_00_00_15\source\kernel\nortos\DPL\A53。
typedef void (*func_ptr)(void);
extern func_ptr __preinit_array_start[0], __preinit_array_end[0];
extern func_ptr __init_array_start[0], __init_array_end[0];
extern func_ptr __fini_array_start[0], __fini_array_end[0];
void __init()
{
for ( func_ptr* func = __preinit_array_start; func != __preinit_array_end; func++ )
(*func)();
for ( func_ptr* func = __init_array_start; func != __init_array_end; func++ )
(*func)();
}
void __deinit()
{
for ( func_ptr* func = __fini_array_start; func != __fini_array_end; func++ )
(*func)();
}
2.修改 __SYSTEM_START 传递函数。
int __system_start(void)
{
volatile unsigned int * bs;
volatile unsigned int * be;
unsigned int * dl;
unsigned int * ds;
unsigned int * de;
#if defined (SMP_FREERTOS)
/* Initialization of bss section is done only once (From Core0) */
if (0 == Armv8_getCoreId())
{
/* initialize .bss to zero */
bs = & __bss_start__;
be = & __bss_end__;
while (bs < be)
{
*bs = 0;
bs++;
}
/* relocate the .data section */
dl = & __data_load__;
ds = & __data_start__;
de = & __data_end__;
if (dl != ds)
{
while (ds < de)
{
*ds = *dl;
dl++;
ds++;
}
}
/* Set flag to indicate bss initialization is done by Core0 */
bssInitDone = 1;
}
else
{
/* Core1 should wait until bss initialization is done by Core0 */
while(bssInitDone != 1)
{
;
}
}
#else
/* initialize .bss to zero */
bs = & __bss_start__;
be = & __bss_end__;
while (bs < be)
{
*bs = 0;
bs++;
}
/* relocate the .data section */
dl = & __data_load__;
ds = & __data_start__;
de = & __data_end__;
if (dl != ds)
{
while (ds < de)
{
*ds = *dl;
dl++;
ds++;
}
}
#endif
#if defined (SMP_FREERTOS)
/* Wait for MMU init to be done by Core0 when running SMP FreeRTOS */
/* This is done to synchronise between Core0 and Core1 so that MMU initialization is done by Core 0 */
if (1 == Armv8_getCoreId())
{
while(mmuInitDone != 1)
{
;
}
}
#endif
CacheP_enableSMP();
/* initialize mmu and cache */
__mmu_init();
#if defined (SMP_FREERTOS)
/* Set flag to indicate the MMU initialization completion by Core0 */
if (0 == Armv8_getCoreId())
{
mmuInitDone = 1;
CacheP_wb((void *)&mmuInitDone, sizeof(mmuInitDone), CacheP_TYPE_ALL);
}
#endif
__init();
main();
__deinit();
Armv8_exit();
return(0);
}
3.构建内核的库。
cd ${MCU+SDK}/source/kernel/nortos
gmake -s -f makefile.am64x.a53.gcc-aarch64 PROFILE=debug
gmake -s -f makefile.am64x.a53.gcc-aarch64
4.在示例的 SysConfig 文件中、添加以下部分。
.ARM.exidx : {} > DDR
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} > DDR
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} > DDR
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} > DDR
5.重建应用程序。 它现在应该可以工作了。
请告知我们上述解决方案是否有效。
此致、
Tushar