Commit 970aef95 authored by Adam Wujek's avatar Adam Wujek 💬 Committed by Grzegorz Daniluk

tools: fix mapper to work on some systems

Mapper didn't work on two machines that I use for testing.
For some reason accessing LM32's memory by 4 bytes solved this problem.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 1824ff82
...@@ -1274,6 +1274,10 @@ The @i{mapper} tool used above, and part of @i{wrpc-sw}, reads a file ...@@ -1274,6 +1274,10 @@ The @i{mapper} tool used above, and part of @i{wrpc-sw}, reads a file
using @i{mmap()}. The kernel doesn't allow plain @i{read()} from a using @i{mmap()}. The kernel doesn't allow plain @i{read()} from a
resource file. resource file.
@b{Note:} Data read by @t{mapper} may look like has wrong endianness comparing
to the file used for programming lm32 by @t{spec-cl}, but @t{spec-cl} is the
one which change the endianness of the binary data during the programming.
With @i{etherbone}, you can get a snapshot for @i{wrpc} memory using With @i{etherbone}, you can get a snapshot for @i{wrpc} memory using
@t{eb-get} and the proper address (the size is always 128kB) @t{eb-get} and the proper address (the size is always 128kB)
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <errno.h> #include <errno.h>
#include <stdint.h>
#include <arpa/inet.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -19,6 +21,7 @@ int main(int argc, char **argv) ...@@ -19,6 +21,7 @@ int main(int argc, char **argv)
unsigned int len, len_pg, len_off; unsigned int len, len_pg, len_off;
void *address; void *address;
char *rest; char *rest;
int i;
if (argc !=4 if (argc !=4
|| sscanf(argv[2],"%i", &pos) != 1 || sscanf(argv[2],"%i", &pos) != 1
...@@ -60,9 +63,9 @@ int main(int argc, char **argv) ...@@ -60,9 +63,9 @@ int main(int argc, char **argv)
fprintf(stderr, "mapped \"%s\" from %i to %i (0x%x to 0x%x) \n", fprintf(stderr, "mapped \"%s\" from %i to %i (0x%x to 0x%x) \n",
fname, pos, pos+len, pos_pg, pos_pg+len_pg); fname, pos, pos+len, pos_pg, pos_pg+len_pg);
if (fwrite(address+pos_off, 1, len, stdout) != len) { for (i = 0; i < (len + 3) / 4; i++) {
fprintf(stderr, "%s: write(): %s\n", argv[0], strerror(errno)); write(fileno(stdout), address + pos_off + i * 4, 4);
exit(1);
} }
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment