Cov txheej txheem:

ESP32 - Kev daws teeb meem pheej yig rau hauv Kev Pabcuam Debug: 5 Kauj Ruam
ESP32 - Kev daws teeb meem pheej yig rau hauv Kev Pabcuam Debug: 5 Kauj Ruam

Video: ESP32 - Kev daws teeb meem pheej yig rau hauv Kev Pabcuam Debug: 5 Kauj Ruam

Video: ESP32 - Kev daws teeb meem pheej yig rau hauv Kev Pabcuam Debug: 5 Kauj Ruam
Video: I Built a MIDI THEREMIN! Theremidi - A DIY Arduino MIDI Controller 2024, Hlis ntuj nqeg
Anonim
ESP32 - Kev daws teeb meem pheej yig rau hauv Kev Tshaj Tawm Debug
ESP32 - Kev daws teeb meem pheej yig rau hauv Kev Tshaj Tawm Debug

Nyob zoo, Hauv cov lus qhia no tau piav qhia yuav teeb tsa JTAG pheej yig li cas raws li FTDI 2232HL nti, nrog cov lej pom thiab arduino addon.

- FTDI 2232HL module nrog USB txuas pib ntawm 8 $ ntawm ebay thiab tsis xav tau software them nyiaj. Qhov no yog kev daws teeb meem zoo rau cov nyiam ua haujlwm uas tsis xav siv 50 $+ ntawm profesionall JTAG adapter.

- Cov adapter no tuaj yeem siv rau kev debug ntawm lwm lub platform zoo li ESP8266, ARM, AVR thiab ntau yam ntxiv. Qee qhov teeb tsa nyob ntawm lub hom phiaj platform, cov lus qhia no tsuas yog teeb tsa rau ESP32.

- Yog tias koj twb muaj qee tus JTAG adapter, koj tuaj yeem siv nws thaum nws tau txais kev txhawb nqa los ntawm openOCD, tsuas yog pib openocd nrog cov ntaub ntawv teeb tsa sib txawv raws li hom koj li jtag adapter.

- platform.io tuaj yeem teeb tsa yooj yim rau koj, tab sis kev debug tau txais kev txhawb nqa nkaus xwb hauv kev tshaj lij tshaj lij.

- Ua haujlwm nrog feem ntau ntawm ESP32 cov qauv. (piv txwv li pheej yig wemos lolin 32)

- qhov jtag adapter no yuav tsum ua haujlwm nrog linux ib yam nkaus, tab sis kuv tus kheej tsis tau sim nws.

Kauj Ruam 1: Software Xav Tau

Arduino IDE version 1.8 lossis tshiab dua. Windows khw version tsis txhawb. Koj yuav tsum siv cov khoos phis tawj qub uas tuaj yeem rub tawm los ntawm nplooj ntawv Arduino

Microsoft pom lub studio suab

Cov addons no rau kev pom lub suab studio yog qhov yuav tsum tau ua

  • Arduino
  • Ib txwm muaj debug

Kuv kuj pom zoo rau nruab qhov addon no uas ua rau muaj kev nkag siab zoo rau C/C ++

C/C ++

Hauv phau ntawv qhia no kuv yuav siv 2 cov ntawv ua haujlwm:

D: / devel / ESP32 / tools / - ntawm no kuv tau tso txhua yam cuab yeej

C: / Users / xxxxx / Documents / Arduino / YourProject / - qhov no yog nplaub tshev nrog kos duab

koj tuaj yeem tso koj cov ntaub ntawv nyob qhov twg lwm qhov yog tias koj xav tau, tsuas yog thov tsis txhob hnov qab hloov kho txhua qhov kev hais tawm nrog koj txoj hauv kev.

Kauj ruam 2: Driver Install and Configuration

Driver Install and Configuration
Driver Install and Configuration
Driver Install and Configuration
Driver Install and Configuration
Driver Install and Configuration
Driver Install and Configuration

Txawm hais tias lub qhov rais tsis siv neeg pom FT2232 los ntawm lub neej ntawd, lub qhov rais pib tsav tsheb tsis txaus rau txhua qhov ua ntej thiab nws yog qhov yuav tsum tau rub tawm thiab teeb tsa tus tsav tsheb los ntawm FTDI qhov chaw

