Commit d1f22d4bdf2b20a83277f10f858582d18b01df03

Authored by Simon Glass
Committed by Jagannadha Sutradharudu Teki
1 parent 66cb9eb1d6

sandbox: spi: Adjust 'sf test' to work on sandbox

Add map_sysmem() calls so that this test works correctly on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Hung-ying Tyan <tyanh@chromium.org>
Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

Showing 1 changed file with 9 additions and 5 deletions Side-by-side Diff

... ... @@ -358,7 +358,8 @@
358 358 int bps; /* Bits per second */
359 359  
360 360 speed = (long long)test->bytes * 1000;
361   - do_div(speed, test->time_ms[stage] * 1024);
  361 + if (test->time_ms[stage])
  362 + do_div(speed, test->time_ms[stage] * 1024);
362 363 bps = speed * 8;
363 364  
364 365 printf("%d %s: %d ticks, %d KiB/s %d.%03d Mbps\n", stage,
365 366  
... ... @@ -446,11 +447,13 @@
446 447 {
447 448 unsigned long offset;
448 449 unsigned long len;
449   - uint8_t *buf = (uint8_t *)CONFIG_SYS_TEXT_BASE;
  450 + uint8_t *buf, *from;
450 451 char *endp;
451 452 uint8_t *vbuf;
452 453 int ret;
453 454  
  455 + if (argc < 3)
  456 + return -1;
454 457 offset = simple_strtoul(argv[1], &endp, 16);
455 458 if (*argv[1] == 0 || *endp != 0)
456 459 return -1;
457 460  
458 461  
... ... @@ -460,17 +463,18 @@
460 463  
461 464 vbuf = malloc(len);
462 465 if (!vbuf) {
463   - printf("Cannot allocate memory\n");
  466 + printf("Cannot allocate memory (%lu bytes)\n", len);
464 467 return 1;
465 468 }
466 469 buf = malloc(len);
467 470 if (!buf) {
468 471 free(vbuf);
469   - printf("Cannot allocate memory\n");
  472 + printf("Cannot allocate memory (%lu bytes)\n", len);
470 473 return 1;
471 474 }
472 475  
473   - memcpy(buf, (char *)CONFIG_SYS_TEXT_BASE, len);
  476 + from = map_sysmem(CONFIG_SYS_TEXT_BASE, 0);
  477 + memcpy(buf, from, len);
474 478 ret = spi_flash_test(flash, buf, len, offset, vbuf);
475 479 free(vbuf);
476 480 free(buf);