Blips4 Bootloader - Mega164

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

Ok so im trying to compile this bootloader on my mega164P and the documentation is kinda lacking on how to add your chip properly.

I edited these things in the .asm

.INCLUDE "m164Pdef.inc"
.equ	clock 	        = 8000000
.equ	bootldr_baud	= 19200

#ifdef _M164PDEF_INC_
;--- device code and signature bytes
.equ 	DT  	= 0x09 ; atmega bootloader

; values to use in configuring UART
.set	BAUDL 	=UBRR0L
.set	UARTC	=UCSR0B
.set	USTAT	=UCSR0A
.set	UDATA	=UDR0
.set	URXC	=RXC0
.set	UTXE	=UDRE0
.set	UTXC	=TXC0
.set	UARTENA	=((1<<RXEN0) | (1<<TXEN0))
.MACRO BOOTIDSTRING 
 	.DB "Mega164", 0
.ENDMACRO
; .set	SPMEN = SELFPRGEN
.set	EEMWE = EEMPE
.set	EEWE = EEPE
#endif

Now the top three are easy. Got the 19200baud from a chart 0.2% error rate. I dont know what to put in as the device string as the datasheet is for the mega644 and out of the 3 bytes im assuming its the right hand one I wanted.

I get these compile time errors:
-I commented out SPMEN as it said "Invalid redefinition of 'SPMEN'"
-elpm R16, Z+ Unsuported instruction on atmega164P
-End of .cseg at 0x400a is beond end of memory 0x3fff

I have never used a bootloader before and I do not understand asm without a headache so im unsure what to do here.

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

deleted by dumb author

Last Edited: Tue. Aug 18, 2009 - 05:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Will the Mega64 setup work on a Mega164? I though it was a Mega16 + some features.

I say this because that Mega64 code section gives all the same errors....

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

oops. My error.
Let me work and repost.
Unless someone else has done so already for the '164

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

frostblu3710 wrote:
Will the Mega64 setup work on a Mega164? I though it was a Mega16 + some features.

Atmel's file m164Pdef.inc in the current version of AVR Studio correctly omits the RAMPZ definition. In prior versions, RAMPZ was incorrectly present. BLIPS asm code uses RAMPZ to decide on use of ELPM in chips with larger than 64KB flash.

This set of definitions for the mega164P assembles OK for me. Please test and let me know (I have no 164P chip).

.INCLUDE "m164Pdef.inc"	; <<< CHANGE THIS according to chip type

...

#ifdef _M164PDEF_INC_ ; is within the chosen include file
;==========================================================
;==================== mega164P =============================
;==========================================================
; 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 ; 
.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   = 0x09 ; 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 "Mega164", 0 ; change this 7 char string.  bootloader ID string, information-only to PC
.ENDMACRO
;.set	SPMEN	=SELFPRGEN		;SPMEN to SELFPRGEN
.set	EEMWE	=EEMPE			;EEMWE to EEMPE
.set	EEWE	=EEPE			;EEWE to EEPE
;=========================================================
#endif

and the memory map is

ATmega164P memory use summary [bytes]:
Segment   Begin    End      Code   Data   Used    Size   Use%
---------------------------------------------------------------
[.cseg] 0x003e00 0x003ff8    496      8    504   16384   3.1%
[.dseg] 0x000100 0x000100      0      0      0    1024   0.0%
[.eseg] 0x000000 0x000000      0      0      0     512   0.0%

Assembly complete, 0 errors, 0 warnings
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the changes.

How do I disable RAMPZ? I did a search for that string and only find .ifdef RAMPZ and had to remove all the ifdef and make the else standard to get it to compile.

My memory map:

ATmega164P memory use summary [bytes]:
Segment   Begin    End      Code   Data   Used    Size   Use%  Warn
--------------------------------------------------------------------
[.cseg] 0x003e00 0x004006    510      8    518   16384   3.2%  OVER
[.dseg] 0x000100 0x000100      0      0      0    1024   0.0%
[.eseg] 0x000000 0x000000      0      0      0     512   0.0%

and my code below:
(Latest edition of Blips from this sites download & Updated AVRStudio)

Attachment(s): 

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

RAMPZ is correctly absent in the most recent Atmel files. Use the latest Studio download.

In earlier versions, it was present. It should be absent from ateml's files, for chips with 64KB or less of flash.