cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP157 processor and OpenAMP

Holti
Associate

Hello i have STM32MP157 board with A7 and M4 processors, i am trying to setup OpenAMP which works when i use the OpenAMP_TTY_echo
But when i try to create a new project from:

SMT32Cube IDE 1.16.0 version

STM32MP1 version: 1.6.0

I cannot seem to make it work

For example, when i deploy the example it properly opens the port /dev/ttyRPMSG0 and when i read with this command cat /dev/ttyRPMSG0 it wait for messages , so i connect to another temrinal send some messages and receive them perfectly

But when i try to use generated project the port is not even open and this is my output of the rpmsg0 :

[ 1.668065] rpmsg_sdb_drv_init(rpmsg_sdb): Init done
[ 40.830549] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x400
[ 40.837511] virtio_rpmsg_bus virtio0: creating channel rpmsg-tty addr 0x401
[ 40.848325] virtio_rpmsg_bus virtio0: rpmsg host is online

Looks good , also when starting the processor:

root@myir:~# dmesg | grep remoteproc
[ 1.667805] remoteproc remoteproc0: releasing m4
[ 1.749203] remoteproc remoteproc0: releasing m4
[ 1.788187] remoteproc remoteproc0: releasing m4
[ 1.923612] remoteproc remoteproc0: releasing m4
[ 4.222566] remoteproc remoteproc0: m4 is available
[ 40.754770] remoteproc remoteproc0: powering up m4
[ 40.797573] remoteproc remoteproc0: Booting fw image rproc-m4-fw, size 2443240
[ 40.865267] remoteproc remoteproc0: remote processor m4 is now up

I am not sure what i am doing wrong
This is my code

 

 

/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "openamp.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include <string.h> #include <virt_uart.h> #include <ctype.h> // For character transformations like toupper /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ #define MAX_BUFFER_SIZE RPMSG_BUFFER_SIZE /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ IPCC_HandleTypeDef hipcc; /* USER CODE BEGIN PV */ VIRT_UART_HandleTypeDef huart0; VIRT_UART_HandleTypeDef huart1; __IO FlagStatus VirtUart0RxMsg = RESET; uint8_t VirtUart0ChannelBuffRx[MAX_BUFFER_SIZE]; uint16_t VirtUart0ChannelRxSize = 0; __IO FlagStatus VirtUart1RxMsg = RESET; uint8_t VirtUart1ChannelBuffRx[MAX_BUFFER_SIZE]; uint16_t VirtUart1ChannelRxSize = 0; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_IPCC_Init(void); int MX_OPENAMP_Init(int RPMsgRole, rpmsg_ns_bind_cb ns_bind_cb); /* USER CODE BEGIN PFP */ void VIRT_UART0_RxCpltCallback(VIRT_UART_HandleTypeDef *huart); void VIRT_UART1_RxCpltCallback(VIRT_UART_HandleTypeDef *huart); /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initialize the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ if(IS_ENGINEERING_BOOT_MODE()) { /* Configure the system clock */ SystemClock_Config(); } /* USER CODE END Init */ /*HW semaphore Clock enable*/ __HAL_RCC_HSEM_CLK_ENABLE(); /* IPCC initialisation */ MX_IPCC_Init(); MX_OPENAMP_Init(RPMSG_REMOTE, NULL); /* OpenAmp initialisation ---------------------------------*/ /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ /* USER CODE BEGIN 2 */ /* * Create Virtual UART device * defined by a rpmsg channel attached to the remote device */ if (VIRT_UART_Init(&huart0) != VIRT_UART_OK) { Error_Handler(); } if (VIRT_UART_Init(&huart1) != VIRT_UART_OK) { Error_Handler(); } /*Need to register callback for message reception by channels*/ if(VIRT_UART_RegisterCallback(&huart0, VIRT_UART_RXCPLT_CB_ID, VIRT_UART0_RxCpltCallback) != VIRT_UART_OK) { Error_Handler(); } if(VIRT_UART_RegisterCallback(&huart1, VIRT_UART_RXCPLT_CB_ID, VIRT_UART1_RxCpltCallback) != VIRT_UART_OK) { Error_Handler(); } /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { OPENAMP_check_for_message(); /* USER CODE END WHILE */ if (VirtUart0RxMsg) { VirtUart0RxMsg = RESET; VIRT_UART_Transmit(&huart0, VirtUart0ChannelBuffRx, VirtUart0ChannelRxSize); } if (VirtUart1RxMsg) { VirtUart1RxMsg = RESET; VIRT_UART_Transmit(&huart1, VirtUart1ChannelBuffRx, VirtUart1ChannelRxSize); } /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSIDivValue = RCC_HSI_DIV1; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.PLL2.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.PLL3.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.PLL4.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** RCC Clock Config */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_ACLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 |RCC_CLOCKTYPE_PCLK3|RCC_CLOCKTYPE_PCLK4 |RCC_CLOCKTYPE_PCLK5; RCC_ClkInitStruct.AXISSInit.AXI_Clock = RCC_AXISSOURCE_HSI; RCC_ClkInitStruct.AXISSInit.AXI_Div = RCC_AXI_DIV1; RCC_ClkInitStruct.MCUInit.MCU_Clock = RCC_MCUSSOURCE_HSI; RCC_ClkInitStruct.MCUInit.MCU_Div = RCC_MCU_DIV1; RCC_ClkInitStruct.APB4_Div = RCC_APB4_DIV1; RCC_ClkInitStruct.APB5_Div = RCC_APB5_DIV1; RCC_ClkInitStruct.APB1_Div = RCC_APB1_DIV1; RCC_ClkInitStruct.APB2_Div = RCC_APB2_DIV1; RCC_ClkInitStruct.APB3_Div = RCC_APB3_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct) != HAL_OK) { Error_Handler(); } } /** * @brief IPCC Initialization Function * @PAram None * @retval None */ static void MX_IPCC_Init(void) { /* USER CODE BEGIN IPCC_Init 0 */ /* USER CODE END IPCC_Init 0 */ /* USER CODE BEGIN IPCC_Init 1 */ /* USER CODE END IPCC_Init 1 */ hipcc.Instance = IPCC; if (HAL_IPCC_Init(&hipcc) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN IPCC_Init 2 */ /* USER CODE END IPCC_Init 2 */ } /* USER CODE BEGIN 4 */ void VIRT_UART0_RxCpltCallback(VIRT_UART_HandleTypeDef *huart) { uint16_t total_len; const char *response; // Ensure the received message is null-terminated uint16_t received_size = (huart->RxXferSize < MAX_BUFFER_SIZE - 1) ? huart->RxXferSize : MAX_BUFFER_SIZE - 2; memcpy(VirtUart0ChannelBuffRx, huart->pRxBuffPtr, received_size); VirtUart0ChannelBuffRx[received_size] = '\0'; // Null-terminate // Trim trailing whitespace and control characters while (received_size > 0 && (VirtUart0ChannelBuffRx[received_size - 1] == '\n' || VirtUart0ChannelBuffRx[received_size - 1] == '\r' || VirtUart0ChannelBuffRx[received_size - 1] == ' ' || VirtUart0ChannelBuffRx[received_size - 1] == '\t')) { VirtUart0ChannelBuffRx[received_size - 1] = '\0'; received_size--; } // Check the received message and set the response if (strcmp((char *)VirtUart0ChannelBuffRx, "ledon") == 0) { response = "The LED is on"; } else if (strcmp((char *)VirtUart0ChannelBuffRx, "ledoff") == 0) { response = "The LED is off"; } else { response = "Unknown command"; } // Copy the response into the buffer total_len = strlen(response); if (total_len >= MAX_BUFFER_SIZE) { total_len = MAX_BUFFER_SIZE - 1; } memcpy(VirtUart0ChannelBuffRx, response, total_len); VirtUart0ChannelBuffRx[total_len] = '\0'; // Null-terminate // Update the size for transmission VirtUart0ChannelRxSize = total_len; VirtUart0RxMsg = SET; } void VIRT_UART1_RxCpltCallback(VIRT_UART_HandleTypeDef *huart) { /* copy received msg in a variable to sent it back to master processor in main infinite loop*/ VirtUart1ChannelRxSize = huart->RxXferSize < MAX_BUFFER_SIZE? huart->RxXferSize : MAX_BUFFER_SIZE-1; memcpy(VirtUart1ChannelBuffRx, huart->pRxBuffPtr, VirtUart1ChannelRxSize); VirtUart1RxMsg = SET; } /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @PAram file: pointer to the source file name * @PAram line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
View more

 

 


I searched the internet but with no luck , not sure what i am missing

 

If somebody could help

Thank you

 

0 REPLIES 0