Skip to content

Commit 31ce009

Browse files
committed
mcumgr: relocate uart transport
The uart_mcumgr.c implements the APIs used by the smp_uart.c but lives in the drivers/console folder which is kinda awkward, as the files in the drivers/console generally implements the stdout & printk hooks. Relocate it into subsys/mgmt/mcumgr/transport/src/ alongside smp_uart.c instead. Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
1 parent ad4c3e3 commit 31ce009

File tree

7 files changed

+38
-28
lines changed

7 files changed

+38
-28
lines changed

drivers/console/Kconfig

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,34 +203,26 @@ config IPM_CONSOLE_LINE_BUF_LEN
203203
where characters are stored before sending the whole line.
204204

205205
config UART_MCUMGR
206-
bool "Mcumgr UART driver"
207-
select UART_INTERRUPT_DRIVEN
206+
bool "Mcumgr UART driver [DEPRECATED]"
207+
select DEPRECATED
208208
help
209-
Enable the mcumgr UART driver. This driver allows the application to
210-
communicate over UART using the mcumgr protocol for image upgrade and
211-
device management. The driver doesn't inspect received data (as
212-
contrary to console UART driver) and all aspects of received protocol
213-
data are handled by an application provided callback.
209+
This option is deprecated.
214210

215211
if UART_MCUMGR
216212

217213
config UART_MCUMGR_RX_BUF_SIZE
218-
int "Size of receive buffer for mcumgr fragments received over UART, in bytes"
219-
default 128
214+
int "Size of receive buffer for mcumgr fragments received over UART, in bytes [DEPRECATED]"
215+
default 0
220216
help
221-
Specifies the size of the mcumgr UART receive buffer, in bytes. This
222-
value must be large enough to accommodate any line sent by an mcumgr
223-
client.
217+
This option is deprecated.
218+
Please use MCUMGR_TRANSPORT_UART_RX_BUF_SIZE instead.
224219

225220
config UART_MCUMGR_RX_BUF_COUNT
226-
int "Number of receive buffers for mcumgr fragments received over UART"
227-
default 2
221+
int "Number of receive buffers for mcumgr fragments received over UART [DEPRECATED]"
222+
default 0
228223
help
229-
Specifies the number of the mcumgr UART receive buffers. Receive
230-
buffers hold received mcumgr fragments prior to reassembly. This
231-
setting's value must satisfy the following relation:
232-
UART_MCUMGR_RX_BUF_COUNT * UART_MCUMGR_RX_BUF_SIZE >=
233-
MCUMGR_TRANSPORT_UART_MTU
224+
This option is deprecated.
225+
Please use MCUMGR_TRANSPORT_UART_RX_BUF_COUNT instead.
234226

235227
endif # UART_MCUMGR
236228

