Tone.cpp multiple definition error, R2018b. Arduino, Simulink.

2 Ansichten (letzte 30 Tage)
Euan French
Euan French am 18 Dez. 2018
Beantwortet: Pratik am 17 Jul. 2024
I have a Simulink model which I want to deploy on my Arduino Uno. When I attempt to build it in R2018b, I encounter a build error. The error is quite lengthy but contains the following snippet towards the end:
"### Creating standalone executable "../PulseLED12.elf" ..." C:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/arduino-1.8.1/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections,--relax -mmcu=atmega328p -o ../PulseLED12.elf MW_AnalogInput.o PulseLED12.o PulseLED12_data.o updown.o ext_work.o rtiostream_utils.o makeatune_wrapper.o wiring_pulse.S.o hooks.o WInterrupts.o wiring.o wiring_analog.o wiring_digital.o wiring_pulse.o wiring_shift.o abi.o CDC.o HardwareSerial.o HardwareSerial0.o HardwareSerial1.o HardwareSerial2.o HardwareSerial3.o PluggableUSB.o IPAddress.o new.o Print.o Stream.o Tone.o USBCore.o WMath.o WString.o MW_ArduinoHWInit.o io_wrappers.o arduinoAVRScheduler.o rtiostream_interface.o ext_svr_daemon.o rtiostream_serial_daemon.o daemon_checksum.o ert_main.o -lm Tone.o: In function `__vector_7': C:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/arduino-1.8.1/hardware/arduino/avr/cores/arduino/Tone.cpp:539: multiple definition of `__vector_7' makeatune_wrapper.o:C:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/arduino-1.8.1/hardware/arduino/avr/cores/arduino/Tone.cpp:539: first defined here c:/programdata/matlab/supportpackages/r2018b/3p.instrset/arduinoide.instrset/arduino-1.8.1/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions collect2.exe: error: ld returned 1 exit status gmake: *** [../PulseLED12.elf] Error 1
I attempted to follow the fix in this question, but like someone else, I then get an error telling me that I don't have matlab coder installed.
Please help!

Antworten (1)

Pratik
Pratik am 17 Jul. 2024
Hi Euan,
From what can be understood from the error message, some particular system object is using the "NewPing.cpp" file which includes the definition of a timer interrupt handler.
The Simulink Arduino Support package also includes a "Tone.cpp" in the build process, which also contains a definition of the same timer interrupt handler as "NewPing.cpp". This results in a conflict during the build process.
A solution to this issue can be to exclude "Tone.cpp" from the build process. This can be done by following the steps below:
1. Go to the following location in your MATLAB support package root folder
XXXXX\toolbox\target\supportpackages\arduinotarget/registry/attributes
where XXXXX is the root support package folder location and can be obtained by executing "matlabshared.supportpkg.getSupportPackageRoot" at the MATLAB command window.
Note: You might have multiple folders containing "R20XXb" in the "SupportPackages" folder. Simply use the one that contains the "toolbox" folder in it.
2. Make a copy of the file "Arduino Uno_attributes.xml" for backup, and then open it in a text editor.
3. Delete line 31 from "Arduino Uno_attributes.xml" which includes "Tone.cpp" for the build.
4. Execute the following commands at the MATLAB command window.
clear classes
rehash toolboxcache
sl_refresh_customizations
5. Now open your Simulink model. Go to "Configuration Parameters --> Hardware Implementation" and reselect the "Hardware board" to "Arduino Uno"
6. Try to build and deploy the model.
I hope this helps!

Kategorien

Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by