summaryrefslogtreecommitdiffstats
path: root/utils/jz4760_tools
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-24 15:23:21 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2017-01-24 15:23:21 +0100
commit83155f32bfa3e8f3641b81098744431f6fc59e56 (patch)
tree8d726739b6d0e3a659a7fb8c591306cf51e7d25f /utils/jz4760_tools
parentf698b201adf18e0e046554d382531df1ae6d1d27 (diff)
downloadrockbox-83155f32bfa3e8f3641b81098744431f6fc59e56.tar.gz
rockbox-83155f32bfa3e8f3641b81098744431f6fc59e56.tar.bz2
rockbox-83155f32bfa3e8f3641b81098744431f6fc59e56.zip
jz4760b_tools: improve usbboot tool
Change-Id: I21b61a3f56d718bef3aa0cf5096359c463c1f93a
Diffstat (limited to 'utils/jz4760_tools')
-rw-r--r--utils/jz4760_tools/usbboot.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/utils/jz4760_tools/usbboot.c b/utils/jz4760_tools/usbboot.c
index 0d7c7242fd..b6c378f538 100644
--- a/utils/jz4760_tools/usbboot.c
+++ b/utils/jz4760_tools/usbboot.c
@@ -25,6 +25,7 @@
#include <libusb.h>
#include <getopt.h>
#include <stdbool.h>
+#include <unistd.h>
#define VR_GET_CPU_INFO 0
#define VR_SET_DATA_ADDRESS 1
@@ -200,12 +201,24 @@ int renumerate(libusb_device_handle **dev)
return 0;
}
+int jz_stage1(libusb_device_handle *dev, unsigned long addr, const char *file)
+{
+ int ret = jz_set_addr(dev, addr);
+ if(ret != 0)
+ return ret;
+ ret = jz_download(dev, file);
+ if(ret != 0)
+ return ret;
+ return jz_start1(dev, addr);
+}
+
void usage()
{
printf("Usage: usbboot [options]\n");
printf("\n");
printf("Basic options:\n");
printf(" --stage1 <file> Upload first stage program (<=16Kio)\n");
+ printf(" --s1-addr <addr> Change first stage address (default is 0x80000000)\n");
printf(" --stage2 <file> Upload second stage program to SDRAM\n");
printf(" --s2-addr <addr> Change second stage address (default is 0x80000000)\n");
printf(" --ram <target> Setup SDRAM for <target>, see list below\n");
@@ -253,9 +266,11 @@ int main(int argc, char **argv)
enum
{
OPT_ADDR = 0x100, OPT_LENGTH, OPT_UPLOAD, OPT_CPUINFO, OPT_DOWNLOAD,
- OPT_START1, OPT_WAIT, OPT_RENUMERATE, OPT_START2, OPT_FLUSH_CACHES
+ OPT_START1, OPT_WAIT, OPT_RENUMERATE, OPT_START2, OPT_FLUSH_CACHES,
+ OPT_S1_ADDR, OPT_STAGE1
};
unsigned long last_length = 0;
+ unsigned long s1_addr = 0x80000000;
while(1)
{
static struct option long_options[] =
@@ -271,13 +286,16 @@ int main(int argc, char **argv)
{"renumerate", no_argument, 0, OPT_RENUMERATE},
{"start2", required_argument, 0, OPT_START2},
{"flush-caches", no_argument, 0, OPT_FLUSH_CACHES},
+ {"s1-addr", required_argument, 0, OPT_S1_ADDR},
+ {"stage1", required_argument, 0, OPT_STAGE1},
{0, 0, 0, 0}
};
int c = getopt_long(argc, argv, "hv", long_options, NULL);
char *end = 0;
unsigned long param;
- if(c == OPT_ADDR || c == OPT_LENGTH || c == OPT_START1 || c== OPT_WAIT)
+ if(c == OPT_ADDR || c == OPT_LENGTH || c == OPT_START1 || c == OPT_WAIT
+ || c == OPT_S1_ADDR)
{
param = strtoul(optarg, &end, 0);
if(*end)
@@ -333,6 +351,12 @@ int main(int argc, char **argv)
case OPT_FLUSH_CACHES:
ret = jz_flush_caches(dev);
break;
+ case OPT_S1_ADDR:
+ s1_addr = param;
+ break;
+ case OPT_STAGE1:
+ ret = jz_stage1(dev, s1_addr, optarg);
+ break;
}
if(ret != 0)
break;
@@ -346,4 +370,4 @@ int main(int argc, char **argv)
libusb_close(dev);
libusb_exit(NULL);
return ret;
-} \ No newline at end of file
+}