Skip to content

Commit 3e75161

Browse files
committed
feat(cherryusb): add cherryusb library
Signed-off-by: sakumisu <[email protected]>
1 parent 95ea6ac commit 3e75161

11 files changed

+95
-0
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "lib/btstack"]
1414
path = lib/btstack
1515
url = https://github.com/bluekitchen/btstack.git
16+
[submodule "lib/cherryusb"]
17+
path = lib/cherryusb
18+
url = https://github.com/cherry-embedded/CherryUSB.git

lib/cherryusb

Submodule cherryusb added at d3aafb2

src/cmake/rp2_common.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ if (NOT PICO_BARE_METAL)
119119
pico_add_subdirectory(rp2_common/cmsis)
120120
endif()
121121
pico_add_subdirectory(rp2_common/tinyusb)
122+
pico_add_subdirectory(rp2_common/cherryusb)
122123
pico_add_subdirectory(rp2_common/pico_stdio_usb)
123124
pico_add_subdirectory(rp2_common/pico_i2c_slave)
124125

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
if (DEFINED ENV{PICO_CHERRYUSB_PATH} AND (NOT PICO_CHERRYUSB_PATH))
2+
set(PICO_CHERRYUSB_PATH $ENV{PICO_CHERRYUSB_PATH})
3+
message("Using PICO_CHERRYUSB_PATH from environment ('${PICO_CHERRYUSB_PATH}')")
4+
endif ()
5+
6+
set(CHERRYUSB_TEST_PATH "port/rp2040")
7+
if (NOT PICO_CHERRYUSB_PATH)
8+
set(PICO_CHERRYUSB_PATH ${PROJECT_SOURCE_DIR}/lib/cherryusb)
9+
if (NOT EXISTS ${PICO_CHERRYUSB_PATH}/${CHERRYUSB_TEST_PATH})
10+
message(WARNING "CherryUSB submodule has not been initialized; USB support will be unavailable
11+
hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).")
12+
endif()
13+
elseif (NOT EXISTS ${PICO_CHERRYUSB_PATH}/${CHERRYUSB_TEST_PATH})
14+
message(WARNING "PICO_CHERRYUSB_PATH specified but content not present.")
15+
endif()
16+
17+
if (EXISTS ${PICO_CHERRYUSB_PATH}/${CHERRYUSB_TEST_PATH})
18+
message("CherryUSB available at ${PICO_CHERRYUSB_PATH}; enabling build support for USB.")
19+
pico_register_common_scope_var(PICO_CHERRYUSB_PATH)
20+
21+
set(CONFIG_CHERRYUSB_DEVICE 1)
22+
set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
23+
set(CONFIG_CHERRYUSB_DEVICE_HID 1)
24+
set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
25+
set(CONFIG_CHERRYUSB_DEVICE_AUDIO 1)
26+
set(CONFIG_CHERRYUSB_DEVICE_VIDEO 1)
27+
set(CONFIG_CHERRYUSB_DEVICE_DCD "rp2040")
28+
include(${PICO_CHERRYUSB_PATH}/cherryusb.cmake)
29+
pico_add_library(cherryusb_device NOFLAG)
30+
target_include_directories(cherryusb_device_headers SYSTEM INTERFACE ${cherryusb_incs})
31+
target_include_directories(cherryusb_device_headers SYSTEM INTERFACE ${PICO_CHERRYUSB_PATH}/demo)
32+
target_sources(cherryusb_device INTERFACE ${cherryusb_srcs})
33+
34+
set(CONFIG_CHERRYUSB_HOST 1)
35+
set(CONFIG_CHERRYUSB_HOST_CDC_ACM 1)
36+
set(CONFIG_CHERRYUSB_HOST_HID 1)
37+
set(CONFIG_CHERRYUSB_HOST_MSC 1)
38+
set(CONFIG_CHERRYUSB_OSAL "freertos")
39+
set(CONFIG_CHERRYUSB_HOST_HCD "rp2040")
40+
41+
include(${PICO_CHERRYUSB_PATH}/cherryusb.cmake)
42+
pico_add_library(cherryusb_host NOFLAG)
43+
target_include_directories(cherryusb_host_headers SYSTEM INTERFACE ${cherryusb_incs})
44+
target_include_directories(cherryusb_host_headers SYSTEM INTERFACE ${PICO_CHERRYUSB_PATH}/demo)
45+
target_sources(cherryusb_host INTERFACE ${cherryusb_srcs})
46+
47+
pico_promote_common_scope_vars()
48+
endif()

