rbutil: define USE_LIBUSBAPI for Linux builds

Resolves "DFU not working at all" under rbutil on Linux

And fix some related warnings

Change-Id: Ie44ebc960cfc0c5d0121e8ceb24576ed427746a8
This commit is contained in:
Solomon Peachy 2026-07-04 11:46:34 -04:00
parent 9e6135ecd2
commit 96f1b19149
3 changed files with 7 additions and 4 deletions

View file

@ -67,6 +67,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(PkgConfig)
pkg_check_modules(libusb QUIET REQUIRED IMPORTED_TARGET libusb-1.0)
message("-- Found libusb: ${libusb_LINK_LIBRARIES}")
add_compile_definitions(USE_LIBUSBAPI)
# optional system libs.
pkg_check_modules(speex QUIET IMPORTED_TARGET speex speexdsp)

View file

@ -245,6 +245,7 @@ struct dfuAPI {
/*
* DFU API low-level (specific) functions
*/
#if defined(WIN32) || defined(USE_LIBUSBAPI) || defined(__APPLE__)
static bool dfu_check_id(int vid, int pid, int *pid_list)
{
int *p;
@ -263,6 +264,7 @@ static void dfu_add_reqerrstr(struct dfuDev *dfuh, struct usbControlSetup *cs)
sizeof(dfuh->err) - strlen(dfuh->err), " (cs=%02x/%d/%d/%d/%d)",
cs->bmRequestType, cs->bRequest, cs->wValue, cs->wIndex, cs->wLength);
}
#endif
#ifdef WIN32
static bool dfu_winapi_chkrc(struct dfuDev *dfuh, char *str, bool success)
@ -695,7 +697,7 @@ static struct dfuAPI api_list[] =
*/
static int DEBUG_DFUREQ = 0;
static dfuAPIResult dfuapi_request(struct dfuDev *dfuh,
static __attribute__ ((noinline)) dfuAPIResult dfuapi_request(struct dfuDev *dfuh,
struct usbControlSetup *cs, void *data)
{
if (!DEBUG_DFUREQ)
@ -902,7 +904,7 @@ static int ipoddfu_download_file(struct dfuDev* dfuh,
{
unsigned int blknum, len, remaining;
int poll_tmo;
DFUStatus status;
DFUStatus status = errNONE;
DFUState state;
if (dfuapi_req_getstate(dfuh, &state) != DFUAPISuccess)

View file

@ -191,9 +191,9 @@ unsigned char *mkdfu(int dfu_type, char *dfu_arg, int* dfu_size,
{
const struct ipod_models *model = NULL;
unsigned char *dfu_buf = NULL;
unsigned char *f_buf;
unsigned char *f_buf = NULL;
int f_size;
uint32_t padded_bl_size;
uint32_t padded_bl_size = 0;
uint32_t cert_off, cert_sz;
off_t cur_off;
char *dfu_desc;