Skip to content

R_AVR_7_PCREL on ATMEGA 2560 #683

@Emcotek

Description

@Emcotek

Bug Report

Current behavior

arduino-cli compile -b arduino:avr:mega PhMeter

I have been chasing this issue using the GUI IDE off and on for over two months. I have posted on the Arduino Forum seeking help but the problem persists. Most recently I discovered that there is a known bug in the compiler that causes RJMP and RCALL which in certain cases result in the inability to resolve addressing. The solution I found was to change the order of the library linkage.

Here is the suggested compiler invocation string suggested to fix this issue. Note: I am not an expert on command line methods for compilation and beg forgiveness if this is obvious what to do. I am going down the trail of setting up MS VS Code and Arduino-cli vs using the traditional GUI IDE.

/usr/pkg/bin/avr-g++ -mmcu=atmega2560 -I. -DF_CPU=16000000 -DARDUINO=105 -I/home/stix/src/arduino-1.0.5/hardware/arduino/cores/arduino -I/home/stix/src/arduino-1.0.5/libraries/LiquidCrystal -I/home/stix/src/arduino-1.0.5/libraries/Wire -I/home/stix/src/arduino-1.0.5/libraries/utility/twi  -I../libraries/DS1307RTC -I../libraries/OneWire -I../libraries/Time -I/home/stix/src/arduino-1.0.5/libraries/LiquidCrystal/utility/ -I/home/stix/src/arduino-1.0.5/libraries/Wire/utility/ -I/home/stix/src/arduino-1.0.5/libraries/utility/twi/utility/ -I../libraries/DS1307RTC/utility/ -I../libraries/OneWire/utility/ -I../libraries/Time/utility/ -I/home/stix/src/arduino-1.0.5/hardware/arduino/variants/mega -Os -mno-short-calls -o applet/thermo.elf applet/thermo.cpp -L. applet/core.a -nodefaultlibs -Wl,--gc-sections -lm -lgcc -lc -lgcc

Note the -nodefaultlibs and -lm -lgcc -lc -lgcc options. This supposedly will use non-relative jumps and calls and then resolve undefined links with the second pass.

While this is not a bug in arduino-cli Per Se, it is an unresolved Arduino ecosystem issue that needs a fix. I struggled looking for a makefile solution but all required a Linux box and that is a whole other story; short version is I don't have a viable Linux platform.

I have recently installed GNU Make and am attempting to put together a makefile with arduino-cli to execute the aforementioned avr-g++ commands, It has been a long time since I worked on makefiles,

Is there an easier way to get there? If not, how do I fix this error?

thank you.

I apologize if this is not an appropriate use of the issue system to get my issue addressed . Please forgive...I am getting desperate. This is the code that generates the error.

PhMeter 20200504A.zip

Expected behavior

Compile without the error message.

Environment

  • CLI version (output of arduino-cli version): 0.10.0 Commit: ec5c3ed
  • OS and platform:
    Windows 10; Dell M6800 Laptop. Atmega2560 target.

Metadata

Metadata

Assignees

Labels

topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions