Skip to content

Problem with 'debug' on Arduino2 #2

@ozarchie

Description

@ozarchie

Hi,
I have been porting your library to the STM32 series uP.
After introducing some "#if defined(ARDUINO_ARCH_STM32)" into your examples to address some processor specific issues, I have run into a problem with the Interface,hpp code that I cannot understand.
I am using:
Arduino Version: 2.3.3
Date: 2024-09-25T09:35:36.798Z (1 month ago)
CLI Version: 1.0.4

on a MAC M2.

I can compile and upload (but not work!) successfully without 'debug' turned on.

However, if I set "Optimize" for debug (-Og'), I get the following errors:

Library/Arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/13.2.1-1.1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: sketch/TMCTestStepperInterface.ino.cpp.o: in function `TMC51X0::TMC51X0()':
Documents/Arduino/libraries/TMC51X0/src/TMC51X0.hpp:23:(.text._ZN7TMC51X0C2Ev[_ZN7TMC51X0C5Ev]+0x6c):

undefined reference to vtable for tmc51x0::Interface

collect2: error: ld returned 1 exit status

Internet searches suggest I need to change :

virtual void writeRegister(uint8_t register_address, uint32_t data);
virtual uint32_t readRegister(uint8_t register_address)};

to

virtual void writeRegister(uint8_t register_address, uint32_t data){};
virtual uint32_t readRegister(uint8_t register_address){return(0);};

This allows the code to compile and allows the Arduino debug interface to work.

But, if I then set the compile options back to smallest '-Os', compile fails with:

Documents/Arduino/libraries/TMC51X0/src/./TMC51X0/Interface.hpp: In member function 'virtual void tmc51x0::Interface::writeRegister(uint8_t, uint32_t)':
Documents/Arduino/libraries/TMC51X0/src/./TMC51X0/Interface.hpp:25:40: warning: unused parameter 'register_address' [-Wunused-parameter]
   25 |     virtual void writeRegister(uint8_t register_address, uint32_t data) {};
      |                                ~~~~~~~~^~~~~~~~~~~~~~~~
Documents/Arduino/libraries/TMC51X0/src/./TMC51X0/Interface.hpp:25:67: warning: unused parameter 'data' [-Wunused-parameter]
   25 |     virtual void writeRegister(uint8_t register_address, uint32_t data) {};
      |                                                          ~~~~~~~~~^~~~

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions