Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: Странность при компиляции
Форум разработчиков электроники ELECTRONIX.ru > Микроконтроллеры (MCs) > AVR
Sirko
Вернее сказать странность некомпиляции.

Код
for(;;){
    evenFlag.Wait();
    u08 *data;
    u08 length = UART1_IsReceptionCompleate(data);

    UART1_TransmitData(data, length);

    u08 dataWeight[] = {0x03, 0x04, 0x76, 0xC1, 0x00, 0x02};
    UART0_TransmitData(dataWeight, 6);
    OS::Sleep(10);
    length = UART0_IsReceptionCompleate(data);
//    data[0] = 0;    
}

Вероятно я чего-то недопонимаю, но логики не вижу.
Суть проблемы в следующем:
если разкоментарить последнюю строчку, то все замечательно собирается. Но если переменная data не используется, то получается вот такая вот ерунда:
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51/crtm128.o: In function `__vector_default':
(.vectors+0x80): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_32' defined in .text.__vector_32 section in obj/Signal_UART.o
make: *** [exe/event_flag.elf] Error 1
Build failed with 1 errors and 6 warnings...
Причем не имеет значения, какие действия над переменной будут производиться, важен сам факт использования переменной data после строки "length = UART0_IsReceptionCompleate(data);".
Makefile взят из примера scmRTOS прот GCC

Сергей Борщ
Добавьте в LDFLAGS -Wl,-lm. Считайте это черной магией, или поищите в гугле или на форуме магические слова "relocation truncated to fit: R_AVR_13_PCREL"
Sirko
laughing.gif
Код
Build started 16.2.2011 at 08:50:49
======== Beginning of project event_flag processing
avr-gcc.exe (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

==== Link to event_flag.elf
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51/crtm128.o: In function `__vector_default':
(.vectors+0x80): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_32' defined in .text.__vector_32 section in obj/Signal_UART.o
make: *** [exe/event_flag.elf] Error 1
Build failed with 1 errors and 0 warnings...


#
# scmRTOS avr-gcc port
#
# project-dependent makefile for samples
#

# can change WinAVR version by setting AVRGCC variable here (override environment)
AVRGCC :=C:/WinAVR-20100110
#AVRGCC :=c:/kgp-avr/20071102
#AVRGCC :=c:/kgp-avr/20070928
#AVRGCC :=c:/WinAVR-20071221
#AVRGCC :=c:/WinAVR-20070525
#AVRGCC :=c:/WinAVR-20060421
#AVRGCC :=d:/mingw/local

# Y/N - !!! N for gcc < 4.x
MAKE_SMALLEST_HEX = Y

# point to start of project sources subtree,
PROJ_SRCTOP := .

#put the name of the target file here (without extension)
TRG = event_flag

# project modules (directories with source files)
# "current" directory (.) included automatically in gcc-avr.make
MODULES := ./src ../scmRTOS/Common ../scmRTOS/AVR
# needed for includes below
COMMON_MAKEFILES := ./makefiles

###########
# used in gcc-avr.make and avreal.make
MCU := atmega128
#MCU := atmega48
TRGPGMEXT := hex
#eep

# used in avreal.make and transferred to source files as '#define'
F_CPU=14745600

# additional options for avreal (like -n)
# put -l2 here for lock chip after programming by 'make run'
#AVREAL_OPT= -n
FUSES = bodlevel=5,cksel=2,ckdiv8=off,sut=0


# additional libraries and object files to link
LIB =

# assembler flags
ASFLAGS =

#OPT = -Os -mcall-prologues
OPT = -Os

# compiler flags
CSTD = # -std=c++98 --pedantic

CWARN = -Wextra -Wall #-Wstrict-prototypes -Wno-main
CFLAGS = -g $(OPT) $(CSTD) $(CWARN) \
-DF_CPU=$(F_CPU)UL \
-fno-exceptions -fno-rtti \
-funsigned-bitfields -fshort-enums

# -fpack-struct не йде для scmRTOS для avr-gcc 3.4.6
# OS_Kernel.h:167: error: cannot bind packed field `((OS::TKernel*)this)->OS::TKernel::ReadyProcessMap' to `OS::TProcessMap&'

# linker flags
#---------------- Library Options ----------------
LDFLAGS += -Wl
LDFLAGS += -lm


ifeq "$(MAKE_SMALLEST_HEX)" "Y"
CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--relax
endif

########### you should not need to change the following lines #############
# keep order!
# avreal.make must be included after gcc-avr because of TRGPGM definition
include $(COMMON_MAKEFILES)/gcc-avr.mak
include $(COMMON_MAKEFILES)/avreal.mak

## end



Пользуясь случаем, заодно спрошу, как поправить Makefile, что бы файл elf сохранялся по указанному пути, либо делалась его копия по указанному пути?
_Pasha
Цитата
LDFLAGS += -Wl
LDFLAGS += -lm


Та нет жеж! LDFLAGS += -Wl,-lm
Сергей Борщ
QUOTE (Sirko @ Feb 16 2011, 09:02) *
CODE
#---------------- Library Options ----------------
[color="#FF0000"]LDFLAGS += -Wl
LDFLAGS += -lm[/color]

