Assembler Errors

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

Hello all. I am trying to assemble the BLIPS_bootloader with AVR Studio for an ATMEGA324P. This is my first time using AVR Studio and I am not very good at assembly (I normally use WINAVR).

Here is the error from the assembler:

Quote:
AVRASM: AVR macro assembler 2.1.17 (build 435 Apr 10 2008 09:27:55)
Copyright (C) 1995-2008 ATMEL Corporation

C:\Working\Bootloader\BLIPS_Bootloader.asm(75): Including file 'C:\Program Files\Atmel\AVR Tools\AvrAssembler2\Appnotes\m324Pdef.inc'
C:\Working\Bootloader\BLIPS_Bootloader.asm(911): warning: end of .cseg at 0x800a is beyond end of memory at 0x7fff
C:\Working\Bootloader\BLIPS_Bootloader.asm(550): error: elpm r16, z+: Unsupported instruction on ATmega324P
C:\Working\Bootloader\BLIPS_Bootloader.asm(553): error: elpm r16, z+: Unsupported instruction on ATmega324P
C:\Working\Bootloader\BLIPS_Bootloader.asm(704): error: elpm r24, z+: Unsupported instruction on ATmega324P
C:\Working\Bootloader\BLIPS_Bootloader.asm(705): error: elpm r16, z+: Unsupported instruction on ATmega324P
C:\Working\Bootloader\BLIPS_Bootloader.asm(807): error: elpm r16, z+: Unsupported instruction on ATmega324P
C:\Working\Bootloader\BLIPS_Bootloader.asm(864): error: Undefined symbol: EEMWE
C:\Working\Bootloader\BLIPS_Bootloader.asm(866): error: Undefined symbol: EEWE
C:\Working\Bootloader\BLIPS_Bootloader.asm(911): No EEPROM data, deleting C:\Working\Bootloader\BLIPS_Bootloader.eep

Would someone be kind enough to help me get this file assembled?

Attachment(s): 

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

I fixed the last two errors by adding:

.set	EEMWE	=EEMPE
.set	EEWE	=EEPE
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'll take a look at it for you.

How do you intend to program the device?

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

I just looked,

Quote:
; Test status
; mega8: tested
; mega16: tested
; mega32: tested
; mega128: tested
; mega168 tested
; m8535: tested

It nowhere mentions your avr, so the errors you are getting are normal. You will need to modify the code to instructions your avr understands, or just simply purchase the compatible chip. I would simply buy the right micro unless there is an underlying issue I am missing.

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

Thank you for the help. I am already married to the ATMEGA324P.

One thing I don't understand, why doesn't it like elpm? elpm is listed in the MEGA324P datasheet under instruction set summary.

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

HMMMM Lemme go take a peek

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

Why would ELPM need to be used on a 32K AVR?

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

Thats exactly what I want to know. If you find out please tell me.

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

Presumably the code has something like:

#ifdef AVR_UNDER_64K
 LPM
#else
 ELPM
#endif

In which case that has wrongly identified your AVR

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

Actually it has

#ifdef RAMPZ 
 LPM 
#else 
 ELPM 
#endif 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Success. If I comment out RAMPZ in the file "m324Pdef.inc" then it assembles just fine.

Is there a cleaner way? I am not very good at preprocessor directives.

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

you have listed the code backwards in your last post

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

Funny,
I tried assembling it with version 2 and got the errors, I assembled it with version 1 and it was only annoyed with the duplicate macro symbols.

jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

I think that the root problem is the fact that the MEGA324P has a RAMPZ register but it doesn't actually use it. Someone please correct me if I am wrong.

The original author of the code assumed that if the RAMPZ registar exists, then the mcu required extended memory access.

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

You might be on to something there, but the datasheet does list it as a valid opcode. The funny thing is that if you click on the assembler help menu item, then scroll down, there is no mention of the mega324p anywhere.

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

jgmdesign wrote:
you have listed the code backwards in your last post

Jim

Yes you are right. I just copied what clawson wrote and modified it incorrectly.

Here is an actual quote from the code:

.ifdef RAMPZ	; as on mega128
		ldi		R16,(1 << RAMPZ0)	; 128MB Flash
		out		RAMPZ,R16			; string is in 2nd 64K block
		elpm	R16,Z+	
.else
		lpm 	R16,Z+
.endif
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why don't you semicolon out those sections and see if the code assembles, and even more importantly....works?

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

Jim:

