devmem2: reinstate previous patches, removed by mistake
PATCH 1/3 devmem2: reinstate previous patches, removed by mistake
This reverts commit 5e8f4720aaa3da7350ead06959cae0492133cd61.
--- meta-oe/recipes-support/devmem2/devmem2.bb | 3 +- ...word-is-32-bit-and-add-support-for-6.patch | 70 ++++++++++++++ .../devmem2/devmem2/devmem2-fixups-2.patch | 91 +++++++++++++++++++ 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch create mode 100644 meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patch
meta-oe/recipes-support/devmem2/devmem2.bb +2 -1
@@ -4,7 +4,8 @@ LIC_FILES_CHKSUM = "file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf9862 PR = "r7" SRC_URI = "http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ - " + file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \ + file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch" S = "${WORKDIR}"
meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch new file +70 -0
70 lines not on this page · raw message
meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patch new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/3 devmem2: add support for different page sizes
Instead of hardcoding 4K page size, query the system and use the value for memory mapping.
--- meta-oe/recipes-support/devmem2/devmem2.bb | 4 ++- ...ort-different-page-sizes-at-run-time.patch | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-support/devmem2/devmem2/0001-devmem2-support-different-page-sizes-at-run-time.patch
meta-oe/recipes-support/devmem2/devmem2.bb +3 -1
@@ -5,7 +5,9 @@ PR = "r7" SRC_URI = "http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \ - file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch" + file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \ + file://0001-devmem2-support-different-page-sizes-at-run-time.patch \ +" S = "${WORKDIR}"
meta-oe/recipes-support/devmem2/devmem2/0001-devmem2-support-different-page-sizes-at-run-time.patch new file +35 -0
@@ -0,0 +1,35 @@ +From 0f6af48b2fbc71ec8abe862d3e9eb6da7b03538b Mon Sep 17 00:00:00 2001 +From: Denys Dmytriyenko <[email protected]> +Date: Wed, 8 Aug 2018 14:38:00 -0400 +Subject: [PATCH] devmem2: support different page sizes at run-time + +Signed-off-by: Denys Dmytriyenko <[email protected]> +--- + devmem2.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/devmem2.c b/devmem2.c +index 68131b2..76af2d6 100644 +--- a/devmem2.c ++++ b/devmem2.c +@@ -53,8 +53,6 @@ + #define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \ + __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0) + +-#define MAP_SIZE 4096UL +-#define MAP_MASK (MAP_SIZE - 1) + + static inline void *fixup_addr(void *addr, size_t size); + +@@ -66,6 +64,8 @@ int main(int argc, char **argv) { + int access_type = 'w'; + char fmt_str[128]; + size_t data_size; ++ unsigned long MAP_SIZE = sysconf(_SC_PAGE_SIZE); ++ unsigned long MAP_MASK = (MAP_SIZE - 1); + + if(argc < 2) { + fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n" +-- +2.7.4 +
Signature · 1 line
2.25.1
PATCH 3/3 devmem2: update SRC_URI according to redirect
In reply to Denys DmytriyenkoFrom: Michael Opdenacker <[email protected]>
http://www.free-electrons.com now redirects to https://bootlin.com
--- meta-oe/recipes-support/devmem2/devmem2.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/recipes-support/devmem2/devmem2.bb +1 -1
@@ -3,7 +3,7 @@ LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM = "file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf986297cf" PR = "r7" -SRC_URI = "http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ +SRC_URI = "https://bootlin.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \ file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \ file://0001-devmem2-support-different-page-sizes-at-run-time.patch \
Signature · 1 line
2.25.1
Re: [oe] [kirkstone][PATCH 3/3] devmem2: update SRC_URI according to redirect
Anyone willing to create a repo for this on github instead of patching this in metadata?
This is another reproducer for do_patch issue described here
https://lists.yoctoproject.org/g/yocto/message/56602
Quoted 46 lines · Denys Dmytriyenko
From: Michael Opdenacker <[email protected]>
http://www.free-electrons.com now redirects to https://bootlin.com
Signed-off-by Michael Opdenacker <[email protected]>Signed-off-by Khem Raj <[email protected]>Signed-off-by Denys Dmytriyenko <[email protected]>--- meta-oe/recipes-support/devmem2/devmem2.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta-oe/recipes-support/devmem2/devmem2.bb +0
-0@@ -3,7 +3,7 @@ LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM ="file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf986297cf"
PR = "r7"-SRC_URI = "
http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c
\
+SRC_URI = "https://bootlin.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \
file://0001-devmem2-support-different-page-sizes-at-run-time.patch \
--
2.25.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#97085):
https://lists.openembedded.org/g/openembedded-devel/message/97085
Mute This Topic: https://lists.openembedded.org/mt/91070560/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [oe] [kirkstone][PATCH 3/3] devmem2: update SRC_URI according to redirect
Sure, I can do that and put it in the repo, since I've made few patches on top of it... Before I do that, are there any objections? Bootlin?
Quoted 41 lines · Martin Jansa
Anyone willing to create a repo for this on github instead of patching this in metadata?
This is another reproducer for
do_patchissue described here
https://lists.yoctoproject.org/g/yocto/message/56602Quoted 33 lines · Denys Dmytriyenko
From: Michael Opdenacker <[email protected]>
http://www.free-electrons.com now redirects to https://bootlin.com
Signed-off-by Michael Opdenacker <[email protected]>Signed-off-by Khem Raj <[email protected]>Signed-off-by Denys Dmytriyenko <[email protected]>--- meta-oe/recipes-support/devmem2/devmem2.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta-oe/recipes-support/devmem2/devmem2.bb +0
-0@@ -3,7 +3,7 @@ LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM ="file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf986297cf"
PR = "r7"-SRC_URI = "
http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c
\
+SRC_URI = "https://bootlin.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \
file://0001-devmem2-support-different-page-sizes-at-run-time.patch \
--
2.25.1
Re: [oe] [kirkstone][PATCH 3/3] devmem2: update SRC_URI according to redirect
Quoted 3 lines · Denys Dmytriyenko
Sure, I can do that and put it in the repo, since I've made few patches on top of it... Before I do that, are there any objections? Bootlin?
I would suggest to cross post with buildroot and see if there is interest in using it from
a separate repository.
Quoted 53 lines · Martin Jansa
Quoted 36 lines
Anyone willing to create a repo for this on github instead of patching this in metadata?
This is another reproducer for
do_patchissue described here
https://lists.yoctoproject.org/g/yocto/message/56602Quoted 28 lines · Denys Dmytriyenko
From: Michael Opdenacker <[email protected]>
http://www.free-electrons.com now redirects to https://bootlin.com
Signed-off-by Michael Opdenacker <[email protected]>Signed-off-by Khem Raj <[email protected]>Signed-off-by Denys Dmytriyenko <[email protected]>--- meta-oe/recipes-support/devmem2/devmem2.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta-oe/recipes-support/devmem2/devmem2.bb +0
-0@@ -3,7 +3,7 @@ LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM ="file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf986297cf"
PR = "r7"-SRC_URI = "
http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c
\
+SRC_URI = "https://bootlin.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \Quoted 5 lines
Quoted 5 lines
file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \
file://0001-devmem2-support-different-page-sizes-at-run-time.patch \
--
2.25.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#97271): https://lists.openembedded.org/g/openembedded-devel/message/97271
Mute This Topic: https://lists.openembedded.org/mt/91070560/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [oe] [kirkstone][PATCH 3/3] devmem2: update SRC_URI according to redirect
buildroot removed it in 2019 and recommends to use busybox version instead:
https://github.com/buildroot/buildroot/commit/2b2579afebfc7a9b8a458af1f2d206101fbfa19c
"Use the the Busybox devmem utility, instead, which provides the same functionality."
Quoted 72 lines · Khem Raj
Quoted 2 lines · Denys Dmytriyenko
Sure, I can do that and put it in the repo, since I've made few patches
on top
Quoted 1 line
of it... Before I do that, are there any objections? Bootlin?
I would suggest to cross post with buildroot and see if there is interest in using it from
a separate repository.Quoted 4 lines · Martin Jansa
Quoted 1 line
Anyone willing to create a repo for this on github instead of patching
this
Quoted 6 lines
Quoted 6 lines
in metadata?
This is another reproducer for
do_patchissue described here
https://lists.yoctoproject.org/g/yocto/message/56602On Fri, May 13, 2022 at 1:43 AM Denys Dmytriyenko <[email protected]>
Quoted 22 lines · wrote:
Quoted 22 lines
Quoted 22 lines
From: Michael Opdenacker <[email protected]>
http://www.free-electrons.com now redirects to https://bootlin.com
Signed-off-by Michael Opdenacker <[email protected]>Signed-off-by Khem Raj <[email protected]>Signed-off-by Denys Dmytriyenko <[email protected]>--- meta-oe/recipes-support/devmem2/devmem2.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta-oe/recipes-support/devmem2/devmem2.bb +0
-0@@ -3,7 +3,7 @@ LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM ="file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf986297cf"
PR = "r7"Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
-SRC_URI = "
http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
\
+SRC_URI = "https://bootlin.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
file://0001-devmem2-support-different-page-sizes-at-run-time.patch \
--
2.25.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#97271):https://lists.openembedded.org/g/openembedded-devel/message/97271
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/91070560/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [oe] [kirkstone][PATCH 3/3] devmem2: update SRC_URI according to redirect
https://lists.openembedded.org/g/openembedded-devel/message/97339
Quoted 38 lines · Philip Balister
Quoted 5 lines · Martin Jansa
buildroot removed it in 2019 and recommends to use busybox version instead:
https://github.com/buildroot/buildroot/commit/2b2579afebfc7a9b8a458af1f2d206101fbfa19c"Use the the Busybox devmem utility, instead, which provides the same functionality."
I want to say there is an issue with the busybox devmem. As I recall (and this is an ancient memory), if you use busybox devmem to write, it does a readback. This is a bad thing if the address you write to is a hardware device that uses the read to reset state.
Philip
Quoted 24 lines
On Wed, May 25, 2022 at 8:32 PM Khem Raj <[email protected] <mailto:[email protected]>> wrote:
Quoted 2 lines · On Wed, May 25, 2022 at 11:08 AM Denys Dmytriyenko <[email protected]…
Sure, I can do that and put it in the repo, since I've made few
patches on top
Quoted 1 line
of it... Before I do that, are there any objections? Bootlin?
I would suggest to cross post with buildroot and see if there is interest in using it from
a separate repository.Quoted 4 lines · Martin Jansa
Quoted 1 line
Anyone willing to create a repo for this on github instead of
patching this
Quoted 4 lines
Quoted 4 lines
in metadata?
This is another reproducer for
do_patchissue described here
https://lists.yoctoproject.org/g/yocto/message/56602
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [oe] [kirkstone][PATCH 3/3] devmem2: update SRC_URI according to redirect
The history of this is deep :)
https://git.openembedded.org/openembedded/log/packages/devmem2?h=master
https://git.openembedded.org/openembedded/log/recipes/devmem2?h=master
https://git.openembedded.org/meta-openembedded/log/meta-oe/recipes-support/devmem2
Quoted 57 lines · Martin Jansa via lists.openembedded.org
Anyone willing to create a repo for this on github instead of patching this in metadata?
This is another reproducer for
do_patchissue described here
https://lists.yoctoproject.org/g/yocto/message/56602Quoted 25 lines · Denys Dmytriyenko
From: Michael Opdenacker <[email protected]>
http://www.free-electrons.com now redirects to https://bootlin.com
Signed-off-by Michael Opdenacker <[email protected]>Signed-off-by Khem Raj <[email protected]>Signed-off-by Denys Dmytriyenko <[email protected]>--- meta-oe/recipes-support/devmem2/devmem2.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta-oe/recipes-support/devmem2/devmem2.bb +0
-0@@ -3,7 +3,7 @@ LICENSE = "GPL-2.0-or-later" LIC_FILES_CHKSUM ="file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf986297cf"
PR = "r7"-SRC_URI = "
http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c
\
+SRC_URI = "Quoted 13 lines
https://bootlin.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch \
file://0001-devmem2-support-different-page-sizes-at-run-time.patch \
--
2.25.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#97270):
https://lists.openembedded.org/g/openembedded-devel/message/97270
Mute This Topic: https://lists.openembedded.org/mt/91070560/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 5 lines · Denys Dmytriyenko
This reverts commit
5e8f4720aaa3da7350ead06959cae0492133cd61.Signed-off-by Denys Dmytriyenko <[email protected]>Signed-off-by Khem Raj <[email protected]>Signed-off-by Denys Dmytriyenko <[email protected]>
thanks, I already have this staged in stable/kirtkstone-nut
-armin
Quoted 204 lines
--- meta-oe/recipes-support/devmem2/devmem2.bb | 3 +- ...word-is-32-bit-and-add-support-for-6.patch | 70 ++++++++++++++ .../devmem2/devmem2/devmem2-fixups-2.patch | 91 +++++++++++++++++++ 3 files changed, 163 insertions(+), 1 deletion(-)create mode 100644
meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patchcreate mode 100644meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patchmeta-oe/recipes-support/devmem2/devmem2.bb +2
-1@@ -4,7 +4,8 @@ LIC_FILES_CHKSUM = "file://devmem2.c;endline=38;md5=a9eb9f3890384519f435aedf9862 PR = "r7" SRC_URI = "http://www.free-electrons.com/pub/mirror/devmem2.c;downloadfilename=devmem2-new.c \ - " + file://devmem2-fixups-2.patch;apply=yes;striplevel=0 \ + file://0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch" S = "${WORKDIR}"meta-oe/recipes-support/devmem2/devmem2/0001-devmem.c-ensure-word-is-32-bit-and-add-support-for-6.patch new file +70
-0@@ -0,0 +1,70 @@ +From 1360a907879dd24041797a3b709d49aeac2ab444 Mon Sep 17 00:00:00 2001 +From: Denys Dmytriyenko <[email protected]> +Date: Tue, 29 May 2018 16:55:42 -0400 +Subject: [PATCH] devmem.c: ensure word is 32-bit and add support for 64-bit + long + +Signed-off-by: Denys Dmytriyenko <[email protected]> +--- + devmem2.c | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) + +diff --git a/devmem2.c b/devmem2.c +index 5845381..68131b2 100644 +--- a/devmem2.c ++++ b/devmem2.c +@@ -39,6 +39,7 @@ + + #include <stdio.h> + #include <stdlib.h> ++#include <stdint.h> + #include <unistd.h> + #include <string.h> + #include <errno.h> +@@ -69,7 +70,7 @@ int main(int argc, char **argv) { + if(argc < 2) { + fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n" + "\taddress : memory address to act upon\n" +- "\ttype : access operation type : [b]yte, [h]alfword, [w]ord\n" ++ "\ttype : access operation type : [b]yte, [h]alfword, [w]ord, [l]ong\n" + "\tdata : data to be written\n\n", + argv[0]); + exit(1); +@@ -103,9 +104,14 @@ int main(int argc, char **argv) { + read_result = *((unsigned short *) virt_addr); + break; + case 'w': +- data_size = sizeof(unsigned long); ++ data_size = sizeof(uint32_t); + virt_addr = fixup_addr(virt_addr, data_size); +- read_result = *((unsigned long *) virt_addr); ++ read_result = *((uint32_t *) virt_addr); ++ break; ++ case 'l': ++ data_size = sizeof(uint64_t); ++ virt_addr = fixup_addr(virt_addr, data_size); ++ read_result = *((uint64_t *) virt_addr); + break; + default: + fprintf(stderr, "Illegal data type '%c'.\n", access_type); +@@ -129,9 +135,14 @@ int main(int argc, char **argv) { + read_result = *((unsigned short *) virt_addr); + break; + case 'w': +- virt_addr = fixup_addr(virt_addr, sizeof(unsigned long)); +- *((unsigned long *) virt_addr) = write_val; +- read_result = *((unsigned long *) virt_addr); ++ virt_addr = fixup_addr(virt_addr, sizeof(uint32_t)); ++ *((uint32_t *) virt_addr) = write_val; ++ read_result = *((uint32_t *) virt_addr); ++ break; ++ case 'l': ++ virt_addr = fixup_addr(virt_addr, sizeof(uint64_t)); ++ *((uint64_t *) virt_addr) = write_val; ++ read_result = *((uint64_t *) virt_addr); + break; + } + sprintf(fmt_str, "Write at address 0x%%08lX (%%p): 0x%%0%dlX, " +-- +2.7.4 +meta-oe/recipes-support/devmem2/devmem2/devmem2-fixups-2.patch new file +91
-1@@ -0,0 +1,91 @@ +--- devmem2.c 2004-08-05 01:55:25.000000000 +0200 ++++ devmem2_modif.c 2011-01-13 15:48:37.798799784 +0100 +@@ -45,12 +45,16 @@ + #define MAP_SIZE 4096UL + #define MAP_MASK (MAP_SIZE - 1) + ++static inline void *fixup_addr(void *addr, size_t size); ++ + int main(int argc, char **argv) { + int fd; + void *map_base, *virt_addr; +- unsigned long read_result, writeval; ++ unsigned long read_result, write_val; + off_t target; + int access_type = 'w'; ++ char fmt_str[128]; ++ size_t data_size; + + if(argc < 2) { + fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n" +@@ -79,38 +83,51 @@ + virt_addr = map_base + (target & MAP_MASK); + switch(access_type) { + case 'b': ++ data_size = sizeof(unsigned char); ++ virt_addr = fixup_addr(virt_addr, data_size); + read_result = *((unsigned char *) virt_addr); + break; + case 'h': ++ data_size = sizeof(unsigned short); ++ virt_addr = fixup_addr(virt_addr, data_size); + read_result = *((unsigned short *) virt_addr); + break; + case 'w': ++ data_size = sizeof(unsigned long); ++ virt_addr = fixup_addr(virt_addr, data_size); + read_result = *((unsigned long *) virt_addr); + break; + default: + fprintf(stderr, "Illegal data type '%c'.\n", access_type); + exit(2); + } +- printf("Value at address 0x%X (%p): 0x%X\n", target, virt_addr, read_result); ++ sprintf(fmt_str, "Read at address 0x%%08lX (%%p): 0x%%0%dlX\n", 2*data_size); ++ printf(fmt_str, (unsigned long)target, virt_addr, read_result); + fflush(stdout); + + if(argc > 3) { +- writeval = strtoul(argv[3], 0, 0); ++ write_val = strtoul(argv[3], 0, 0); + switch(access_type) { + case 'b': +- *((unsigned char *) virt_addr) = writeval; ++ virt_addr = fixup_addr(virt_addr, sizeof(unsigned char)); ++ *((unsigned char *) virt_addr) = write_val; + read_result = *((unsigned char *) virt_addr); + break; + case 'h': +- *((unsigned short *) virt_addr) = writeval; ++ virt_addr = fixup_addr(virt_addr, sizeof(unsigned short)); ++ *((unsigned short *) virt_addr) = write_val; + read_result = *((unsigned short *) virt_addr); + break; + case 'w': +- *((unsigned long *) virt_addr) = writeval; ++ virt_addr = fixup_addr(virt_addr, sizeof(unsigned long)); ++ *((unsigned long *) virt_addr) = write_val; + read_result = *((unsigned long *) virt_addr); + break; + } +- printf("Written 0x%X; readback 0x%X\n", writeval, read_result); ++ sprintf(fmt_str, "Write at address 0x%%08lX (%%p): 0x%%0%dlX, " ++ "readback 0x%%0%dlX\n", 2*data_size, 2*data_size); ++ printf(fmt_str, (unsigned long)target, virt_addr, ++ write_val, read_result); + fflush(stdout); + } + +@@ -119,3 +136,12 @@ + return 0; + } + ++static inline void *fixup_addr(void *addr, size_t size) ++{ ++#ifdef FORCE_STRICT_ALIGNMENT ++ unsigned long aligned_addr = (unsigned long)addr; ++ aligned_addr &= ~(size - 1); ++ addr = (void *)aligned_addr; ++#endif ++ return addr; ++} -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#97083): https://lists.openembedded.org/g/openembedded-devel/message/97083
Mute This Topic: https://lists.openembedded.org/mt/91070558/3616698
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-