Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Zephyr pulled in changes to upstream openocd 20181009 #2

Merged
merged 268 commits into from
Oct 17, 2018

Conversation

galak
Copy link
Contributor

@galak galak commented Oct 16, 2018

No description provided.

fdols added 30 commits October 16, 2018 11:01
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
  Further more, strip out module specifics
  and migrate to single arc.h include.

Signed-off-by: Frank Dols <frank.dols@synopsys.com>
  Further more, strip out module specifics
  and migrate to single arc.h include.

Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
Signed-off-by: Frank Dols <frank.dols@synopsys.com>
anthony-kolesov and others added 14 commits October 16, 2018 11:01
arc_mem_is_slow_memory had invalid check for the end of region - it wouldn't
return a valid answer if memory area to check was at the end of CCM. So the
check should "lesser than or equal" not just "lesser than", because both the
ccm_end and addr_end point to the address after the last byte, but the
previous check was treating addr_end as an address of the last byte.

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
Some static functions in arc_mem.c were using `int` for count and size
parameters, even though those are obviously unsigned and external interface
for memory operations uses `uint32_t` as well. This patches converts all
`int` count and size to `uint32_t` and updates log formatting where
necessary.

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
It was addded in HS 2.1.

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
Add registers for Secure MPU support, as described for
MPU_BUILD.version == 4.

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
The prototype of target_type.blank_check_memory() has changed. Update
arc_mem_blank_check() accordingly.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Fixes: arc-0.9-dev-2017.03
Jim_GetOpt_String() expects a pointer a const pointer.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Fixes: arc-0.9-dev-2017.03
We can't use a while() loop to search for an available action point,
as that doesn't take into account the array size. Instead, change over
to a for loop.
This fixes a segfault when no actionpoints are available.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
We can't use a while() loop to search for an available action point.
A previous commit fixed this for arc_dbg_set_breakpoint(), but the
exact same problem is present in arc_dbg_set_watchpoint(). Fix it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
ARC port of OpenOCD currently doesn't support L2 cache - it is not flushed
and invalidated when memory is being modified.  However that is not needed
for a simplified case where OpenOCD is needed only to do an initial load of
image into target and then let it run. Still, to be sure that this operation
is safe it is preferably to flush and invalidate L2 cache before loading
image. This can be easily done in the TCL configuration script, for example
in in reset handler.

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
@galak galak requested a review from nashif October 16, 2018 16:07
@nashif
Copy link
Member

nashif commented Oct 17, 2018

does this build for you? I am getting:

src/rtos/Zephyr.c:85:25: error: initialization of ‘int (*)(struct rtos *, int64_t,  struct rtos_reg **, int *)’ {aka ‘int (*)(struct rtos *, long int,  struct rtos_reg **, int *)’} from incompatible pointer type ‘int (*)(struct rtos *, int64_t,  char **)’ {aka ‘int (*)(struct rtos *, long int,  char **)’} [-Werror=incompatible-pointer-types]
  .get_thread_reg_list = Zephyr_get_thread_reg_list,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/rtos/Zephyr.c:85:25: note: (near initialization for ‘Zephyr_rtos.get_thread_reg_list’)
src/rtos/Zephyr.c: In function ‘Zephyr_get_thread_reg_list’:
src/rtos/Zephyr.c:352:22: error: passing argument 4 of ‘rtos_generic_stack_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   thr.stack_pointer, hex_reg_list);
                      ^~~~~~~~~~~~
In file included from src/rtos/Zephyr.c:27:
src/rtos/rtos.h:110:21: note: expected ‘struct rtos_reg **’ but argument is of type ‘char **’
   struct rtos_reg **reg_list,
   ~~~~~~~~~~~~~~~~~~^~~~~~~~
src/rtos/Zephyr.c:351:9: error: too few arguments to function ‘rtos_generic_stack_read’
  return rtos_generic_stack_read(rtos->target, params->reg_stacking,
         ^~~~~~~~~~~~~~~~~~~~~~~
In file included from src/rtos/Zephyr.c:27:
src/rtos/rtos.h:107:5: note: declared here
 int rtos_generic_stack_read(struct target *target,
     ^~~~~~~~~~~~~~~~~~~~~~~
src/rtos/Zephyr.c:353:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:3665: src/rtos/src_rtos_librtos_la-Zephyr.lo] Error 1
make[2]: *** Waiting for unfinished jobs....

@nashif
Copy link
Member

nashif commented Oct 17, 2018

this untested patch fixes the build:

diff --git a/src/rtos/Zephyr.c b/src/rtos/Zephyr.c
index 91b09af2..8bea7f3b 100644
--- a/src/rtos/Zephyr.c
+++ b/src/rtos/Zephyr.c
@@ -73,7 +73,7 @@ static struct Zephyr_params Zephyr_params_list[] = {
 static bool Zephyr_detect_rtos(struct target *target);
 static int Zephyr_create(struct target *target);
 static int Zephyr_update_threads(struct rtos *rtos);
-static int Zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list);
+static int Zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs);
 static int Zephyr_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]);

 struct rtos_type Zephyr_rtos = {
@@ -326,7 +326,8 @@ static int Zephyr_update_threads(struct rtos *rtos)
        return ERROR_OK;
 }

-static int Zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char **hex_reg_list)
+static int Zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list,
+                                     int *num_regs)
 {
        struct Zephyr_thread thr;
        struct Zephyr_params *params;
@@ -349,7 +350,7 @@ static int Zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, char
                return retval;

        return rtos_generic_stack_read(rtos->target, params->reg_stacking,
-               thr.stack_pointer, hex_reg_list);
+               thr.stack_pointer, reg_list, num_regs);
 }

Copy link
Member

@nashif nashif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not build

With this patch, the Zephyr[1] RTOS is supported by OpenOCD.

As usual with support for other RTOSes, Zephyr must be compiled with
the CONFIG_SUPPORT_OPENOCD option.  This will generate some symbols
with information needed in order to build the list of threads.  Please
see Zephyr instructions on how to use Kconfig.

[1] https://www.zephyrproject.org/
@galak
Copy link
Contributor Author

galak commented Oct 17, 2018

does not build

Should be fixed now.

@galak galak merged commit ea2753a into zephyrproject-rtos:zephyr-20181009 Oct 17, 2018
abrodkin referenced this pull request in EvgeniiDidin/openocd-1 Nov 26, 2019
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
abrodkin added a commit to abrodkin/openocd that referenced this pull request Nov 10, 2021
In zephyrproject-rtos/zephyr#35284 it was
found that use of "verify_image" command for ARC boards lead to
OpenOCD segfault:
--------------------------->8--------------------------
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 zephyrproject-rtos#1  0x0000000000455e27 in target_checksum_memory (target=target@entry=0xa52450, address=2415919104, size=19952, crc=crc@entry=0x7fffffffcf64) at src/target/target.c:2522
 zephyrproject-rtos#2  0x0000000000456066 in handle_verify_image_command_internal (cmd=0x7fffffffd040, verify=IMAGE_VERIFY) at src/target/target.c:3846
 zephyrproject-rtos#3  0x000000000047e4ca in run_command (num_words=2, words=0xa80800, c=0x9f3ea0, context=0x9a7010) at src/helper/command.c:582
 zephyrproject-rtos#4  exec_command (argv=0x7fffffffd140, argc=<optimized out>, c=0x9f3ea0, cmd_ctx=0x9a7010, interp=0x9a7070) at src/helper/command.c:950
 zephyrproject-rtos#5  jim_command_dispatch (interp=0x9a7070, argc=<optimized out>, argv=0x7fffffffd140) at src/helper/command.c:1001
 zephyrproject-rtos#6  0x00000000005b839a in JimInvokeCommand (interp=interp@entry=0x9a7070, objc=objc@entry=2, objv=objv@entry=0x7fffffffd140) at jim.c:10514
 zephyrproject-rtos#7  0x00000000005b8fbc in Jim_EvalObj (interp=interp@entry=0x9a7070, scriptObjPtr=scriptObjPtr@entry=0x9e96d0) at jim.c:11006
 zephyrproject-rtos#8  0x00000000005bb12b in Jim_EvalSource (interp=interp@entry=0x9a7070, filename=filename@entry=0x0, lineno=lineno@entry=0,
     script=script@entry=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at jim.c:11298
 zephyrproject-rtos#9  0x000000000047df5f in command_run_line (context=context@entry=0x9a7010, line=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at src/helper/command.c:626
 zephyrproject-rtos#10 0x000000000047f6b8 in parse_config_file (cmd_ctx=cmd_ctx@entry=0x9a7010) at src/helper/configuration.c:136
 zephyrproject-rtos#11 0x00000000004053ae in openocd_thread (cmd_ctx=0x9a7010, argv=0x7fffffffd378, argc=18) at src/openocd.c:296
 zephyrproject-rtos#12 openocd_main (argc=18, argv=0x7fffffffd378) at src/openocd.c:356
 zephyrproject-rtos#13 0x00007ffff710d505 in __libc_start_main () from /lib64/libc.so.6
 zephyrproject-rtos#14 0x0000000000404e9e in _start ()
