Remapping CAN-bus pins in fmuv3

Hello, I have got board with no CAN pins outputted from stm32f4, I still had some pins with alternate function, so I tried to remap I2C1 pins, and CAN to I2C1 default pins.
I did it almost year ago, I2C worked, but I cant test CAN, now I have got Uavcan module, which is working with Pixhawk, which I used to implement it. But I cant see it with my “flying” board.

How I remapped:

  1. I found that pins are configured in
    /home/nikita/ardupilot/modules/PX4Firmware/nuttx-configs/px4fmu-v2/include/board.h
    Info about them is stored in /home/nikita/ardupilot/modules/PX4NuttX/nuttx/arch/arm/src/stm32/chip/stm32f40xxx_pinmap.h

  2. Now I try to change CAN from GPIO_CAN1_RX_3

a

#define GPIO_CAN1_RX GPIO_CAN1_RX_2
#define GPIO_CAN1_TX GPIO_CAN1_TX_2
#define GPIO_CAN2_RX GPIO_CAN2_RX_1
#define GPIO_CAN2_TX GPIO_CAN2_TX_2

to

#define GPIO_CAN1_RX_2        (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN8)
#define GPIO_CAN1_TX_2        (GPIO_ALT|GPIO_AF9|GPIO_SPEED_50MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN9)

Now I have

#define GPIO_CAN1_RX GPIO_CAN1_RX_2
#define GPIO_CAN1_TX GPIO_CAN1_TX_2
#define GPIO_CAN2_RX GPIO_CAN2_RX_1
#define GPIO_CAN2_TX GPIO_CAN2_TX_2
  1. Changing I2C pins

I had

#define GPIO_I2C1_SCL		GPIO_I2C1_SCL_2
#define GPIO_I2C1_SDA		GPIO_I2C1_SDA_2
#define GPIO_I2C1_SCL_GPIO	(GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN8)
#define GPIO_I2C1_SDA_GPIO	(GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN9)

#define GPIO_I2C2_SCL		GPIO_I2C2_SCL_1
#define GPIO_I2C2_SDA		GPIO_I2C2_SDA_1
#define GPIO_I2C2_SCL_GPIO	(GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN10)
#define GPIO_I2C2_SDA_GPIO	(GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN11)

I want to use B8,B9, so I change I2C1 to I2C3 and dont touch I2C2.

#define GPIO_I2C1_SCL		GPIO_I2C3_SCL_2
#define GPIO_I2C1_SDA		GPIO_I2C3_SDA_2
#define GPIO_I2C1_SCL_GPIO	(GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN7)
#define GPIO_I2C1_SDA_GPIO	(GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN8)

Lightware SF11 and some other devices are working on I2C2. I can see my uavcan module with sniffer, but I cant see autopilot node.
I am working with arduplane 3.8.5 branch.
I am looking for any help.
Nikita.

It might be easier to rebase to use the ChibiOS HAL, and modify the hwdef.dat file.

Thanks for the advice,

I forked 3.9.0 release branch, changed CAN1 pins to I2C1, but I there is no pins for I2C1; if I try to comment them out, I cant build it, due to I2Cdevice.cpp errors. Is it possible to disable I2C1?

Nikita.

can you link to your repo / hwdef.dat file?

Ive got local fork, here is gist for hwdef.dat, I tried to remove I2C1 from line 131 where order of I2C buses assigned. I got build, but cant connect to autopilot

Hello, I published repo to github, https://github.com/n1kitap/ardupilot
That is fork of stable 3.9.0, with just 1 commit of changing hwdef.dat file

Nikita

Switch can_tx and rx

Regards,

James

I see that I mixed them, not sure if that was the build which I tried to upload, I will fix this pins later and test it only on monday. I asked for help one of my friends to try to solder default CAN pins, maybe software fix will not be needed.
Thank You,
Nikita

Hello, I as I thought I mixed them, it was impossible to build it, so I switched them and got firmware, anyway as stated at the start - board cant boot.
I hope that my friend can fix CAN output with “soldering iron”

Regard,
Nikita

Ok. Good luck with it.
You’d have needed an external can transceiver on the i2c anyway (I assumed you knew that but should have mentioned it). Whilst the pins can be setup for canbus they don’t have the hardware built in.