2013年12月25日 星期三

RK3566 / RK3568 SWD debug

Refer to
http://notes.zahoryzontnik.com/
https://fatalfeel.blogspot.com/2015/12/openocd-with-eclipse-debug-kernel-of.html

1. openocd source download and install
https://github.com/fatalfeel/openocd_integrated
note: site include rk3566.cfg (fit for rk3568 too)

2. bus blaster dangerous prototypes v3c or v4.1a jtag to swd
https://fatalfeel.blogspot.com/2013/09/bus-blaster-flash-to-swd-mode-in-openocd.html

3. hardware dp_busblaster_kt-link connect to swd of rk3568
(a) remove off sdcard connector, or the connector spring will trigger jtag disable
https://www.mediafire.com/view/gljvlwq83nauxbc/sdcard_connector.jpg
(b) swd connect circuit, do not connect any vref like 3.3v or 5.0v
tck  - swclk
tms - swdio
gnd - gnd

4. Get Processor debug address & Cross Trigger Interface address for rk3566.cfg
using dap info 0
openocd -f /opt/openocd/share/openocd/scripts/test/explore_swd.cfg
~~~message as follows~~~
AP # 0x0
    AP ID register 0x24770002
    Type is MEM-AP APB2 or APB3

Component base address 0x81004000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x15, Debug Logic, Processor
Dev Arch is 0x47708a15, ARM Ltd "Processor debug architecture (v8.2-A)" rev.0

Component base address 0x81005000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x15, Debug Logic, Processor
Dev Arch is 0x47708a15, ARM Ltd "Processor debug architecture (v8.2-A)" rev.0

Component base address 0x81006000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x15, Debug Logic, Processor
Dev Arch is 0x47708a15, ARM Ltd "Processor debug architecture (v8.2-A)" rev.0

Component base address 0x81007000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x15, Debug Logic, Processor
Dev Arch is 0x47708a15, ARM Ltd "Processor debug architecture (v8.2-A)" rev.0

Component base address 0x8100c000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x16, Performance Monitor, Processor
Dev Arch is 0x47702a16, ARM Ltd "Processor Performance Monitor (PMU) architecture" rev.0

Component base address 0x8100d000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x16, Performance Monitor, Processor
Dev Arch is 0x47702a16, ARM Ltd "Processor Performance Monitor (PMU) architecture" rev.0

Component base address 0x8100e000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x16, Performance Monitor, Processor
Dev Arch is 0x47702a16, ARM Ltd "Processor Performance Monitor (PMU) architecture" rev.0

Component base address 0x8100f000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x16, Performance Monitor, Processor
Dev Arch is 0x47702a16, ARM Ltd "Processor Performance Monitor (PMU) architecture" rev.0

Component base address 0x81014000
Peripheral ID 0x04007bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x14, Debug Control, Trigger Matrix
Dev Arch is 0x47701a14, ARM Ltd "Cross Trigger Interface (CTI) architecture" rev.0

Component base address 0x81015000
Peripheral ID 0x04007bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x14, Debug Control, Trigger Matrix
Dev Arch is 0x47701a14, ARM Ltd "Cross Trigger Interface (CTI) architecture" rev.0

Component base address 0x81016000
Peripheral ID 0x04007bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x14, Debug Control, Trigger Matrix
Dev Arch is 0x47701a14, ARM Ltd "Cross Trigger Interface (CTI) architecture" rev.0

Component base address 0x81017000
Peripheral ID 0x04007bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x14, Debug Control, Trigger Matrix
Dev Arch is 0x47701a14, ARM Ltd "Cross Trigger Interface (CTI) architecture" rev.0

Component base address 0x8101c000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x13, Trace Source, Processor
Dev Arch is 0x47724a13, ARM Ltd "Embedded Trace Macrocell (ETM) architecture" rev.2

Component base address 0x8101d000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x13, Trace Source, Processor
Dev Arch is 0x47724a13, ARM Ltd "Embedded Trace Macrocell (ETM) architecture" rev.2

Component base address 0x8101e000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x13, Trace Source, Processor
Dev Arch is 0x47724a13, ARM Ltd "Embedded Trace Macrocell (ETM) architecture" rev.2

Component base address 0x8101f000
Peripheral ID 0x04003bbd05
Designer is 0x23b, ARM Ltd
Part is 0xd05, Unrecognized 
Component class is 0x9, CoreSight component
Type is 0x13, Trace Source, Processor
Dev Arch is 0x47724a13, ARM Ltd "Embedded Trace Macrocell (ETM) architecture" rev.2