--------------------------->8--------------------------

That happens because we used to have ".checksum_memory" undefined
for ARC. And it was undefined on purpose as we never got to implement
a target-executed applet for CRC calculation.

But there seems to be a work-around of using real memory read back
via JTAG. And for that we just need to return anything != ERROR_OK
from ".checksum_memory()" callback. Which we do here.

Now image verification works for ARC as well!

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
galak pushed a commit that referenced this pull request Nov 10, 2021
In zephyrproject-rtos/zephyr#35284 it was
found that use of "verify_image" command for ARC boards lead to
OpenOCD segfault:
--------------------------->8--------------------------
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 #1  0x0000000000455e27 in target_checksum_memory (target=target@entry=0xa52450, address=2415919104, size=19952, crc=crc@entry=0x7fffffffcf64) at src/target/target.c:2522
 #2  0x0000000000456066 in handle_verify_image_command_internal (cmd=0x7fffffffd040, verify=IMAGE_VERIFY) at src/target/target.c:3846
 #3  0x000000000047e4ca in run_command (num_words=2, words=0xa80800, c=0x9f3ea0, context=0x9a7010) at src/helper/command.c:582
 #4  exec_command (argv=0x7fffffffd140, argc=<optimized out>, c=0x9f3ea0, cmd_ctx=0x9a7010, interp=0x9a7070) at src/helper/command.c:950
 #5  jim_command_dispatch (interp=0x9a7070, argc=<optimized out>, argv=0x7fffffffd140) at src/helper/command.c:1001
 #6  0x00000000005b839a in JimInvokeCommand (interp=interp@entry=0x9a7070, objc=objc@entry=2, objv=objv@entry=0x7fffffffd140) at jim.c:10514
 #7  0x00000000005b8fbc in Jim_EvalObj (interp=interp@entry=0x9a7070, scriptObjPtr=scriptObjPtr@entry=0x9e96d0) at jim.c:11006
 #8  0x00000000005bb12b in Jim_EvalSource (interp=interp@entry=0x9a7070, filename=filename@entry=0x0, lineno=lineno@entry=0,
     script=script@entry=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at jim.c:11298
 #9  0x000000000047df5f in command_run_line (context=context@entry=0x9a7010, line=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at src/helper/command.c:626
 #10 0x000000000047f6b8 in parse_config_file (cmd_ctx=cmd_ctx@entry=0x9a7010) at src/helper/configuration.c:136
 #11 0x00000000004053ae in openocd_thread (cmd_ctx=0x9a7010, argv=0x7fffffffd378, argc=18) at src/openocd.c:296
 #12 openocd_main (argc=18, argv=0x7fffffffd378) at src/openocd.c:356
 #13 0x00007ffff710d505 in __libc_start_main () from /lib64/libc.so.6
 #14 0x0000000000404e9e in _start ()
--------------------------->8--------------------------

That happens because we used to have ".checksum_memory" undefined
for ARC. And it was undefined on purpose as we never got to implement
a target-executed applet for CRC calculation.

