Help on choose a debug method.

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

i have an integrated system and one of the functions of my microcontroller(Atmega32A) is to apply the avr910 protocol(ISP) and program an other microcontroller. Now i want my main microcontroller(atmega32A) to know the value of the pins of the microcontroller i programmed. Which method is better?Like Jtag or debugWire protocol?And where i can find a code which just apply this protocol and read the port registers of the other microcontroller?I dont want set breakpoints and other functions..just read the port register of the microcontroller.

Or to find the inteface and the commands bettween my main microcontroller and the microcontroller which i want to read the port registers.

Thank you.Sorry for my english.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

GRIMMJOWG21 wrote:
read the port registers of the other microcontroller

 

This is not difficult, use TWI.

 

GRIMMJOWG21 wrote:
know the value of the pins of the microcontroller i programmed. Which method is better?Like Jtag or debugWire protocol

 

This is difficult, does it means that one AVR use JTAG or DW towards another AVR. Explain, please.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

GRIMMJOWG21 wrote:
Like Jtag or debugWire protocol?
PDI or UPDI

sniffing the RAM using the UPDI | AVR Freaks

 


debugWIRE via USB UART | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use what is available on the target device! For many of the "modern" chips, you have no choice. JTAG is offered on only a few legacy AVRs.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

twi demand a protocol from both microcontollers, my main atmega32A and the atmega328p which is the target.I want my main atmega32a have this function no matter what code is written to the target.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok lets say i want use jtag and both devices supported .Where i can find a datasheet or an example on internet or github that explains the interface needed , the commands your avr should send to target avr through jtag interface and corresponding responses. Most articles just include a hex file.Same results if i search for other debug methods. Maybe i need improve my google search ....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

GRIMMJOWG21 wrote:
my main atmega32A and the atmega328p

 

The first one is a JTAG device, alright, but the second one is DW. Is it the problem- how you will use JTAG, for programming and debug I presume?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

GRIMMJOWG21 wrote:
Now i want my main microcontroller(atmega32A) to know the value of the pins of the microcontroller i programmed. Which method is better?Like Jtag or debugWire protocol?
JTAG for high-pin-count megaAVR.

ATmega32A Datasheet

[page 227]

25.5.1 Scanning the Digital Port Pins

Boundary Scan (BSDL) Files (Document Title in pull-down menu, enter AVR)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For that situation, I would invest in a dedicated programmer/debugger for each device AND a logic analyzer to observe bus activity.

 

Well, maybe not. I would verify bus operation on the M32 with the logic analyzer and a known-good hardware slave, probably no debugger. Then I would substitute the M328 for the known good hardware slave, maybe with a programmer/debugger. With just a little bit of care, you probably do not need to debug  both MCUs simultaneously.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Sun. Dec 5, 2021 - 07:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cypress and FTDI (others?) have USB UART with a JTAG function.

GitHub - viveris/jtag-boundary-scanner: JTAG boundary scan debug & test tool.

 

P.S.

FTDI for megaAVR debugger bridge (OCD <-> JTAG <-> USB JTAG <-> AVR Studio)

>>> LURA <<<

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not clear. Are you saying you want master (mega32) to actually read second chip via JTAG? That's actually really complicated. Why not get PC to read the slave with JTAG. 

 

Otherwise use a chip-to-chip comms channel (UART, SPI, TWI/I2C) to have one micro interrogate the state of the other. That does rely on code running on the 2nd to report back requested state (whereas, if you could have used JTAG) it would have needed no code involvement on the second. 

 

In effect what you are doing is writing a "monitor" for the slave (this is something that used to be very common 30-40 years ago before things like JTAG were widely available) 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
In effect what you are doing is writing a "monitor" for the slave
AVR GDB is available though not akin to a GDB server service on an APU.

GitHub - jdolinay/avr_debug: Source level debugger for Arduino - GDB stub for Atmega328 microcontroller used in Arduino Uno. via avr-stub — PlatformIO 5.2.0a5 documentation

 

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

YES i want master (mega32) to actually read second chip(atmega328p) via JTAG or an other protocol that will help the master knows the value of the pins of atmega328p.Atmega32A can apply like i said before the avr910 (isp) protocol to atmega328p and programm it succesfully.But now i want to know the value of the pins of atmega328p .So who is the better method to do it considering my master is atmega32a and slave is atmega328p?atmega328p doesnt support jtag so can atmega32a with debugwire protocol read the values of atmega328p?And if yes where i can find a good approach to build my code?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The debug interface on a mega328P is not JTAG, it is debugWire. But you face a bit of an issue as Atmel do not openly document the debugWire protocol. It's true that some 3rd party debugger code has managed to reverse engineer it but you aren't going to get much support if you get stuck.

 

Like I said above, of you forget about the On Chip Debug interface but instead run a small "monitor" on the 328P then there can be an agreed protocol between the mega32 master and the 328P slave where over some comms interface like UART or SPI or TWI/I2C the mega32 maybe makes a request like "tell me state of pin 13" then the monito checks PIN for that port and extracts the state of the bit and sends it back (or it might just send the complete PINB or whatever and let the master extract the pin of interest. The master and the monitor in the slave would have to agree a protocol of how they would converse.

 

What makes you want to use debugWire anyway? Is it purely because it is non-invasive ? (well it is kind of invasive in that the CPU has to be halted for the interface to read the state of things).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How often, and at what speed, do you need to read the 328's pins?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

GRIMMJOWG21 wrote:
atmega328p doesnt support jtag so can atmega32a with debugwire protocol read the values of atmega328p?
Yes

GRIMMJOWG21 wrote:
And if yes where i can find a good approach to build my code?
dwire-debug

Data, flash, register, and stack display commands | dwire-debug/Manual.md at master · dcwbrown/dwire-debug · GitHub

due to

debugWIRE via USB UART | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
(well it is kind of invasive in that the CPU has to be halted for the interface to read the state of things).
indecision

Features | debugWIRE | AVR® Microcontroller with Core Independent Peripherals and PicoPower® Technology

  • Non-intrusive Operation

IIRC, DWDR is at a very low rate between OCD and the debugger.

debugWire Data Register | AVR® Microcontroller with Core Independent Peripherals and PicoPower® Technology

 

"Dare to be naïve." - Buckminster Fuller