Build Failed after configuring toolchain using USBasp for atmega64

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
------ Build started: Project: EMTestRun, Configuration: Debug AVR ------
Build started.
Project "EMTestRun.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "E:\EMTestRunDev\EMTestRun\EMTestRun\EMTestRun.cproj" (target "Build" depends on it):
	Using "RunCompilerTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync 
		Building file: .././boot_ld.c
		Invoking: AVR/GNU C Compiler : 4.3.3
		"C:\WinAVR-20100110\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG -DF_CPU = 16000000  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include"  -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall  -mmcu=atmega64  -c -std=gnu99 -MD -MP -MF "boot_ld.d" -MT"boot_ld.d" -MT"boot_ld.o"   -o "boot_ld.o" ".././boot_ld.c" 
E:\EMTestRunDev\EMTestRun\EMTestRun\Debug\Makefile(107,1): error: recipe for target 'boot_ld.o' failed
		avr-gcc.exe: =: No such file or directory
		avr-gcc.exe: 16000000: No such file or directory
		make: *** [boot_ld.o] Error 1
		make: *** Waiting for unfinished jobs....
		Building file: .././level3.c
		Invoking: AVR/GNU C Compiler : 4.3.3
		"C:\WinAVR-20100110\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG -DF_CPU = 16000000  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include"  -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall  -mmcu=atmega64  -c -std=gnu99 -MD -MP -MF "level3.d" -MT"level3.d" -MT"level3.o"   -o "level3.o" ".././level3.c" 
E:\EMTestRunDev\EMTestRun\EMTestRun\Debug\Makefile(107,1): error: recipe for target 'level3.o' failed
		avr-gcc.exe: =: No such file or directory
		avr-gcc.exe: 16000000: No such file or directory
		make: *** [level3.o] Error 1
		avr-gcc.exe: =: No such file or directory
		avr-gcc.exe: 16000000: No such file or directory
		make: *** [level2.o] Error 1
		Building file: .././level2.c
		Invoking: AVR/GNU C Compiler : 4.3.3
		"C:\WinAVR-20100110\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG -DF_CPU = 16000000  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include"  -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall  -mmcu=atmega64  -c -std=gnu99 -MD -MP -MF "level2.d" -MT"level2.d" -MT"level2.o"   -o "level2.o" ".././level2.c" 
E:\EMTestRunDev\EMTestRun\EMTestRun\Debug\Makefile(107,1): error: recipe for target 'level2.o' failed
		Building file: .././level4.c
		Invoking: AVR/GNU C Compiler : 4.3.3
		"C:\WinAVR-20100110\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG -DF_CPU = 16000000  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include"  -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall  -mmcu=atmega64  -c -std=gnu99 -MD -MP -MF "level4.d" -MT"level4.d" -MT"level4.o"   -o "level4.o" ".././level4.c" 
E:\EMTestRunDev\EMTestRun\EMTestRun\Debug\Makefile(107,1): error: recipe for target 'level4.o' failed
		.././level4.c: In function 'uart_putchar':
E:\EMTestRunDev\EMTestRun\EMTestRun\level4.c(316,1): warning: left shift count >= width of type
		.././level4.c: In function 'uart_transmit':
E:\EMTestRunDev\EMTestRun\EMTestRun\level4.c(418,1): warning: left shift count >= width of type
		avr-gcc.exe: =: No such file or directory
		avr-gcc.exe: 16000000: No such file or directory
		make: *** [level4.o] Error 1
	Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "EMTestRun.cproj" -- FAILED.
Done building project "EMTestRun.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

 

Can anyone tell me what went wrong here? I followed exactly what was in this blog: https://blog.manash.me/setting-u...

 

 

Azim

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1
-DF_CPU = 16000000

You can't have spaces in that. It should be:

-DF_CPU=16000000

So in the place where you defined preprocessor symbols remove extraneous spaces.

 

With the spaces you can see the errors it generated:

		avr-gcc.exe: =: No such file or directory
		avr-gcc.exe: 16000000: No such file or directory

So it took:

-DF_CPU = 16000000

to mean simply:

-DF_CPU

that is "define a symbol called F_CPU so it simply exists". Then the compiler comes to:

= 16000000

and does not know what to do with them. You could probably "solve" this with quotes too:

-D"F_CPU = 16000000"

