From a36694eb4a1905ec45593ceff2fc20d7eff7c8d8 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 2 Aug 2016 15:37:30 +0100 Subject: hwstub: implement EXEC command over net Apparently I completely forgot to implement it so using hwstub over net would just fail all EXEC commands :-s Change-Id: I0d0506cbbce9b86c9a4f19036dacc922d1e51338 --- utils/hwstub/tools/hwstub_load.cpp | 46 ++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'utils/hwstub/tools') diff --git a/utils/hwstub/tools/hwstub_load.cpp b/utils/hwstub/tools/hwstub_load.cpp index 6ca6079294..7e79b206cb 100644 --- a/utils/hwstub/tools/hwstub_load.cpp +++ b/utils/hwstub/tools/hwstub_load.cpp @@ -113,6 +113,8 @@ void usage(void) printf(" --type/-t Override file type\n"); printf(" --dev/-d Device URI (see below)\n"); printf(" --verbose/-v Display debug output\n"); + printf(" --noload Skip loading stage and only execute the given address\n"); + printf(" --noexec Skip execute stage and only load data the given address\n"); printf("file types:\n"); printf(" raw Load a raw binary blob\n"); printf(" rockbox Load a rockbox image produced by scramble\n"); @@ -129,8 +131,9 @@ int main(int argc, char **argv) { bool quiet = false; enum image_type_t type = IT_DETECT; - const char *uri = "usb:"; bool verbose = false; + const char *uri = hwstub::uri::default_uri().full_uri().c_str(); + bool no_load = false, no_exec = false; // parse command line while(1) @@ -142,10 +145,12 @@ int main(int argc, char **argv) {"type", required_argument, 0, 't'}, {"dev", required_argument, 0, 'd'}, {"verbose", no_argument, 0, 'v'}, + {"noload", no_argument, 0, 'e'}, + {"noexec", no_argument, 0, 'l'}, {0, 0, 0, 0} }; - int c = getopt_long(argc, argv, "?qt:d:v", long_options, NULL); + int c = getopt_long(argc, argv, "?qt:d:elv", long_options, NULL); if(c == -1) break; switch(c) @@ -176,6 +181,11 @@ int main(int argc, char **argv) break; case 'v': verbose = true; + case 'e': + no_load = true; + break; + case 'l': + no_exec = true; break; default: abort(); @@ -266,15 +276,33 @@ int main(int argc, char **argv) return 1; } - size_t out_size = size; - ret = hwdev->write(addr, buffer, out_size, false); - if(ret != hwstub::error::SUCCESS || out_size != size) + /* load */ + if(!no_load) + { + size_t out_size = size; + ret = hwdev->write(addr, buffer, out_size, false); + if(ret != hwstub::error::SUCCESS || out_size != size) + { + fprintf(stderr, "Image write failed: %s, %zu/%zu\n", error_string(ret).c_str(), + out_size, size); + goto Lerr; + } + } + else + printf("Skip load as requested\n"); + + /* exec */ + if(!no_exec) { - fprintf(stderr, "Image write failed: %s, %zu/%zu\n", error_string(ret).c_str(), - out_size, size); - goto Lerr; + ret = hwdev->exec(addr, HWSTUB_EXEC_JUMP); + if(ret != hwstub::error::SUCCESS) + { + fprintf(stderr, "Exec failed: %s\n", error_string(ret).c_str()); + goto Lerr; + } } - hwdev->exec(addr, HWSTUB_EXEC_JUMP); + else + printf("Skip exec as requested\n"); return 0; -- cgit v1.2.3