summaryrefslogtreecommitdiff
path: root/rbutil/jztool/jztool.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-07-17 19:35:09 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-07-20 14:56:58 +0000
commit740a50687f67f3684e4b5698f8f30e3adebb8f6e (patch)
treecc2afcc989f0ca89e849338ad136e4042acd6bc1 /rbutil/jztool/jztool.c
parent6f042e91dd8730bf72b423248aa2c520708f03c5 (diff)
downloadrockbox-740a50687f67f3684e4b5698f8f30e3adebb8f6e.tar.gz
rockbox-740a50687f67f3684e4b5698f8f30e3adebb8f6e.zip
jztool: add support for Shanling Q1 and Eros Qbootloader_shanlingq1_v1
Change-Id: I8e93162d1a9d82e9d132219f2803b1856d24ae6c
Diffstat (limited to 'rbutil/jztool/jztool.c')
-rw-r--r--rbutil/jztool/jztool.c79
1 files changed, 48 insertions, 31 deletions
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 @@
28jz_context* jz = NULL; 28jz_context* jz = NULL;
29jz_usbdev* usbdev = NULL; 29jz_usbdev* usbdev = NULL;
30const jz_device_info* dev_info = NULL; 30const jz_device_info* dev_info = NULL;
31const jz_cpu_info* cpu_info = NULL;
31 32
32void usage_fiiom3k(void) 33void usage_x1000(void)
33{ 34{
34 printf("Usage:\n" 35 printf(
35 " jztool fiiom3k load <bootloader.m3k>\n" 36"Usage:\n"
36 "\n" 37" jztool fiiom3k load <bootloader.m3k>\n"
37 "The 'load' command is used to boot the Rockbox bootloader in\n" 38" jztool shanlingq1 load <bootloader.q1>\n"
38 "recovery mode, which allows you to install the Rockbox bootloader\n" 39" jztool erosq load <bootloader.erosq>\n"
39 "and backup or restore bootloader images. You need to connect the\n" 40"\n"
40 "M3K in USB boot mode in order to use this tool.\n" 41"The 'load' command is used to boot the Rockbox bootloader in recovery\n"
41 "\n" 42"mode, which allows you to install the Rockbox bootloader and backup or\n"
42 "On Windows, you will need to install the WinUSB driver for the M3K\n" 43"restore bootloader images. You need to connect your player in USB boot\n"
43 "using a 3rd-party tool such as Zadig <https://zadig.akeo.ie>. For\n" 44"mode in order to use this tool.\n"
44 "more details check the jztool README.md file or the Rockbox wiki at\n" 45"\n"
45 "<https://rockbox.org/wiki/FiioM3K>.\n" 46"To connect the player in USB boot mode, follow these steps:\n"
46 "\n" 47"\n"
47 "To connect the M3K in USB boot mode, plug the microUSB into the\n" 48"1. Ensure the player is fully powered off.\n"
48 "M3K, and hold the VOL- button while plugging the USB into your\n" 49"2. Plug one end of the USB cable into your player.\n"
49 "computer. If successful, the button light will turn on and the\n" 50"3. Hold down your player's USB boot key (see below).\n"
50 "LCD will remain black. If you encounter any errors and need to\n" 51"4. Plug the other end of the USB cable into your computer.\n"
51 "reconnect the device, you must force a power off by holding POWER\n" 52"5. Let go of the USB boot key.\n"
52 "for more than 10 seconds.\n" 53"\n"
53 "\n" 54"USB boot keys:\n"
54 "Once the Rockbox bootloader is installed on your M3K, you can\n" 55"\n"
55 "access the recovery menu by holding VOL+ while powering on the\n" 56" FiiO M3K - Volume Down\n"
56 "device.\n"); 57" Shanling Q1 - Play\n"
58" Eros Q - Menu\n"
59"\n"
60"Not all players give a visible indication that they are in USB boot mode.\n"
61"If you're having trouble connecting your player, try resetting it by\n"
62"holding the power button for 10 seconds, and try the above steps again.\n"
63"\n"
64"Note for Windows users: you need to install the WinUSB driver using a\n"
65"3rd-party tool such as Zadig <https://zadig.akeo.ie> before this tool\n"
66"can access your player in USB boot mode. You need to run Zadig while the\n"
67"player is plugged in and in USB boot mode. For more details check the\n"
68"jztool README.md file or visit <https://rockbox.org/wiki/IngenicX1000>.\n"
69"\n");
70
57 exit(4); 71 exit(4);
58} 72}
59 73
60int cmdline_fiiom3k(int argc, char** argv) 74int cmdline_x1000(int argc, char** argv)
61{ 75{
62 if(argc < 2 || strcmp(argv[0], "load")) { 76 if(argc < 2 || strcmp(argv[0], "load")) {
63 usage_fiiom3k(); 77 usage_x1000();
64 return 2; 78 return 2;
65 } 79 }
66 80
67 int rc = jz_usb_open(jz, &usbdev, dev_info->vendor_id, dev_info->product_id); 81 int rc = jz_usb_open(jz, &usbdev, cpu_info->vendor_id, cpu_info->product_id);
68 if(rc < 0) { 82 if(rc < 0) {
69 jz_log(jz, JZ_LOG_ERROR, "Cannot open USB device: %d", rc); 83 jz_log(jz, JZ_LOG_ERROR, "Cannot open USB device: %d", rc);
70 return 1; 84 return 1;
71 } 85 }
72 86
73 rc = jz_fiiom3k_boot(usbdev, argv[1]); 87 rc = jz_x1000_boot(usbdev, dev_info->device_type, argv[1]);
74 if(rc < 0) { 88 if(rc < 0) {
75 jz_log(jz, JZ_LOG_ERROR, "Boot failed: %d", rc); 89 jz_log(jz, JZ_LOG_ERROR, "Boot failed: %d", rc);
76 return 1; 90 return 1;
@@ -90,8 +104,7 @@ void usage(void)
90 " -v, --verbose Display detailed logging output\n\n"); 104 " -v, --verbose Display detailed logging output\n\n");
91 105
92 printf("Supported devices:\n\n"); 106 printf("Supported devices:\n\n");
93 int n = jz_get_num_device_info(); 107 for(int i = 0; i < JZ_NUM_DEVICES; ++i) {
94 for(int i = 0; i < n; ++i) {
95 const jz_device_info* info = jz_get_device_info_indexed(i); 108 const jz_device_info* info = jz_get_device_info_indexed(i);
96 printf(" %s - %s\n", info->name, info->description); 109 printf(" %s - %s\n", info->name, info->description);
97 } 110 }
@@ -182,11 +195,15 @@ int main(int argc, char** argv)
182 exit(2); 195 exit(2);
183 } 196 }
184 197
198 cpu_info = jz_get_cpu_info(dev_info->cpu_type);
199
185 /* Dispatch to device handler */ 200 /* Dispatch to device handler */
186 --argc, ++argv; 201 --argc, ++argv;
187 switch(dev_info->device_type) { 202 switch(dev_info->device_type) {
188 case JZ_DEVICE_FIIOM3K: 203 case JZ_DEVICE_FIIOM3K:
189 return cmdline_fiiom3k(argc, argv); 204 case JZ_DEVICE_SHANLINGQ1:
205 case JZ_DEVICE_EROSQ:
206 return cmdline_x1000(argc, argv);
190 207
191 default: 208 default:
192 jz_log(jz, JZ_LOG_ERROR, "INTERNAL ERROR: unhandled device type"); 209 jz_log(jz, JZ_LOG_ERROR, "INTERNAL ERROR: unhandled device type");