But there seems to be a work-around of using real memory read back
via JTAG. And for that we just need to return anything != ERROR_OK
from ".checksum_memory()" callback. Which we do here.

Now image verification works for ARC as well!

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
aaillet pushed a commit to iotbzh/openocd that referenced this pull request May 9, 2022
In zephyrproject-rtos/zephyr#35284 it was
found that use of "verify_image" command for ARC boards lead to
OpenOCD segfault:
--------------------------->8--------------------------
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 zephyrproject-rtos#1  0x0000000000455e27 in target_checksum_memory (target=target@entry=0xa52450, address=2415919104, size=19952, crc=crc@entry=0x7fffffffcf64) at src/target/target.c:2522
 zephyrproject-rtos#2  0x0000000000456066 in handle_verify_image_command_internal (cmd=0x7fffffffd040, verify=IMAGE_VERIFY) at src/target/target.c:3846
 zephyrproject-rtos#3  0x000000000047e4ca in run_command (num_words=2, words=0xa80800, c=0x9f3ea0, context=0x9a7010) at src/helper/command.c:582
 zephyrproject-rtos#4  exec_command (argv=0x7fffffffd140, argc=<optimized out>, c=0x9f3ea0, cmd_ctx=0x9a7010, interp=0x9a7070) at src/helper/command.c:950
 zephyrproject-rtos#5  jim_command_dispatch (interp=0x9a7070, argc=<optimized out>, argv=0x7fffffffd140) at src/helper/command.c:1001
 zephyrproject-rtos#6  0x00000000005b839a in JimInvokeCommand (interp=interp@entry=0x9a7070, objc=objc@entry=2, objv=objv@entry=0x7fffffffd140) at jim.c:10514
 zephyrproject-rtos#7  0x00000000005b8fbc in Jim_EvalObj (interp=interp@entry=0x9a7070, scriptObjPtr=scriptObjPtr@entry=0x9e96d0) at jim.c:11006
 zephyrproject-rtos#8  0x00000000005bb12b in Jim_EvalSource (interp=interp@entry=0x9a7070, filename=filename@entry=0x0, lineno=lineno@entry=0,
     script=script@entry=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at jim.c:11298
 zephyrproject-rtos#9  0x000000000047df5f in command_run_line (context=context@entry=0x9a7010, line=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at src/helper/command.c:626
 zephyrproject-rtos#10 0x000000000047f6b8 in parse_config_file (cmd_ctx=cmd_ctx@entry=0x9a7010) at src/helper/configuration.c:136
 zephyrproject-rtos#11 0x00000000004053ae in openocd_thread (cmd_ctx=0x9a7010, argv=0x7fffffffd378, argc=18) at src/openocd.c:296
 zephyrproject-rtos#12 openocd_main (argc=18, argv=0x7fffffffd378) at src/openocd.c:356
 zephyrproject-rtos#13 0x00007ffff710d505 in __libc_start_main () from /lib64/libc.so.6
 zephyrproject-rtos#14 0x0000000000404e9e in _start ()
--------------------------->8--------------------------

That happens because we used to have ".checksum_memory" undefined
for ARC. And it was undefined on purpose as we never got to implement
a target-executed applet for CRC calculation.

But there seems to be a work-around of using real memory read back
via JTAG. And for that we just need to return anything != ERROR_OK
from ".checksum_memory()" callback. Which we do here.

