Dukungan RTOS seperti MitM di GDB

Sudah lama saya berpikir apakah mungkin untuk menerbitkan ulang artikel tentang HabrΓ©, saya mempelajari peraturannya, sepertinya sekarang tidak dilarang. Jika saya melakukan kesalahan, saya akan memperbaikinya :)


Begitu...


Beberapa waktu lalu, saya menulis kode firmware untuk tangan-tangan Epiphan dari baris AV.io:


  • AV.io HD - pilot kami, di mana banyak arsitektur yang telah di-debug dan dibentuk
  • AV.io SDI - memperbaiki posisi
  • AV.io 4K - sudah hardware baru dan pendekatan baru, sekarang kami meluncurkan hampir secara instan
  • KVM2USB 3.0 - Pemikiran mendalam AV.io HD . Bahkan, berkat potensi untuk modernisasi dalam model dasar, dengan hampir tidak ada modifikasi dari besi, mereka mampu membuat produk baru murni perangkat lunak.

Cypress FX3 terlibat di sana , dan SDK dibangun di atas ThreadX. Anda dapat menggunakan Olimex ARM-USB-OCD-H bersamaan dengan OpenOCD sebagai debugger JTAG . Sayangnya, OpenOCD tidak tahu apa-apa tentang utas di RTOS, dan meskipun dukungan dasar ada dalam kode, khusus untuk prosesor kami, kami menggunakan skema susun register yang berbeda dari apa yang sudah diterapkan. Saya harus mengerti dan memodifikasi . Keuntungan menggunakan JTAG untuk pengembangan sulit ditaksir terlalu tinggi, setidaknya dalam hal pekerjaan yang didistribusikan .


Jadi waktu hampir habis. Sekarang giliran FPGA Xilinx dan prosesor perangkat lunak MicroBlaze-nya, di mana Anda dapat menjalankan FreeRTOS versi 10.x. Tetapi masalahnya persis sama: tidak ada dukungan untuk utas di debugger!


XSDK


Xilinx ARM Cortex-A53, ARM Cortex-R5 MicroBlaze. MicroBlaze β€” , FPGA. .


( CPU, FPGA, β€” Vivado) β€” XSDK ( 2020 Vitis), Eclipse. FPGA . , JTAG ( OpenOCD!) , . : , , .


, Eclipse, , β€” XSTC. . .


.


JTAG hw_server. TCP , β€” 3121, , , 3000 β€” GDB :


  • N+0 (3000) β€” ARM Cortex-A53
  • N+1 (3001) β€” ARM Cortex-R5
  • N+2 (3002) β€” MicroBlaze ( )

-, .


, . , . , ( !) β€” System Debugger GDB. MicroBlaze GDB β€” mb-gdb.


System Debugger . , Xilinx GDB β€” .


,


, RTOS OpenOCD, , , :


  1. RTOS TCB (Thread Control Block), , . . ( ) β€” Reverse Engineering! : , , .
  2. RTOS β€” . , , . , , β€” . .. . β€” .
  3. 1 β€” TCB ( β€” RTOS).

, GDB GDB , info threads info registers thread N bt.


, RTOS , , RTOS ( , SDK , ). , .


: . . p , , . , ThreadX Cypress FX3. , . β€” .


… GDB-client GDB-server , , , MitM ""? , , , , ?


, : . gdbproxy , .


β€” . C++ ( , , ), Asio, C++17 , , C++2a β€” , , , 100%, 90% !


,


, β€” . . Asio , . . .


: . TCB, . … GDB- . . … ! β€” . , , ( β€” ) : qSymbol::, : - ? β€” . β€” , . qSymbol:NAME, qSymbol:ADDR:NAME qSymbol::NAME , nullptr. - ( , β€” ) , .


. , , , , β€” … , !


.. , .


, : , . .


, . . (SMP , ) β€” . GDB ( ) β€” : . .


, GDB-client . , . : - , - SP (Stack Pointer) FP (Frame Pointer) . , .


: Set Current Thread ( OK EXX β€” XX β€” , ), . RTOS, , , . , β€” . β€” Current Execution? : β€” . , . ! . Set Current Thread Set Current Thread , xxxxxxxx , β€” ! , RTOS , Set Current Thread , Set Current Thread . : . .


, SP : TCB . SP , .


, . . Stop Reply Packets. , . , breakpoint, watchpoint Break ( , , 0x03 Stop Reply Packet). , , . Stop Reply Packet, . . Stop Reply Packets : vCont c β€” Continue s β€” Step ( ).


. , , .


, , . : . β€” . GDB. MicroBlaze GDB microblaze-tdep.h enum microblaze_regnum:


enum microblaze_regnum
{
  MICROBLAZE_R0_REGNUM,
  MICROBLAZE_R1_REGNUM, MICROBLAZE_SP_REGNUM = MICROBLAZE_R1_REGNUM,
  MICROBLAZE_R2_REGNUM,
  MICROBLAZE_R3_REGNUM, MICROBLAZE_RETVAL_REGNUM = MICROBLAZE_R3_REGNUM,
  MICROBLAZE_R4_REGNUM,
  MICROBLAZE_R5_REGNUM, MICROBLAZE_FIRST_ARGREG = MICROBLAZE_R5_REGNUM,
  MICROBLAZE_R6_REGNUM,
  MICROBLAZE_R7_REGNUM,
  MICROBLAZE_R8_REGNUM,
  MICROBLAZE_R9_REGNUM,
  MICROBLAZE_R10_REGNUM, MICROBLAZE_LAST_ARGREG = MICROBLAZE_R10_REGNUM,
  MICROBLAZE_R11_REGNUM,
  MICROBLAZE_R12_REGNUM,
  MICROBLAZE_R13_REGNUM,
  MICROBLAZE_R14_REGNUM,
  MICROBLAZE_R15_REGNUM,
  MICROBLAZE_R16_REGNUM,
  MICROBLAZE_R17_REGNUM,
  MICROBLAZE_R18_REGNUM,
  MICROBLAZE_R19_REGNUM,
  MICROBLAZE_R20_REGNUM,
  MICROBLAZE_R21_REGNUM,
  MICROBLAZE_R22_REGNUM,
  MICROBLAZE_R23_REGNUM,
  MICROBLAZE_R24_REGNUM,
  MICROBLAZE_R25_REGNUM,
  MICROBLAZE_R26_REGNUM,
  MICROBLAZE_R27_REGNUM,
  MICROBLAZE_R28_REGNUM,
  MICROBLAZE_R29_REGNUM,
  MICROBLAZE_R30_REGNUM,
  MICROBLAZE_R31_REGNUM,
  MICROBLAZE_PC_REGNUM,
  MICROBLAZE_MSR_REGNUM,
  MICROBLAZE_EAR_REGNUM,
  MICROBLAZE_ESR_REGNUM,
  MICROBLAZE_FSR_REGNUM,
  MICROBLAZE_BTR_REGNUM,
  MICROBLAZE_PVR0_REGNUM,
  MICROBLAZE_PVR1_REGNUM,
  MICROBLAZE_PVR2_REGNUM,
  MICROBLAZE_PVR3_REGNUM,
  MICROBLAZE_PVR4_REGNUM,
  MICROBLAZE_PVR5_REGNUM,
  MICROBLAZE_PVR6_REGNUM,
  MICROBLAZE_PVR7_REGNUM,
  MICROBLAZE_PVR8_REGNUM,
  MICROBLAZE_PVR9_REGNUM,
  MICROBLAZE_PVR10_REGNUM,
  MICROBLAZE_PVR11_REGNUM,
  MICROBLAZE_REDR_REGNUM,
  MICROBLAZE_RPID_REGNUM,
  MICROBLAZE_RZPR_REGNUM,
  MICROBLAZE_RTLBX_REGNUM,
  MICROBLAZE_RTLBSX_REGNUM,
  MICROBLAZE_RTLBLO_REGNUM,
  MICROBLAZE_RTLBHI_REGNUM,
  MICROBLAZE_SLR_REGNUM, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_SLR_REGNUM,
  MICROBLAZE_SHR_REGNUM,
  MICROBLAZE_NUM_REGS
};

, . - , , 00000000 xxxxxxxx, β€” , β€” : unavail. β€” . , qFeatures (TBD: !) , β€” .


, ?


: https://github.com/h4tr3d/gdbproxy/


, BSD MIT. OpenOCD (, : , , , ). .


: . , , RTOS, . . .


?


XSDK:


  1. β€” GDB , System Debugger
  2. GDB, 4002 ( gdbproxy, )
  3. gdbproxy, XSDK hw_server :
    ./gdbproxy --port 4002 --remote-host localhost --remote-port 3002 -- mb_freertos
  4. ...
  5. PROFIT!

Dalam hal menggunakan remote hw_server, karena fleksibilitas kecil dari konfigurasi XSDK, itu gdbproxyharus dijalankan pada mesin yang sama dengan hw_server.


temuan


Tidak ada Intinya: threading pada FreeRTOS dan MicroBlaze didukung.


All Articles