debug problem

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

Hi everybody.
On the next code, when I'm debugging, I got an error when the simulator reach the cos line.

#include 
#include 
#include 

double		RADIUS=0;
double		LONG=150;
double		ANGLE=0.2;

#define PI 3.1415926535897932384626433832795

int main(void)
{
    while(1)
    {
		RADIUS = cos(ANGLE);
		RADIUS = RADIUS/PI;
		RADIUS = RADIUS*180;
		RADIUS = RADIUS*LONG;
//		RADIUS = LONG*(180*cos(ANGULO)/PI);
    }
}

AS5 says:

Quote:

"No source available"
Call stack location: radious.elf! _mulsf3 Line:949

and if I go to the disassembly view, It's looking for a file located at:
Quote:

C:\home\tools\hudson\workspace\avr8-gnu-toolchain\build-win32_x86\avr-gcc-full\gcc\fp-bit.c

(that path is not mine)

I'm mistaking on the code?

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

Ah this is now known as the "Hudson" problem (search for it). Bottom line the libs were built by an idiot who forgot the "avr-strip -g" at the end. So you just need to run that same command on your local libm.a and libgcc.a

By the way I bet you aren't linking libm.a either - because Atmel screwed that bit too!

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

just libm.a and libgcc.a ??
I already did it but still have the problem...
by the way....I'm getting old doing that on every directory that appears libm and libgcc.
¿is there any fast method to do that on windows?
something similar as you suggested on linux...???

find . -name \*.[ao] -exec avr-strip -g {} ; 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, solved, somehow, the variables tags was generating the problem again.
After eliminate the tags and put them again, the debugger start working fine.
thanks!!

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

Quote:

Bottom line the libs were built by an idiot who forgot the "avr-strip -g" at the end.

Careful now, Cliff.. Some very well respected men has been known to make that mistake, IIRC.. :wink:

But I'll say this: We should not see this problem again in the AVR Toolchain, since once you discover a build mishap you fix it in the automated build sequence that Hudson manages and runs. If that does not happen then I'd fall in and agree with you..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Quote:

ok, solved, somehow, the variables tags was generating the problem again.
After eliminate the tags and put them again, the debugger start working fine.
thanks!!

I don't understand what you mean - what are "tags"?

For the record this works using the find.exe that comes with WinAVR:

find . -name \*.[ao] -exec avr-strip -g {} ";"

Note the only difference there from "normal" syntax is that the semi-colon is double-quoted.

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

It should also be noted that since the original code does nothing useful the optimizer (if activated) will most likely throw all of the code out.

OTOH, since "Hudson" is involved this hints at AS5 also, where the optimizer is de-activated by default.

-----

I am also wondering about the expression "variables tags"..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Quote:

"Hudson" is involved this hints at AS5

Just being pedantic but it hints at "AVR Toolchain" in fact but I guess that's most likely found bolted onto the back end of AS5.

(the post in AS5 forum might be the stronger clue ;-))

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

Quote:

the post in AS5 forum might be the stronger clue

Messerschmidt'er..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

clawson wrote:

For the record this works using the find.exe that comes with WinAVR:

find . -name \*.[ao] -exec avr-strip -g {} ";"

Quote:

I wish I had read that line yesterday!!!
anyway, good to know that the find command is available with WinAVR.

By tags, I mean those similar to "postit tags" that you can paste over the debug session and contains the name of a variable and the current value (hex, decimal)...something like the "watch window" but you can post it all over the code.

--

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

test

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

Quote:

test

that worked (but I bet your % signs didn't ;-))

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

jaja, sorry, I was trying to do a post and the server wasn't allowing me.

Few hours ago, I was getting an error when compiling, (an error unknown for me at this moment), but when I paste the error here to ask you, the hudson guy appear in the path....
This time, using the find command as you suggested, run it and fix all .a and .o files...
now.... I still can't compile, but there are no errors (a step forward I think) ....
but the compiler exit with the next message:

Quote:
"C:/Archivos de programa/Atmel/AVR Studio 5.0/extensions/Application/Avr ToolChain/bin/avr-gcc.exe" -mmcu=atmega2560 -o Cons_2.elf Arduino_Core/pins_arduino.o Arduino_Core/WInterrupts.o Arduino_Core/wiring.o Arduino_Core/wiring_analog.o Arduino_Core/wiring_digital.o Arduino_Core/wiring_pulse.o Arduino_Core/wiring_shift.o Cons_2.o Gru/Gru.o
c:/archivos de programa/atmel/avr studio 5.0/extensions/application/avr toolchain/bin/../lib/gcc/avr/4.5.1/../../../../avr/lib/avr6\libc.a(fp_powsodd.o): In function `__fp_powsodd':
(.text.avr-libc.fplib+0x10): relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in c:/archivos de programa/atmel/avr studio 5.0/extensions/application/avr toolchain/bin/../lib/gcc/avr/4.5.1/avr6\libgcc.a(_mul_sf.o)
c:/archivos de programa/atmel/avr studio 5.0/extensions/application/avr toolchain/bin/../lib/gcc/avr/4.5.1/../../../../avr/lib/avr6\libc.a(fp_powsodd.o): In function `__fp_powsodd':
(.text.avr-libc.fplib+0x20): relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in c:/archivos de programa/atmel/avr studio 5.0/extensions/application/avr toolchain/bin/../lib/gcc/avr/4.5.1/avr6\libgcc.a(_mul_sf.o)
collect2: ld returned 1 exit status

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

Another Atmel screw up - they don't link libm.a by default so you get the crap out of libc.a instead.

So just add libm.a to the libraries to be linked and this error should evaporate.

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

And the problem is solved.... thanks!

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

any way to do this permanently? (I added on the project properties)
now, every time I create a new project, I have to add it to the libraries...

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

Quote:

now, every time I create a new project, I have to add it to the libraries...

Petition Atmel to solve this and hope they listen in the next issue of AS5

(don't hold your breath - I first raised this as an issue against AS4 about 5+ years ago - still nothing).

A solution they might like to consider is that rather than holding a default Makefile template within the code of AS5 they actually make that template editable by the user. That way we could all arrange for the default project settings to be the way we like them (-O0 for "Debug" is nutty for example).

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

just few minutes ago, I was compiling a code containing a function modf() and the library math.h was not included.
I realise that, after doing a debug session because I was seeing lot of trash on the variables...
And the compiler don't care about...any warning, nothing.
If I step over modf with the mouse...(no info at all)
I thought that AS5 is not reliable, but when I move to the version 4, found that:

Quote:
(.text.avr-libc.fplib+0x20): relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr5\libgcc.a(_mul_sf.o)

This is almost the same message before, (exept the path with HUDSON is not present)

I want to give a finish to all this crap... I need a stable platform to compile, and all this is :twisted: :twisted: :twisted: :twisted: me

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

Did you link with libm.a in your AVR Studio 4 project, then?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Now I did....
Why is that?
the avr-strip command only afects the avr studio 5 toolchain right?

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

Quote:

This is almost the same message before, (exept the path with HUDSON is not present)

Don't mix your problems. The "hudson" problem only affects "toolchain" (the compiler in AS5) and is simply because someone forgot to strip symbols when they built the library. You will also see this with AS4 *if* you have it configured to use that same toolchain (and it's not stripped yet). As long as AS4 is using WinAVR you should not see prompts to locate library source files.

The other problem is typified by the appearance of R_AVR_13_PCREL when using math.h functions *if* you are not linking with libm.a. As I say the default for both As4 and AS5 is to *not* list libm.a in the link so you are likely to get this error in either (worse if you don't get it you will actually be using horrendous and error prone math library code)

So (a) if you suspect your libs contain symbols then avr-strip -g them (do this just once and for all until the next problematic install) and (b) always but always make sure "-lm" is listed on the end of the link for every GCC program you ever write. It does nothing if you don't use math but it's absolutely vital if you do.

(and one day someone at Atmel will finally recognize this fact!)

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

Quote:

and one day someone at Atmel will finally recognize this fact!

I still admire your sense of irony, Cliff..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Hi,

I'm using an ATMEGA16 chip for my senior design project and I have the same problem (hudson) as I'm working on interfacing the uC with an LCD. I just started learning about atmel and AVR studio 5. I read your posts and figured out how to "link libm.c" but I don't understand what you mean by "you just need to run that same command on your local libm.a and libgcc.a" how do I do that ?

Thanks

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

Quote:

I don't understand what you mean by "you just need to run that same command on your local libm.a and libgcc.a" how do I do that ?

Did you not read this post above:

https://www.avrfreaks.net/index.p...

Issue that command in a command prompt with ...\AVR Toolchain\avr\lib as the current directory.

That is something like:

C:\Program Files\Atmel\AVR Studio 5.0\AVR Toolchain\avr\lib>find . -name \*.[ao] -exec avr-strip -g {} ";"

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

Before you do the procedure that Cliff says, you have to ad libm.a to the libraries.

On AVR Studio this is done like this:

Project -> [name of the project] Properties TAB ->
-> look for the Toolchain TAB ->
then under AVR/GNU C linker look for the tab called Libraries ->
and for last, inside the first blank box, add libm.a

and finish..

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

Quote:

Before you do the procedure that Cliff says, you have to ad libm.a to the libraries.

No those two things are completely unconnected. You do need to do both but it doesn't matter what order. The find/strip should only ever need to be done once. The addition of libm.a o the project should be done for every new solution you start.

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

When I type C:\Program Files\Atmel\AVR Studio 5.0\AVR Toolchain\avr\lib>find . -name \*.[ao] -exec avr-strip -g {} ";" in the cmd.exe, I get a bunch of find: avr-strip: Invalid argument and C:\Program Files\Atmel\AVR Studio 5.0\AVR Toolchain\avr\lib> at the end....

Is that what it's supposed to do?

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

Show a screen dump of that - there's a lot of punctuation in that command and if you get even a single symbol or space wrong it will not work as expected.

You may want to add an additional -print in there as follows which gives more output about what find is doing. It should look something like this:

Attachment(s): 

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

Quote:

When I type [...]

Clawson typed for you. Your computer operating system has cut/paste functionality. Use it.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Guys, debugging the code below, I can't see the variables changing on the "watch view"
It's not a delay update problem, because added several assignations and the variable is not updated.
Already restarted the machine... etc..
I want to use AVR simulator and ATmega164
Any idea of possible solutions?
thanks

#include 
uint16_t x1;
uint16_t y2;
uint8_t INTEGER_8;

extern uint16_t x1=1;
extern uint16_t y2=2;
extern uint8_t INTEGER_8=3;



int main(void)
{
    while(1){
		x1=0x0008;
		y2=0x0103;
	
		x1 +=1;
		INTEGER_8=0x13;
		y2=8; 
		x1=8;
		x1+=2;

		for (INTEGER_8 = 142; INTEGER_8 < 160; INTEGER_8++) {
				x1 +=16;
				if (x1 > 185) { 
					x1 = 0;
					y2 +=16;
				}
		}	

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

Read this

Bottom line: if you are going to try running pointless programs then make the variables temporarily volatile.

As it stands your entire program is:

int main(void)
{
  82:	ff cf       	rjmp	.-2      	; 0x82 

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

that was very helpful, thanks

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

clawson wrote:
Show a screen dump of that - there's a lot of punctuation in that command and if you get even a single symbol or space wrong it will not work as expected.

You may want to add an additional -print in there as follows which gives more output about what find is doing. It should look something like this:

Attachment(s): 

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

clawson wrote:
Show a screen dump of that - there's a lot of punctuation in that command and if you get even a single symbol or space wrong it will not work as expected.

You may want to add an additional -print in there as follows which gives more output about what find is doing. It should look something like this:

Would you by any chance know about interfacing atmega16 with an lcd display? i'm programming my chip with fuses set to 99-E1 using an internal 1mhz clock and on my breadboard nothing's plugged to xtal1/xtal2, just a resistor going from pin 9 to reset...when I debug everything works fine but the lcd is not even cleared...

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

Here's the code I'm using:

#include
#include
#define F_CPU 1000000UL 
#define LCD_DATA PORTA		// LCD data port
#define ctrl PORTC
#define en PC2		// enable signal
#define rw PC1		// read/write signal
#define rs PC0		// register select signal00000000000000
 
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);

 
int main()
{
    while(1){
	MCUCSR|=(1<<JTD);		// sendig 1 to JTD
	MCUCSR|=(1<<JTD);
	DDRA=0xff;		// making LCD_DATA port as output port
	DDRC=0x07;		// making signal as out put
	init_LCD();		// initialization of LCD
	_delay_ms(50);		// delay of 50 milli seconds
	LCD_write('NEVILLE');		// call a function to write A on LCD
	}	
	
	return 0;   //TODO:: Please write your application code 
}
 
void init_LCD(void)
{
	LCD_cmd(0x38);		// initialization of 16X2 LCD in 8bit mode
	//for (int i = 0; i<5; i++)
	_delay_ms(1);
 
	LCD_cmd(0x01);		// clear LCD
	//for (int i = 0; i<5; i++)
	_delay_ms(1);
 
	LCD_cmd(0x0E);		// cursor ON
	//for (int i = 0; i<10; i++)
	_delay_ms(1);
 
	LCD_cmd(0x80);		// ---8 go to first line and --0 is for 0th position
	//for (int i = 0; i<10; i++)
	_delay_ms(1);
	return;
}
 
void LCD_cmd(unsigned char cmd)
{
	LCD_DATA=cmd;
	ctrl =(0<<rs)|(0<<rw)|(1<<en);	// RS and RW as LOW and EN as HIGH
	//for (int i = 0; i<20; i++)
	_delay_ms(50);
	ctrl =(0<<rs)|(0<<rw)|(0<<en);	// RS, RW , LOW and EN as LOW
	//for (int i 0= 0; i<20; i++)
	_delay_ms(50);
	return;
}
 
void LCD_write(unsigned char data)
{
	LCD_DATA= data;
	ctrl = (1<<rs)|(0<<rw)|(1<<en);	// RW as LOW and RS, EN as HIGH
	//for (int i = 0; i<5; i++)
	_delay_ms(1);
	ctrl = (1<<rs)|(0<<rw)|(0<<en);	// EN and RW as LOW and RS HIGH
	//for (int i = 0; i<5; i++)
	_delay_ms(50);			// delay to get things executed
	return ;
}

$ Please use the CODE button when posting code to preserve format - JS $

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

Why are you putting EVERYTHING inside a while loop?

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

What's more why the 10 gazillionth attempt to roll your own. It's not as if there aren't lots of working HD44780 drivers to choose from. For a start the compiler/library comes with one that works really well and the irony is that the example is even written for ATmega16:

http://www.nongnu.org/avr-libc/u...

This rather suggest you never read the user manual!

Another widely respected one that's written for use with GCC is the Peter Fleury code which has more functionality and extra features like being able to spread all the data and control lines across different PORTs and pins:

http://homepage.hispeed.ch/peter...

Then I believe the famous Procyon Avrlib by Pascal Stang also includes HD44780 support (though I don't know much about this one):

http://www.procyonengineering.co...

So use one of those to prove your hardware wiring at the very least - maybe also compare (especially the init sequence) against your own code to see what you've done wrong (if anything).

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

Hello from year 2012!

I'm using standalone AVR 32-bit Toolchain (3.4.0) and have a problem with Mr. Hudson. Although, some has indicated that this has been fixed in the latest release of the Toolchain (3.4.0), the problem still exists for me. Maybe it was fixed only for the Toolchain that comes within Studio 6 -- Go figure.

Nevertheless, I tried to strip my Toolchain with the hybrid of find and avr-strip commands:

clawson wrote:

C:\Program Files\Atmel\AVR Studio 5.0\AVR Toolchain\avr\lib>find . -name \*.[ao] -exec avr-strip -g {} ";"

However, this did not work out. My find command was not working like Clawson's. It complained that
File not found - \*.[ao]

After struggling with the find, I found out that my find command was a "Microsoft version", and there wasn't "GNU version" inside my 32-bit Toolchain bin-folder. So I installed GnuWin32 and tried again. This time I was able to find files. However now avr-strip complains that it is unable to rename files, see the screenshot below. How to overcome this?

P.S. I know that there is version 6 of Atmel Studio. Furthermore, I decided to try stripping avr8 lib, before going any further with the 32-bit libs.

Attachment(s): 

Last Edited: Mon. Jul 30, 2012 - 10:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have permission to write in the Program Files folder? Are you running with administrator priviliges?

Atmel Studio 6 is also recommended since Studio 5 won't be maintained.

-- Bjarne

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

Sorry for the late response.

bjdrot wrote:
Do you have permission to write in the Program Files folder? Are you running with administrator priviliges?
No I hadn't and that fixed the problem. I have also made a Python script that might be more easy to use in Windows than find command, https://gist.github.com/4100575