Two UART Shells running on different MCU cores, Shell works but Shell_01 fails when adding core_id cmd? (tc397 triboard)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
avatar
Level 3
Level 3
First like received 10 replies posted 25 sign-ins

Dear All,

1. My code is based on the demo example provided by infineon to modify iLLD_1_0_1_12_1__TC3xx_Demos\iLLD_1_0_1_12_1__TC3xx_Demos\AsclinShellInterface

2. It is build by BIFACES with HighTec GNUC compiler.

     the Config_Gnuc.mk is set as follows because the HighTec toolchain is installed in that path

     B_GNUC_TRICORE_PATH:= C:\HighTec\toolchains\tricore\v4.9.3.0-infineon-1.0

3. I have extended the AsclinShellInterface to two instances and running on different cores, this also works.

     (a). two App_AsclinShellInterface instances are used, App_AsclinShellInterface and App_AsclinShellInterface_01

     (b). g_AsclinShellInterface is assigned to uart0_rx = p14.1, uart0_tx = p14.0, and set cpu0 for uart0's ISR_PROVIDER,

     (c). g_AsclinShellInterface_01 is assigned to uart1_rx = p15.1, uart1_tx = p15.0, and set cpu1 for uart1's ISR_PROVIDER 

             it is needed to connected a UART-TO-USB dongle to PC's terminal (ref to file uarts_on_diff_cores.png)

4. After adding a core_id command on the Shell Interface, the g_AsclinShellInterface WORKS but g_AsclinShellInterface _01 hangs after shows the "Welcome Screen text" (ref to file Shells.png)

5. the attachment is the source code.(ref to 03-TwoAsclinShellInterfacesDiffCores_TC39B.zip)

Is there any wrong? Thanks

0 Likes
1 Solution
E-John
Level 3
Level 3
10 replies posted First like given 25 sign-ins

Although two instances App_AsclinShellInterface, g_AsclinShellInterface and g_AsclinShellInterface_01 are used in the code.

They share the common variable Ifx_g_console after Ifx_Console_init() is called.

1. It seems to work fine after commenting all console_print c Ifx_Console_print() in all code. 

2. Add mutex to prevent two cores accessing same memory at the same time.

     like 

 

    if(IfxCpu_acquireMutex(&g_MutexUart)) {
        Ifx_Console_print(ENDL "Enter 'help' to see the available commands"ENDL);
        IfxCpu_releaseMutex(&g_MutexUart);
    }
    waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, WAIT_TIME));

 

View solution in original post

0 Likes
9 Replies
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Hi Avater,

You said " this also works", I think it's core1 and uart1 output works, but for input, have you verified?

i.e.

 

const Ifx_Shell_Command AppShell_commands[] = {
    {"status", "   : Show the application status", &g_AsclinShellInterface,       &AppShell_status,    },
    {"info",   "     : Show the welcome screen",   &g_AsclinShellInterface,       &AppShell_info,      },
#if (COREID_CMD == 1)
	{"coreid", "     : Get CPU core id", 		   &g_AsclinShellInterface,		  &AppShell_coreid,    },
#endif
	{"help",   SHELL_HELP_DESCRIPTION_TEXT,        &g_AsclinShellInterface.shell, &Ifx_Shell_showHelp, },
    IFX_SHELL_COMMAND_LIST_END
};

 

Have you tested other commands? i.e. status/info/help?

I suspect some struct or variables are for core0 only, you could try to create a core1 copy.

 

dw

0 Likes
avatar
Level 3
Level 3
First like received 10 replies posted 25 sign-ins

Hi dw,

1. After UART1 output , UART1 hangs. Send text from terminal to UART1, not works.

2. If set "#define CORE_ID  (0), UART1 outpu and input works.

 

0 Likes
avatar
Level 3
Level 3
First like received 10 replies posted 25 sign-ins

If change the order of AsclinShellInterface_init() and gpio_init_pins() in Cpu0_Main.c, then both two Shell works with coreid cmds.

It is weird, it seems that something is conflict and do not know how to make sync to them?

see attachment files

two_shells_on_diff_cores_work.gif and change_initial_sequences.png

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Debugging method: Please reproduce the problem, and then trace this function:

 

void Ifx_Shell_process(Ifx_Shell *shell)

 

Output below status:

 

shell->control.enabled
count
inputbuffer[i]
shell->locals.cmdState
NormalKeyPress
Cmd->historyAdd

 

The purpose is to check if some strange chars input which leads the While Loop hang.

dw

0 Likes
avatar
Level 3
Level 3
First like received 10 replies posted 25 sign-ins

Hi dw,

still can not see what is wrong, the working shell(shell) variables are the same as the failure one(shell_01)

Shell

shell->control.enabled, = 1

count, not valid (can not view because of code is optimization)

shell->inputbuffer[i], all 128 items are 0x00

shell->locals.cmdState, IFX_SHELL_CMD_STATE_NORMAL

NormalKeyPress, FALSE

Cmd->historyAdd, 0

 

 

Shell_01

shell->control.enabled, = 1

count, not valid (can not view because of code is optimization)

shell->inputbuffer[i], all 128 items are 0x00

shell->locals.cmdState, IFX_SHELL_CMD_STATE_NORMAL

NormalKeyPress, FALSE

Cmd->historyAdd, 0

0 Likes
avatar
Level 3
Level 3
First like received 10 replies posted 25 sign-ins

this modification(change the order of initial sequence) is just luck, can not resolve this issue indeed.

it fails again if more code are added in function AppShell_coreid, lie below

it seems something conflict between two cores? do not know to modify

boolean AppShell_coreid(pchar args, void *data, IfxStdIf_DPipe *io)
{
IfxCpu_Id core_id;
IfxCpu_ResourceCpu core_index;

core_id = IfxCpu_getCoreId();
core_index = IfxCpu_getCoreIndex();

IfxStdIf_DPipe_print(io, "CPU core id : %ld"ENDL, (sint32)core_id);
IfxStdIf_DPipe_print(io, "CPU core index : %ld"ENDL, (sint32)core_index);

return TRUE;
}

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

A way  to debug: to keep UART0 and CPU0 only for miniwiggler, UART1 and CPU1 is used for ASCLIN shell operations. UDE can be used for debugging which needs loading .elf file after project build.

0 Likes
E-John
Level 3
Level 3
10 replies posted First like given 25 sign-ins

Although two instances App_AsclinShellInterface, g_AsclinShellInterface and g_AsclinShellInterface_01 are used in the code.

They share the common variable Ifx_g_console after Ifx_Console_init() is called.

1. It seems to work fine after commenting all console_print c Ifx_Console_print() in all code. 

2. Add mutex to prevent two cores accessing same memory at the same time.

     like 

 

    if(IfxCpu_acquireMutex(&g_MutexUart)) {
        Ifx_Console_print(ENDL "Enter 'help' to see the available commands"ENDL);
        IfxCpu_releaseMutex(&g_MutexUart);
    }
    waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, WAIT_TIME));

 

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

As you told  Ifx_Console_print() has problem, and below variable is used in that function by CPU0 and CPU1, I suggest to use a copy of it for CPU1, e.g. Ifx_g_consoleCPU1

 

IFX_EXTERN Ifx_Console Ifx_g_console;

 

 If both cores access standardIo, and timeout is TIME_INFINITE, the system may be hang.

return IfxStdIf_DPipe_write(Ifx_g_console.standardIo, (void *)message, &count, TIME_INFINITE);

 

dw

0 Likes