Thaum txhim kho tus tsav tsheb raug, koj yuav tsum pom koj li FT2232 tus lej hauv tus thawj tswj ntaus ntawv tsis yog tsuas yog 2 qhov chaw nres nkoj tab sis tseem yog "USB hloov pauv hloov pauv A" thiab "USB hloov pauv serial B"

Cov kauj ruam thib ob yog hloov tus tsav tsheb rau ib qho channel ntawm peb cov hloov pauv. Rub tawm zadig cuab yeej los ntawm https://zadig.akeo.ie/. Yog tias kuv nkag siab qhov tseeb qhov cuab yeej txuas winUSB tus tsav tsheb rau FTDI cov cuab yeej uas ua rau muaj kev sib txuas lus qis ntawm openOCD thiab USB ntaus ntawv.

Hauv cov cuab yeej zadig, hauv cov ntawv qhia zaub mov "Xaiv" kos "Qhia tag nrho Cov Khoom Siv", tom qab ntawd koj yuav tsum pom koj lub adapter hauv cov npe khoom siv. Xaiv "Dual RS232-HS (Interface 0)" tom qab ntawd xaiv hloov tus tsav tsheb "WinUSB v6.1.xxxx" thiab thaum kawg nyem rau ntawm hloov tus tsav tsheb.

Thaum koj txuas koj lub adapter rau sib txawv USB chaw nres nkoj ntawm koj lub khoos phis tawj, nws yog qhov yuav tsum tau hloov pauv chaw teeb tsa ntawm zadig cuab tam dua, otehwise openOCD yuav tsis pom koj lub adapter.

Kauj Ruam 3: OpenOCD, Toolchain thiab Gdb

OpenOCD, Toolchain thiab Gdb
OpenOCD, Toolchain thiab Gdb

1. Qhib OCD yog cov cuab yeej rau hauv kev debuging debuging, ntawm ib sab nws tham rau nti ntawm lwm sab nws muab gdb server qhov debugger (tus thov kev pabcuam) tuaj yeem txuas tau. Rub tawm openOCD rau ESP32 los ntawm https://github.com/espressif/openocd-esp32/releases thiab unpack nws mus rau nplaub tshev D: / devel / ESP32 / tools

2. kho kom raug openOCD cov ntaub ntawv teeb tsa:

esp-wroom-32.cfg

Tag nrho txoj hauv kev rau cov ntawv no yog:

D: / devel / ESP32 / tools / openocd-esp32 / share / openocd / scripts / board / esp-wroom-32.cfg

Hauv cov ntawv no koj tuaj yeem teeb tsa kev sib txuas lus nrawm los ntawm kev hloov pauv "adapter_khz". Piv txwv "adapter_khz 8000" txhais tau tias 8Mhz.

Default yog 20MHz thiab nws yuav siab dhau yog tias koj siv cov hlua txuas ntev dua lossis cov qhob cij. Kuv pom zoo kom pib ntawm 1Mhz thiab yog txhua yam zoo, mus rau qhov nrawm dua, rau kuv 8Mhz ua haujlwm tau zoo.

minimodule.cfg

Tag nrho txoj hauv kev rau cov ntawv no yog: D: / devel / ESP32 / tools / openocd-esp32 / share / openocd / scripts / interface / ftdi / minimodule.cfg

Yog tias kuv nkag siab raug, qhov tseeb minimodule tau them nqi ntau dhau ntawm kev tshem tawm lub rooj tsavxwm nrog FT 2232 tsim los ntawm FTDI thiab tsuas yog qhov sib txawv ntawm cov minimodule tiag thiab cov qauv pheej yig lossis cov nti liab nyob rau ntawm kev ua lag luam yog lub hauv paus USB piav qhia. qhib OCD tab tom nrhiav jtag adapter raws li cov lus piav qhia ntawm lub cuab yeej, thiab cov txheej txheem pib xav tau hloov kho.

