Skip to content

Commit

Permalink
[xrock]add dtb param for exec command
Browse files Browse the repository at this point in the history
  • Loading branch information
jianjunjiang committed Aug 30, 2024
1 parent 10babcd commit fd6d401
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ usage:
xrock dump <address> <length> - Binary memory dump to stdout
xrock read <address> <length> <file> - Read memory to file
xrock write <address> <file> - Write file to memory
xrock exec <address> - Call function address
xrock exec <address> [dtb] - Call function address
xrock flash - Detect flash and show information
xrock flash erase <sector> <count> - Erase flash sector
xrock flash read <sector> <count> <file> - Read flash sector to file
Expand Down
7 changes: 4 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void usage(void)
printf(" xrock dump <address> <length> - Binary memory dump to stdout\r\n");
printf(" xrock read <address> <length> <file> - Read memory to file\r\n");
printf(" xrock write <address> <file> - Write file to memory\r\n");
printf(" xrock exec <address> - Call function address\r\n");
printf(" xrock exec <address> [dtb] - Call function address\r\n");
printf(" xrock flash - Detect flash and show information\r\n");
printf(" xrock flash erase <sector> <count> - Erase flash sector\r\n");
printf(" xrock flash read <sector> <count> <file> - Read flash sector to file\r\n");
Expand Down Expand Up @@ -215,10 +215,11 @@ int main(int argc, char * argv[])
{
argc -= 2;
argv += 2;
if(argc == 1)
if(argc >= 1)
{
uint32_t addr = strtoul(argv[0], NULL, 0);
rock_exec(&ctx, addr);
uint32_t dtb = (argc >= 2) ? strtoul(argv[1], NULL, 0) : 0;
rock_exec(&ctx, addr, dtb);
}
else
usage();
Expand Down
4 changes: 2 additions & 2 deletions rock.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ int rock_reset(struct xrock_ctx_t * ctx, int maskrom)
return 1;
}

int rock_exec(struct xrock_ctx_t * ctx, uint32_t addr)
int rock_exec(struct xrock_ctx_t * ctx, uint32_t addr, uint32_t dtb)
{
struct usb_request_t req;
struct usb_response_t res;
Expand All @@ -431,7 +431,7 @@ int rock_exec(struct xrock_ctx_t * ctx, uint32_t addr)
req.cmd.opcode = OPCODE_EXEC_SDRAM;
req.cmd.subcode = 0xaa;
write_be32(&req.cmd.address[0], (uint32_t)addr);
write_be32(&req.cmd.size[0], (uint32_t)0);
write_be32(&req.cmd.size[0], (uint32_t)dtb);

usb_bulk_send(ctx->hdl, ctx->epout, &req, sizeof(struct usb_request_t));
usb_bulk_recv(ctx->hdl, ctx->epin, &res, sizeof(struct usb_response_t));
Expand Down
2 changes: 1 addition & 1 deletion rock.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int rock_ready(struct xrock_ctx_t * ctx);
int rock_version(struct xrock_ctx_t * ctx, uint8_t * buf);
int rock_capability(struct xrock_ctx_t * ctx, uint8_t * buf);
int rock_reset(struct xrock_ctx_t * ctx, int maskrom);
int rock_exec(struct xrock_ctx_t * ctx, uint32_t addr);
int rock_exec(struct xrock_ctx_t * ctx, uint32_t addr, uint32_t dtb);
int rock_read(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int rock_write(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int rock_read_progress(struct xrock_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
Expand Down

0 comments on commit fd6d401

Please sign in to comment.