Skip to content

Commit 129b80f

Browse files
committed
board: raytac: Add support for raytac_mdbt50q_cx_40_dongle
Add support for Raytac's new TYPE-C dongle. Signed-off-by: Stanley Huang <[email protected]>
1 parent 6463c68 commit 129b80f

17 files changed

+766
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
zephyr_library_sources(board.c)
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Raytac MDBT50Q-CX Dongle NRF52840 board configuration
2+
#
3+
# Copyright (c) 2018-2023 Nordic Semiconductor ASA
4+
# Copyright (c) 2025 Raytac Corporation.
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
if BOARD_RAYTAC_MDBT50Q_CX_40_DONGLE
8+
9+
config BOARD_HAS_NRF5_BOOTLOADER
10+
bool "Board has nRF5 bootloader"
11+
default y
12+
help
13+
If selected, applications are linked so that they can be loaded by Nordic
14+
nRF5 bootloader.
15+
16+
config BOARD_SERIAL_BACKEND_CDC_ACM
17+
bool "USB CDC"
18+
default y
19+
20+
endif # BOARD_RAYTAC_MDBT50Q_CX_40_DONGLE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Raytac MDBT50Q-CX-40 Dongle NRF52840 board configuration
2+
#
3+
# Copyright (c) 2018-2023 Nordic Semiconductor ASA
4+
# Copyright (c) 2025 Raytac Corporation
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
if BOARD_RAYTAC_MDBT50Q_CX_40_DONGLE
8+
9+
config BOARD
10+
default "raytac_mdbt50q_cx_40_dongle_nrf52840"
11+
12+
# To let the nRF5 bootloader load an application, the application
13+
# must be linked after Nordic MBR, that is factory-programmed on the board.
14+
15+
# Nordic nRF5 bootloader exists outside of the partitions specified in the
16+
# DTS file, so we manually override FLASH_LOAD_OFFSET to link the application
17+
# correctly, after Nordic MBR.
18+
19+
# When building MCUBoot, MCUBoot itself will select USE_DT_CODE_PARTITION
20+
# which will make it link into the correct partition specified in DTS file,
21+
# the offset is applied here so that the full partition size can be used when
22+
# the bootloader Kconfig option has been disabled.
23+
24+
config FLASH_LOAD_OFFSET
25+
default 0x1000
26+
depends on BOARD_HAS_NRF5_BOOTLOADER && (MCUBOOT || !USE_DT_CODE_PARTITION)
27+
28+
source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig"
29+
30+
endif # BOARD_RAYTAC_MDBT50Q_CX_40_DONGLE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Raytac MDBT50Q-CX-40 Dongle nRF52840 board configuration
2+
#
3+
# Copyright (c) 2018 Nordic Semiconductor ASA
4+
# Copyright (c) 2025 Raytac Corporation
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
config BOARD_RAYTAC_MDBT50Q_CX_40_DONGLE
8+
select SOC_NRF52840_QIAA
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2018 Nordic Semiconductor ASA.
3+
* Copyright (c) 2025 Raytac Corporation.
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <zephyr/init.h>
9+
#include <hal/nrf_power.h>
10+
11+
static int board_raytac_mdbt50q_cx_40_dongle_nrf52840_init(void)
12+
{
13+
14+
/* if the nrf52840dongle_nrf52840 board is powered from USB
15+
* (high voltage mode), GPIO output voltage is set to 1.8 volts by
16+
* default and that is not enough to turn the green and blue LEDs on.
17+
* Increase GPIO voltage to 3.0 volts.
18+
*/
19+
if ((nrf_power_mainregstatus_get(NRF_POWER) ==
20+
NRF_POWER_MAINREGSTATUS_HIGH) &&
21+
((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) ==
22+
(UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos))) {
23+
24+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
25+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
26+
;
27+
}
28+
29+
NRF_UICR->REGOUT0 =
30+
(NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) |
31+
(UICR_REGOUT0_VOUT_3V0 << UICR_REGOUT0_VOUT_Pos);
32+
33+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
34+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
35+
;
36+
}
37+
38+
/* a reset is required for changes to take effect */
39+
NVIC_SystemReset();
40+
}
41+
42+
return 0;
43+
}
44+
45+
SYS_INIT(board_raytac_mdbt50q_cx_40_dongle_nrf52840_init, PRE_KERNEL_1,
46+
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2018-2023 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_runner_args(jlink "--device=nrf52840_xxaa" "--speed=4000")
5+
board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
6+
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
7+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
8+
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: raytac_mdbt50q_cx_40_dongle
3+
full_name: Raytac MDBT50Q-CX-40 Dongle
4+
vendor: raytac
5+
socs:
6+
- name: nrf52840
Loading
Loading

0 commit comments

Comments
 (0)