CODE
LDFLAGS += -Wl,-lm

QUOTE (Sirko @ Feb 16 2011, 09:02) *
Пользуясь случаем, заодно спрошу, как поправить Makefile, что бы файл elf сохранялся по указанному пути, либо делалась его копия по указанному пути?
Исправьте в gcc-avr.mak строку EXEDIR := ./exe или строку TRGELF := $(EXEDIR)/$(TRG).elf
Sirko
Спасибо.
Вернусь домой - попробую.
Sirko
Эх, в моем случае эта магия, вероятно, черна как смоль. crying.gif
Цитата
Та нет жеж! LDFLAGS += -Wl,-lm

Пробовал и так и эдак, и make файлы попробовал из других примеров, и как-то безрезультатно.


Цитата
Build started 16.2.2011 at 20:01:38
======== Beginning of project message processing
avr-gcc.exe (WinAVR 20100110) 4.3.3
Copyright © 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

==== Compiling ./src/main.cpp
In file included from ./src/main.cpp:12:
./src/menu.h: In member function 'LCD_HD44780::ModePrintDigit TMenu::getModePrintDigit()':
./src/menu.h:105: error: no matching function for call to 'LCD_HD44780::ModePrintDigit::ModePrintDigit(u16&)'
./src/LCD.HD4478.Driver.h:34: note: candidates are: LCD_HD44780::ModePrintDigit::ModePrintDigit()
./src/LCD.HD4478.Driver.h:34: note: LCD_HD44780::ModePrintDigit::ModePrintDigit(const LCD_HD44780::ModePrintDigit&)
./src/main.cpp: In static member function 'static void OS::process<pr, stack_size>::Exec() [with OS::TPriority pr = pr2, short unsigned int stack_size = 500u]':
./src/main.cpp:130: warning: missing initializer for member 'LCD_HD44780::ModePrintDigit::factor'
./src/main.cpp:131: warning: missing initializer for member 'LCD_HD44780::ModePrintDigit::factor'
./src/main.cpp:132: warning: missing initializer for member 'LCD_HD44780::ModePrintDigit::factor'
./src/main.cpp:133: warning: missing initializer for member 'LCD_HD44780::ModePrintDigit::factor'
./src/main.cpp:134: warning: missing initializer for member 'LCD_HD44780::ModePrintDigit::factor'
make: *** [obj/main.o] Error 1
Build failed with 1 errors and 5 warnings...




Код
#
#  scmRTOS avr-gcc port
#
#  project-dependent makefile for samples
#

# can change WinAVR version by setting AVRGCC variable here (override environment)
#AVRGCC :=c:/kgp-avr/20071102
#AVRGCC :=c:/kgp-avr/20070928
#AVRGCC :=d:/mingw/local
#AVRGCC :=c:/WinAVR-20071221
#AVRGCC :=c:/WinAVR-20070525
#AVRGCC :=c:/WinAVR-20060421
AVRGCC :=C:/WinAVR-20100110

# Y/N - !!! N for gcc < 4.x
MAKE_SMALLEST_HEX = Y

# point to start of project sources subtree,
PROJ_SRCTOP := .

#put the name of the target file here (without extension)
TRG    = message

# project modules (directories with source files)
# "current" directory (.) included automatically in gcc-avr.make
MODULES := ./src ../scmRTOS/Common ../scmRTOS/AVR
# needed for includes below
COMMON_MAKEFILES := ./makefiles

###########
# used in gcc-avr.make and avreal.make
MCU := atmega128
#MCU := atmega48
TRGPGMEXT := hex
#eep

# used in avreal.make and transferred to source files as '#define'
F_CPU=14745600

# additional options for avreal (like -n)
# put -l2 here for lock chip after programming by 'make run'
#AVREAL_OPT= -n
FUSES = bodlevel=5,cksel=2,ckdiv8=off,sut=0


# additional libraries and object files to link
LIB    =

# assembler flags
ASFLAGS =

#OPT = -Os  -mcall-prologues
OPT = -Os

# compiler flags
CSTD = # -std=c++98 --pedantic

CWARN = -Wextra -Wall #-Wstrict-prototypes -Wno-main
CFLAGS    = -g $(OPT) $(CSTD) $(CWARN) \
-DF_CPU=$(F_CPU)UL \
-fno-exceptions -fno-rtti \
-funsigned-bitfields -fshort-enums


# linker flags
#---------------- Library Options ----------------
LDFLAGS =
LDFLAGS += -Wl,-lm

ifeq "$(MAKE_SMALLEST_HEX)" "Y"
    CFLAGS += -ffunction-sections -fdata-sections
    LDFLAGS += -Wl,--gc-sections
    LDFLAGS += -Wl,--relax
endif

########### you should not need to change the following lines #############
# keep order!
# avreal.mak must be included after gcc-avr because of TRGPGM definition
include $(COMMON_MAKEFILES)/gcc-avr.mak
include $(COMMON_MAKEFILES)/avreal.mak

## end
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Invision Power Board © 2001-2025 Invision Power Services, Inc.