Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# This file is autogenerated when a board is built. Do not edit. Do commit it to git. Other scripts use its info.
name = "Adafruit Industries LLC CLUE nRF52840 Express"

[modules]
__future__ = true
_bleio = true # Zephyr board has _bleio
_eve = false
_pew = false
_pixelmap = false
_stage = false
adafruit_bus_device = true
adafruit_pixelbuf = false
aesio = true
alarm = false
analogbufio = false
analogio = false
atexit = false
audiobusio = false
audiocore = false
audiodelays = false
audiofilewriter = false
audiofilters = false
audiofreeverb = false
audioi2sin = false
audioio = false
audiomixer = false
audiomp3 = false
audiopwmio = false
audiospeed = false
aurora_epaper = false
bitbangio = false
bitmapfilter = true # Zephyr board has busio
bitmaptools = true # Zephyr board has busio
bitops = false
board = false
busdisplay = true # Zephyr board has busio
busio = true # Zephyr board has busio
camera = false
canio = false
codeop = false
countio = false
digitalio = true
displayio = true # Zephyr board has displayio
dotclockframebuffer = false
dualbank = false
epaperdisplay = true # Zephyr board has busio
floppyio = false
fontio = true # Zephyr board has busio
fourwire = true # Zephyr board has busio
framebufferio = true # Zephyr board has busio
frequencyio = false
getpass = true
gifio = true # Zephyr board has busio
gnss = false
hashlib = true
hostnetwork = false
i2cdisplaybus = true # Zephyr board has busio
i2cioexpander = false
i2ctarget = false
imagecapture = false
ipaddress = false
is31fl3741 = false
jpegio = true # Zephyr board has busio
keypad = false
keypad_demux = false
locale = false
lvfontio = true # Zephyr board has busio
math = true
max3421e = false
mcp4822 = false
mdns = false
memorymap = false
memorymonitor = false
microcontroller = true
mipidsi = false
msgpack = true
neopixel_write = false
nvm = true # Zephyr board has nvm
onewireio = false
os = true
paralleldisplaybus = false
ps2io = false
pulseio = false
pwmio = false
qrio = false
qspibus = false
rainbowio = true
random = true
rclcpy = false
rgbmatrix = false
rotaryio = true # Zephyr board has rotaryio
rtc = false
sdcardio = true # Zephyr board has busio
sdioio = false
sharpdisplay = true # Zephyr board has busio
socketpool = false
spitarget = false
ssl = false
storage = true # Zephyr board has flash
struct = true
supervisor = true
synthio = false
terminalio = true # Zephyr board has busio
tilepalettemapper = true # Zephyr board has busio
time = true
touchio = false
traceback = true
uheap = false
usb = false
usb_audio = false
usb_cdc = true
usb_hid = true
usb_host = false
usb_midi = false
usb_video = false
ustack = false
vectorio = true # Zephyr board has busio
warnings = true
watchdog = false
wifi = false
zephyr_display = true # Zephyr board has zephyr_display
zephyr_kernel = false
zlib = true
# extmod modules shared with MicroPython
asyncio = true
binascii = true
json = true
re = true
select = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CIRCUITPY_BUILD_EXTENSIONS = ["hex", "uf2"]
USB_VID=0x239A
USB_PID=0x8072
NAME="CLUE nRF52840 Express"
6 changes: 6 additions & 0 deletions ports/zephyr-cp/boards/adafruit_clue_nrf52840_uf2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_USE_DT_CODE_PARTITION=y

CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n

# Enable the ST7789V TFT via the Zephyr display subsystem
CONFIG_DISPLAY=y
49 changes: 49 additions & 0 deletions ports/zephyr-cp/boards/adafruit_clue_nrf52840_uf2.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
};
};

&zephyr_udc0 {
/delete-node/ board_cdc_acm_uart;
};


&gd25q16 {
/delete-node/ partitions;
};

/delete-node/ &storage_partition;
/delete-node/ &code_partition;

&flash0 {
partitions {
code_partition: partition@26000 {
compatible = "zephyr,mapped-partition";
label = "Application";
reg = <0x00026000 0x000c4000>;
};

storage_partition: partition@ea000 {
compatible = "zephyr,mapped-partition";
label = "storage";
reg = <0x000ea000 0x00008000>;
};

nvm_partition: partition@f2000 {
compatible = "zephyr,mapped-partition";
label = "nvm";
reg = <0x000f2000 0x00002000>;
};
};
};

&uart0 {
status = "okay";
};

#include "../app.overlay"
1 change: 1 addition & 0 deletions ports/zephyr-cp/boards/board_aliases.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ endmacro()

