1

Hello on my kernel module my probe funtion gets not called.

static const struct of_device_id stm32_match[] = {
    { .compatible = "st,stm32-uart", .data = &stm32f4_info},
    { .compatible = "st,stm32f7-uart", .data = &stm32f7_info},
    { .compatible = "st,stm32h7-uart", .data = &stm32h7_info},
    { .compatible = "st,stm32_usart_net",},
    {},
};

static int stm_uart_probe(struct serdev_device *serdev)
{
    printk("<1>Hello world 1.\n");
}

static void stm_uart_remove(struct serdev_device *serdev)
{
     printk("<2>Bye world 2.\n");
}

static struct serdev_device_driver qca_uart_driver = {
    .probe = stm_uart_probe,
    .remove = stm_uart_remove,
    .driver = {
        .name = QCAUART_DRV_NAME,
        .of_match_table = of_match_ptr(stm32_match),
    },
};

module_serdev_device_driver(qca_uart_driver);

in my kernel log i can not find my my log. I presentation for the bluetooth example so i changed my device tree like this:

&usart3 {
    compatible = "st,stm32-uart", "st,stm32f7-uart", "st,stm32h7-uart";
    pinctrl-names = "default", "sleep", "idle";
    pinctrl-0 = <&usart3_pins_b>;
    pinctrl-1 = <&usart3_sleep_pins_b>;
    pinctrl-2 = <&usart3_idle_pins_b>;
    uart-has-rtscts;
    status = "okay";
    
    ethernet {
        compatible = "st,stm32_usart_net";
        local-mac-address = [ AB AB AB AB AB AB ];
        current-speed = <10000000>;
    };
};

The orriginal configuration with let the usart show up as character device looked like this:

&usart3 {
    pinctrl-names = "default", "sleep", "idle";
    pinctrl-0 = <&usart3_pins_b>;
    pinctrl-1 = <&usart3_sleep_pins_b>;
    pinctrl-2 = <&usart3_idle_pins_b>;
    uart-has-rtscts;
    status = "okay";
};

Now my device will not be loaded as Character device and on the directories it shows up like this: /sys/devices/platform/soc/4000f000.serial

  • serial0 -> serial0.0

But thers no HCI Device. I orientated myself on this side https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/net/qca,qca7000.txt

I also kreated a Kconfig

config ST32_UART
    tristate "STM32 UART support"
    select usartNet
    depends on SERIAL_DEV_BUS && OF
    help
      This UART protocol driver supports the STM32 Usart.

      Currently the driver assumes these device UART settings:
        Data bits: 8
        Parity: None
        Stop bits: 1
        Flow control: None

      To compile this driver as a module, choose M here. The module
      will be called qcauart.

My Makefile

ifeq ($(KERNELRELEASE),)
    KERNELDIR ?= /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-11-12/stm32mp1-openstlinux-5-4-dunfell-mp1-20-11-12/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.4.56-r0/build
    PWD := $(shell pwd)

modules:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

clean:
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY: modules clean

else
    obj-$(ST32_UART) += usartNet.o
    obj-m := usartNet.o
endif

i build the module just by calling make. Then i insert it with insmod. But i do not get any logs.

As a solution I needed to enable some points in the Kconfig:

Device drivers --->
    Character devices --->
        <*> Serial Device bus --->
            <*> Serial Device TTY port controller --->
  • See https://stackoverflow.com/q/7578582/1216776 – stark May 18 '21 at 19:50
  • I still wonder why because when I write a platform driver the probe gets called. – Gonzo Gonzales May 18 '21 at 19:57
  • I have the same problem - do you found a solution? – Hoehli Jan 17 '22 at 11:03
  • 1
    My problem was that I had a mistake when I build the Kernel. that's why it did not load. But if you want I can provide you a link to my project where I used it. Or you can create a Post so I can take a look on your code and configurations. Or you can write me a mail and I can also take a look on it. – Gonzo Gonzales Jan 17 '22 at 12:18
  • Maybe you can write your solution down here as solved-answer? I think this would help other people too! Many Thanks in advance ;) – Hoehli Jan 17 '22 at 12:44
  • did adding: CONFIG_SERIAL_DEV_BUS=y CONFIG_SERIAL_DEV_CTRL_TTYPORT=y to the ".config" file, solved your problems? – Hoehli Jan 17 '22 at 15:42
  • Yes this needs to be enabled. I added it to my post. – Gonzo Gonzales Jan 18 '22 at 21:19

0 Answers0