Не удается скомпилировать модуль ядра для BeagleBone Debian

Я следую руководству Дерека Моллоя для создания загружаемых модулей ядра, но в некоторых моментах застрял.

У меня есть код ядра в .c-файле: hello.c

#include <linux/init.h>             // Macros used to mark up functions e.g., __init __exit
#include <linux/module.h>           // Core header for loading LKMs into the kernel
#include <linux/kernel.h>           // Contains types, macros, functions for the kernel

MODULE_LICENSE("GPL");              ///< The license type -- this affects runtime behavior
MODULE_AUTHOR("Derek Molloy");      ///< The author -- visible when you use modinfo
MODULE_DESCRIPTION("A simple Linux driver for the BBB.");  ///< The description -- see modinfo
MODULE_VERSION("0.1");              ///< The version of the module

static char *name = "world";        ///< An example LKM argument -- default value is "world"
module_param(name, charp, S_IRUGO); ///< Param desc. charp = char ptr, S_IRUGO can be read/not changed
MODULE_PARM_DESC(name, "The name to display in /var/log/kern.log");  ///< parameter description

/** @brief The LKM initialization function
 *  The static keyword restricts the visibility of the function to within this C file. The __init
 *  macro means that for a built-in driver (not a LKM) the function is only used at initialization
 *  time and that it can be discarded and its memory freed up after that point.
 *  @return returns 0 if successful
 */
static int __init helloBBB_init(void){
   printk(KERN_INFO "EBB: Hello %s from the BBB LKM!\n", name);
   return 0;
}

/** @brief The LKM cleanup function
 *  Similar to the initialization function, it is static. The __exit macro notifies that if this
 *  code is used for a built-in driver (not a LKM) that this function is not required.
 */
static void __exit helloBBB_exit(void){
   printk(KERN_INFO "EBB: Goodbye %s from the BBB LKM!\n", name);
}

/** @brief A module must use the module_init() module_exit() macros from linux/init.h, which
 *  identify the initialization function at insertion time and the cleanup function (as
 *  listed above)
 */
module_init(helloBBB_init);
module_exit(helloBBB_exit);

и make-файл следующим образом: Makefile

obj-m+=hello.o

all:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean

когда я пытаюсь запустить make в каталоге только с двумя вышеуказанными файлами, я получаю

Make: Ничего не поделаешь для всех

Я использую 3.8.13-bone47, но мне не удалось найти точные файлы заголовков, соответствующие этому ссылка, которую рекомендовал Дерек, поэтому вместо этого я скачал 3.8.13-bone71. Может ли это быть проблема? Нужно ли загружать заголовки при компиляции непосредственно на BeagleBone? Я также пытался изменить строки в Makefile на жестко заданное имя дистрибутива, которое совпадает с моим (3.8.13-bone47), тоже не работает.

Большое спасибо, ребята!


person Wiingaard    schedule 01.10.2015    source источник
comment
Вы определили объектный файл как загружаемый модуль, для его компиляции вы должны использовать make modules. Проверьте путь к вашим заголовкам и файлам. Вы уверены, что ваша папка вообще считается построенной?   -  person 0andriy    schedule 01.10.2015
comment
Каждая строка в рецепте должна начинаться с табуляции. Вы забыли вкладку перед make ... командами.   -  person Tsyvarev    schedule 02.10.2015
comment
Вставка вкладки заставила ее скомпилироваться. хотя теперь я получаю 2 ошибки: /lib/modules/3.8.13-bone47/build/: Нет такого файла или каталога, поэтому он не находит мои заголовки. Как вы думаете, я могу использовать это: rcn-ee.net/deb /wheezy-armhf/v3.8.13-bone47   -  person Wiingaard    schedule 06.10.2015


Ответы (1)


Я решил свой вопрос. У меня было две проблемы:

Отсутствуют вкладки в Makefile. Я добавил вкладку в начало каждой строки с оператором make. На самом деле это должна быть вкладка, ‹\t> у меня не работает.

Неправильные файлы заголовков Оказывается, правильная версия файлов заголовков очень важна :) Я взял их с http://rcn-ee.net/deb/trusty-armhf/v3.8.13-bone47/ и добавил файл mach/timex.h файл, и с тех пор смог следовать указаниям Дерека.

person Wiingaard    schedule 06.10.2015