5.
after eclipse installed then debug start
openocd -f /opt/openocd/share/openocd/scripts/target/rk3566-ngb.cfg
~~~debug spl of loader only

6. unlock jtag bin for uboot and kernel debugging
~/rk356x_sdk/rkbin/bin/rk35/rk3568_bl31_v1.32.elf
(a) original: swd failed
0x000000000005CF3C                 MOV             X0, #0x8008
0x000000000005CF40                 MOV             W1, #0x100000
op code: 01 02 A0 52
0x000000000005CF44                 MOVK          X0, #0xFDD1,LSL#16
0x000000000005CF48                 STR               W1, [X0]
convert to c is memory[0xFDD18008] = 0x100000;

(b) modified: swd pass
000000000005CF3C                 MOV             X0, #0x8008
000000000005CF40                 MOV             W1, #0x0
op code: 01 00 80 52
000000000005CF44                 MOVK          X0, #0xFDD1,LSL#16
000000000005CF48                 STR               W1, [X0]
convert to c is memory[0xFDD18008] = 0x0;

find op code :
01 02 A0 52 20 BA BF F2  01 00 00 B9 C3 E3 FF 97
modify to
01 00 80 52 ...
save to ~/rk356x_sdk/rkbin/bin/rk35/rk3568_bl31_v1.32.elf

7. make sure spl loader rebuild
gedit ~/rk356x_sdk/device/rockchip/rk356x/BoardConfig-rk3566-evb2-lp4x-v10.mk
export RK_LOADER_UPDATE_SPL=true

8. disable arm cpu idle:
~/rk356x_sdk/kernel/arch/arm64/configs/rockchip_linux_defconfig
### begin: issue #0012642 by stone
###CONFIG_ARM_CPUIDLE=y
### end: issue #0012642 by stone

9.
./build.sh all && ./build.sh firmware && ./build.sh updateimg && ./rkflash.sh all
~~~now jtag always hook

10. (option)
rk3566/rk3568 aarch64-buildroot-linux-gnu-strip have a fatal bug.
running in ~/rk356x_sdk/buildroot/Makefile
$(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true

when build rootfs third time, STRIPCMD will create failed bin in target directory.
after burn the firmware, boot log show qt.qpa.plugin error messages.
download old version of aarch64-buildroot-linux-gnu-strip can fix it.

gedit ~/rk356x_sdk/buildroot/toolchain/toolchain-buildroot/toolchain-buildroot.mk
~~~before $(eval $(virtual-package)) add these lines
###start by stone
define INSTALL_STRIP
wget --continue https://github.com/RMerl/am-toolchains/raw/master/brcm-arm-hnd/crosstools-aarch64-gcc-5.3-linux-4.1-glibc-2.22-binutils-2.25/usr/bin/aarch64-buildroot-linux-gnu-strip
chmod +x ./aarch64-buildroot-linux-gnu-strip
cp -f ./aarch64-buildroot-linux-gnu-strip $(HOST_DIR)/bin
endef
TOOLCHAIN_BUILDROOT_POST_INSTALL_TARGET_HOOKS += INSTALL_STRIP
###end by stone

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
gdb build scripts:
https://www.mediafire.com/file/t7f8ervmt6a4xw7/build_aarch64_gdb_rockchip.sh
https://www.mediafire.com/file/dwx6g4ac1g2q8at/build_aarch64_lzma_gdb_rockchip.sh

Demo:
https://www.mediafire.com/view/2sjh14qtckb0rhg/rk3568_jtag00.png
https://www.mediafire.com/view/0awgnmp1yc8yz0y/rk3568_jtag01.png
https://www.mediafire.com/view/0qllw8367htzor4/rk3568_jtag02.png
https://www.mediafire.com/view/zv37ffy0d4jjpgd/rk3568_jtag03.png

Video:
https://drive.google.com/file/d/1rc6-Gx_XjHuRWgCEmMRwTYFZ8jf56chz

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Tesla told in New York Herald: I prefer to be remembered as the inventor who succeeded in abolishing war. That will be my highest pride.
http://www.teslacollection.com/tesla_articles/1898/new_york_herald/f_l_christman/tesla_declares_he_will_abolish_war (in middle section)

Albert Einstein: The release of atom power has changed everything except our way of thinking... the solution to this problem lies in the heart of mankind. If only I had known, I should have become a watchmaker.
https://atomictrauma.wordpress.com/the-scientists/albert-einstein

1 則留言:

  1. rk3566/rk3568 mipi flow chart.
    https://pic4.zhimg.com/v2-2dd0e1fac7f89dc7990032585c44b61f_r.jpg

    回覆刪除