From 21d48d5ae3ea84dd7fc8941789ebb739a7c4deed Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 31 Jul 2026 11:20:47 -0400 Subject: [PATCH] iap: Improve IAPGeneralCommandID_RequestIPodName iap-serial was hardcoded to return "ROCKBOX", and it was not implemented at all in iap-usb. Extend the iap-serial implementation to return the contents of /playername.txt, or "Rockbox" if there is an error opening/reading that file. And cut-n-paste this into the iap-usb side of things Change-Id: I9d328be390b4cc8bd92237f996c41ef1e5e19724 --- apps/iap/iap-lingo4.c | 11 +++++++++-- firmware/usbstack/iap/libiap/iap.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/iap/iap-lingo4.c b/apps/iap/iap-lingo4.c index 746d59f397..d29f4d1612 100644 --- a/apps/iap/iap-lingo4.c +++ b/apps/iap/iap-lingo4.c @@ -16,6 +16,7 @@ * ******************************************************************************/ +#include "misc.h" #include "iap-core.h" #include "iap-lingo.h" #include "dir.h" @@ -1034,12 +1035,18 @@ void iap_handlepkt_mode4(const unsigned int len, const unsigned char *buf) * 5 0x14 Command ID (bits 7:0) * 6 0xE5 Telegram payload checksum byte * - * We return ROCKBOX, should this be definable? * Should it be Volume Name? */ { + char ipod_name[32] = "Rockbox"; + int fd = open_utf8(ROCKBOX_DIR "/playername.txt", O_RDONLY); + if (fd >= 0) { + read_line(fd, ipod_name, sizeof(ipod_name)); + close(fd); + ipod_name[sizeof(ipod_name)-1] = 0; + } IAP_TX_INIT4(0x04, 0x0015); - IAP_TX_PUT_STRING("ROCKBOX"); + IAP_TX_PUT_STRING(ipod_name); iap_send_tx(); break; } diff --git a/firmware/usbstack/iap/libiap/iap.c b/firmware/usbstack/iap/libiap/iap.c index b5f700b0a2..af1fe2545c 100644 --- a/firmware/usbstack/iap/libiap/iap.c +++ b/firmware/usbstack/iap/libiap/iap.c @@ -1,6 +1,8 @@ #include #include +#include "misc.h" + #include "constants.h" #include "endian.h" #include "iap.h" @@ -201,6 +203,25 @@ static int32_t handle_command(struct IAPContext* ctx, uint8_t lingo, uint16_t co response->is_ext_mode = 1; return IAPGeneralCommandID_ReturnExtendedInterfaceMode; } break; + case IAPGeneralCommandID_RequestIPodName: { + // Note: This should be pulled from .rockbox/playername.txt + char ipod_name[32] = "Rockbox"; + int fd = open_utf8(ROCKBOX_DIR "/playername.txt", O_RDONLY); + if (fd >= 0) { + read_line(fd, ipod_name, sizeof(ipod_name)); + close(fd); + ipod_name[sizeof(ipod_name)-1] = 0; + } + + check_ret( + iap_span_append(response_span, + ipod_name, + strlen(ipod_name) + 1), + -IAPAckStatus_EOutOfResource + ); + + return IAPGeneralCommandID_ReturnIPodName; + } break; case IAPGeneralCommandID_RequestIPodSoftwareVersion: { alloc_response(IAPReturnIPodSoftwareVersionPayload); response->major = 18;