subsys/mgmt/mcumgr/transport/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_SHELL
2121
)
2222
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UART
2323
src/smp_uart.c
24+
src/uart_mcumgr.c
2425
)
2526
zephyr_library_sources_ifdef(CONFIG_MCUMGR_TRANSPORT_UDP
2627
src/smp_udp.c

subsys/mgmt/mcumgr/transport/Kconfig.uart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ menuconfig MCUMGR_TRANSPORT_UART
1414
depends on CONSOLE
1515
depends on BASE64
1616
depends on CRC
17-
select UART_MCUMGR
1817
help
1918
Enables handling of SMP commands received over UART. This is a
2019
lightweight alternative to MCUMGR_TRANSPORT_SHELL. It allows mcumgr
@@ -60,4 +59,22 @@ config MCUMGR_TRANSPORT_UART_MTU
6059
This value must satisfy the following relation:
6160
MCUMGR_TRANSPORT_UART_MTU <= MCUMGR_TRANSPORT_NETBUF_SIZE + 2
6261

62+
config MCUMGR_TRANSPORT_UART_RX_BUF_SIZE
63+
int "Size of receive buffer for mcumgr fragments received over UART, in bytes"
64+
default 128
65+
help
66+
Specifies the size of the mcumgr UART receive buffer, in bytes. This
67+
value must be large enough to accommodate any line sent by an mcumgr
68+
client.
69+
70+
config MCUMGR_TRANSPORT_UART_RX_BUF_COUNT
71+
int "Number of receive buffers for mcumgr fragments received over UART"
72+
default 2
73+
help
74+
Specifies the number of the mcumgr UART receive buffers. Receive
75+
buffers hold received mcumgr fragments prior to reassembly. This
76+
setting's value must satisfy the following relation:
77+
MCUMGR_TRANSPORT_UART_RX_BUF_COUNT * MCUMGR_TRANSPORT_UART_RX_BUF_SIZE >=
78+
MCUMGR_TRANSPORT_UART_MTU
79+
6380
endif # MCUMGR_TRANSPORT_UART

include/zephyr/drivers/console/uart_mcumgr.h renamed to subsys/mgmt/mcumgr/transport/include/mgmt/mcumgr/transport/uart_mcumgr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* @see include/mgmt/serial.h
1111
*/
1212

13-
#ifndef ZEPHYR_INCLUDE_DRIVERS_CONSOLE_UART_MCUMGR_H_
14-
#define ZEPHYR_INCLUDE_DRIVERS_CONSOLE_UART_MCUMGR_H_
13+
#ifndef ZEPHYR_INCLUDE_MGMT_SMP_UART_MCUMGR_H_
14+
#define ZEPHYR_INCLUDE_MGMT_SMP_UART_MCUMGR_H_
1515

1616
#include <stdlib.h>
1717
#include <zephyr/types.h>
@@ -25,7 +25,7 @@ extern "C" {
2525
*/
2626
struct uart_mcumgr_rx_buf {
2727
void *fifo_reserved; /* 1st word reserved for use by fifo */
28-
uint8_t data[CONFIG_UART_MCUMGR_RX_BUF_SIZE];
28+
uint8_t data[CONFIG_MCUMGR_TRANSPORT_UART_RX_BUF_SIZE];
2929
int length;
3030
};
3131

subsys/mgmt/mcumgr/transport/src/smp_dummy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
*/
1111

1212
/* Define required for uart_mcumgr.h functionality reuse */
13-
#define CONFIG_UART_MCUMGR_RX_BUF_SIZE CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
13+
#define CONFIG_MCUMGR_TRANSPORT_UART_RX_BUF_SIZE CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
1414
#define MCUMGR_DUMMY_MAX_FRAME CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE
1515

16+
#include <mgmt/mcumgr/transport/uart_mcumgr.h>
1617
#include <zephyr/kernel.h>
1718
#include <zephyr/init.h>
1819
#include <zephyr/sys/crc.h>
1920
#include <zephyr/sys/byteorder.h>
2021
#include <zephyr/net_buf.h>
2122
#include <zephyr/sys/base64.h>
22-
#include <zephyr/drivers/console/uart_mcumgr.h>
2323
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
2424
#include <zephyr/mgmt/mcumgr/smp/smp.h>
2525
#include <zephyr/mgmt/mcumgr/transport/smp.h>

subsys/mgmt/mcumgr/transport/src/smp_uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
*/
1010

1111
#include <string.h>
12+
#include <mgmt/mcumgr/transport/uart_mcumgr.h>
1213
#include <zephyr/kernel.h>
1314
#include <zephyr/init.h>
1415
#include <zephyr/net_buf.h>
15-
#include <zephyr/drivers/console/uart_mcumgr.h>
1616
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
1717
#include <zephyr/mgmt/mcumgr/smp/smp.h>
1818
#include <zephyr/mgmt/mcumgr/transport/smp.h>

drivers/console/uart_mcumgr.c renamed to subsys/mgmt/mcumgr/transport/src/uart_mcumgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
*/
1111

1212
#include <string.h>
13+
#include <mgmt/mcumgr/transport/uart_mcumgr.h>
1314
#include <zephyr/kernel.h>
1415
#include <zephyr/drivers/uart.h>
1516
#include <zephyr/mgmt/mcumgr/transport/serial.h>
16-
#include <zephyr/drivers/console/uart_mcumgr.h>
1717

1818
static const struct device *const uart_mcumgr_dev =
1919
DEVICE_DT_GET(DT_CHOSEN(zephyr_uart_mcumgr));
@@ -32,7 +32,7 @@ static bool uart_mcumgr_ignoring;
3232

3333
/** Contains buffers to hold incoming request fragments. */
3434
K_MEM_SLAB_DEFINE(uart_mcumgr_slab, sizeof(struct uart_mcumgr_rx_buf),
35-
CONFIG_UART_MCUMGR_RX_BUF_COUNT, 1);
35+
CONFIG_MCUMGR_TRANSPORT_UART_RX_BUF_COUNT, 1);
3636

3737
#if defined(CONFIG_MCUMGR_TRANSPORT_UART_ASYNC)
3838
uint8_t async_buffer[CONFIG_MCUMGR_TRANSPORT_UART_ASYNC_BUFS]

0 commit comments

Comments
 (0)