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.

ethercat unreliable app_reload flag

Hi,

    I was experiencing a cold boot hang due to problems with the app_reload logic. Warm reset from debugger worked ok.

    I have an XAM3359 where [0x4a310330] often== 0x593a0daa from cold reset as soon as LRST is deasserted in pru_icss_init(). 

    Since this location is used as APP_RELOAD_FLAG_REG, and the low 8 bits are compared to 0xaa, the get_app_reload_flag() logic sometimes returns 0xaa when it shouldn't.

    As set_app_reload_flag sets all 32 bits of APP_RELOAD_FLAG_REG (e.g. 0x000000aa), this issue can be improved by simply changing get_app_reload_flag to return int32_t:

@@ -75,14 +75,15 @@
/*
Get app reload flag value
*/
-Uint8 get_app_reload_flag()
+uint32_t get_app_reload_flag()
{
- Uint32 temp = 0;
+ uint32_t temp = 0;
/*
* Get PRUSS_MEM status - if bit 23 and 24 are set, then PRUSS memory is ON.
* These bits are not reset on warm reset. Meaning, on warm reset, these bits
* may be set if PRUSS memory was enabled before warm reset.
*/
+ /* This code has no effect, as the reset state has pru_icss_mem set ON */
temp = HWREG(SOC_PRM_PER_REGS + PRM_PER_PM_PER_PWRSTST);
if((temp & PRM_PER_PM_PER_PWRSTST_ICSS_MEM_STATEST) != (PRM_PER_PM_PER_PWRSTST_ICSS_MEM_STATEST_MEM_ON << PRM_PER_PM_PER_PWRSTST_ICSS_MEM_STATEST_SHIFT) )
return 0;
@@ -95,7 +96,7 @@
ENABLE_PRUSS_ACCESS_FROM_HOST
temp = HWREG(APP_RELOAD_FLAG_REG);
DISABLE_PRUSS_ACCESS_FROM_HOST
- return (Uint8)temp;
+ return temp;
}

/*

Header tiesc_appreload.h must be revised, as well.

BUT, the first call to get_app_reload_flag() from common_main() actually returns 0 (non-reload) due to the clock activity check. Later calls to get_app_reload_flag() then succeed due to my lucky SoC. So, if this first call determines no-reload, resulting in PRUSS disabled safe, the issue should be forced in the common_main() conditional to ensure subsequent calls don't get lucky:

PRUSSDRVPruDisable(0);
PRUSSDRVPruDisable(1);
+
+ set_app_reload_flag(0);
DISABLE_PRUSS_ACCESS_FROM_HOST
}

Thanks - Dave