diff options
Diffstat (limited to 'meta-oe')
3 files changed, 163 insertions, 1 deletions
diff --git a/meta-oe/recipes-support/devmem2/devmem2.bb b/meta-oe/recipes-support/devmem2/devmem2.bb index 92c05fe06..c6b8df5e4 100644 --- a/meta-oe/recipes-support/devmem2/devmem2.bb +++ b/meta-oe/recipes-support/devmem2/devmem2.bb | |||
@@ -4,7 +4,8 @@ LIC_FILES_CHKSUM = "file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf9862 | |||
4 | PR = "r7" | 4 | PR = "r7" |
5 | 5 | ||
6 | SRC_URI = "http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ | 6 | SRC_URI = "http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ |
7 | " | 7 | file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \ |
8 | file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch" | ||
8 | 9 | ||
9 | S = "${WORKDIR}" | 10 | S = "${WORKDIR}" |
10 | 11 | ||
diff --git a/meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch b/meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch new file mode 100644 index 000000000..2a57f2989 --- /dev/null +++ b/meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch | |||
@@ -0,0 +1,70 @@ | |||
1 | From 1360a907879dd24041797a3b709d49aeac2ab444 Mon Sep 17 00:00:00 2001 | ||
2 | From: Denys Dmytriyenko <denys@ti.com> | ||
3 | Date: Tue, 29 May 2018 16:55:42 -0400 | ||
4 | Subject: [PATCH] devmem.c: ensure word is 32-bit and add support for 64-bit | ||
5 | long | ||
6 | |||
7 | Signed-off-by: Denys Dmytriyenko <denys@ti.com> | ||
8 | --- | ||
9 | devmem2.c | 23 +++++++++++++++++------ | ||
10 | 1 file changed, 17 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/devmem2.c b/devmem2.c | ||
13 | index 5845381..68131b2 100644 | ||
14 | --- a/devmem2.c | ||
15 | +++ b/devmem2.c | ||
16 | @@ -39,6 +39,7 @@ | ||
17 | |||
18 | #include <stdio.h> | ||
19 | #include <stdlib.h> | ||
20 | +#include <stdint.h> | ||
21 | #include <unistd.h> | ||
22 | #include <string.h> | ||
23 | #include <errno.h> | ||
24 | @@ -69,7 +70,7 @@ int main(int argc, char **argv) { | ||
25 | if(argc < 2) { | ||
26 | fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n" | ||
27 | "\taddress : memory address to act upon\n" | ||
28 | - "\ttype : access operation type : [b]yte, [h]alfword, [w]ord\n" | ||
29 | + "\ttype : access operation type : [b]yte, [h]alfword, [w]ord, [l]ong\n" | ||
30 | "\tdata : data to be written\n\n", | ||
31 | argv[0]); | ||
32 | exit(1); | ||
33 | @@ -103,9 +104,14 @@ int main(int argc, char **argv) { | ||
34 | read_result = *((unsigned short *) virt_addr); | ||
35 | break; | ||
36 | case 'w': | ||
37 | - data_size = sizeof(unsigned long); | ||
38 | + data_size = sizeof(uint32_t); | ||
39 | virt_addr = fixup_addr(virt_addr, data_size); | ||
40 | - read_result = *((unsigned long *) virt_addr); | ||
41 | + read_result = *((uint32_t *) virt_addr); | ||
42 | + break; | ||
43 | + case 'l': | ||
44 | + data_size = sizeof(uint64_t); | ||
45 | + virt_addr = fixup_addr(virt_addr, data_size); | ||
46 | + read_result = *((uint64_t *) virt_addr); | ||
47 | break; | ||
48 | default: | ||
49 | fprintf(stderr, "Illegal data type '%c'.\n", access_type); | ||
50 | @@ -129,9 +135,14 @@ int main(int argc, char **argv) { | ||
51 | read_result = *((unsigned short *) virt_addr); | ||
52 | break; | ||
53 | case 'w': | ||
54 | - virt_addr = fixup_addr(virt_addr, sizeof(unsigned long)); | ||
55 | - *((unsigned long *) virt_addr) = write_val; | ||
56 | - read_result = *((unsigned long *) virt_addr); | ||
57 | + virt_addr = fixup_addr(virt_addr, sizeof(uint32_t)); | ||
58 | + *((uint32_t *) virt_addr) = write_val; | ||
59 | + read_result = *((uint32_t *) virt_addr); | ||
60 | + break; | ||
61 | + case 'l': | ||
62 | + virt_addr = fixup_addr(virt_addr, sizeof(uint64_t)); | ||
63 | + *((uint64_t *) virt_addr) = write_val; | ||
64 | + read_result = *((uint64_t *) virt_addr); | ||
65 | break; | ||
66 | } | ||
67 | sprintf(fmt_str, "Write at address 0x%%08lX (%%p): 0x%%0%dlX, " | ||
68 | -- | ||
69 | 2.7.4 | ||
70 | |||
diff --git a/meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patch b/meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patch new file mode 100644 index 000000000..4517797fc --- /dev/null +++ b/meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patch | |||
@@ -0,0 +1,91 @@ | |||
1 | --- devmem2.c 2004-08-05 01:55:25.000000000 +0200 | ||
2 | +++ devmem2_modif.c 2011-01-13 15:48:37.798799784 +0100 | ||
3 | @@ -45,12 +45,16 @@ | ||
4 | #define MAP_SIZE 4096UL | ||
5 | #define MAP_MASK (MAP_SIZE - 1) | ||
6 | |||
7 | +static inline void *fixup_addr(void *addr, size_t size); | ||
8 | + | ||
9 | int main(int argc, char **argv) { | ||
10 | int fd; | ||
11 | void *map_base, *virt_addr; | ||
12 | - unsigned long read_result, writeval; | ||
13 | + unsigned long read_result, write_val; | ||
14 | off_t target; | ||
15 | int access_type = 'w'; | ||
16 | + char fmt_str[128]; | ||
17 | + size_t data_size; | ||
18 | |||
19 | if(argc < 2) { | ||
20 | fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n" | ||
21 | @@ -79,38 +83,51 @@ | ||
22 | virt_addr = map_base + (target & MAP_MASK); | ||
23 | switch(access_type) { | ||
24 | case 'b': | ||
25 | + data_size = sizeof(unsigned char); | ||
26 | + virt_addr = fixup_addr(virt_addr, data_size); | ||
27 | read_result = *((unsigned char *) virt_addr); | ||
28 | break; | ||
29 | case 'h': | ||
30 | + data_size = sizeof(unsigned short); | ||
31 | + virt_addr = fixup_addr(virt_addr, data_size); | ||
32 | read_result = *((unsigned short *) virt_addr); | ||
33 | break; | ||
34 | case 'w': | ||
35 | + data_size = sizeof(unsigned long); | ||
36 | + virt_addr = fixup_addr(virt_addr, data_size); | ||
37 | read_result = *((unsigned long *) virt_addr); | ||
38 | break; | ||
39 | default: | ||
40 | fprintf(stderr, "Illegal data type '%c'.\n", access_type); | ||
41 | exit(2); | ||
42 | } | ||
43 | - printf("Value at address 0x%X (%p): 0x%X\n", target, virt_addr, read_result); | ||
44 | + sprintf(fmt_str, "Read at address 0x%%08lX (%%p): 0x%%0%dlX\n", 2*data_size); | ||
45 | + printf(fmt_str, (unsigned long)target, virt_addr, read_result); | ||
46 | fflush(stdout); | ||
47 | |||
48 | if(argc > 3) { | ||
49 | - writeval = strtoul(argv[3], 0, 0); | ||
50 | + write_val = strtoul(argv[3], 0, 0); | ||
51 | switch(access_type) { | ||
52 | case 'b': | ||
53 | - *((unsigned char *) virt_addr) = writeval; | ||
54 | + virt_addr = fixup_addr(virt_addr, sizeof(unsigned char)); | ||
55 | + *((unsigned char *) virt_addr) = write_val; | ||
56 | read_result = *((unsigned char *) virt_addr); | ||
57 | break; | ||
58 | case 'h': | ||
59 | - *((unsigned short *) virt_addr) = writeval; | ||
60 | + virt_addr = fixup_addr(virt_addr, sizeof(unsigned short)); | ||
61 | + *((unsigned short *) virt_addr) = write_val; | ||
62 | read_result = *((unsigned short *) virt_addr); | ||
63 | break; | ||
64 | case 'w': | ||
65 | - *((unsigned long *) virt_addr) = writeval; | ||
66 | + virt_addr = fixup_addr(virt_addr, sizeof(unsigned long)); | ||
67 | + *((unsigned long *) virt_addr) = write_val; | ||
68 | read_result = *((unsigned long *) virt_addr); | ||
69 | break; | ||
70 | } | ||
71 | - printf("Written 0x%X; readback 0x%X\n", writeval, read_result); | ||
72 | + sprintf(fmt_str, "Write at address 0x%%08lX (%%p): 0x%%0%dlX, " | ||
73 | + "readback 0x%%0%dlX\n", 2*data_size, 2*data_size); | ||
74 | + printf(fmt_str, (unsigned long)target, virt_addr, | ||
75 | + write_val, read_result); | ||
76 | fflush(stdout); | ||
77 | } | ||
78 | |||
79 | @@ -119,3 +136,12 @@ | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | +static inline void *fixup_addr(void *addr, size_t size) | ||
84 | +{ | ||
85 | +#ifdef FORCE_STRICT_ALIGNMENT | ||
86 | + unsigned long aligned_addr = (unsigned long)addr; | ||
87 | + aligned_addr &= ~(size - 1); | ||
88 | + addr = (void *)aligned_addr; | ||
89 | +#endif | ||
90 | + return addr; | ||
91 | +} | ||