[dorkbotpdx-blabber] Does benito5 only program but not debug AVRs

30 views
Skip to first unread message

Transistor Toaster

unread,
Jun 29, 2008, 1:09:24 PM6/29/08
to dorkbotpd...@dorkbot.org
Hi,
I'm a n00b just starting out with AVRS. I have been programming with
FLIP the AT90USB162. I would like to know that if the benito5 only has
the capability to program another AVR but not to debug?
Frank
--
Transistor Toaster
transist...@fastmail.fm

--
http://www.fastmail.fm - mmm... Fastmail...

_______________________________________________
dorkbotpdx-blabber mailing list
dorkbotpd...@dorkbot.org
http://music.columbia.edu/mailman/listinfo/dorkbotpdx-blabber

Donald Delmar Davis

unread,
Jun 29, 2008, 2:28:21 PM6/29/08
to A discussion list for dorkbot-pdx (portland, or)
Frank,

That is an interesting place to start. Which at90usb162 board are you using? The benito 5 design has the spi pins on portB and the serial pins on port D exposed. The new board  that we just sent to sunstone (benito7 rev b) just has all of port D exposed. My original thought was to have a dual port device. Later I realized that the usart will do Master mode SPI, so one port would do both SPI for in circuit programming and serial for programming through a bootloader. In both case i built the hardware and minimal software (usb 2 serial with a reset pulse on dtr requests) and planned to write better firmware later. 

I am in the process of writing the firmware to make an STK500v2 compatible device with it which I hope to have done before the first 1000 board run gets here in a couple of weeks. 

In either case it will support only programming and communication, neither of which is specific to a particular avr (or even the avr for that mater). Nothing says you couldn't write firmware to get JTAG out of it but that is a bit beyond what I currently have time for. 

Don.

Paul Stoffregen

unread,
Jun 29, 2008, 2:57:40 PM6/29/08
to A discussion list for dorkbot-pdx (portland, or)
Has Atmel ever released JTAG or debug wire protocol specs for any of
their chips?


-Paul

Donald Delmar Davis

unread,
Jun 29, 2008, 2:54:39 PM6/29/08
to A discussion list for dorkbot-pdx (portland, or)
Frank,
Yes.

The short answer which was in the last email was yes. 

Debugging would require either jtag or debugWIRE(tm). JTAG is a defined standard which could be implemented using the Benito. 
Paul Stoffregon has done some work towards this using the at90usb82. 
Debug wire as I understand it is Atmel proprietary. 

Don.

On Jun 29, 2008, at 10:09 AM, Transistor Toaster wrote:

Paul Stoffregen

unread,
Jun 29, 2008, 3:41:04 PM6/29/08
to A discussion list for dorkbot-pdx (portland, or)
All my debug stuff is for the NXP/Philips LPC2000 chips, which are based
on an ARM7 (32 bit) core. I am using the AT90USB82 chip as a USB to
JTAG adaptor, but I can only debug 32 bit ARM chips, not Atmel's 8 bit
AVR chips.

For an analogy, consider using a USB-serial adaptor with an FTDI chip to
program a bare-bones Arduino. The adaptor uses a FTDI chip, but it only
programs the AVR (Arduino) chip, not a FTDI chip.