Module pheej yig tau piav qhia "Dual RS232-HS". Yog tias koj tsis paub meej txog kev piav qhia ntawm koj lub cuab yeej, koj tuaj yeem tshawb xyuas nws hauv tus thawj tswj ntaus ntawv -> cov cuab yeej khoom siv -> tab cov ntsiab lus -> tus nqi ntawm cov cuab yeej "Tsheb qhia cov khoom piav qhia"

Cov ntsiab lus ntawm minimodule.cfg yuav tsum zoo li piv txwv hauv qab no, kab pib nrog # tuaj yeem raug tshem tawm.

interface ftdi #ftdi_device_desc "FT2232H MiniModule" ftdi_device_desc "Dual RS232 -HS" ftdi_vid_pid 0x0403 0x6010 #ftdi_layout_init 0x0018 0x05fb ftdi_layout_init 0x0008 0x000b 0x000b

esp32.cfg

Tag nrho txoj hauv kev rau cov ntawv no yog:

D: / devel / ESP32 / tools / openocd-esp32 / share / openocd / scripts / target / esp32.cfg

Txuas ntxiv 2 kab no mus rau qhov kawg ntawm esp32.cfg. Yog tsis muaj qhov kev hloov kho no, ntxiv cov nres tsheb yuav tsis ua haujlwm.

#Force hw breakpoints. Thaum peb muaj daim ntawv qhia kev nco, peb tseem tuaj yeem tso cai software bps.gdb_breakpoint_override nyuaj

3. Rub tawm thiab teeb tsa xtensa-esp32-elf toolchain-cov cuab yeej no muaj cov kab hais kom ua debugger (gdb tus thov) uas yog qhov tseem ceeb kom muaj kev ua haujlwm debug los ntawm ib qho duab IDE. Cov cuab yeej tsis muaj peev xwm tuaj yeem rub tawm los ntawm qhov chaw espressif, ntu "Lwm txoj kev teeb tsa"

Kauj Ruam 4: Xaim thiab Kev Xeem Thawj

Kev thaiv thiab Kev Xeem Thawj
Kev thaiv thiab Kev Xeem Thawj
Kev thaiv thiab Kev Xeem Thawj
Kev thaiv thiab Kev Xeem Thawj

Txuas FT2322 module nrog ESP. Kuv xav kom siv cov xov hluav taws xob luv li sai tau yog tias koj yog tus tshiab rau JTAG, tsis txhob hnov qab tias TDI ntawm adapter yuav mus rau TDI ntawm nti, kuj TDO ntawm adapter yuav mus rau TDO ntawm nti. JTAG cov kab ntawv tsis raug hla zoo li Rx/Tx ntawm uart!

Txog qhov kev sim tom qab no kuv pom zoo tso cov duab ntsais piv txwv lossis qee qhov kos duab uas tuaj yeem qhia thaum CPU khiav lossis tsis yog los ntawm ntsais LED lossis beeping lossis sau rau lub console.

Pib openOCD los ntawm cov lus txib hauv qab no

D: / devel / ESP32 / tools / openocd-esp32 / bin / openocd.exe-s D: / devel / ESP32 / tools / openocd-esp32 / share / openocd / scripts -f interface/ftdi/minimodule.cfg -f board /esp-wroom-32.cfg

Qhov no yuav pib openOCD thiab yog tias txhua yam ua tau zoo koj yuav tsum pom hauv kab hais kom ua cov kab ntawv muaj cov kab hauv qab no:

Cov ntaub ntawv: moos nrawm 8000 kHzInfo: JTAG kais: esp32.cpu0 kais/ntaus pom: 0x120034e5 (mfg: 0x272 (Tensilica), ntu: 0x2003, ver: 0x1) mfg: 0x272 (Tensilica), ib feem: 0x2003, ver: 0x1)

Kuj tseem qhib txheej txheem yuav mloog ntawm TCP chaw nres nkoj 3333

Qhib lub davhlau ya nyob twg tshiab thiab pib hais kom ua kab gdb tus thov kev pabcuam los ntawm kev ua raws li comand

D: / devel / ESP32 / tools / xtensa-esp32-elf / bin / xtensa-esp32-elf-gdb.exe

Tos ib pliag thiab thaum lub davhlau ya nyob twg gdb yuav npaj tau sau cov lus txib ib los ntawm ib qho

