This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit cab92d310da399005b9f463793e585b127449627
Author: wangjianyu3 <[email protected]>
AuthorDate: Sat Sep 5 00:21:27 2026 +0800

    boards/rp2040: add USB fastboot composite support for waveshare boards
    
    Add a CDC/ACM (console) + USB fastboot (ADB "fastboot" personality)
    composite device to the shared rp2040_composite.c board glue, and a
    new "fastboot_usb" defconfig for waveshare-rp2040-zero and
    waveshare-rp2040-lcd-1.28.
    
    - boards/arm/rp2040/common/src/rp2040_composite.c: add a third
      composite slot for CONFIG_USBADB (covers both plain ADB and, with
      CONFIG_USBFASTBOOT, the "fastboot" personality of the same driver)
      alongside the existing MSC/CDC-ACM slots.  While adding this,
      fixed a latent bug: the CDC/ACM block never advanced ifnobase/
      strbase after filling in its own slot, because CDC/ACM used to
      always be the *last* device in the composite (nothing downstream
      ever needed the incremented values).  Now that a device can follow
      CDC/ACM, the missing increment caused the fastboot interface to be
      assigned the same USB interface number as CDC/ACM's control
      interface (both 0), which the Linux kernel rejects with "Duplicate
      descriptor for config 1 interface 0 altsetting 0, skipping" and
      drops the fastboot interface entirely (confirmed via lsusb -v and
      disassembly of the generated board_composite_connect() code).
    
    - boards/arm/rp2040/waveshare-rp2040-zero/configs/fastboot_usb and
      boards/arm/rp2040/waveshare-rp2040-lcd-1.28/configs/fastboot_usb:
      new defconfig booting directly into fastbootd
      (CONFIG_INIT_ENTRYPOINT="fastbootd_main", no nsh) which brings up
      the CDC/ACM + fastboot composite via
      CONFIG_SYSTEM_FASTBOOTD_USB_BOARDCTL as soon as fastbootd starts,
      so the CDC/ACM sub-interface still provides a console for boot/
      fastbootd log visibility without requiring a wired UART, while the
      fastboot vendor interface is what `fastboot devices`/`getvar` talk
      to.
    
    Assisted-by: OpenCode:claude-sonnet-5
    Signed-off-by: wangjianyu3 <[email protected]>
---
 boards/arm/rp2040/common/src/rp2040_composite.c    | 45 ++++++++++++++++++-
 .../configs/fastboot_usb/defconfig                 | 51 ++++++++++++++++++++++
 .../configs/fastboot_usb/defconfig                 | 51 ++++++++++++++++++++++
 3 files changed, 146 insertions(+), 1 deletion(-)

diff --git a/boards/arm/rp2040/common/src/rp2040_composite.c 
b/boards/arm/rp2040/common/src/rp2040_composite.c
index 72bfed64fea..031480389ea 100644
--- a/boards/arm/rp2040/common/src/rp2040_composite.c
+++ b/boards/arm/rp2040/common/src/rp2040_composite.c
@@ -32,6 +32,7 @@
 #include <nuttx/usb/usbdev.h>
 #include <nuttx/usb/cdcacm.h>
 #include <nuttx/usb/usbmsc.h>
+#include <nuttx/usb/adb.h>
 #include <nuttx/usb/composite.h>
 
 #if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
