Unable to change the board_config_v3.h file

Hi,

for my project I need to add pins to my AxisHardwareConfig_t (enable_gpio_pin and error_gpio_pin)
I define them in the board_config_v3.h file like this :

const BoardHardwareConfig_t hw_configs[2] = { {
    //M0
    .axis_config = {
        .step_gpio_pin = 1,
        .dir_gpio_pin = 2,
        .enable_gpio_pin = 5,  // new pin 1
        .error_gpio_pin = 3,   // new pin 2
        .thread_priority = (osPriority)(osPriorityHigh + (osPriority)1),
    }, 

//M1
.axis_config = {
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 5
    .step_gpio_pin = 7,
    .dir_gpio_pin = 8,
    .enable_gpio_pin = 6, // same for M1
    .error_gpio_pin = 4,
#else
    .step_gpio_pin = 3,
    .dir_gpio_pin = 4,
#endif
    .thread_priority = osPriorityHigh,
},

I compiled a first time and it worked great, but I made a mistake in the value of enable_gpio_pin for M1 (8 instead of 6), and now when I compile with the right value, enable_gpio_pin is stuck to the wrong value (8).

I use visual studio code, and it seems that it doesn’t want to compile what’s after the #ifdef __MAIN_CPP__ anymore.
When I want to force this by adding
#ifndef __MAIN_CPP__
#define __MAIN_CPP__
#endif
up in the file I get the following errors :

build/obj/Board_v3_Src_usbd_desc.c.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/Board_v3_Src_usbd_desc.c.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/Board_v3_Src_usbd_desc.c.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_low_level.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_low_level.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_low_level.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_axis.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_axis.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_axis.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_motor.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_motor.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_motor.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_encoder.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_encoder.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_encoder.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_controller.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_controller.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_controller.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_sensorless_estimator.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_sensorless_estimator.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_sensorless_estimator.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_trapTraj.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_trapTraj.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_trapTraj.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/MotorControl_main.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/MotorControl_main.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/MotorControl_main.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/communication_communication.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/communication_communication.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/communication_communication.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/communication_ascii_protocol.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/communication_ascii_protocol.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/communication_ascii_protocol.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here
build/obj/communication_interface_usb.cpp.o:(.rodata.hw_configs+0x0): multiple definition of `hw_configs'
build/obj/Board_v3_Src_main.c.o:(.rodata.hw_configs+0x0): first defined here
build/obj/communication_interface_usb.cpp.o:(.rodata.thermistor_num_coeffs+0x0): multiple definition of `thermistor_num_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_num_coeffs+0x0): first defined here
build/obj/communication_interface_usb.cpp.o:(.rodata.thermistor_poly_coeffs+0x0): multiple definition of `thermistor_poly_coeffs'
build/obj/Board_v3_Src_main.c.o:(.rodata.thermistor_poly_coeffs+0x0): first defined here 

any help would be greatly appreciated :slight_smile:

you shouldn’t need to define __MAIN_CPP__ yourself because it is being compiled with main.cpp. Did you try make clean before rebuilding?

I tried but I get this error :

PS G:\Mon Drive\Odrive\ODrive\Firmware> make clean
rm -fR .dep build
process_begin: CreateProcess(NULL, rm -fR .dep build, ...) failed.
make (e=2): Le fichier spécifié est introuvable. (trad : the specified file can not be found.)
make: [clean] Erreur 2 (ignorée)

I’ve never seen that error before but maybe the whitespace in your path “Mon Drive” is causing it.
Anyways I tried compiling your changes in board_config_v3.h file and changes are being built as expected:


Were you checking the actual pins’ behavior? I am assuming you made changes to Axis::load_default_step_dir_pin_config and Axis::decode_step_dir_pins as well as Axis::set_step_dir_active

hi @naktamello, I will try to change the location, and yes indeed I changed the other files. But for now I will try to use the can feature since it seems to be a better solution to what I’m trying to do. Thanks!

Why did you add that MAIN_CPP stuff? board_version_v3.h is included in main.cpp at the top, right after _MAIN_CPP_ is defined. Of course you’re getting multiple definition issues - it’s being defined multiple times. Undo that #ifdef stuff.

You probably just need to do an odrv0.erase_configuration(), since the CRC hasn’t changed.

hi @Wetmelon for the moment I use your fork (the CAN one) and I made changes to the config file but this time it compilated OK. I’ll let you know if this bug happen again.