cp_board_alias(pca10056 nrf52840dk/nrf52840)
cp_board_alias(adafruit_feather_nrf52840_zephyr adafruit_feather_nrf52840/nrf52840/uf2)
cp_board_alias(adafruit_clue_nrf52840_zephyr adafruit_clue_nrf52840/nrf52840/uf2)
cp_board_alias(adafruit_feather_nrf52840_sense_zephyr adafruit_feather_nrf52840/nrf52840/sense/uf2)
cp_board_alias(adafruit_feather_rp2040_zephyr adafruit_feather_rp2040/rp2040)
cp_board_alias(renesas_ek_ra6m5 ek_ra6m5)
Expand Down
23 changes: 23 additions & 0 deletions ports/zephyr-cp/cptools/zephyr2cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,29 @@
"D12",
"D13",
],
"adafruit-clue": [
["P0", "D0", "A2", "RX"],
["P1", "D1", "A3", "TX"],
["P2", "D2", "A4"],
["P3", "D3", "A5"],
["P4", "D4", "A6"],
["P5", "D5", "BUTTON_A"],
["P6", "D6"],
["P7", "D7"],
["P8", "D8"],
["P9", "D9"],
["P10", "D10", "A7"],
["P11", "D11", "BUTTON_B"],
["P12", "D12", "A0"],
["P13", "D13", "SCK"],
["P14", "D14", "MISO"],
["P15", "D15", "MOSI"],
["P16", "D16", "A1"],
["P17", "D17", "L", "LED"],
["P18", "D18", "NEOPIXEL"],
["P19", "D19", "SCL"],
["P20", "D20", "SDA"],
],
"nordic,expansion-board-header": [
"P1_04",
"P1_05",
Expand Down
1 change: 1 addition & 0 deletions ports/zephyr-cp/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=32768
CONFIG_ISR_STACK_SIZE=4096
CONFIG_UDC_DWC2_STACK_SIZE=4096
CONFIG_UDC_NRF_THREAD_STACK_SIZE=4096
CONFIG_USBD_THREAD_STACK_SIZE=4096
CONFIG_USBD_MSC_STACK_SIZE=4096
CONFIG_IDLE_STACK_SIZE=1024
Expand Down
39 changes: 36 additions & 3 deletions ports/zephyr-cp/supervisor/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <zephyr/kernel.h>
#include <zephyr/usb/usbd.h>
#include <zephyr/usb/class/usbd_msc.h>
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbd)
#include <nrfx_power.h>
#endif

#include "shared-module/storage/__init__.h"
#include "supervisor/filesystem.h"
Expand Down Expand Up @@ -396,19 +399,49 @@ void usb_init(void) {
printk("usbd_init\n");
err = usbd_init(&main_usbd);
if (err) {
LOG_ERR("Failed to initialize device support");
LOG_ERR("Failed to initialize device support (%d)", err);
return;
}

printk("USB initialized\n");

if (!usbd_can_detect_vbus(&main_usbd)) {
/* No VBUS detection — just enable unconditionally. */
err = usbd_enable(&main_usbd);
if (err) {
LOG_ERR("Failed to enable device support");
LOG_ERR("Failed to enable device support (%d)", err);
return;
}
printk("usbd enabled\n");
} else {
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbd)
/*
* On nRF52 USBD, the UDC driver enables VBUS detection interrupts
* inside usbd_init(). If USB is already plugged in, the VBUS_READY
* event arrives before usbd_init() sets status.initialized = true,
* causing a __ASSERT in usbd_thread (with CONFIG_ASSERT=y) that kills
* the event-processing thread. Our _msg_cb then never receives
* VBUS_READY, and USB never enumerates.
*
* Work around the race by checking the current VBUS state directly.
* udc_nrf_enable() does not require VBUS to be present, so it's safe
* to call usbd_enable() if VBUS is already up.
*/
nrfx_power_usb_state_t vbus = nrfx_power_usbstatus_get();
if (vbus != NRFX_POWER_USB_STATE_DISCONNECTED) {
err = usbd_enable(&main_usbd);
if (err) {
LOG_ERR("Failed to enable device support (%d)", err);
return;
}
}
#else
/*
* On nRF54 USBHS, VBUS events arrive via NRFS IPC which has a natural
* startup delay, so the assert race doesn't occur. Additionally,
* udc_enable() blocks until VBUS is ready, so we must NOT call
* usbd_enable() here — let _msg_cb handle it on VBUS_READY.
*/
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion ports/zephyr-cp/zephyr-config/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ manifest:
path: modules/bsim_hw_models/nrf_hw_models
- name: zephyr
url: https://github.com/adafruit/zephyr
revision: 3c402d80bd86628065f2a7d2af4a55a42556b08e
revision: 62e7a3764b652fff733cee43f23f82217403a51d
clone-depth: 100
import: true
Loading