‎2020-05-05 11:54 AM
I've a problem to setup the NUCLEO-L552ZE-Q as PD Sink.
The debugger always disconnect at the following line (void HardFault_Handler(void)):
CHECK_CAD_FUNCTION_CALL(USBPD_CAD_Init(USBPD_PORT_0, (USBPD_CAD_Callbacks *)&CAD_cbs, (USBPD_SettingsTypeDef *)&DPM_Settings[USBPD_PORT_0], &DPM_Params[USBPD_PORT_0]));
I've followed this instruction but also missing SysTick_IRQn but how i've seen it was removed with newer version.. so what to do with that? Is there a new instruction for PD setup?
I'm also missing option "Port 0: UCPD1" as stack configuration for USBPD I just see the following:
I also testet the exmaple from this repo "STM32CubeL5-master\Projects\NUCLEO-L552ZE-Q\Applications\USB-PD\USB-PD_Consumer_1port" - ends up in same error handler.
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
Hopefully someone can help me - thanks.
EDIT: Can someone else confirm that issue or is it just by me? Just to exclude hardware fault.
‎2020-06-02 02:54 AM
Dear @TG..1​
You mean that using the USBPD application provided in STM32L5 Firmware package under \Projects\NUCLEO-L552ZE-Q\Applications\USB-PD\USB-PD_Consumer_1port, without any modifications, you encounter hardfault in exact same way than with your generated application ?
If so, could you try to perform the following update in your usbpd_dpm_core.c file : in the #else part, increase DPM_STACK_SIZE_ADDON_FOR_CMSIS define from 3 to 4.
#if (osCMSIS < 0x20000U)
#define DPM_STACK_SIZE_ADDON_FOR_CMSIS 1
#else
#define DPM_STACK_SIZE_ADDON_FOR_CMSIS 4
#endif /* osCMSIS < 0x20000U */
Please let me know if this helps.
Otherwise, could you share your project ?
Regards
Guenael
‎2020-06-02 03:44 AM
‎2020-06-02 03:45 AM
‎2020-06-02 09:58 AM
Thanks for sharing your projects.
1 - In order to ensure that an HW issue is out of scope, could you just rebuild using STM32CubeIDE the provided project in \Projects\NUCLEO-L552ZE-Q\Applications\USB-PD\USB-PD_Consumer_1port of the STM32L5 Firmware package (do not use CubeMx, do not rebuild project files, only compile provided code and project).
I'm not able to use the Zip you provided as "USB-PD_Test", as containing only C files (no H files found so not sure if you use those from the STM32L5 FW package, or others ...)
I've been able to reproduce an Hardfault as you mentioned.
Now on this basis, could you apply the following patch in main.c
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128
};
to be modified to (default stack size is increased to 256) :
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 256
};
With this patch (+ previous one, mentioned earlier), no more Hardfaults on my side.
2) I also attached the updated project : if not existing on your side in the FW package. To be unzipped in \Projects\NUCLEO-L552ZE-Q\Applications\USB-PD\ directory of the STM32L5 Firmware package, in order to be able to use all FW package provided files + relative links inside the projects. This also includes corresponding binary, generated on my side (in case, you are not able to rebuild the reference project on your side).
3) if everything is ok, please try to apply same patch on your project.
At first glance on your project (PDSink_Test), some elements seem missing in configuration (you would be able to check differences with the reference project) :
Hope this helps.
Regards
Guenael
‎2020-06-28 12:25 PM
Thanks for sharing =) - Sorry for answering late but I played a bit to understand what happens..
So I figured out that "PM_STACK_SIZE_ADDON_FOR_CMSIS 4" fixes the hardwarefault while tracing is enabled - in other case it's enough to increase stack size.
Another issue (on second board) happens while calling BSP_GUI_LoadDataFromFlash()... function can't read the value on addr pointer.
For me that looks like that the hw is broken?
GUI_StatusTypeDef BSP_GUI_LoadDataFromFlash(void)
{
GUI_StatusTypeDef _status = GUI_ERROR;
uint32_t _addr = GUI_FLASH_ADDR_NB_PDO_SNK_P0;
/* Check that we did not reach the end of page */
if (GUI_FLASH_SIZE_RESERVED < 0)
{
goto _exit;
}
/* Update USBPD_NbPDO? */
if (0xFFFFFFFFu != *((uint32_t*)_addr)) // This caused in hardwarefault *((uint32_t*)_addr)
{
uint32_t* _ptr = (uint32_t*)USBPD_NbPDO;
USPBPD_WRITE32 (_ptr,*((uint32_t*)_addr));
_status = GUI_OK;
}
Thanks for you help.
best Regards,
Thomas