主题MATHLIB 中讨论的其他器件
工具/软件:
我尝试在没有 BIOS/SYS 的情况下使用双核操作。 当我从 CCS 运行/调试时、它可以正常工作、但当我将应用程序写入闪存并独立引导时、它不起作用。
https://github.com/rk4526/dualExampleC6657.git
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.
工具/软件:
我尝试在没有 BIOS/SYS 的情况下使用双核操作。 当我从 CCS 运行/调试时、它可以正常工作、但当我将应用程序写入闪存并独立引导时、它不起作用。
https://github.com/rk4526/dualExampleC6657.git
/********************************************************************************************
*版权所有 (c) 2011 Texas Instruments Incorporated - http://www.ti.com
*
*重新分发和使用源代码和二进制格式,无论有无
*允许修改,前提是满足以下条件
*符合:
*
*源代码的重新分发必须保留上述版权
*声明、本条件列表和以下免责声明。
*
*二进制形式的再发行必须复制上述版权
*声明、本条件列表和中的下述免责声明
*随附的文档和/或其他材料
*分发。
*
*既不是 Texas Instruments 公司的名称,也不是公司的名称
*其贡献者可用于认可或推广衍生产品
*未经事先书面许可,从本软件下载。
*
*本软件由版权持有者和贡献者提供
“按现状“和“按可得到“的基础提供的任何明示或暗示的保证,包括但不限于
仅限于对适销性和适用性的暗示保证
*不承认特定目的。 在任何情况下均不得使用版权
*所有者或贡献者对任何直接、间接、附带、
*特殊、惩戒性或后果性损害(包括但不包括
不会侵犯任何第三者对该物品享有的物权,或版权、专利、商标、商业秘密或其他知识产权;
*数据,或利润;或业务中断)然而引起和任何
*责任理论,无论是在合同,严格责任,还是 TORT
*(包括疏忽或其他)在使用中以任何方式产生
*本软件,即使被告知可能发生此类损坏。
*
************************************************************************************** /
/*
*链接器命令文件
*
*/
-c
-heap 0x40000
-stack 0x10000
-l ti/DSPLIB/lib/DSPLIB.lib
-l ti/DSPLIB/lib/DSPLIB_Cn.lib
-l ti/mathlib/lib/mathlib.lib
移动数据
{
L1PSRAM (rwx):org = 0x00E00000、len = 0x0007FFF // L1PSRAM
L1DSRAM (rwx):org = 0x00F00000、len = 0x0007FFF // L1DSRAM
L2SRAM (rwx):org = 0x1800000、len = 0x080000 /*my testing*/
L2SRAM_2 (rwx):org = 0x11800000、len = 0x080000
RUNMEM (RWX):org = 0x0820000、len = 0x01000000
uPP (rwx): org = 0x0c000000、len = 0x800
MSMCSRAM (rwx):org = 0x0c001000、len = 0x00FF000
}
很重要
{
.kernel:{
DSPLIB*<*.o*>(.text:optimized){ size (_kernel_size)}
}加载> MSMCSRAM
.text:load >> MSMCSRAM
.text:touch:load >> MSMCSRAM
platform_lib:load > MSMCSRAM
组 (NEAR_DP)
{
.neardata
.rodata
.bss
} LOAD > MSMCSRAM
.init_array:load >> MSMCSRAM
.far:load >> MSMCSRAM
.fardata:load >> MSMCSRAM
.neardata 加载>> MSMCSRAM
.rodata load >> MSMCSRAM
.data:Load >> MSMCSRAM
.switch:load >> MSMCSRAM
.stack:load > MSMCSRAM
.args:load > MSMCSRAM align = 0x4、fill = 0{_argsize = 0x200;}
.sysmem:load > MSMCSRAM
.cinit:LOAD > MSMCSRAM
.const:load > MSMCSRAM start (const_start) size (const_size)
.pinit:load > MSMCSRAM
.cio:load >> MSMCSRAM
.csl_vect:load > MSMCSRAM
xdc.meta:load >> MSMCSRAM、type = copy
//.sharedPacket > MSMCSRAM
.sharedPacket align (4096):{}> MSMCSRAM
.boot_load >> MSMCSRAM
Platform_lib > MSMCSRAM
}
正确吗?
/* core1_linker.cmd(针对双核引导进行了修改)*/
-c
-heap 0x40000
-stack 0x10000
移动数据
{
L1PSRAM (rwx):org = 0x00E00000、len = 0x0007FFF
L1DSRAM (rwx):org = 0x00F00000、len = 0x0007FFF
L2SRAM (rwx):org = 0x1800000、len = 0x080000
L2SRAM_2 (rwx):org = 0x11800000、len = 0x080000
MSMCSRAM (rwx):org = 0x0c001000、len = 0x00FF000
core1_flash (RX):org = 0x00880000、len = 0x00100000 /*对于 core1 映像为 1MB */
}
很重要
{
.text:load = core1_flash、run = MSMCSRAM、load_start (_core1_load_start)、run_start (_core1_run_start)、size (_core1_size)
.cinit:load = Core1_flash、run = MSMCSRAM
.const:load = core1_flash、run = MSMCSRAM
.bss:run = MSMCSRAM
.data:run = MSMCSRAM
.neardata:run = MSMCSRAM
.rodata:run = MSMCSRAM
.stack:运行= MSMCSRAM
.sysmem:运行= MSMCSRAM
.init_array:运行= MSMCSRAM
.switch:run = MSMCSRAM
.pinit:运行= MSMCSRAM
.cio:运行= MSMCSRAM
.args:run = MSMCSRAM align = 0x4、fill = 0 {_argsize = 0x200;}
.csl_vect:run = MSMCSRAM
.sharedPacket align (4096):{}> MSMCSRAM
.boot_load:运行= MSMCSRAM
platform_lib:run = MSMCSRAM
xdc.meta:run = MSMCSRAM、type = copy
}
#include
#include
#include
包含“ti/csl/csl_chip.h"</s>“
#include “ti/csl/cacheAux.h"</s>“
#include “platform.h"</s>“
包含“c6x.h"</s>“
#define DEVICE_REG32_W (x、y)*(volatile uint32_t *)(x)=(y)
#define DEVICE_REG32_R (x)(*(volatile uint32_t *)(x))
#define CHIP_LEVEL_REG 0x02620000
#define KICK0 (CHIP_LEVEL_REG + 0x0038)
#define KICK1 (CHIP_LEVEL_REG + 0x003C)
#define IPCGR (n)(0x02620240 +(4 *(n))
#define BOOT_MAGIC_ADDR (CORE)(0x0C03FF00 +((CORE)* 4))
#define SHARED_MEM_ADDR 0x0C000000
1024
typedef 结构{
易失性 uint32_t 标志;
易失性 uint32_t 大小;
volatile char buffer[BUFFER_SIZE];
} SharedPacket;
Volatile SharedPacket* Shared =(SharedPacket*)SHARED_MEM_ADDR;
// core1 映像的链接器符号(如果链接器脚本不相同,请更新符号名称!)
extern unsigned int _core1_load_start;
extern unsigned int _core1_run_start;
extern unsigned int _core1_size;
void uart_print (const char* msg){
while (*msg){
platform_uart_write (* msg++);
}
}
void DELAY_LOOP (void){
Volatile int i;
对于 (I = 0;I < 500000;I++);
}
void copy_core1_image_to_ram (void){
uint32_t * src =&_core1_load_start;
uint32_t *dst =&_core1_run_start;
uint32_t size =((uint32_t)&_core1_size)/ sizeof (uint32_t);
uint32_t i;
对于 (i = 0;i < size;i++){
DST[i]= src [i];
}
}
void start_core1 (void){
Volatile uint32_t *magic =(volatile uint32_t *) boot_magic_ADDR (1);
*magic = 0x58535901;
DEVICE_REG32_W (IPCGR (1)、1);//触发 CORE1
}
uint32_t counter = 0;
int main (void){
uint32_t CoreID = CSL_chipReadReg (CSL_CHIP_DNUM);
如果 (CoreID == 0){
platform_uart_init();
platform_uart_set_baudrate (115200);
uart_print(“Core0:正在引导 Core1...\r\n“);
DEVICE_REG32_W (KICK0、0x83e70b13);
DEVICE_REG32_W (KICK1、0x95a4f1e0);
//可选:设置同步标志 core1 可以检查
*(volatile uint32_t *) shared_MEM_ADDR = 0xDEADBEEF;
//清除数据包缓冲区
shared->flag = 0;
Shared->size = 0;
//--映像复制步骤--
uart_print(“Core0:将 Core1 映像从闪存复制到 RAM……\r\n“);
copy_core1_image_to_ram ();
uart_print(“Core0:复制 Core1 映像已完成。\r\n“);
//----------------------------
start_core1();
delay_loop();
while (1){
snprintf((char*) shared->buffer、buffer_size、“Hello from Core0 - msg %u“、counter);
shared->size = strlen ((char*) shared->buffer);
Shared->flag = 1;
cache_wbL1d (void *) shared、sizeof (SharedPacket)、cache_wait);
char outbuf[128];
snprintf (outbuf、sizeof (outbuf)、“Core0:已发送\“%s\"\r\n",“,共享“共享->、->缓冲器);
uart_print (outbuf);
while (1){
CACHE_INVL1d (void *) shared、sizeof (SharedPacket)、cache_wait);
如果 (shared->flag =2) 中断;
}
snprintf (outbuf、sizeof (outbuf)、“Core0:获得回复:\“%s\"\r\n",“,共享“共享->、->缓冲区);
uart_print (outbuf);
shared->flag = 0;
counter++;
delay_loop();
}
}其他{
uart_print(“core1:正在等待 Core0 魔术……\r\n“);
而 (*(volatile uint32_t *) shared_MEM_ADDR!= 0xDEADBEEF);
uart_print(“core1:已成功启动!\r\n“);
while (1){
CACHE_INVL1d (void *) shared、sizeof (SharedPacket)、cache_wait);
如果 (shared->flag ==1){
char outbuf[128];
snprintf (outbuf、sizeof (outbuf)、“Core1:已接收\“%s\"\r\n",“,共享“共享->、->缓冲器);
uart_print (outbuf);
snprintf((char*) shared->buffer、buffer_size、“ACK from core1 to msg %u“、counter);
shared->size = strlen ((char*) shared->buffer);
Shared->flag = 2;
cache_wbL1d (void *) shared、sizeof (SharedPacket)、cache_wait);
counter++;
}
}
}
返回 0;
}
您好 Betsy、
它在从闪存启动时不工作、但通过调试测试时工作良好。
#include
#include
#include
#include “platform.h"</s>“
#include “resource_mgr.h"</s>“
//--寄存器/系统定义--
#define DEVICE_REG32_W (x、y)*(volatile uint32_t *)(x)=(y)
#define CHIP_LEVEL_REG 0x02620000
#define KICK0 (CHIP_LEVEL_REG + 0x0038)
#define KICK1 (CHIP_LEVEL_REG + 0x003C)
#define IPCGR(x)(0x02620240 +(x)*4)
#define MAGIC_ADDR 0x8FFFFC // core1 引导地址的共享区域
define CORE1_ENTRY_ADDR 0x00880000
#define BOOT_MAGIC_ADDR (x)(MAGIC_ADDR +(1<<28)+((x)<<24))
#define BOOT_MAGIC_NUMBER 0xBABEFACE
#define BOOT_UART_BAUDRATE 115200
typedef 结构 test_config{
uint8_t print_info;
uint8_t print_current_core_id;
uint8_t print_switch_state;
uint8_t test_EEPROM;
uint8_t test_nand;
uint8_t test_nor;
uint8_t test_led;
uint8_t test_uart;
uint8_t test_external_mem;
uint8_t test_internal_mem;
uint32_t init_config_pll1_pllm;
uint32_t init_config_uart_baudrate;
uint32_t nand_test_block_number;
uint32_t NOR_TEST_SECTOR_NUMBER;
uint32_t EEPROM_TEST_SLAVE_ADDRESS;
uint32_t led_test_loop_COUNT;
uint32_t led_test_loop_delay;
uint32_t ext_mem_test_base_addr;
uint32_t ext_mem_test_length;
uint32_t int_mem_test_core_id;
} TEST_CONFIG;
//--平台的 OSAL 残桩--
uint8_t *OSAL_platformMalloc (uint32_t num_bytes、uint32_t alignment){return malloc (num_bytes);}
void OSAL_platformFree (uint8_t *dataPtr、uint32_t num_bytes){ if (dataPtr) free (dataPtr);}
void OSAL_platformSpiCsEnter (void){while (CSL_semAcquireDirect (platform_SPI_HW_SEM)== 0);}
void OSAL_platformSpiCsExit (void){CSL_semReleaseSemaphore (platform_SPI_HW_SEM);}
//-- GPIO/LED --
#define GPIO0_BASE 0x02320000
#define GPIO_SET_DATA (GPIO0_BASE + 0x18)
#define GPIO_CLR_DATA (GPIO0_BASE + 0x1C)
#define GPIO_DIR (GPIO0_BASE + 0x10)
#define LED_GPIO_BIT (1 << 12)// GPIO0_12
void led_init (void){*(volatile uint32_t *) GPIO_DIR &=~LED_GPIO_BIT;}
void led_on (void){*(volatile uint32_t *) GPIO_SET_DATA = LED_GPIO_BIT;}
void led_off (void){*(volatile uint32_t *) GPIO_CLR_DATA = LED_GPIO_BIT;}
Void
WRITE_UART (char* msg)
{
uint32_t i;
uint32_t msg_len = strlen (msg);
/*将消息写入 UART */
对于 (i = 0;i < msg_len;i++)
{
platform_uart_write (msg[i]);
}
}
//--将 core1_main 放在.core1text 段的 0x00880000 --
#pragma CODE_SECTION (core1_main、“.core1text")“)
void core1_main (void){
易失性 uint32_t 计数器= 0;
led_init();
platform_write(“Core1 已成功启动。\n“);
while (1){
counter++;
if (counter ==10000000){
platform_write(“Core1 heartbeat.\n“);
COUNTER = 0;
}
}
}
pragma CODE_SECTION (write_boot_magic_number、“.core1text")“)
void write_boot_magic_number (void)
{
uint32_t coreNum;
coreNum = platform_get_CoreID ();
DEVICE_REG32_W (magic_ADDR、BOOT_magic_number);
// whid(1);
}
extern cregister volatile 无符号整型 DNUM;
void boot_core1 (void){
//解锁芯片寄存器
DEVICE_REG32_W (KICK0、0x83e70b13);
DEVICE_REG32_W (KICK1、0x95a4f1e0);
//将 Core1 入口地址写入引导加载程序的魔术地址
DEVICE_REG32_W (magic_ADDR、Core1_ENTRY_ADDR);
platform_delay (10);//等待写入稳定
//向 Core1 发送 IPC 中断以开始执行
DEVICE_REG32_W (IPCGR (1)、1);
platform_write(“Core1 引导由 Core0.\n“触发);
}
uint32_t 内核;
void main (void){
platform_init_flags init_flags ={0};
platform_init_config init_config ={0};
platform_info p_info;
TEST_CONFIG args;
if (platform_init (&init_flags、&init_config)!= Platform_eok){
printf(“Platform init failed、errno = 0x%x\n“、platform_errno);
返回;
}
platform_write_configure (platform_write_printf);
platform_get_info (&p_info);
如果 (DNUM == 0){
platform_write(“在 Core0 上运行。 通过 MagicAddr...\n“引导 Core1;
boot_core1();
易失性 uint32_t 计数器= 0;
if( args.print_current_core_id == 1 ){
/*解锁芯片寄存器*/
//踢 0 和踢 1
DEVICE_REG32_W (0x02620038、0x83e70b13);
DEVICE_REG32_W (0x0262003C、0x95a4f1e0);
/*将入口地址写入其他内核*/
对于 (CORE = 1;CORE < p_info.cpu.core_count;CORE++)
{
printf(“我将从第一个内核弹出。 第二个 Core 的引导魔术地址为:%x\n“、boot_magic_ADDR (core));
DEVICE_REG32_W (boot_magic_ADDR (core)、(uint32_t) write_boot_magic_number);
/*延迟 1us 秒*/
platform_delay (1);
}
对于 (CORE = 1;CORE < p_info.cpu.core_count;CORE++)
{
/* IPC 中断其他内核*/
DEVICE_REG32_W (IPCGR (CORE)、1);
platform_delay (1000);
}
}
else write_boot_magic_number ();
platform_uart_init();
platform_uart_set_baudrate (boot_UART_BAUDRATE);
易失性 uint32_t cntuart = 0;
char uart_buf[64];
while (1){
counter++;
if (counter ==10000000){
platform_write(“Core0 heartbeat.\n“);
COUNTER = 0;
cntuart++;
snprintf (uart_buf、sizeof (uart_buf)、“Core:%lu\r\n“、(unsigned long) cntuart);
WRITE_UART (UART_buf);
}
}
} else if (DNUM ==1){
// Core1 应跳转到 0x00880000 处的函数(在 RAM 中)
void (* core1_entry)(void)=(void (*)(void)) core1_entry_ADDR;
core1_entry();
core1_main();
}
}
移动数据
{
//适用于 Core0 的 L2SRAM:0x00800000 - 0x0087FFC0 (512KB - 64B)
L2SRAM:origin = 0x00800000、length = 0x0007FFC0
// Core1 的 L2SRAM:0x00880000、保留 32KB(或根据需要进行调整)
L2SRAM_Core1:origin = 0x00880000、长度= 0x00008000
// MSMCSRAM(可选共享)
MSMCSRAM:origin = 0x0C000000、length = 0x00040000
// boot_magic:L2SRAM 的最后 64 个字节
boot_magic:origin = 0x0087FFC0、length = 0x00000040
}
很重要
{
// Core0 应用部分
.text > L2SRAM
.const > L2SRAM
.cinit > L2SRAM
.pinit > L2SRAM
.bss > L2SRAM
.data > L2SRAM
.stack > L2SRAM
.cio > L2SRAM
.switch > L2SRAM
// Core1 入口点段(必须与 C 文件的 code_section 匹配)
.core1text > L2SRAM_Core1
//用于次级内核引导的魔术地址
boot_magic > boot_magic
//可选共享缓冲区(用于内核间通信)
.sharedBuf > MSMCSRAM
}
此致、
Eric
您好 Betsy、
双核示例的完整工程位于此处:
https://github.com/rk4526/bootDualCoreC6657.git
您能看一下并告诉我您的反馈吗?
此致、
Eric
您好 Betsy、
正确吗?
https://github.com/rk4526/bootversion2forC6657.git
此致、
Eric