Now image verification works for ARC as well!

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
stephanosio pushed a commit that referenced this pull request Jun 14, 2022
In zephyrproject-rtos/zephyr#35284 it was
found that use of "verify_image" command for ARC boards lead to
OpenOCD segfault:
--------------------------->8--------------------------
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 #1  0x0000000000455e27 in target_checksum_memory (target=target@entry=0xa52450, address=2415919104, size=19952, crc=crc@entry=0x7fffffffcf64) at src/target/target.c:2522
 #2  0x0000000000456066 in handle_verify_image_command_internal (cmd=0x7fffffffd040, verify=IMAGE_VERIFY) at src/target/target.c:3846
 #3  0x000000000047e4ca in run_command (num_words=2, words=0xa80800, c=0x9f3ea0, context=0x9a7010) at src/helper/command.c:582
 #4  exec_command (argv=0x7fffffffd140, argc=<optimized out>, c=0x9f3ea0, cmd_ctx=0x9a7010, interp=0x9a7070) at src/helper/command.c:950
 #5  jim_command_dispatch (interp=0x9a7070, argc=<optimized out>, argv=0x7fffffffd140) at src/helper/command.c:1001
 #6  0x00000000005b839a in JimInvokeCommand (interp=interp@entry=0x9a7070, objc=objc@entry=2, objv=objv@entry=0x7fffffffd140) at jim.c:10514
 #7  0x00000000005b8fbc in Jim_EvalObj (interp=interp@entry=0x9a7070, scriptObjPtr=scriptObjPtr@entry=0x9e96d0) at jim.c:11006
 #8  0x00000000005bb12b in Jim_EvalSource (interp=interp@entry=0x9a7070, filename=filename@entry=0x0, lineno=lineno@entry=0,
     script=script@entry=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at jim.c:11298
 #9  0x000000000047df5f in command_run_line (context=context@entry=0x9a7010, line=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at src/helper/command.c:626
 #10 0x000000000047f6b8 in parse_config_file (cmd_ctx=cmd_ctx@entry=0x9a7010) at src/helper/configuration.c:136
 #11 0x00000000004053ae in openocd_thread (cmd_ctx=0x9a7010, argv=0x7fffffffd378, argc=18) at src/openocd.c:296
 #12 openocd_main (argc=18, argv=0x7fffffffd378) at src/openocd.c:356
 #13 0x00007ffff710d505 in __libc_start_main () from /lib64/libc.so.6
 #14 0x0000000000404e9e in _start ()
--------------------------->8--------------------------

That happens because we used to have ".checksum_memory" undefined
for ARC. And it was undefined on purpose as we never got to implement
a target-executed applet for CRC calculation.

But there seems to be a work-around of using real memory read back
via JTAG. And for that we just need to return anything != ERROR_OK
from ".checksum_memory()" callback. Which we do here.

Now image verification works for ARC as well!

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
stephanosio pushed a commit to stephanosio/zephyr-openocd that referenced this pull request Jun 14, 2022
In zephyrproject-rtos/zephyr#35284 it was
found that use of "verify_image" command for ARC boards lead to
OpenOCD segfault:
--------------------------->8--------------------------
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 zephyrproject-rtos#1  0x0000000000455e27 in target_checksum_memory (target=target@entry=0xa52450, address=2415919104, size=19952, crc=crc@entry=0x7fffffffcf64) at src/target/target.c:2522
 zephyrproject-rtos#2  0x0000000000456066 in handle_verify_image_command_internal (cmd=0x7fffffffd040, verify=IMAGE_VERIFY) at src/target/target.c:3846
 zephyrproject-rtos#3  0x000000000047e4ca in run_command (num_words=2, words=0xa80800, c=0x9f3ea0, context=0x9a7010) at src/helper/command.c:582
 zephyrproject-rtos#4  exec_command (argv=0x7fffffffd140, argc=<optimized out>, c=0x9f3ea0, cmd_ctx=0x9a7010, interp=0x9a7070) at src/helper/command.c:950
 zephyrproject-rtos#5  jim_command_dispatch (interp=0x9a7070, argc=<optimized out>, argv=0x7fffffffd140) at src/helper/command.c:1001
 zephyrproject-rtos#6  0x00000000005b839a in JimInvokeCommand (interp=interp@entry=0x9a7070, objc=objc@entry=2, objv=objv@entry=0x7fffffffd140) at jim.c:10514
 zephyrproject-rtos#7  0x00000000005b8fbc in Jim_EvalObj (interp=interp@entry=0x9a7070, scriptObjPtr=scriptObjPtr@entry=0x9e96d0) at jim.c:11006
 zephyrproject-rtos#8  0x00000000005bb12b in Jim_EvalSource (interp=interp@entry=0x9a7070, filename=filename@entry=0x0, lineno=lineno@entry=0,
     script=script@entry=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at jim.c:11298
 zephyrproject-rtos#9  0x000000000047df5f in command_run_line (context=context@entry=0x9a7010, line=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at src/helper/command.c:626
 zephyrproject-rtos#10 0x000000000047f6b8 in parse_config_file (cmd_ctx=cmd_ctx@entry=0x9a7010) at src/helper/configuration.c:136
 zephyrproject-rtos#11 0x00000000004053ae in openocd_thread (cmd_ctx=0x9a7010, argv=0x7fffffffd378, argc=18) at src/openocd.c:296
 zephyrproject-rtos#12 openocd_main (argc=18, argv=0x7fffffffd378) at src/openocd.c:356
 zephyrproject-rtos#13 0x00007ffff710d505 in __libc_start_main () from /lib64/libc.so.6
 zephyrproject-rtos#14 0x0000000000404e9e in _start ()
