Skip to main content
Visitor II
November 30, 2020
Question

Hello I'm trying to write a loadable kernel module driver. I get an error during compilation: ERROR: modpost: "platform_device_alloc" [/home/rdm/ethtest/eth-ins.ko] undefined! Do I need something to set in the Kernel Config? Helloworld works as LKM.

  • November 30, 2020
  • 1 reply
  • 784 views

#include <linux/platform_device.h>

#include <linux/module.h

#include <linux/types.h>

MODULE_LICENSE("GPL");

MODULE_AUTHOR("Robert W. Oliver II");

MODULE_DESCRIPTION("A simple example Linux module.");

MODULE_VERSION("0.01");

static struct platform_device *pdev;

static int __init fake_eth_add(void)

{

  int inst_id = 0;

  pdev = platform_device_alloc("fake-eth", inst_id);

  return 0;

}

static void __exit fake_eth_put(void)

{

}

module_init(fake_eth_add);

module_exit(fake_eth_put);

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    December 2, 2020

    Hi @Community member​ 

    Did you refer to following wiki page ?

    https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package#Modifying-2Fadding_an_external_Linux_kernel_module

    Such kind of error usually come from bad installation / initialization of the SDK.

    Double check your environment.

    Hope it help,

    Olivier