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

Zephyr 20191003 #13

Merged
merged 289 commits into from
Oct 3, 2019
Merged

Conversation

galak
Copy link
Contributor

@galak galak commented Oct 3, 2019

No description provided.

fdols added 30 commits October 3, 2019 13:02
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>
 >$ djtgcfg -d JtagHs2 prog -i 4 -f <fpga bit file to progam>.bit

Signed-off-by: Frank Dols <frank.dols@synopsys.com>
      particularly ARC-EM4 core registers r61 or r62

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>
…tion

Signed-off-by: Frank Dols <frank.dols@synopsys.com>
…ss-for-synopsys-dwc-arc-processors/openocd.git into arc-0.7.0-dev-00151
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>
zejiang0jason and others added 22 commits October 3, 2019 13:12
 - Add nor flash files
 - Add target files

Signed-off-by: Jason Yu <xuzj03@gmail.com>

[ Pulled in from https://github.com/open-isa-rv32m1/rv32m1-openocd ]

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
 - Originally, for command `reg`, all
   registers are shown, no matter exist
   or not.
 - This patch update to only show the
   exist registers

Signed-off-by: Jason Yu <xuzj03@gmail.com>

[ Pulled in from https://github.com/open-isa-rv32m1/rv32m1-openocd ]

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
 - Originally rv32m1_save_context is called in
   the function rv32m1_get_gdb_reg_list, so every
   time reading or writing registers in GDB, the
   register value are read from hardware
   again.
 - This patch removes the rv32m1_save_context
   in the function rv32m1_get_gdb_reg_list.

Signed-off-by: Jason Yu <xuzj03@gmail.com>
 - When software breakpoint is hit, for example 0x08000010,
   then the PC after halt is 0x08000014 (4-byte breakpoint)
   or 0x08000012 (2-byte breakpoint). When resume again, the
   original instruction at 0x08000010 is not executed.
 - The resolution: When the core is halt because of software
   breakpoint, set the PC to previous PC.

Signed-off-by: Jason Yu <xuzj03@gmail.com>
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/

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
asprintf is not portable and OpenOCD provides a replacement

Signed-off-by: Daniel Glöckner <dg@emlix.com>
doc/manual/style.txt says that lines that exceed 80 columns should be
avoided. Indentation should use tabs and a tab is 4 columns wide.
The ?: operator needs spaces around ? and :.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
Signed-off-by: Daniel Glöckner <dg@emlix.com>
There is a helper function for that.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
Almost all architectures store the stack pointer in the _callee_saved
structure and we know which other registers are stored there as well.
The rest of the general registers should have been stored to the stack
of the thread. The only exception is x86-64, which is not yet in a
usable state and eventually has to store the stack pointer somewhere.

For ARM Cortex-M we must also skip the floating point registers on the
stack if they have been stored by the cpu and undo the stack pointer
realignment to 8 bytes. It is not possible to return the floating point
registers to GDB with the current OpenOCD RTOS API.

Fixes zephyrproject-rtos#4

Signed-off-by: Daniel Glöckner <dg@emlix.com>
The current version reported by Zephyr in the offsets array is 1.
It is compatible to version 0 but offers a few more values in the
array. zephyrproject-rtos/zephyr#13461 adds a separate symbol to
hold the size of the array, so that future compatible additions
do not require the version number to be incremented.

Fixes zephyrproject-rtos#3

Signed-off-by: Daniel Glöckner <dg@emlix.com>
if available. We read a fixed number of bytes, like most of the other
files in src/rtos/ do. This is probably faster than reading the name
byte by byte to stop at the terminating null byte.

The array element for the offset to the thread name pointer has been
added with version 1 of the array. Currently the Zephyr Kconfig system
automatically selects CONFIG_THREAD_NAME when CONFIG_OPENOCD_SUPPORT
is enabled, but we check if the offset is different from 0xffffffff
before we use it, as it has to be done for some other offsets.
And even if the thread name pointer exists, it might still be NULL.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
If the target type name is "hla_target", we have to use other means to
determine the cpu type. Since in Zephyr right now the only supported
ARM variant is Cortex-M, we can map the gdb architecture name "arm" to
"cortex_m". After all hla_target currently also only supports Cortex-M
devices.

Fixes zephyrproject-rtos#7

Signed-off-by: Daniel Glöckner <dg@emlix.com>
int32 used to be the first item in enum, i.e. non-initilaized
type value meant int32. But since
commit 0808c6e ("tdesc: bitfields may carry a type") default
value is bool and GDB doesn't like bool values larger than 1 bit.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
The CC3220/CC3235 SoC family has a restricted set of ways to perform a
reset, either at SoC or CPU level. The only method that leaves the
JTAG/SWD connection attached is the AIRCR VECTRESREQ bit. This change
to the TCL .cfg script for CC3220 adopts the 'cortex_m reset_config
vectreset' method to handle the reset command.  The reset is caught
(halted) by using the DEMCR debug feature to stop on fetch of reset
vector. After halting, the user reset vector and stack pointer are
read from the fixed address (as defined by SoC) and used to
initialize MSP and PC. This is similar to psoc4.cfg implementation.
Note that this only resets the CPU - not peripherals.

Signed-off-by: Mark Grosen <mgrosen@ti.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
As it is mentioned here [1] type's ID is unique name within containing feature.

That said if regs of the same type located in different features it's required
to insert type definition at least in each feature.

See more details in discussion here [2].

[1] https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Types
[2] foss-for-synopsys-dwc-arc-processors/openocd@2a5f512#r33460077

Change-Id: Id92b061cfbf47d5c032a02c2c406b28affd0b02a
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Since Zephyr commit 38129ce1a651 ("kernel: fix CONFIG_THREAD_NAME
from user mode.") the thread->name layout in memory has changed.
Now the name is stored directly in k_thread structure.
This commit changes the way how  OpenOCD reads thread->name from memory
according to the recent changes(which are the part of 2.0.0 release).

Signed-off-by: Evgeniy Didin <didin@synopsys.com>
@galak galak merged commit 5aa5f5e into zephyrproject-rtos:zephyr-20191003 Oct 3, 2019
@galak galak deleted the zephyr-20191003 branch October 3, 2019 19:12
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.