I think you might have missed one of my previous posts. I did get it assembled by commenting out

.equ	RAMPZ	= 0x3b

in the file "m324Pdef.inc".

Thanks for your help Jim and clawson. I appreciate it. I will let you know if I can get the bootloader to work.

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

Your welcome!!

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

Looking for instances of ELPM and RAMPZ occuring in data sheets for ATmega devices with 64K Bytes or less of flash memory revealed the following.

_________________________________________________________

Done Right!

ATmega640/1280/1281/2560/2561 data sheet doc2549L

29.5 Addressing the Flash During Self-Programming
... Note that the RAMPZ register is only implemented when the program
space is larger than 64K bytes.

34. Instruction Set Summary
[Table]
"Note: ELPM does not exist in ATmega640."

_________________________________________________________

ATmega644 data sheet doc2593m

24.8.13 Simple Assembly Code Example for a Boot Loader - Includes sample code with ELPM.

29. Instruction Set Summary - Includes ELPM in the instruction set table with no qualifications.

33. Datasheet Revision History
33.11 Rev. 2593C - 03/06

2. Removed RAMPZ– Extended Z-pointer Register for ELPM/SPM from datasheet.

_________________________________________________________

ATmega164P/324P/644P data sheet doc8011i

"(E)LPM" occurs 24 times in the data sheet.
"ELPM" occurs 3 times in text outside of tables and sample code.
"RAMPZ" occurs 5 times in text outside of tables.

6.5.2 RAMPZ - Extended Z-pointer Register for ELPM/SPM

25.7 Addressing the Flash During Self-Programming
The Z-pointer is used to address the SPM commands. The Z pointer consists of the Z-registers
ZL and ZH in the register file, and RAMPZ in the I/O space. The number of bits actually used is
implementation dependent. Note that the RAMPZ register is only implemented when the program
space is larger than 64K bytes.

[Figure/Table detailing RAMPZ, ZH (R31), ZL (R30)]

...

The (E)LPM instruction use the Z-pointer to store the address. Since this instruction addresses
the Flash byte-by-byte, also bit Z0 of the Z-pointer is used.

25.8.13 Simple Assembly Code Example for a Boot Loader - Includes sample code with ELPM.

29. Register Summary - At location 0x3B (0x5B) the RAMPZ register is specified for Bit 0 - RAMPZ0.

30. Instruction Set Summary - Includes three variations of the ELPM instruction with no qualifications.

_________________________________________________________

These part description .xml files appear to erroneously define the RAMPZ register for devices with 64K Bytes or less of flash memory.

Location: C:\Program Files\Atmel\AVR Tools\Partdescriptionfiles

ATmega164P.xml --- RAMPZ at $3B ($5B) with Bit0=RAMPZ0
ATmega324P.xml --- RAMPZ at $3B ($5B) with Bit0=RAMPZ0
ATmega644P.xml --- RAMPZ at $3B ($5B) with Bit0=RAMPZ0
ATmega644.xml --- RAMPZ at $3B ($5B) with Bit0=RAMPZ0
ATmega640.xml --- RAMPZ at $3B ($5B) with Bit1=RAMPZ1, Bit0=RAMPZ0, EIND at $3C ($5C)
_________________________________________________________

These definition .def files files appear to erroneously define the RAMPZ register for devices with 64K Bytes or less of flash memory.

Located at: C:\Program Files\Atmel\AVR Tools\AvrAssembler2\Appnotes

m164Pdef.inc --- .equ RAMPZ = 0x3b, .equ RAMPZ0 = 0
m324Pdef.inc --- .equ RAMPZ = 0x3b, .equ RAMPZ0 = 0
m644Pdef.inc --- .equ RAMPZ = 0x3b, .equ RAMPZ0 = 0
m644def.inc --- .equ RAMPZ = 0x3b, .equ RAMPZ0 = 0
m640def.inc --- .equ RAMPZ = 0x3b, .equ RAMPZ0 = 0, .equ RAMPZ1 = 1, .equ EIND = 0x3c
_________________________________________________________

Do these registers actually exist on these ATmega devices?

I've emailed this information to avr@atmel.com.

Stan

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

Hi Stan,

I have filed a bug (#8291) on the issue with the XML part descriptions for these devices. (the assembler include files are machine-generated from the XML part description files and hence have the same bug).

Thank you for reporting it.

- roland

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

Update: After troubleshooting some baud rate problems I got the bootloader to work with the BLIPS gui. Thanks again.