Samsung / TizenRT

TizenRT is a lightweight RTOS-based platform to support low-end IoT devices
Apache License 2.0
566 stars 571 forks source link

build/tools/amebasmart/gnu_utility: fix stuck tash when key held on boot #6402

Closed lhenry-realtek closed 1 week ago

lhenry-realtek commented 2 weeks ago

This fix does the following:

After KM0 core start, IER bit set to 0 to disable LOGUART After CA32 ipc_send_message in board_initialize(), set IER bit to 1 in KM0 IPC command handler (ROM LOGUART is disabled here) CA32 can use tizen RAM handler now, and tash shell is working properly

Root cause:

lhenry-realtek commented 2 weeks ago

Please check rtk jira SDAIOT30E-291 for more info, there is another proposed fix for same issue

sunghan-chang commented 2 weeks ago

Please check rtk jira SDAIOT30E-291 for more info, there is another proposed fix for same issue

Did you leave this for RTK engineers?

lhenry-realtek commented 2 weeks ago

Hi @sunghan-chang,

We are discussing the way to implement this with Dane, I was unsure if you had access to our outward-facing jira as I am relatively new to the project. I will paste the triage and suggestion here


Cause due to LOGUART ERBFI interrupt bit not being re-enabled, causing the peripheral to not generate any data receive events from the Host (PC) input

This cause Tash shell to also lock up due to shared peripheral, so the bit is re-enabled in the IPC handler of KM0 when IPC_A2L_DISLOGUART is received by KM0

Currently we have found an alternative solution, so the fix can be introduced in 2 methods


The fix is a one liner: LOGUART_INTConfig(LOGUART_DEV, LOGUART_BIT_ERBI, ENABLE);

For Method 1, this line is placed inside KM0's IPC handler, which is fired after https://github.com/Samsung/TizenRT/blob/2f722e6c907268b892fb1a77719857f3ea05ddb6/os/board/rtl8730e/src/rtl8730e_boot.c#L513

For Method 2, instead of placing it in our KM0 bin, we set the bit after the line above in rtl8730e_boot.c:

ipc_send_message(IPC_AP_TO_LP, IPC_A2L_DISLOGUART, &ipc_msg_loguart);

/* enable event generation for rx data interrupt again */
LOGUART_INTConfig(LOGUART_DEV, LOGUART_BIT_ERBI, ENABLE);
lhenry-realtek commented 2 weeks ago

This fix does the following:

after KM0 core start, IER bit set to 0 after CA32 ipc_send_message, set IER bit to 1 in KM0 handler (ROM LOGUART is disabled here) CA32 can use tizen RAM handler now, and tash shell is working properly

Root cause will follow in a separate comment after I have confirm with Dane, but it is a concurrency issue due to LOGUART peripheral being shared by KM0, KM4 and CA32, during init certain operations overwrite the interrupt bit and cause the peripheral to lock up in an invalid state. Once locked up, it will not respond to any sort of key press, thus causing Tash shell to hang as well as it rely on LOGUART at low level

sunghan-chang commented 1 week ago

@lhenry-realtek Could you leave what you said in the commit description? @jylee9613 Could you verify this?

lhenry-realtek commented 1 week ago

Use loadable_apps_ext_ddr or ext_psram configuration for quickest reproduce

Negative example: Clone TizenRT master branch, use above config and disable USB so all the output is on UART only, then press and hold a key while reset board to boot. Shell will hang

Positive example: Clone TizenRT master branch and apply this patch, repeat above step

lhenry-realtek commented 1 week ago