but removing the spaces is almost certainly "better".

 

PS I followed the link to the blog you mentioned - don't see anything about defining F_CPU there, so why do you think that is relevant?

 

PPS the 16000000 should actually be 16000000UL

Last Edited: Fri. Nov 3, 2017 - 05:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That worked like a charm. But the warnings still remain. Remember I had posted once to create uart_transmit and uart_receive functions. I followed that blog to setup the USBasp. I thought that the build error was probably caused by making changes in the toolchain environment. But it turned out to be symbol definition error. (I followed that from a YouTube video. I had not defined the F_CPU since the beginning). Does it matter?(maybe a dumb question; the development board that we have uses a 16 MHz crystal)

 

Below is the code snippet were the warning is: I have commented them as -------> HERE: WARNING.

void UARTIni(void) { 
 
   // UCSRA is not necessary to set up, using initial values         
   // no double transmission speed, no multi-processor mode           

   UART_UCSRA = UART_UCSRA_INIT;
   UART_UCSRB  = UART_UCSRB_INIT; 
                       // set up : RXCIE, UDRIE, RXEN, TXEN           
                       // (interrupt enable from receiver,            
                       // UART receiver enable, UART transmit enable) 

   UART_UCSRC = UART_UCSRC_INIT; 
                       // asynchronous operation, 8 data bits,        
                       // no parity, 1 stop bit                       

   UART_UBRRL = UART_SPEED; // baud rate - see UBRR register setting table 
                       //             in AVR ATmega8 specification    
                       // UBRRH - using initial values                
                       // UBRRL - 25 for 38k4Bd and frequency f=16 MHz 
                       // (using SINGLE transmission speed)           

  uart_in_read = uart_in_write = uart_in_end = 0;
  uart_out_read = uart_out_write = uart_out_end = 0; 
  uart_state = UART_EMPTY;
  
  stdout = stdin = &uart_str; //uart serial printing
  
} 

//printf/scanf //uart serial printing function definitions --------> inserted by Azim

int uart_putchar(char c, FILE *stream)
{

	if (c == '\a')			//'\a'
	{
		fputs("*ring*\n", stderr);
		return 0;
	}

	if (c == '\n')			//
	uart_putchar('\r', stream);
	loop_until_bit_is_set(UART_UCSRA, UART_UDRE);//--------> HERE: WARNING
	UART_UDR = c;

	return 0;
}

//Inserted by Azim
int uart_getchar(FILE *stream)
{
	uint8_t c;
	char *cp, *cp2;
	static char b[UART_IN_BUFFER_SIZE];
	static char *rxp;

	if (rxp == 0)
	for (cp = b;;)
	{
		loop_until_bit_is_set(UART_UCSRA, RXC);
		if (UART_UCSRA & _BV(FE))
		return _FDEV_EOF;
		if (UART_UCSRA & _BV(DOR))
		return _FDEV_ERR;
		c = UART_UDR;
		//behaviour similar to Unix stty ICRNL
		if (c == '\r')
		c = '\n';
		if (c == '\n')
		{
			*cp = c;
			uart_putchar(c, stream);
			rxp = b;
			break;
		}
		else if (c == '\t')
		c = ' ';

		if ((c >= (uint8_t)' ' && c <= (uint8_t)'\x7e') ||
		c >= (uint8_t)'\xa0')
		{
			if (cp == b + UART_IN_BUFFER_SIZE - 1)
			uart_putchar('\a', stream);
			else
			{
				*cp++ = c;
				uart_putchar(c, stream);
			}
			continue;
		}

		switch (c)
		{
			case 'c' & 0x1f:
			return -1;

			case '\b':
			case '\x7f':
			if (cp > b)
			{
				uart_putchar('\b', stream);
				uart_putchar(' ', stream);
				uart_putchar('\b', stream);
				cp--;
			}
			break;

			case 'r' & 0x1f:
			uart_putchar('\r', stream);
			for (cp2 = b; cp2 < cp; cp2++)
			uart_putchar(*cp2, stream);
			break;

			case 'u' & 0x1f:
			while (cp > b)
			{
				uart_putchar('\b', stream);
				uart_putchar(' ', stream);
				uart_putchar('\b', stream);
				cp--;
			}
			break;

			case 'w' & 0x1f:
			while (cp > b && cp[-1] != ' ')
			{
				uart_putchar('\b', stream);
				uart_putchar(' ', stream);
				uart_putchar('\b', stream);
				cp--;
			}
			break;
		}
	}

	c = *rxp++;
	if (c == '\n')
	rxp = 0;

	return c;
}

