From 740a50687f67f3684e4b5698f8f30e3adebb8f6e Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 17 Jul 2021 19:35:09 +0100 Subject: jztool: add support for Shanling Q1 and Eros Q Change-Id: I8e93162d1a9d82e9d132219f2803b1856d24ae6c --- rbutil/jztool/jztool.c | 79 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 31 deletions(-) (limited to 'rbutil/jztool/jztool.c') diff --git a/rbutil/jztool/jztool.c b/rbutil/jztool/jztool.c index 5fb6dc173f..dcd78137b3 100644 --- a/rbutil/jztool/jztool.c +++ b/rbutil/jztool/jztool.c @@ -28,49 +28,63 @@ jz_context* jz = NULL; jz_usbdev* usbdev = NULL; const jz_device_info* dev_info = NULL; +const jz_cpu_info* cpu_info = NULL; -void usage_fiiom3k(void) +void usage_x1000(void) { - printf("Usage:\n" - " jztool fiiom3k load \n" - "\n" - "The 'load' command is used to boot the Rockbox bootloader in\n" - "recovery mode, which allows you to install the Rockbox bootloader\n" - "and backup or restore bootloader images. You need to connect the\n" - "M3K in USB boot mode in order to use this tool.\n" - "\n" - "On Windows, you will need to install the WinUSB driver for the M3K\n" - "using a 3rd-party tool such as Zadig . For\n" - "more details check the jztool README.md file or the Rockbox wiki at\n" - ".\n" - "\n" - "To connect the M3K in USB boot mode, plug the microUSB into the\n" - "M3K, and hold the VOL- button while plugging the USB into your\n" - "computer. If successful, the button light will turn on and the\n" - "LCD will remain black. If you encounter any errors and need to\n" - "reconnect the device, you must force a power off by holding POWER\n" - "for more than 10 seconds.\n" - "\n" - "Once the Rockbox bootloader is installed on your M3K, you can\n" - "access the recovery menu by holding VOL+ while powering on the\n" - "device.\n"); + printf( +"Usage:\n" +" jztool fiiom3k load \n" +" jztool shanlingq1 load \n" +" jztool erosq load \n" +"\n" +"The 'load' command is used to boot the Rockbox bootloader in recovery\n" +"mode, which allows you to install the Rockbox bootloader and backup or\n" +"restore bootloader images. You need to connect your player in USB boot\n" +"mode in order to use this tool.\n" +"\n" +"To connect the player in USB boot mode, follow these steps:\n" +"\n" +"1. Ensure the player is fully powered off.\n" +"2. Plug one end of the USB cable into your player.\n" +"3. Hold down your player's USB boot key (see below).\n" +"4. Plug the other end of the USB cable into your computer.\n" +"5. Let go of the USB boot key.\n" +"\n" +"USB boot keys:\n" +"\n" +" FiiO M3K - Volume Down\n" +" Shanling Q1 - Play\n" +" Eros Q - Menu\n" +"\n" +"Not all players give a visible indication that they are in USB boot mode.\n" +"If you're having trouble connecting your player, try resetting it by\n" +"holding the power button for 10 seconds, and try the above steps again.\n" +"\n" +"Note for Windows users: you need to install the WinUSB driver using a\n" +"3rd-party tool such as Zadig before this tool\n" +"can access your player in USB boot mode. You need to run Zadig while the\n" +"player is plugged in and in USB boot mode. For more details check the\n" +"jztool README.md file or visit .\n" +"\n"); + exit(4); } -int cmdline_fiiom3k(int argc, char** argv) +int cmdline_x1000(int argc, char** argv) { if(argc < 2 || strcmp(argv[0], "load")) { - usage_fiiom3k(); + usage_x1000(); return 2; } - int rc = jz_usb_open(jz, &usbdev, dev_info->vendor_id, dev_info->product_id); + int rc = jz_usb_open(jz, &usbdev, cpu_info->vendor_id, cpu_info->product_id); if(rc < 0) { jz_log(jz, JZ_LOG_ERROR, "Cannot open USB device: %d", rc); return 1; } - rc = jz_fiiom3k_boot(usbdev, argv[1]); + rc = jz_x1000_boot(usbdev, dev_info->device_type, argv[1]); if(rc < 0) { jz_log(jz, JZ_LOG_ERROR, "Boot failed: %d", rc); return 1; @@ -90,8 +104,7 @@ void usage(void) " -v, --verbose Display detailed logging output\n\n"); printf("Supported devices:\n\n"); - int n = jz_get_num_device_info(); - for(int i = 0; i < n; ++i) { + for(int i = 0; i < JZ_NUM_DEVICES; ++i) { const jz_device_info* info = jz_get_device_info_indexed(i); printf(" %s - %s\n", info->name, info->description); } @@ -182,11 +195,15 @@ int main(int argc, char** argv) exit(2); } + cpu_info = jz_get_cpu_info(dev_info->cpu_type); + /* Dispatch to device handler */ --argc, ++argv; switch(dev_info->device_type) { case JZ_DEVICE_FIIOM3K: - return cmdline_fiiom3k(argc, argv); + case JZ_DEVICE_SHANLINGQ1: + case JZ_DEVICE_EROSQ: + return cmdline_x1000(argc, argv); default: jz_log(jz, JZ_LOG_ERROR, "INTERNAL ERROR: unhandled device type"); -- cgit v1.2.3