espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.69k stars 7.29k forks source link

Cherry usb error compilation (IDFGH-13755) #14617

Open maaamcube opened 1 month ago

maaamcube commented 1 month ago

Answers checklist.

IDF version.

v5.2

Operating System used.

Windows

How did you build your project?

Command line with Make

If you are using Windows, please specify command line type.

None

What is the expected behavior?

I'm trying to compile cherryusb from menuconfig with my esp idf v5.2, i got this error :

C:/cherryusb_esp32/examples/host/managed_components/cherry-embedded__cherryusb/platform/none/usbh_lwip.c:31:2: error: #error PBUF_POOL_BUFSIZE must be larger than 1600 31 | #error PBUF_POOL_BUFSIZE must be larger than 1600

How can i correct it ?

Thanks.

What is the actual behavior?

C:/cherryusb_esp32/examples/host/managed_components/cherry-embedded__cherryusb/platform/none/usbh_lwip.c:31:2: error: #error PBUF_POOL_BUFSIZE must be larger than 1600 31 | #error PBUF_POOL_BUFSIZE must be larger than 1600

Steps to reproduce.

  1. Step : copy cherryusb https://github.com/CherryUSB/cherryusb_esp32 to C:/
  2. Step : Compil with esp idf v5.2 using menuconfig : Enable host usb ncm and DWC2 esp, enable LWIP_TCPIP_CORE_LOCKING and LWIP_TCPIP_CORE_LOCKING_INPUT
  3. Step : C:/cherryusb_esp32/examples/host/managed_components/cherry-embedded__cherryusb/platform/none/usbh_lwip.c:31:2: error: #error PBUF_POOL_BUFSIZE must be larger than 1600 31 | #error PBUF_POOL_BUFSIZE must be larger than 1600

Build or installation Logs.

No response

More Information.

No response

david-cermak commented 3 weeks ago

Hi @maaamcube

The requirement for packet buffer size seems to come from the cherry-usb itself:

https://github.com/cherry-embedded/CherryUSB/blob/773d67016fb33fc341bc379c1572e35103d23d32/platform/none/usbh_lwip.c#L25-L27

This is not configurable on IDF side, as the default LWIP size is used instead.

You can override this option from the project (but also from the cherry-usb component) makefile placing:

idf_component_get_property(lwip lwip COMPONENT_LIB)
target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")

after idf_component_register().

PS: Documented in https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/lwip.html#customized-lwip-options-from-esp-idf-build-system

maaamcube commented 3 weeks ago

@david-cermak thanks for your reply. I added the lines but i still have the error.

david-cermak commented 5 days ago

@maaamcube Do you have a branch with the actual changes? I recall that I had to fix some other refs, includes and other minor stuff to get it compiled besides the lwip defines? Maybe if you post your updates, I'll check if I can share a fixing commit.

maaamcube commented 5 days ago

@david-cermak No, sorry. I did those changes locally during my tests.

To make it work, i put comment to those lines :

"#if LWIP_TCPIP_CORE_LOCKING_INPUT != 1

warning suggest you to set LWIP_TCPIP_CORE_LOCKING_INPUT to 1, usb handles eth input with own thread

endif

if LWIP_TCPIP_CORE_LOCKING != 1

error must set LWIP_TCPIP_CORE_LOCKING to 1

endif

if PBUF_POOL_BUFSIZE < 1600

error PBUF_POOL_BUFSIZE must be larger than 1600

endif"

I changed those lines : "

include "FreeRTOS.h"

include "task.h"

include "semphr.h"

include "timers.h"

ip_addr_t g_ipaddr; ip_addr_t g_netmask; ip_addr_t g_gateway;"

by : "

include "freertos/FreeRTOS.h"

include "freertos/task.h"

include "freertos/semphr.h"

include "freertos/timers.h"

ip4_addr_t g_ipaddr; ip4_addr_t g_netmask; ip4_addr_t g_gateway;"

I used CherryUSB V1.4.0

igrr commented 5 days ago

Just FYI, there is an ORIG_INCLUDE_PATH property of FreeRTOS component which could be used to make includes like FreeRTOS.h work. Here is an example in tinyusb component: https://github.com/espressif/tinyusb/blob/4b4c984c04e686954a35b3d552dd4cccaa008034/CMakeLists.txt#L18-L30

By adding the two lines in CMake you can keep the includes unchanged.

david-cermak commented 5 days ago

...and about the ip_addr_t -> ip4_addr_t change, it should be enough to disable IPv6 in LWIP component config

david-cermak commented 5 days ago

Here're my changes to make the host example compilable:

diff --git a/examples/host/main/CMakeLists.txt b/examples/host/main/CMakeLists.txt
index 7524c18..1d69647 100644
--- a/examples/host/main/CMakeLists.txt
+++ b/examples/host/main/CMakeLists.txt
@@ -1,3 +1,6 @@

 idf_component_register(SRCS "main.c"
                     INCLUDE_DIRS ".")
+
+idf_component_get_property(lwip lwip COMPONENT_LIB)
+target_compile_definitions(${lwip} PRIVATE "-DPBUF_POOL_BUFSIZE=1600")
\ No newline at end of file
diff --git a/examples/host/main/idf_component.yml b/examples/host/main/idf_component.yml
index aa668de..8060976 100644
--- a/examples/host/main/idf_component.yml
+++ b/examples/host/main/idf_component.yml
@@ -1,6 +1,8 @@
 ## IDF Component Manager Manifest File
 dependencies:
-  cherry-embedded/cherryusb: "^1.4.0~1"
+  cherry-embedded/cherryusb:
+    version: "^1.4.0~1"
+#    override_path: ../../..
   ## Required IDF version
   idf:
     version: ">=4.1.0"

(changes against https://github.com/CherryUSB/cherryusb_esp32/commit/a0e15d45225c4731921dcf53dbdea985d03ba413)

To update the freertos include dirs and lwip IPv4 only config, it's probably better to update the component makefile (rather then project one)

sakumisu commented 1 day ago

@igrr @david-cermak Thank you for your suggestions, i will add these into cherryusb cmakelist.