lub hom phiaj nyob deb: 3333 hli rov pib dua nres

thawj cov lus txib qhib kev sib txuas rau openocd debug server, thib ob yuav tsum nres qhov kev ua haujlwm ntawm ESP thiab LED yuav tsum tsis txhob ntsais muag, txuas ntxiv rov kho qhov kev ua tiav thiab LED sshould pib ntsais muag dua.

Kauj ruam 5: Ntxiv Debug Configuration rau Visual Studio Code

Ntxiv Debug Configuration rau Visual Studio Code
Ntxiv Debug Configuration rau Visual Studio Code

Kuv suav txij ntawm qhov ntawd koj twb tau teeb tsa lub qhov muag pom duab chaws thiab arduino addon kom raug thiab koj tuaj yeem txheeb xyuas thiab xa koj daim duab kos rau lub rooj tsavxwm. Yog tias tsis yog, thov txheeb xyuas qee qhov kev qhia yuav ua li cas teeb tsa lub vis dis aus code thiab arduino, piv txwv li ntawm nplooj ntawv no

Txhawm rau kom debug ua haujlwm nws xav tau los qhia kom tsim cov ntawv tais ceev tseg. Hauv qab koj daim duab sketch muaj (zais) nplaub tshev.vscode, qhov twg yog cov ntaub ntawv arduino.json. ntxiv rau cov ntaub ntawv hauv qab kab no:

"tso tawm": "BuildOutput/"

khiav pov thawj lossis rub tawm thiab txheeb xyuas koj daim duab daim duab dua, yuav tsum muaj daim nplaub tshev BuildOutput tshiab thiab sab hauv nws ua nrog.elf txuas ntxiv. elf cov ntaub ntawv tseem ceeb heev rau kev debug.

Kev teeb tsa debugger yog nyob rau hauv cov ntaub ntawv launch.json. Tsim cov ntawv no nrog cov ntsiab lus hauv qab no, lossis koj tuaj yeem luam cov ntawv no los ntawm qhov piv txwv qhov project. Tsis txhob hnov qab kho kab 26 thiab txheeb xyuas txoj hauv kev rau koj txoj haujlwm.elf cov ntaub ntawv.

{// Siv IntelliSense los kawm txog cov peev xwm ua tau. // Hover los saib cov lus piav qhia ntawm tus cwj pwm uas twb muaj lawm. // Yog xav paub ntxiv, mus saib: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [{"name": "Arduino-GDB-openOCD "," hom ":" cppdbg "," thov ":" pib "," program ":" $ {file} "," cwd ":" $ {workspaceRoot}/BuildOutput/"," MIMode ":" gdb ", "targetArchitecture": "caj npab", "miDebuggerPath": "D: /devel/ESP32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe", "debugServerArgs": "," customLaunchSetupCommands ": [{" text ":" target remote: 3333 "}, {" text ":" mon reset halt "}, {// dynamic variant" text ":" file c:/Users/xxxxx/Documents/Arduino /$ {"text": "flushregs"}, {"text": "thb app_main"}, {"text": "c", "ignoreFailures": true}], "stopAtEntry": tseeb, "serverStarted": "Cov ntaub ntawv \: [w / d \.]*: / hardware "," launchCompleteCommand ":" exec-continue "," filterStderr ": tseeb," args ": }]}

Yuav pib debuging li cas:

  1. Ua kom tiav thiab xa koj daim duab kos rau lub rooj tsavxwm
  2. Pib openOCD nrog qhov ntsuas
  3. Teem nres nres hauv cov cai uas koj xav tau
  4. Tom qab teeb tsa tag nrho cov nres tsheb, xyuas kom tseeb tias koj tau qhib koj txoj haujlwm tseem ceeb.ino cov ntaub ntawv. (lossis txoj hauv kev nyuaj rau.elf cov ntaub ntawv hauv launch.json)
  5. Qhib debug vaj huam sib luag hauv vs code (Ctrl + Ua haujlwm + D)
  6. Xaiv "Arduino-GDB-openOCD" debugger, yuav tsum muaj xwb.
  7. Ntaus F5 kom pib debug

Pom zoo: