Skip to content
Draft
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
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ west build -b lpcxpresso55s16/lpc55s16 cannectivity/app/ -- -DFILE_SUFFIX=releas

After building, the firmware can be flashed to the board by running the `west flash` command.

> **Note:** Build configurations for using the legacy USB device stack in Zephyr are also
> provided. These can be selected by setting either `FILE_SUFFIX=legacy` or
> `FILE_SUFFIX=legacy_release`.

## USB Device Firmware Upgrade (DFU) Mode

CANnectivity supports USB Device Firmware Upgrade
Expand Down
40 changes: 2 additions & 38 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,9 @@ config CANNECTIVITY_MAX_CHANNELS
The Linux kernel driver supports up to 3 channels. Other drivers may support just one
channel.

if USB_DEVICE_STACK

configdefault USB_DEVICE_MANUFACTURER
default CANNECTIVITY_USB_MANUFACTURER

configdefault USB_DEVICE_PRODUCT
default CANNECTIVITY_USB_PRODUCT

configdefault USB_DEVICE_VID
default CANNECTIVITY_USB_VID

configdefault USB_DEVICE_PID
default CANNECTIVITY_USB_PID

configdefault USB_SELF_POWERED
default CANNECTIVITY_USB_SELF_POWERED

configdefault USB_MAX_POWER
default CANNECTIVITY_USB_MAX_POWER

configdefault USB_DEVICE_GS_USB_MAX_CHANNELS
default CANNECTIVITY_MAX_CHANNELS

configdefault USB_DEVICE_BOS
default y

configdefault USB_DEVICE_INITIALIZE_AT_BOOT
default n

endif # USB_DEVICE_STACK

if USB_DEVICE_STACK_NEXT

configdefault USBD_GS_USB_MAX_CHANNELS
default CANNECTIVITY_MAX_CHANNELS

endif # USB_DEVICE_STACK_NEXT

config CANNECTIVITY_LED
bool "LED support"
default y
Expand Down Expand Up @@ -185,9 +150,8 @@ if CANNECTIVITY_DFU_SUPPORT
choice CANNECTIVITY_DFU_BACKEND
bool "DFU backend"
default CANNECTIVITY_DFU_BACKEND_NONE if !BOOTLOADER_MCUBOOT
default CANNECTIVITY_DFU_BACKEND_MCUBOOT if BOOTLOADER_MCUBOOT && USB_DEVICE_STACK
default CANNECTIVITY_DFU_BACKEND_MCUBOOT if BOOTLOADER_MCUBOOT && MCUBOOT_BOOTLOADER_MODE_SINGLE_APP
default CANNECTIVITY_DFU_BACKEND_APP if BOOTLOADER_MCUBOOT && USB_DEVICE_STACK_NEXT
default CANNECTIVITY_DFU_BACKEND_APP if BOOTLOADER_MCUBOOT

config CANNECTIVITY_DFU_BACKEND_NONE
bool "No backend"
Expand All @@ -203,7 +167,7 @@ config CANNECTIVITY_DFU_BACKEND_MCUBOOT

config CANNECTIVITY_DFU_BACKEND_APP
bool "Application"
depends on BOOTLOADER_MCUBOOT && !MCUBOOT_BOOTLOADER_MODE_SINGLE_APP && USB_DEVICE_STACK_NEXT
depends on BOOTLOADER_MCUBOOT && !MCUBOOT_BOOTLOADER_MODE_SINGLE_APP
help
Device Firmware Upgrade is handled by the CANnectivity firmware application. The upgrade
process is handled by MCUboot upon reboot.
Expand Down
5 changes: 0 additions & 5 deletions app/boards/canbardo_same70n20b_legacy.conf

This file was deleted.

5 changes: 0 additions & 5 deletions app/boards/canbardo_same70n20b_legacy_release.conf

This file was deleted.

89 changes: 0 additions & 89 deletions app/boards/native_sim_legacy.overlay

This file was deleted.

7 changes: 0 additions & 7 deletions app/boards/native_sim_legacy_release.overlay

This file was deleted.

7 changes: 0 additions & 7 deletions app/boards/native_sim_native_64_legacy.overlay

This file was deleted.

7 changes: 0 additions & 7 deletions app/boards/native_sim_native_64_legacy_release.overlay

This file was deleted.

10 changes: 0 additions & 10 deletions app/prj_legacy.conf

This file was deleted.

13 changes: 0 additions & 13 deletions app/prj_legacy_release.conf

This file was deleted.

58 changes: 0 additions & 58 deletions app/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,6 @@ common:
regex:
- "CANnectivity firmware initialized with .*"
tests:
app.cannectivity.legacy:
depends_on:
- can
- usb_device
extra_args:
- FILE_SUFFIX=legacy
integration_platforms:
- canbardo
- candlelight
- candlelightfd
- candlelightfd/stm32g0b1xx/dual
- frdm_k64f
- frdm_mcxn947/mcxn947/cpu0
- lpcxpresso55s16
- mks_canable_v20
- nucleo_h723zg
- ucan
- usb2canfdv1
app.cannectivity.legacy.sof:
depends_on:
- can
- usb_device
extra_args:
- FILE_SUFFIX=legacy
integration_platforms:
- nucleo_h723zg
extra_configs:
- CONFIG_USB_DEVICE_GS_USB_TIMESTAMP_SOF=y
app.cannectivity.legacy.release:
depends_on:
- can
- usb_device
extra_args:
- FILE_SUFFIX=legacy_release
integration_platforms:
- canbardo
- candlelight
- candlelightfd
- candlelightfd/stm32g0b1xx/dual
- frdm_k64f
- frdm_mcxn947/mcxn947/cpu0
- lpcxpresso55s16
- mks_canable_v20
- nucleo_h723zg
- ucan
- usb2canfdv1
build_only: true
app.cannectivity:
depends_on:
- can
Expand Down Expand Up @@ -102,17 +55,6 @@ tests:
- ucan
- usb2canfdv1
build_only: true
app.cannectivity.legacy.dfu:
sysbuild: true
depends_on:
- can
- usb_device
platform_allow:
- frdm_k64f
- lpcxpresso55s16
- canbardo
extra_args:
- FILE_SUFFIX=legacy
app.cannectivity.dfu:
sysbuild: true
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion app/src/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ int cannectivity_led_event(const struct device *dev, uint16_t ch, enum gs_usb_ev

lctx->activity[idx] = sys_timepoint_calc(K_MSEC(LED_TICK_MS * LED_TICKS_ACTIVITY));
break;
#if defined(CONFIG_USB_DEVICE_GS_USB_IDENTIFICATION) || defined(CONFIG_USBD_GS_USB_IDENTIFICATION)
#ifdef CONFIG_USBD_GS_USB_IDENTIFICATION
case GS_USB_EVENT_CHANNEL_IDENTIFY_ON:
LOG_DBG("identify channel %u on", ch);
led_event = LED_EVENT_CHANNEL_IDENTIFY_ON;
Expand Down
50 changes: 4 additions & 46 deletions app/src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
#include <zephyr/usb/msos_desc.h>
#include <zephyr/sys/byteorder.h>

#ifdef CONFIG_USB_DEVICE_STACK_NEXT
#include <zephyr/usb/usbd.h>
#else /* CONFIG_USB_DEVICE_STACK_NEXT */
#include <zephyr/usb/usb_device.h>
#include <zephyr/usb/bos.h>
#include <usb_descriptor.h>
#endif /* !CONFIG_USB_DEVICE_STACK_NEXT*/
#ifdef CONFIG_CANNECTIVITY_DFU_BACKEND_APP
#include <zephyr/dfu/mcuboot.h>
#endif /* CONFIG_CANNECTIVITY_DFU_BACKEND_APP */
Expand All @@ -36,13 +30,7 @@ LOG_MODULE_REGISTER(usb, CONFIG_CANNECTIVITY_LOG_LEVEL);
#define CANNECTIVITY_USB_BCD_DRN \
(USB_DEC_TO_BCD(APP_VERSION_MAJOR) << 8 | USB_DEC_TO_BCD(APP_VERSION_MINOR))

#ifdef CONFIG_USB_DEVICE_STACK_NEXT
#define CANNECTIVITY_BOS_DESC_DEFINE_CAP static
#else /* CONFIG_USB_DEVICE_STACK_NEXT */
#define CANNECTIVITY_BOS_DESC_DEFINE_CAP USB_DEVICE_BOS_DESC_DEFINE_CAP
#endif /* !CONFIG_USB_DEVICE_STACK_NEXT */

CANNECTIVITY_BOS_DESC_DEFINE_CAP const struct usb_bos_capability_lpm bos_cap_lpm = {
static const struct usb_bos_capability_lpm bos_cap_lpm = {
.bLength = sizeof(struct usb_bos_capability_lpm),
.bDescriptorType = USB_DESC_DEVICE_CAPABILITY,
.bDevCapabilityType = USB_BOS_CAPABILITY_EXTENSION,
Expand Down Expand Up @@ -227,9 +215,9 @@ struct usb_bos_capability_msosv2 {
} __packed;

#ifdef CONFIG_CANNECTIVITY_DFU_BACKEND_APP
CANNECTIVITY_BOS_DESC_DEFINE_CAP struct usb_bos_capability_msosv2 bos_cap_msosv2 = {
static struct usb_bos_capability_msosv2 bos_cap_msosv2 = {
#else /* CONFIG_CANNECTIVITY_DFU_BACKEND_APP */
CANNECTIVITY_BOS_DESC_DEFINE_CAP const struct usb_bos_capability_msosv2 bos_cap_msosv2 = {
static const struct usb_bos_capability_msosv2 bos_cap_msosv2 = {
#endif /* CONFIG_CANNECTIVITY_DFU_BACKEND_APP */
.platform = {
.bLength = sizeof(struct usb_bos_capability_msosv2),
Expand All @@ -256,8 +244,6 @@ CANNECTIVITY_BOS_DESC_DEFINE_CAP const struct usb_bos_capability_msosv2 bos_cap_
};
/* clang-format on */

#ifdef CONFIG_USB_DEVICE_STACK_NEXT

USBD_DEVICE_DEFINE(usbd, DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)), CONFIG_CANNECTIVITY_USB_VID,
CONFIG_CANNECTIVITY_USB_PID);

Expand Down Expand Up @@ -463,7 +449,7 @@ static void cannectivity_usb_msg_cb(struct usbd_context *const usbd_ctx,
}
#endif /* CONFIG_CANNECTIVITY_DFU_BACKEND_APP */

static int cannectivity_usb_init_usbd(void)
int cannectivity_usb_init(void)
{
int err;

Expand Down Expand Up @@ -613,31 +599,3 @@ static int cannectivity_usb_init_usbd(void)

return 0;
}
#else /* CONFIG_USB_DEVICE_STACK_NEXT */
static int cannectivity_usb_vendorcode_handler(int32_t *tlen, uint8_t **tdata)
{
*tdata = (uint8_t *)(&cannectivity_msosv2_descriptor);
*tlen = sizeof(cannectivity_msosv2_descriptor);

return 0;
}
#endif /* !CONFIG_USB_DEVICE_STACK_NEXT */

int cannectivity_usb_init(void)
{
#ifdef CONFIG_USB_DEVICE_STACK_NEXT
return cannectivity_usb_init_usbd();
#else /* CONFIG_USB_DEVICE_STACK_NEXT */
struct usb_device_descriptor *desc =
(struct usb_device_descriptor *)usb_get_device_descriptor();

desc->bcdDevice = sys_cpu_to_le16(CANNECTIVITY_USB_BCD_DRN);

usb_bos_register_cap((void *)&bos_cap_lpm);
usb_bos_register_cap((void *)&bos_cap_msosv2);

gs_usb_register_vendorcode_callback(cannectivity_usb_vendorcode_handler);

return usb_enable(NULL);
#endif /* !CONFIG_USB_DEVICE_STACK_NEXT */
}
Loading
Loading