2020-03-25 05:38 AM
Hi,
I'm currently working with the STM32MP157-DK2.
I built a firmware to run on the Cortex M4.
To load/start/stop the firmware by the A7 I use :
echo -n "firmware_name" > /sys/class/remoteproc/remoteproc0/firmware
echo -n start > /sys/class/remoteproc/remoteproc0/state
echo -n stop > /sys/class/remoteproc/remoteproc0/state
So far it works fine.
If I run the firmware the first time after a reboot all works fine. But if I stop the firmware, load and start again it begins to run and hangs up.
periphery the fw uses: SPI, GPIO, TIM, DMA, DDR, UART
third party: openAMP, FreeRTOS, virtUart, RESMGR_UTILITY
Is it possible to reset M4 and the peripherals without rebooting A7?
thanks in advance
regards
Lukas
Solved! Go to Solution.
2020-03-27 03:49 AM
@PatrickF
I tried the following and now it works. I added HAL_Init() in front of the reset/DeInit
int main(void)
{
/* USER CODE BEGIN 1 */
HAL_Init();
__HAL_RCC_HSEM_CLK_DISABLE();
__HAL_RCC_TIM5_FORCE_RESET();
__HAL_RCC_TIM5_RELEASE_RESET();
__HAL_RCC_TIM7_FORCE_RESET();
__HAL_RCC_TIM7_RELEASE_RESET();
HAL_IPCC_DeInit(&hipcc);
HAL_SPI_DeInit(&hspi4);
HAL_SPI_DeInit(&hspi5);
HAL_DeInit();
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
...
2020-03-25 06:15 AM
Hello,
this is a known limitation, and today, there is various options to make it working:
Last option is the recommended way.
Obviously, not all peripherals are concerned, e.g. GPIO has not to be reset.
Regards
2020-03-25 07:37 AM
Hi @PatrickF ,
thanks for your fast reply.
I tried this in main before init:
__HAL_RCC_TIM5_FORCE_RESET();
__HAL_RCC_SPI4_FORCE_RESET();
__HAL_RCC_SPI5_FORCE_RESET();
__HAL_RCC_IPCC_FORCE_RESET();
HAL_IPCC_DeInit(&hipcc);
HAL_DMA_DeInit(&hdma_memtomem_dma2_stream1);
HAL_SPI_DeInit(&hspi4);
HAL_SPI_DeInit(&hspi5);
Unfortunately it does not work. Now the firmware hangs up even on the 1st start
best regards
Lukas
2020-03-25 08:13 AM
My answer was a bit misleading.
it is either use of RESET or DeInit. Both are overkilling.
When FORCE_RESET is used, need to put a RELEASE_RESET just after (otherwise peripheral is kept in reset and this explain why it hang during init).
Usually, DeInit function is the better option (not need to use reset).
2020-03-27 02:24 AM
@PatrickF
Unfortunately it still does not work. It hangs up at the second start. Seems like it hangs up when I want to use SPI
2020-03-27 03:03 AM
I think debugging you FW could help to see where it hang precisely.
2020-03-27 03:49 AM
@PatrickF
I tried the following and now it works. I added HAL_Init() in front of the reset/DeInit
int main(void)
{
/* USER CODE BEGIN 1 */
HAL_Init();
__HAL_RCC_HSEM_CLK_DISABLE();
__HAL_RCC_TIM5_FORCE_RESET();
__HAL_RCC_TIM5_RELEASE_RESET();
__HAL_RCC_TIM7_FORCE_RESET();
__HAL_RCC_TIM7_RELEASE_RESET();
HAL_IPCC_DeInit(&hipcc);
HAL_SPI_DeInit(&hspi4);
HAL_SPI_DeInit(&hspi5);
HAL_DeInit();
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
...