Most AVR chips have debug wire, which is a closed, proprietary
protocol. Some also have JTAG. While JTAG itself is an open spec, JTAG
itself only tells you how to access registers inside the chip. To
actually use JTAG, additional specs are necessary to know what registers
are available and how to use them (it's usually quite complicated).
Atmel has published boundary scan info for some chips (which allows
manipulating the external pins for testing the circuit board traces), to
the best of my knowledge, Atmel has never released JTAG debug register
specs which would be necessary to use that JTAG port to debug an AVR
processor.

If those JTAG register specs are available for AVR chips, please tell me
where.

Without that info, there is no hope of ever making an open debug tool
for the AVR/Arduino (which is the main reason I'm using the ARM chip).


-Paul


> Paul Stoffregon has done some work towards this using the at90usb82.
> Debug wire as I understand it is Atmel proprietary.

_______________________________________________

Dan Strother

unread,
Jun 29, 2008, 4:26:26 PM6/29/08
to A discussion list for dorkbot-pdx (portland, or)
It's possible to build a clone of Atmel's JTAG ICE:
http://www.scienceprog.com/build-your-own-avr-jtagice-clone/ (or buy,
for a rather lot less than Atmel charges:
http://www.sparkfun.com/commerce/categories.php?c=7 ). These still
rely on Atmel's firmware, though (which won't work on hardware that
doesn't look very similar to a JTAG ICE). You're not tied into AVR
Studio, at least - you can use GDB with the JTAG ICE:
http://avarice.sourceforge.net/ .

Unfortunately, so far as I can tell, no one has successfully built a
clone of the JTAG ICE mkII; so, if you really want to use debugWire,
you may have to fork over the $300 for the mkII...


Dan S.

Transistor Toaster

unread,
Jun 30, 2008, 12:08:58 AM6/30/08
to A discussion list for dorkbot-pdx (portland, or)
Don,

> Which at90usb162 board are you using?
Actually, I took the at90usb162 all by itself and wired it up using the
Benito5 schematic plus the AT90USBKey schematic
as starting points cutting everything out until I had the minimum to
achieve a "Hello world" of a flashing LED.

My current goal is to be working with a larger pin count ATMEGA, so I
will not be able to rely on FLIP anymore.
I'm going to give this
http://www.scienceprog.com/build-your-own-avr-jtagice-clone/ a try.

Frank

--
http://www.fastmail.fm - The professional email service

Transistor Toaster

unread,
Jun 30, 2008, 12:21:43 AM6/30/08
to A discussion list for dorkbot-pdx (portland, or)
Dan,
Thanks for the links. The
http://www.scienceprog.com/build-your-own-avr-jtagice-clone/ is a clone
of what Atmel product name (Digikey.com part number ATJTAGICE2-ND)?

I am currently writing C code in code::blocks, compiling by hand with
winavr and would need to debug. I typed avr-gdb, included with winavr,
just to see what would happen and don't know too much what. I already
have windows software that talks to my circuit, so I don't want to work
with my Linux distro.

So, I won't really need anything else besides Ponyprog one single time,
then I can use AVRstudio ( that will launch winavr by itself) for all C
compilation, programming and emulation, right???

Frank

--
Transistor Toaster
transist...@fastmail.fm

--
http://www.fastmail.fm - One of many happy users:
http://www.fastmail.fm/docs/quotes.html

Transistor Toaster

unread,
Jun 30, 2008, 1:11:50 PM6/30/08
to dorkbotpd...@dorkbot.org
I think I might have emailed this to myself but not the mailing list, so
pardon me if this is a double post.

Hello,
I was just wondering how does the AT90USB162 know which particular
programming method is to be used? If I hold nHWB low and pulse the RESET
line, how does it know it is supposed to talk to the PC with the USB
port and not JTAG or ICSP?
Frank



>
> On Sun, 29 Jun 2008 13:09:24 -0400, "Transistor Toaster"
> <transist...@fastmail.fm> said:
> > Hi,
> > I'm a n00b just starting out with AVRS. I have been programming with
> > FLIP the AT90USB162. I would like to know that if the benito5 only has
> > the capability to program another AVR but not to debug?
> > Frank
> > --
> > Transistor Toaster
> > transist...@fastmail.fm
> >
> > --
> > http://www.fastmail.fm - mmm... Fastmail...
> >
> --
> Transistor Toaster
> transist...@fastmail.fm
>
> --

> http://www.fastmail.fm - Choose from over 50 domains or use your own
>
--
Transistor Toaster
transist...@fastmail.fm

--
http://www.fastmail.fm - A fast, anti-spam email service.

Donald Delmar Davis

unread,
Jun 30, 2008, 4:40:48 PM6/30/08
to A discussion list for dorkbot-pdx (portland, or)
The at90usb series has a fuse bit for HWB (hardware boot) and if the fuse is set then it checks to see if the HWB pin is pulled before entering either the boot section or the application section. This is pretty well described in the boot sequence section of the datasheet. 

The chips come pre programmed with a boot section that is a Device Firmware Updater. It can be reprogrammed to do whatever. Dean Camera's MyUSB library has source code for a DFU bootloader and one that acts like an stk500 over a cdc device. 

If in your search for more io you check out the 90usb647 family then plan on using deans bootloaders as the stock one is busted.  

Thanks for the links. I am thinking about testing out one of the JTAG clones with the benito for the serial. 

Since you have no fear of tqfp I suggest you check out the mega(16/32/64/)5 family as well as the at90usb64(6/7) all of them have the same footprint as the mega128 at a fraction of the cost. the larger usb parts require only 6 pin changes (the usb specific ones) to work with in the same place as the mega128.

Paul Stoffregen

unread,
Jun 30, 2008, 4:59:33 PM6/30/08
to A discussion list for dorkbot-pdx (portland, or)

> I was just wondering how does the AT90USB162 know which particular
> programming method is to be used?

There are 3 fuse bytes and 1 lock byte that configure the chip.

There is a parallel programming option which can never be disabled. It
is activated by +12 volts on the reset pin, and nearly all the pins are
required for programming the chip. If the chip is locked, it must be
erased before changes can be made. Once unlocked, the fuse bits and all
memory can be changed. Almost nobody uses the parallel mode, except
dedicated eprom programmers.

If enabled by the fuse bits (and it is enabled by default), the chip can
be programmed using ISP mode, which the datasheet calls "serial
downloading". While the chip is in reset, the MISO, MOSI and SCLK pins
are used to program the chip. This mode has complete access, just like
the parallel mode, including changing the fuses. It is possible to
change the fuse bit that disables this mode, and if you do that after
rebooting this mode will be permanently disabled (unless you use the
parallel mode to change the fuse bit disabling it).

There are 2 other fuse bit that configure if the boot loader will always
run after reset, or the main application will always run after reset, or
if the HWB (PD7) pin will control which one gets run. Atmel ships the
chip with a default setting of HWB controlling which gets run after
reset. If you have not changed the fuse bits, that is what your chip
will do.

The bootloader can not change the fuse bits. If you have only ever
programmed the chip using the bootloader Atmel ships pre-programmed into
the chip, you can be sure the fuse bits are still in their default
configuration.

There is also a fuse that enables DebugWire mode. By default it is
disabled.


> If I hold nHWB low and pulse the RESET
> line, how does it know it is supposed to talk to the PC with the USB
> port and not JTAG or ICSP?

There is no JTAG port, so that is never an option.

So, how exactly does it "know" which mode? First, if the reset pin has
+12 volts, you're in parallel mode. If reset is low (the chip is not
running), and the serial mode is enabled by the fuse bits, then it
listens for programming on the SPI pins. Likewise, if DebugWire mode is
enabled by the fuse bits, it listens for the (closed, proprietary,
undocumented) debugwire activity on the reset pin.

Even if the fuse bit enables the "serial downloading" mode (ICSP or
ISP), that mode is only active while reset remains low. Once your reset
pulse ends, that mode is no longer available.

When reset allows the chip to start running (or the brownout or startup
timer acts as reset, also configured by fuse bits), the 2 fuse bits
determine if it will run starting at 0x0000 or the bootloader start
address (which is programmable via fuse bits in 4 different bootloader
sizes), or if the HWB pin is checked to determine which to run.

While the chip is running in the bootloader section, and if the lock
bits permit it, the SPM instruction can be executed to write to the
flash memory. The SPM instruction is never enabled if code is running
in the application section.


If the fuses are still in their default state, your holding HWB low will
cause the bootloader to run when reset goes high. If Atmel's DFU
bootloader is still in the memory, it will begin talking on the USB port
and your PC will enumerate the USB device. If you have only ever used
the bootloader, there is no way you could have ever changed the fuses,
and my limited understanding of Atmel's default bootloader is that it
doesn't allow overwriting itself.

If you've programmed a different bootloader (as I do) and/or changed the
fuse bits, the chip will do whatever you have configured. The
documentation for all this, by the way, is in chapter 25 of the datasheet.


-Paul

Transistor Toaster

unread,
Jun 30, 2008, 5:16:28 PM6/30/08
to A discussion list for dorkbot-pdx (portland, or)
Donald,
Thanks for your response. Actually, I tried programming my at90usb162
with FLIP Dean Camera s myUSB with FLIP for the pure purpose of having a
USB to serial converter and next, I had a pain to reprogram it with FLIP
with the HWB pin low on a reset. (I used Dean s project deisnged for the
purpose of usb2serial in the sample code directory) I had the impression
that it disabled the boatloader that is compatible with FLIP.

Does Dean Camera have a mailing list or forum for his myUSB?

Frank

--
http://www.fastmail.fm - Send your email first class

Donald Delmar Davis

unread,
Jun 30, 2008, 6:32:57 PM6/30/08
to A discussion list for dorkbot-pdx (portland, or)
Not yet, but we have discussed it and I get the impression that it is on the way.

FYI Flip wont let you program the fuses or the bootloader area so you should be able to reflash the application section with hwb pulled low and reset. I generally put a pullup on hwb and reset.  

Dan Strother

unread,
Jul 1, 2008, 2:26:20 AM7/1/08
to A discussion list for dorkbot-pdx (portland, or)
It's actually a clone of the previous JTAG ICE (
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2737 - now
replaced by the mkII, as you found on Digikey).

I think AVR Studio will do everything that you want, particularly now
that it integrates with WinAVR - though, I've never actually done any
in-circuit debugging of AVR's (only researched it a bit), so I don't
have any first-hand experience.

Good luck :)


Dan

Reply all
Reply to author
Forward
0 new messages