--------------------------->8--------------------------

That happens because we used to have ".checksum_memory" undefined
for ARC. And it was undefined on purpose as we never got to implement
a target-executed applet for CRC calculation.

But there seems to be a work-around of using real memory read back
via JTAG. And for that we just need to return anything != ERROR_OK
from ".checksum_memory()" callback. Which we do here.

Now image verification works for ARC as well!

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
stephanosio pushed a commit that referenced this pull request Jun 14, 2022
In zephyrproject-rtos/zephyr#35284 it was
found that use of "verify_image" command for ARC boards lead to
OpenOCD segfault:
--------------------------->8--------------------------
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 #1  0x0000000000455e27 in target_checksum_memory (target=target@entry=0xa52450, address=2415919104, size=19952, crc=crc@entry=0x7fffffffcf64) at src/target/target.c:2522
 #2  0x0000000000456066 in handle_verify_image_command_internal (cmd=0x7fffffffd040, verify=IMAGE_VERIFY) at src/target/target.c:3846
 #3  0x000000000047e4ca in run_command (num_words=2, words=0xa80800, c=0x9f3ea0, context=0x9a7010) at src/helper/command.c:582
 #4  exec_command (argv=0x7fffffffd140, argc=<optimized out>, c=0x9f3ea0, cmd_ctx=0x9a7010, interp=0x9a7070) at src/helper/command.c:950
 #5  jim_command_dispatch (interp=0x9a7070, argc=<optimized out>, argv=0x7fffffffd140) at src/helper/command.c:1001
 #6  0x00000000005b839a in JimInvokeCommand (interp=interp@entry=0x9a7070, objc=objc@entry=2, objv=objv@entry=0x7fffffffd140) at jim.c:10514
 #7  0x00000000005b8fbc in Jim_EvalObj (interp=interp@entry=0x9a7070, scriptObjPtr=scriptObjPtr@entry=0x9e96d0) at jim.c:11006
 #8  0x00000000005bb12b in Jim_EvalSource (interp=interp@entry=0x9a7070, filename=filename@entry=0x0, lineno=lineno@entry=0,
     script=script@entry=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at jim.c:11298
 #9  0x000000000047df5f in command_run_line (context=context@entry=0x9a7010, line=0x9e0db0 "verify_image build/zephyr/zephyr.elf") at src/helper/command.c:626
 #10 0x000000000047f6b8 in parse_config_file (cmd_ctx=cmd_ctx@entry=0x9a7010) at src/helper/configuration.c:136
 #11 0x00000000004053ae in openocd_thread (cmd_ctx=0x9a7010, argv=0x7fffffffd378, argc=18) at src/openocd.c:296
 #12 openocd_main (argc=18, argv=0x7fffffffd378) at src/openocd.c:356
 #13 0x00007ffff710d505 in __libc_start_main () from /lib64/libc.so.6
 #14 0x0000000000404e9e in _start ()
--------------------------->8--------------------------

That happens because we used to have ".checksum_memory" undefined
for ARC. And it was undefined on purpose as we never got to implement
a target-executed applet for CRC calculation.

But there seems to be a work-around of using real memory read back
via JTAG. And for that we just need to return anything != ERROR_OK
from ".checksum_memory()" callback. Which we do here.

Now image verification works for ARC as well!

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants