Skip to content

Commit 76a1a89

Browse files
committed
!fixup Cleanup debug messages and use Error_Handler()
1 parent abef6ee commit 76a1a89

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

cores/arduino/VirtIOSerial.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ void VirtIOSerial::begin(void)
4444
if (initialized) {
4545
return;
4646
}
47-
OPENAMP_Init();
48-
if (VIRT_UART_Init(&huart) != VIRT_UART_OK) {
49-
// log_err("VIRT_UART_Init UART0 failed.\r\n");
47+
if (OPENAMP_Init() != 0) {
48+
Error_Handler();
49+
}
50+
if (VIRT_UART_Init(&virt_huart) != VIRT_UART_OK) {
5051
Error_Handler();
5152
}
5253
/*Need to register callback for message reception by channels*/
@@ -136,6 +137,7 @@ size_t VirtIOSerial::write(uint8_t ch)
136137
size_t VirtIOSerial::write(const uint8_t *buffer, size_t size)
137138
{
138139
if (VIRT_UART_Transmit(&huart, const_cast<uint8_t *>(buffer), size) == VIRT_UART_ERROR) {
140+
// This error usually happens when rpmsg is not ready for
139141
return 0;
140142
}
141143
return size;

cores/arduino/stm32/virtio/mbox_ipcc.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ int MAILBOX_Init(void)
8080

8181
if (HAL_IPCC_ActivateNotification(&hipcc, IPCC_CHANNEL_1, IPCC_CHANNEL_DIR_RX,
8282
IPCC_channel1_callback) != HAL_OK) {
83-
OPENAMP_log_err("%s: ch_1 RX fail\n", __func__);
83+
Error_Handler();
8484
return -1;
8585
}
8686

8787
if (HAL_IPCC_ActivateNotification(&hipcc, IPCC_CHANNEL_2, IPCC_CHANNEL_DIR_RX,
8888
IPCC_channel2_callback) != HAL_OK) {
89-
OPENAMP_log_err("%s: ch_2 RX fail\n", __func__);
89+
Error_Handler();
9090
return -1;
9191
}
9292

@@ -106,27 +106,23 @@ int MAILBOX_Notify(void *priv, uint32_t id)
106106
/* Called after virtqueue processing: time to inform the remote */
107107
if (id == VRING0_ID) {
108108
channel = IPCC_CHANNEL_1;
109-
OPENAMP_log_dbg("Send msg on ch_1\r\n");
110109
} else if (id == VRING1_ID) {
111110
/* Note: the OpenAMP framework never notifies this */
112111
channel = IPCC_CHANNEL_2;
113-
OPENAMP_log_dbg("Send 'buff free' on ch_2\r\n");
114112
return -1;
115113
} else {
116-
OPENAMP_log_err("invalid vring (%d)\r\n", (int)id);
117114
return -1;
118115
}
119116

120117
/* Check that the channel is free (otherwise wait until it is) */
121118
if (HAL_IPCC_GetChannelStatus(&hipcc, channel, IPCC_CHANNEL_DIR_TX) == IPCC_CHANNEL_STATUS_OCCUPIED) {
122-
OPENAMP_log_dbg("Waiting for channel to be freed\r\n");
119+
// Wait for channel to be freed
123120
while (HAL_IPCC_GetChannelStatus(&hipcc, channel, IPCC_CHANNEL_DIR_TX) == IPCC_CHANNEL_STATUS_OCCUPIED)
124121
;
125122
}
126123

127124
/* Inform A7 (either new message, or buf free) */
128125
HAL_IPCC_NotifyCPU(&hipcc, channel, IPCC_CHANNEL_DIR_TX);
129-
130126
return 0;
131127
}
132128

0 commit comments

Comments
 (0)