BLIPS Bootloader - ATMEL ATMEGA128A

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

Hi everybody. I am having trouble getting the BLIPs bootloader to work with my ATMEGA128A microcontroller. I have attached an image of the relevant portions of the schematic below, but basically, I have an FT232RL interfaced with the 128 and an ISP header for initial programming.

 

I have downloaded the latest blips files and only slightly modified the assembly code to create the HEX file I am using. I left the .INCLUDE to "M128def.inc" instead of changing it to M128Adef.inc". The difference between these two IC's from my research is basically the 128A has lower power consumption because the die was shrunk. This my be my issue, but I have tried both ways unsuccessfully. Here is the first section of the code:

.INCLUDE "m128def.inc"	; <<< CHANGE THIS according to chip type <<<<<<<<<<<<<<<<<<<<<<<<<<
						; for example "m128def.inc"

; CHANGE clock 
.equ	clock 			= 16000000	; CPU clock in Hz, given the crystal in use
; CHANGE BAUD. CHANGE UART0 vs. UART1 in one of the blocks of constants, below
.equ	bootldr_baud	= 9600		; Baud rate. Note: PC side software may have limitations on choices

	 ; 
;		as of now, the code is about 486 bytes long; stevech did lots of work to fit in 512 

; these come from the .INCLUDE file
.equ 	SB1 = SIGNATURE_002 	; Atmel chip type Signature byte from include file
.equ 	SB2 = SIGNATURE_001 	; Atmel chip type Signature byte
.equ 	SB3 = SIGNATURE_000 	; Atmel chip type Signature byte (Atmel code)

; Optional Blinking LED while bootloader waits for PC to begin commands
.if	0			; change to 0 to disable blinking LED while boot waits for PC 
.equ	LED_DDR		=DDRA
.equ	LED_PORT	=PORTA
.equ	LED_BITNO	=0
.endif

; CHANGE THIS IF YOU WISH. Controls timeout inside this bootloader waiting for byte from UART
.equ	PCLOOPHZ = ((clock / 5) / 65536)	; Timeout loop's 16 bit counter part, in Hz
.equ	PCTIMEOUT	= PCLOOPHZ * 2	; desire is 0.5Hz outer loop (2 seconds)
							; 8 bits. An incrementing loop count for timeout waiting on PC to send download
							; 75 (decimal) gives 2 seconds with 14.746MHz crystal

 The other section of code is the actual definition. I have tried different things for the boot start with no success. Since this code compiles to 2k, I believe I need the 'SECONDBOOTSTART'. Like I said, I have tried many combinations, but this is presently how  the code looks:

#ifdef _M128DEF_INC_	; is within the chosen include file
;==========================================================
;==================== mega128 =============================
;==========================================================
; UART baud rate setup constant- formula varies by chip type
; where this bootloader code begins, Change if this code outgrows 512 bytes
.equ	MYORG =	SECONDBOOTSTART ; NOTE! This chip doesn't support a boot memory area as small as 512Bytes; see fuses for it
.equ	UBRRLval = (clock - 8 * bootldr_baud) / (16 * bootldr_baud) ;the 8* part helps rounding
;--- device code and signature bytes for a atmega8 with bootloader
.equ 	DT  	= 0x44	; atmega bootloader
; Chip-dependent names for UART0 registers (See Table, below)
.set	BAUDL 	=UBRR0L		; baud rate low order bits
.set	UARTC	=UCSR0B		; control
.set	USTAT	=UCSR0A		; status
.set	UDATA	=UDR0		; data I/O register
.set	URXC	=RXC0		; rx char complete status bit number (data has arrived)
.set	UTXE	=UDRE0		; tx data register is empty
.set	UTXC	=TXC0		; tx complete status bit number
; values to use in configuring UART0
.set	UARTENA	=((1<<RXEN0) | (1<<TXEN0))	; enable tx,rx for uart 0 or 1 (see table)
.MACRO BOOTIDSTRING 
 	.DB "Mega128", 0	; change this 7 char string.  bootloader ID string, information-only to PC

.ENDMACRO
;=========================================================
#endif

The fuses I use are the following:

  • LOW: 0x3F
  • HIGH: 0x9C
  • EXT: 0xFF

 

I use an online fuse calculator and I have attached the definitions of the fuses in the 'fuse.png' image below.

 

Finally, I use USBasp with eXtreme burner - AVR to program the fuses and the flash. The current configuration starts the bootloader in flash at the byte address 01F800 (see attached image 'eXtreme.png'), which I believe is FC00 in words, which should be correct with my fuses and the hex file created from the assembly code. To be honest, I have looked at many forums trying to figure out how this works, and have gotten many answers, but I still am unable to get this to work. One forum discussed that he couldn't get the bootloader to work after switching to a 128A from a 128. This could be part of the problem, but Atmel says that there shouldn't be other differences besides power consumption and die size to my knowledge. Anyways, and help or ideas will be greatly appreciated. Thanks for your time.

Attachment(s): 

This topic has a solution.
Last Edited: Mon. Aug 31, 2015 - 01:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

EDIT - Added tags to the post

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1.  You should remove C13, C14.

2.  Make R100 1k0

3.  use avrdude.exe to control your USBASP.

 

4.  Use diff.exe to compare your edits with the original source code in the distribution.

5.  Remember that the Atmel AVRASM2 uses word addresses for the location counter.

 

David.

 

 

 

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

Thank you for the reply David.  Please see my notes below.

1.  You should remove C13, C14.

This is already done per the schematic. 

2.  Make R100 1k0

I have made this change. I assume this is more of a "best practice" type change?

3.  use avrdude.exe to control your USBASP.

Downloaded win-avr learned how to use AVRdude. It took much longer to program my chip, but 'lo and behold', I got farther than last time! I got an error about not finding the part description list. I fixed this error with this forum: http://www.avrfreaks.net/forum/how-change-xml-file-path. Then another issue was revealed about not finding the chip info xml file with the appropriate signature bytes. I found a solution on this forum located here: http://www.avrfreaks.net/forum/blips-and-avr-studio5-win7-64bit. I downloaded Atmel Studio 4 to get the proper xml files to work with BLIPS. It would be nice if these files were located somewhere for an easy download. They probably do, does anyone know where they exist? Anyways, it works! It takes a bit of time. This is probably due to my slow baud rate. I am going to try to tweak with these settings and see if I can get it to work any faster. Anyways. David, thanks for the help. You're the man!

Attachment(s): 

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

I have never used BLIPs.     It looks very frightening!

 

Regarding avrdude.exe and USBASP.     It just works.     Since the mega128 is a 'older' AVR,    it is well supported by all software.

avrdude is reliable software.

 

I am always wary of anything "Extreme".     Yes,   it might work with some chips and some commands.      I prefer to leave out the guesswork and use something that is reliable.

 

(2) was advised because the MAX232 (or FTDI) output is connected to RXD0.     The USBASP will be able to drive RXD0 pin when there is a 1k series resistor.     A USBASP will probably be ok with 100R,    but Atmel programmers would definitely be upset.

 

Since installing a bootloader is a one-off job,    time is not an issue.     Mind you,    if you had the software available,   it should only take about 2 seconds start to finish!

 

You do need to set up your BLIPs properly.    e.g.   sensible baud rate,   packet size,  etc.

I would expect a 'bootloaded app' to take 30 - 60 secs to upload.

 

David.