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.