已经可以运行,但是还有一个隐藏的很深的BUG还没有来得及改

This commit is contained in:
anguoyoula
2024-01-11 17:51:04 +08:00
parent 58ee6ad53b
commit 255d7464f7
6 changed files with 125 additions and 132 deletions
@@ -83,6 +83,11 @@
*/
#define PRECISION_DEFAULT (INT_MAX)
/**
* max data number of fifi data reg
*/
static const uint32_t SCIF_UART_TX_FIFO_STAGES = 16;
/**
* Enum for storing width modifier.
*/
@@ -785,7 +790,6 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
}
static uint32_t xSerialPortInitialized = 0;
static uint32_t tx_data_empty = 1;
static uint32_t rx_data_full = 0;
static void uart_callback(uart_callback_args_t *const p_arg)
@@ -820,17 +824,26 @@ static void uart_callback(uart_callback_args_t *const p_arg)
}
if (p_arg->event & UART_EVENT_TX_DATA_EMPTY)
{
tx_data_empty = 1;
__NOP();
}
}
static void outbyte1(console_t console, char c)
{
scif_uart_instance_ctrl_t * p_ctrl = (scif_uart_instance_ctrl_t *)g_uart2.p_ctrl;
uint32_t no_send_data_count = 0;
p_ctrl->p_reg->FTDR = c;
for (int i = 0; i < 200; i++){}
while (1)
{
// 获取还未发送的数据数量
no_send_data_count = (uint32_t) p_ctrl->p_reg->FDR_b.T;
// 还存在可以发送数据的空间
if (no_send_data_count < SCIF_UART_TX_FIFO_STAGES)
{
p_ctrl->p_reg->FTDR = c;
break;
}
}
}
void outbyte(console_t console, char c)
@@ -297,12 +297,12 @@ void platform_release_rpmsg_vdev (void * platform, struct rpmsg_device * rpdev)
struct rpmsg_virtio_device * rpmsg_vdev;
struct remoteproc_priv * prproc = rproc->priv;
KTaskDelete(ipi_tsk_id[prproc->notify_id]);
ipi_tsk_id[prproc->notify_id] = -1;
KMutexDelete(ipi.ipi_mutx_id[prproc->notify_id]);
ipi.ipi_mutx_id[prproc->notify_id] = -1;
KTaskDelete(ipi_tsk_id[prproc->notify_id]);
ipi_tsk_id[prproc->notify_id] = -1;
rpmsg_vdev = metal_container_of(rpdev, struct rpmsg_virtio_device, rdev);
rpmsg_deinit_vdev(rpmsg_vdev);
remoteproc_remove_virtio(rproc, rpmsg_vdev->vdev);
@@ -378,7 +378,7 @@ static void* IpiTask (void * exinf)
// KPrintf("IpiTask: after remoteproc_get_notification\n");
if (ret)
{
LPRINTF("remoteproc_get_notification() failed with %d", ret);
KPrintf("remoteproc_get_notification() failed with %d", ret);
break;
}
@@ -400,7 +400,7 @@ static void start_ipi_task (void * platform)
}
ipi.ipi_mutx_id[prproc->notify_id] = mutx_id;
KPrintf("start_ipi_task: prproc->notify_id = %d, ipi.ipi_mutx_id[prproc->notify_id] = %d \n",prproc->notify_id,ipi.ipi_mutx_id[prproc->notify_id]);
// KPrintf("start_ipi_task: prproc->notify_id = %d, ipi.ipi_mutx_id[prproc->notify_id] = %d \n",prproc->notify_id,ipi.ipi_mutx_id[prproc->notify_id]);
int32 ipi_task_id = -1;
ipi_task_id = KTaskCreate("ipi_task",IpiTask,platform,4096,SHELL_TASK_PRIORITY + 1);
@@ -1,198 +0,0 @@
/***********************************************************************************************************************
* Copyright [2020-2021] Renesas Electronics Corporation and/or its affiliates. All Rights Reserved.
*
* This software and documentation are supplied by Renesas Electronics Corporation and/or its affiliates and may only
* be used with products of Renesas Electronics Corp. and its affiliates ("Renesas"). No other uses are authorized.
* Renesas products are sold pursuant to Renesas terms and conditions of sale. Purchasers are solely responsible for
* the selection and use of Renesas products and Renesas assumes no liability. No license, express or implied, to any
* intellectual property right is granted by Renesas. This software is protected under all applicable laws, including
* copyright laws. Renesas reserves the right to change or discontinue this software and/or this documentation.
* THE SOFTWARE AND DOCUMENTATION IS DELIVERED TO YOU "AS IS," AND RENESAS MAKES NO REPRESENTATIONS OR WARRANTIES, AND
* TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, DISCLAIMS ALL WARRANTIES, WHETHER EXPLICITLY OR IMPLICITLY,
* INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT, WITH RESPECT TO THE
* SOFTWARE OR DOCUMENTATION. RENESAS SHALL HAVE NO LIABILITY ARISING OUT OF ANY SECURITY VULNERABILITY OR BREACH.
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT WILL RENESAS BE LIABLE TO YOU IN CONNECTION WITH THE SOFTWARE OR
* DOCUMENTATION (OR ANY PERSON OR ENTITY CLAIMING RIGHTS DERIVED FROM YOU) FOR ANY LOSS, DAMAGES, OR CLAIMS WHATSOEVER,
* INCLUDING, WITHOUT LIMITATION, ANY DIRECT, CONSEQUENTIAL, SPECIAL, INDIRECT, PUNITIVE, OR INCIDENTAL DAMAGES; ANY
* LOST PROFITS, OTHER ECONOMIC DAMAGE, PROPERTY DAMAGE, OR PERSONAL INJURY; AND EVEN IF RENESAS HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH LOSS, DAMAGES, CLAIMS OR COSTS.
**********************************************************************************************************************/
/**
* @file sample_rpmsg.c
* @brief rpmsg sample program for FreeRTOS
* @date 2020.03.24
* @author Copyright (c) 2020, eForce Co., Ltd. All rights reserved.
*
****************************************************************************
* @par History
* - rev 1.0 (2020.01.28) Imada
* Initial version.
* - rev 1.1 (2020.03.24) Imada
* Employed a dedicated function to set a string for Shared memory API.
****************************************************************************
*/
#include <openamp/open_amp.h>
#include "platform_info.h"
#include "rsc_table.h"
#include <xizi.h>
extern int init_system(void);
extern void cleanup_system(void);
#define SHUTDOWN_MSG (0xEF56A55A)
/* Local variables */
/*-----------------------------------------------------------------------------*
* RPMSG callbacks setup by remoteproc_resource_init()
*-----------------------------------------------------------------------------*/
/* Local variables */
static struct rpmsg_endpoint rp_ept[CFG_RPMSG_SVCNO] = {0};
volatile static int evt_svc_unbind[CFG_RPMSG_SVCNO] = {0};
/**
* Callback Function: rpmsg_endpoint_cb
*
* @param[in] rp_svc
* @param[in] data
* @param[in] len
* @param[in] priv
* @param[in] src
*/
static int rpmsg_endpoint_cb0 (struct rpmsg_endpoint * cb_rp_ept, void * data, size_t len, uint32_t src, void * priv)
{
/* service 0 */
(void) priv;
(void) src;
/* On reception of a shutdown we signal the application to terminate */
if ((*(unsigned int *) data) == SHUTDOWN_MSG)
{
evt_svc_unbind[0] = 1;
return RPMSG_SUCCESS;
}
KPrintf("rpmsg_endpoint_cb0: recv data = %p, *data = %d,len = %d\n",data,*((int*)(data)),len);
/* Send data back to master */
if (rpmsg_send(cb_rp_ept, data, (int) len) < 0)
{
LPERROR("rpmsg_send failed\n");
return -1;
}
return RPMSG_SUCCESS;
}
static int rpmsg_endpoint_cb1 (struct rpmsg_endpoint * cb_rp_ept, void * data, size_t len, uint32_t src, void * priv)
{
/* service 1 */
(void) priv;
(void) src;
/* On reception of a shutdown we signal the application to terminate */
if ((*(unsigned int *) data) == SHUTDOWN_MSG)
{
evt_svc_unbind[1] = 1;
return RPMSG_SUCCESS;
}
/* Send data back to master */
if (rpmsg_send(cb_rp_ept, data, (int) len) < 0)
{
LPERROR("rpmsg_send failed \n");
return -1;
}
return RPMSG_SUCCESS;
}
/**
* Callback Function: rpmsg_service_unbind
*
* @param[in] ept
*/
static void rpmsg_service_unbind0 (struct rpmsg_endpoint * ept)
{
(void) ept;
/* service 0 */
rpmsg_destroy_ept(&rp_ept[0]);
memset(&rp_ept[0], 0x0, sizeof(struct rpmsg_endpoint));
evt_svc_unbind[0] = 1;
}
static void rpmsg_service_unbind1 (struct rpmsg_endpoint * ept)
{
(void) ept;
/* service 1 */
rpmsg_destroy_ept(&rp_ept[1]);
memset(&rp_ept[1], 0x0, sizeof(struct rpmsg_endpoint));
evt_svc_unbind[1] = 1;
}
/*-----------------------------------------------------------------------------*
* Application
*-----------------------------------------------------------------------------*/
int app (struct rpmsg_device * rdev, void * platform, unsigned long svcno)
{
(void) platform;
int ret;
if (svcno == 0UL)
{
ret = rpmsg_create_ept(&rp_ept[0],
rdev,
CFG_RPMSG_SVC_NAME0,
APP_EPT_ADDR,
RPMSG_ADDR_ANY,
rpmsg_endpoint_cb0,
rpmsg_service_unbind0);
if (ret)
{
LPERROR("Failed to create endpoint.\n");
return -1;
}
KPrintf("app: Success to create endpoint rp_ept[0]\n");
}
else
{
ret = rpmsg_create_ept(&rp_ept[1],
rdev,
CFG_RPMSG_SVC_NAME1,
APP_EPT_ADDR,
RPMSG_ADDR_ANY,
rpmsg_endpoint_cb1,
rpmsg_service_unbind1);
if (ret)
{
LPERROR("Failed to create endpoint.\n");
return -1;
}
}
LPRINTF("Waiting for events...\n");
while (1)
{
DelayKTask(100);
/* we got a shutdown request, exit */
if (evt_svc_unbind[svcno])
{
break;
}
}
/* Clear shutdown flag */
evt_svc_unbind[svcno] = 0;
return 0;
}
@@ -1,71 +0,0 @@
#include <openamp/open_amp.h>
#include "rpmsg_task.h"
#include "platform_info.h"
#include <xizi.h>
extern int init_system (void);
extern void cleanup_system (void);
extern int app (struct rpmsg_device * rdev, void * platform, unsigned long svcno);
void* RPMsgTask_Entry(void* param)
{
unsigned long proc_id = 0UL;
unsigned long rsc_id = 0UL;
struct rpmsg_device * rpdev;
void * platform;
int ret;
ret = init_system();
if (ret)
{
LPERROR("Failed to init remoteproc device.\n");
goto err;
}
ret = platform_init(proc_id, rsc_id, &platform);
if (ret)
{
LPERROR("Failed to create remoteproc device.\n");
goto err;
}
else
{
do
{
/* RTOS is Master, but this setting must remote in this release. */
rpdev = platform_create_rpmsg_vdev(platform, 0x0U, VIRTIO_DEV_SLAVE, NULL, NULL);
if (!rpdev)
{
LPERROR("Fail, platform_create_rpmsg_vdev.\n");
goto err;
}
// KPrintf("RPMsgTask_Entry: Success platform_create_rpmsg_vdev.\n");
/* Kick the application */
(void) app(rpdev, platform, proc_id);
platform_release_rpmsg_vdev(platform, rpdev);
KPrintf("RPMsgTask_Entry: Success platform_release_rpmsg_vdev.\n");
DelayKTask(RECONNECT_DLY);
} while (RECONNECT_FLG);
}
err:
KPrintf("RPMsgTask_Entry: err \n");
}
void CreateRPMsgTask(void)
{
// 创建的任务优先级与SHELL终端一致,防止该任务无法执行
int32 rpmsg_task_id = KTaskCreate("rpmsg_task",RPMsgTask_Entry,NULL,2048,SHELL_TASK_PRIORITY);
if (rpmsg_task_id < 0)
{
KPrintf("CreateRPMsgTask: create rpmsg task fail!\n");
return ;
}
// 将该任务放入调用
StartupKTask(rpmsg_task_id);
}