@@ -192,7 +193,7 @@ void *board_composite_connect(int port, int configid)
 
   if (configid == 0)
     {
-      struct composite_devdesc_s dev[2];
+      struct composite_devdesc_s dev[3];
       int ifnobase = 0;
       int strbase  = COMPOSITE_NSTRIDS;
       int n = 0;
@@ -264,6 +265,48 @@ void *board_composite_connect(int port, int configid)
       dev[n].devinfo.epno[CDCACM_EP_INTIN_IDX]   = 3;
       dev[n].devinfo.epno[CDCACM_EP_BULKIN_IDX]  = 4;
       dev[n].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 5;
+
+      /* Count up the base numbers.  This used to be omitted here because
+       * CDC/ACM was always the last device in the composite; now that
+       * USB ADB/fastboot may follow it, the offsets must be propagated.
+       */
+
+      ifnobase += dev[n].devinfo.ninterfaces;
+      strbase  += dev[n].devinfo.nstrings;
+      n++;
+#endif
+
+#ifdef CONFIG_USBADB
+      /* Configure the USB ADB/fastboot device.  With CONFIG_USBFASTBOOT
+       * selected this same driver exposes /dev/fastboot instead of
+       * /dev/adb0, so a single "fastboot" personality composite with
+       * CDC/ACM (console) is supported without any additional glue.
+       */
+
+      /* Ask the adb/fastboot driver to fill in the constants we didn't
+       * know here.
+       */
+
+      usbdev_adb_get_composite_devdesc(&dev[n]);
+
+      /* Interfaces */
+
+      dev[n].devinfo.ifnobase = ifnobase;             /* Offset to 
Interface-IDs */
+      dev[n].minor = 0;                               /* The minor interface 
number */
+
+      /* Strings */
+
+      dev[n].devinfo.strbase = strbase;               /* Offset to String 
Numbers */
+
+      /* Endpoints */
+
+      dev[n].devinfo.epno[USBADB_EP_BULKIN_IDX]  = 6;
+      dev[n].devinfo.epno[USBADB_EP_BULKOUT_IDX] = 7;
+
+      /* Count up the base numbers */
+
+      ifnobase += dev[n].devinfo.ninterfaces;
+      strbase  += dev[n].devinfo.nstrings;
       n++;
 #endif
 
diff --git 
a/boards/arm/rp2040/waveshare-rp2040-lcd-1.28/configs/fastboot_usb/defconfig 
b/boards/arm/rp2040/waveshare-rp2040-lcd-1.28/configs/fastboot_usb/defconfig
new file mode 100644
index 00000000000..b6d9f7b9c21
--- /dev/null
+++ b/boards/arm/rp2040/waveshare-rp2040-lcd-1.28/configs/fastboot_usb/defconfig
@@ -0,0 +1,51 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="waveshare-rp2040-lcd-1.28"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_WAVESHARE_RP2040_LCD_1_28=y
+CONFIG_ARCH_CHIP="rp2040"
+CONFIG_ARCH_CHIP_RP2040=y
+CONFIG_ARCH_RAMVECTORS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARDCTL_USBDEVCTRL=y
+CONFIG_BOARD_LOOPSPERMSEC=10450
+CONFIG_BUILTIN=y
+CONFIG_CDCACM=y
+CONFIG_CDCACM_COMPOSITE=y
+CONFIG_CDCACM_CONSOLE=y
+CONFIG_COMPOSITE_PRODUCTID=0x2023
+CONFIG_COMPOSITE_PRODUCTSTR="NuttX Fastboot Composite"
+CONFIG_COMPOSITE_SERIALSTR="fastboot0"
+CONFIG_COMPOSITE_VENDORID=0x03eb
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DISABLE_POSIX_TIMERS=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_PROCFS_REGISTER=y
+CONFIG_INIT_ENTRYPOINT="fastbootd_main"
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_RAM_SIZE=270336
+CONFIG_RAM_START=0x20000000
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_CHILD_STATUS=y
+CONFIG_SCHED_HAVE_PARENT=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=9
+CONFIG_START_MONTH=2
+CONFIG_START_YEAR=2021
+CONFIG_SYSTEM_FASTBOOTD=y
+CONFIG_SYSTEM_FASTBOOTD_USB_BOARDCTL=y
+CONFIG_USBADB=y
+CONFIG_USBADB_COMPOSITE=y
+CONFIG_USBDEV=y
+CONFIG_USBDEV_BUSPOWERED=y
+CONFIG_USBDEV_COMPOSITE=y
+CONFIG_USBFASTBOOT=y
diff --git 
a/boards/arm/rp2040/waveshare-rp2040-zero/configs/fastboot_usb/defconfig 
b/boards/arm/rp2040/waveshare-rp2040-zero/configs/fastboot_usb/defconfig
new file mode 100644
index 00000000000..a2b8e4e8d1b
--- /dev/null
+++ b/boards/arm/rp2040/waveshare-rp2040-zero/configs/fastboot_usb/defconfig
@@ -0,0 +1,51 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="waveshare-rp2040-zero"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_WAVESHARE_RP2040_ZERO=y
+CONFIG_ARCH_CHIP="rp2040"
+CONFIG_ARCH_CHIP_RP2040=y
+CONFIG_ARCH_RAMVECTORS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARDCTL_USBDEVCTRL=y
+CONFIG_BOARD_LOOPSPERMSEC=10450
+CONFIG_BUILTIN=y
+CONFIG_CDCACM=y
+CONFIG_CDCACM_COMPOSITE=y
+CONFIG_CDCACM_CONSOLE=y
+CONFIG_COMPOSITE_PRODUCTID=0x2023
+CONFIG_COMPOSITE_PRODUCTSTR="NuttX Fastboot Composite"
+CONFIG_COMPOSITE_SERIALSTR="fastboot0"
+CONFIG_COMPOSITE_VENDORID=0x03eb
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DISABLE_POSIX_TIMERS=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_PROCFS_REGISTER=y
+CONFIG_INIT_ENTRYPOINT="fastbootd_main"
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_RAM_SIZE=270336
+CONFIG_RAM_START=0x20000000
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_CHILD_STATUS=y
+CONFIG_SCHED_HAVE_PARENT=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=9
+CONFIG_START_MONTH=2
+CONFIG_START_YEAR=2021
+CONFIG_SYSTEM_FASTBOOTD=y
+CONFIG_SYSTEM_FASTBOOTD_USB_BOARDCTL=y
+CONFIG_USBADB=y
+CONFIG_USBADB_COMPOSITE=y
+CONFIG_USBDEV=y
+CONFIG_USBDEV_BUSPOWERED=y
+CONFIG_USBDEV_COMPOSITE=y
+CONFIG_USBFASTBOOT=y

Reply via email to