I enabled fdcan1 support in both the overlay and config file for the Arduino Uno Q:
arduino_uno_q_stm32u585xx.conf
CONFIG_POLL=y
CONFIG_CAN=y
#CONFIG_CAN_FD_MODE=y
arduino_uno_q_stm32u585xx.overlay
&fdcan1 {
status = "okay";
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
pinctrl-names = "default";
};
/ {
chosen {
zephyr,canbus = &fdcan1;
};
};
Not sure if I need to config clocks in &fdcan1 since they are already configured in stm32u5 common.
Then rebuilt core - no issues but the counter test sketch has issues.
Using a slightly modified version of the example: Controller Area Network (CAN) counter — Zephyr Project Documentation I get two distinct errors:
- Seems like work queues dont work. So ran a simple test sketch:
#define STACK_SIZE 1024
#define PRIORITY 5
K_THREAD_STACK_DEFINE(my_stack, STACK_SIZE);
static struct k_work_q my_work_q;
static void my_custom_handler(struct k_work *work)
{
printk("Custom work executed!\n");
}
K_WORK_DEFINE(my_custom_work, my_custom_handler);
void setup(void)
{
k_work_queue_init(&my_work_q);
k_work_queue_start(&my_work_q, my_stack,
K_THREAD_STACK_SIZEOF(my_stack),
PRIORITY, NULL);
printk("Submitting to custom work queue...\n");
k_work_submit_to_queue(&my_work_q, &my_custom_work);
}
void loop() {}
and got the following error messages:
/home/arduino/.arduino15/packages/zephyr/tools/arm-zephyr-eabi/0.16.8/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: /home/arduino/ArduinoApps/ccc/.cache/sketch/sketch/sketch.ino.cpp.o: in function `setup':
/home/arduino/ArduinoApps/ccc/sketch/sketch.ino:23: undefined reference to `k_work_queue_init'
/home/arduino/.arduino15/packages/zephyr/tools/arm-zephyr-eabi/0.16.8/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: /home/arduino/ArduinoApps/ccc/sketch/sketch.ino:23: undefined reference to `k_work_queue_start'
/home/arduino/.arduino15/packages/zephyr/tools/arm-zephyr-eabi/0.16.8/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: /home/arduino/ArduinoApps/ccc/sketch/sketch.ino:23: undefined reference to `k_work_submit_to_queue'
collect2: error: ld returned 1 exit status
- The function
can_send
can_send(can_dev, &change_led_frame, K_FOREVER,
tx_irq_callback,
"LED change");
gives
/home/arduino/ArduinoApps/fdcan1_experiment/sketch/sketch.ino:289:26: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
289 | "LED change");
| ^~~~~~~~~~~~
| |
| const void*
In file included from /home/arduino/Arduino/hardware/arduino/zephyr/variants/arduino_uno_q_stm32u585xx/llext-edk/include/zephyr/include/zephyr/drivers/can.h:1748,
from /home/arduino/ArduinoApps/fdcan1_experiment/sketch/sketch.ino:12:
/home/arduino/Arduino/hardware/arduino/zephyr/variants/arduino_uno_q_stm32u585xx/llext-edk/include/zephyr/include/generated/zephyr/syscalls/can.h:476:143: note: initializing argument 5 of 'int can_send(const device*, const can_frame*, k_timeout_t, can_tx_callback_t, void*)'
476 | static inline int can_send(const struct device * dev, const struct can_frame * frame, k_timeout_t timeout, can_tx_callback_t callback, void * user_data)
ref: zephyr/doc/hardware/peripherals/can/controller.rst at main · zephyrproject-rtos/zephyr
At this point think its up to the Arduino Team to officially enable it and sort the problem with work queue;s
UPDATE: Fixed issue 2 by just adding a void* to literal. But still issue with #1