Custom board DFU on USB port on VS Code

Hello,

i'm using VS Code + Nrf Connect SDK (SDK/Toolchain 2.3.0) to develop firmware for a custom board based on nrf5340. I'm trying to use the USB port of the board (connected to D+ and D- pins of the nrf5340 chip) for both debugging (serial console) and firmware upgrade (DFU). My dream-goal would be having the custom board to behave similarly to a nrf5340DK: i can connect it through USB, it pops up automatically on "Connected Devices" VS Code view and i can flash it pressing "Flash" on Action View. Generally, it would be enough to be able to program it using the USB with whatever software.

Until now, starting from this tutorial and consulting a lot of Kconfig reference and the Zephyr board porting guide i have been able to achieve the following results:

- Build (using VS Code) and flash (using SWD port) the hello world example specifically for my custom board (with custom_board.dts, custom_board_defconfig, etc.)

- Enable MCUBoot subsystem

- Build correctly using MCUMGR options (see prj.conf code below);

- Enable USB console (my "Helloworld" printk statements are printed on serial console through USB connection, tested using Putty software)

However, i'm still missing something to enable DFU. I know that i need to start from SMP_server_sample and configurate MCUMGR correctly, but i'm a bit confused on what is the working procedure.

Here below is my proj.conf

# --------------------------------------- MCUBOOT CONFIG SETTINGS --------------------------------------#

# Enable mcumgr.
CONFIG_MCUMGR=y

# Enable most core commands.
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y

# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y

# Enable the serial mcumgr transport.
CONFIG_MCUMGR_SMP_UART=y

# --------------------------------------- RTT CONSOLE CONFIG SETTINGS --------------------------------------#
#Use this config as alternatives to USB console. USB needs "UART_CONSOLE" dependency, here disabled, so they cannot be used together

# Disable UART Console and enable the RTT console
#CONFIG_UART_CONSOLE=n
#CONFIG_RTT_CONSOLE=y
#CONFIG_USE_SEGGER_RTT=y

# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096


# --------------------------------------- USB CONFIG SETTINGS --------------------------------------#

# Enable the USB stack
CONFIG_USB_DEVICE_STACK=y

# Enable the CDC_ACM service -> the connected device will emulate a modem or serial port
CONFIG_USB_CDC_ACM=y

# Configure name, Product Id and Vendor ID of the USB device
CONFIG_USB_DEVICE_PRODUCT="My Custom board"
CONFIG_USB_DEVICE_PID=0x0110
# CONFIG_USB_DEVICE_VID=0x2FE3   // Zephyr project Device ID - Only for development

# Inizialize USB automatically at boot time
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y

# Enable console inputs and UART based drivers -> Logger and shell can be used on USB
CONFIG_UART_INTERRUPT_DRIVEN=y 

and here below i put the interested parts of my dts:

/ {
	model = "my_custom_board";
	compatible = "cnr-imm,my_custom_board";

	chosen {
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
		zephyr,console = &cdc_acm_uart0;
		zephyr,shell-uart = &uart0;
		zephyr,uart-mcumgr = &uart0;
				
		/* shared memory reserved for the inter-processor communication */
		zephyr,ipc_shm = &sram0_shared;
	};
};


	        

I'm missing something probably both in prj.conf (maybe CONFIG_UART_CONSOLE_MCUMGR?) and dts (maybe zephyr,uart-mcumgr = &uart0 is wrong?). Moreover, i'm missing something aboout procedure (is it possible to flash the custom board using VS Code?)

Thank you for any hint you can provide me

Frax

Parents Reply Children
No Data
Related