//function to transmit -- inserted by Azim
void uart_transmit (unsigned char data)
{
	while (!(UART_UCSRA & (1<<UART_UDRE)));                // wait while register is free //----->HERE: WARNING
	UART_UDR = data;                                   // load data in the register
}
	
 //function to receive -- inserted by Azim
unsigned char uart_recieve (void)
{
	while(!(UART_UCSRA & (1<<RXC)));                   // wait while data is being received
	return UART_UDR;                                   // return 8-bit data
}

Attachment(s): 

Amateur programmer.
Believe when I tell you that my struggle on here is real.

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

azimmali wrote:
loop_until_bit_is_set(UART_UCSRA, UART_UDRE);//--------> HERE: WARNING

 

What is the warning?   BTW: I did not see where the two constants were defined!

 

Jim

 

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

Warning        left shift count >= width of type       316

Warning        left shift count >= width of type       419

 

 

 

Which constants are you referring to?

 

 

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
sfr_defs.h:#define loop_until_bit_is_set(sfr, bit) do { } while (bit_is_clear(sfr, bit))

and from there:

sfr_defs.h:#define bit_is_clear(sfr, bit) (!(_SFR_BYTE(sfr) & _BV(bit)))

also:

#define _BV(bit) (1 << (bit))

There is an argument to say that to be "safe" that "1" should have been "1UL" but I think the author here never expected "bit" to be out of the range 0..7

 

So I guess we do need to know how:

UART_UDRE

is defined. I suspect it is not what you think it is.

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

UART_UDRE has been defined as

 #define UART_UDRE     (1<<UDRE0)

 #define UART_UDRE     (1<<UDRE1)

 

 

UDRE is a flag bit in the USART control and status register. Indicates if the transmit buffer is empty to receive or not. If UDREn is 1, the buffer is empty and ready to be written.

I had inserted the putchar and getchar you see in the code. Also the uart_transmit and uart_receive. I suspect it could be the usage of the UCSR register. I may have defined the transmit and receive functions twice. No clue. I just build the project. No errors and no warnings! WEIRD.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

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

Go on. The bit_is_set() macro requires a bit number and NOT a bit mask.

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

Well, it is using a bit number, no? The flag bits are either 1 or 0.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

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

Welcomed by the same warnings early morning.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

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

Well, it is using a bit number, no?

I fear you have missed David's point:

C:\SysGCC\avr\avr\include\avr>grep UDRE0 iom64.h
#define    UDRE0        5

In this case:

#define UART_UDRE     (1<<UDRE0)
#define UART_UDRE     (1<<UDRE1)

means UART_UDRE is defined as:

#define UART_UDRE     (1<<5)

so it has the value 0x20 or 32. Later you use:

loop_until_bit_is_set(UART_UCSRA, UART_UDRE);//--------> HERE: WARNING

which means you are trying to use:

loop_until_bit_is_set(UART_UCSRA, 32);//--------> HERE: WARNING

There is no bit number 32 in the 8bit UCSRA register. What's more, as I showed previously this loop_until_bit_is_set() macro ultimately ends up using _BV:

#define _BV(bit) (1 << (bit))

and you are passing 32 to this. So it's doing

(1 << 32)

1 shifted 32 bits to the left is an astronomically huge number. What's more this is an integer constant so it has to fit into "int". Well int for AVR is -32768 to +32767. 1<<32 is actually 4,294,967,296 and that won't fit in an AVR sized "int". So you get:

warning: left shift count >= width of type

What you were supposed to use was:

loop_until_bit_is_set(UART_UCSRA, UDRE);//--------> HERE: WARNING

without the UART_ prefix on UDRE. That is now the equivalent of:

loop_until_bit_is_set(UART_UCSRA, 5);//--------> HERE: WARNING

That will work.

 

Seems like you were trying to be "too clever" with your use of macros.

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

I understood that so well. Thank you so much Clawson.smiley.

Amateur programmer.
Believe when I tell you that my struggle on here is real.