src/rp2_common/pico_crt0/rp2040/memmap_blocked_ram.ld

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ SECTIONS
106106
*(.fini_array)
107107
PROVIDE_HIDDEN (__fini_array_end = .);
108108

109+
/* section information for usbh class */
110+
. = ALIGN(4);
111+
__usbh_class_info_start__ = .;
112+
KEEP(*(.usbh_class_info))
113+
__usbh_class_info_end__ = .;
114+
109115
*(.eh_frame*)
110116
. = ALIGN(4);
111117
} > FLASH

src/rp2_common/pico_crt0/rp2040/memmap_copy_to_ram.ld

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ SECTIONS
125125
*(SORT(.dtors.*))
126126
*(.dtors)
127127

128+
/* section information for usbh class */
129+
. = ALIGN(4);
130+
__usbh_class_info_start__ = .;
131+
KEEP(*(.usbh_class_info))
132+
__usbh_class_info_end__ = .;
133+
128134
*(.eh_frame*)
129135
. = ALIGN(4);
130136
__ram_text_end__ = .;

src/rp2_common/pico_crt0/rp2040/memmap_default.ld

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ SECTIONS
106106
*(.fini_array)
107107
PROVIDE_HIDDEN (__fini_array_end = .);
108108

109+
/* section information for usbh class */
110+
. = ALIGN(4);
111+
__usbh_class_info_start__ = .;
112+
KEEP(*(.usbh_class_info))
113+
__usbh_class_info_end__ = .;
114+
109115
*(.eh_frame*)
110116
. = ALIGN(4);
111117
} > FLASH

src/rp2_common/pico_crt0/rp2040/memmap_no_flash.ld

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ SECTIONS
6868
*(SORT(.dtors.*))
6969
*(.dtors)
7070

71+
/* section information for usbh class */
72+
. = ALIGN(4);
73+
__usbh_class_info_start__ = .;
74+
KEEP(*(.usbh_class_info))
75+
__usbh_class_info_end__ = .;
76+
7177
*(.eh_frame*)
7278
} > RAM
7379

src/rp2_common/pico_crt0/rp2350/memmap_copy_to_ram.ld

+6
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ SECTIONS
141141
*(SORT(.dtors.*))
142142
*(.dtors)
143143

144+
/* section information for usbh class */
145+
. = ALIGN(4);
146+
__usbh_class_info_start__ = .;
147+
KEEP(*(.usbh_class_info))
148+
__usbh_class_info_end__ = .;
149+
144150
*(.eh_frame*)
145151
. = ALIGN(4);
146152
__ram_text_end__ = .;

src/rp2_common/pico_crt0/rp2350/memmap_default.ld

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ SECTIONS
9696
*(.fini_array)
9797
PROVIDE_HIDDEN (__fini_array_end = .);
9898

99+
/* section information for usbh class */
100+
. = ALIGN(4);
101+
__usbh_class_info_start__ = .;
102+
KEEP(*(.usbh_class_info))
103+
__usbh_class_info_end__ = .;
104+
99105
*(.eh_frame*)
100106
. = ALIGN(4);
101107
} > FLASH

src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ SECTIONS
6969
*(SORT(.dtors.*))
7070
*(.dtors)
7171

72+
/* section information for usbh class */
73+
. = ALIGN(4);
74+
__usbh_class_info_start__ = .;
75+
KEEP(*(.usbh_class_info))
76+
__usbh_class_info_end__ = .;
77+
7278
*(.eh_frame*)
7379
} > RAM
7480

0 commit comments

Comments
 (0)