Приветствую.
Перепроверил всё ещё раз. При загрузке модуля axi_gpio0_probe() не выполняется???
Код драйвера (совет использовать module_platform_driver(axi_gpio0_driver) пока не учтён):
CODE
/* axi_gpio0.c - The simplest kernel module.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
/* Standard module information, edit as appropriate */
MODULE_LICENSE("GPL");
MODULE_AUTHOR ("Xilinx corp.");
MODULE_DESCRIPTION ("axi_gpio0 - loadable module for axi_gpio control");
#define DRIVER_NAME "axi_gpio0"
int test_value = 0;
struct axi_gpio0_local {
int irq;
unsigned long mem_start;
unsigned long mem_end;
void __iomem *base_addr;
};
static irqreturn_t axi_gpio0_irq(int irq, void *lp)
{
printk("axi_gpio0 interrupt\n");
return IRQ_HANDLED;
}
static int axi_gpio0_probe(struct platform_device *pdev)
{
struct resource *r_irq; /* Interrupt resources */
struct resource *r_mem; /* IO mem resources */
struct device *dev = &pdev->dev;
struct axi_gpio0_local *lp = NULL;
int rc = 0;
int counter = 0;
test_value = 111;
printk("<1>Hello module world.\n");
printk(KERN_ERR "In probe() function\n");
dev_info(dev, "Device Tree Probing\n");
test_value = 222;
return rc;
}
static int axi_gpio0_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct axi_gpio0_local *lp = dev_get_drvdata(dev);
free_irq(lp->irq, lp);
release_mem_region(lp->mem_start, lp->mem_end - lp->mem_start + 1);
kfree(lp);
dev_set_drvdata(dev, NULL);
test_value = 333;
return 0;
}
//#ifdef CONFIG_OF
static struct of_device_id axi_gpio0_of_match[] = {
{ .compatible = "xlnx,xps-gpio-1.00.a", },
{ /* end of list */ },
};
MODULE_DEVICE_TABLE(of, axi_gpio0_of_match);
//#else
//# define axi_gpio0_of_match
//#endif
static struct platform_driver axi_gpio0_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = axi_gpio0_of_match,
},
.probe = axi_gpio0_probe,
.remove = axi_gpio0_remove,
};
static int __init axi_gpio0_init(void)
{
int result = 12;
printk(KERN_INFO "Ver - 09:01 11.03.2016\n");
printk(KERN_INFO "Hello module world.\n");
printk(KERN_INFO "Hello module world.\n");
printk(KERN_INFO ".compatible = xlnx,xps-gpio-1.00.a\n");
printk(KERN_INFO "result = %d\n", result);
//test_counter();
printk(KERN_ERR "axi_gpio0_driver.probe = %p\n", axi_gpio0_driver.probe);
printk(KERN_ERR "axi_gpio0_probe = %p\n", axi_gpio0_probe);
result = platform_driver_register(&axi_gpio0_driver);
printk(KERN_INFO "result = %d\n", result);
printk(KERN_INFO "test_value = %d\n", test_value);
return result;
}
static void __exit axi_gpio0_exit(void)
{
platform_driver_unregister(&axi_gpio0_driver);
printk(KERN_INFO "Goodbye module world.\n");
printk(KERN_INFO "test_value = %d\n", test_value);
}
module_init(axi_gpio0_init);
module_exit(axi_gpio0_exit);
1) Сборка ядра:
CODE
andrei@andrei-pc:~/work/htg_v7_g3/petalinux/peta_test$ petalinux-build
INFO: Checking component...
INFO: Generating make files and build linux
INFO: Generating make files for the subcomponents of linux
INFO: Building linux
[INFO ] pre-build linux/rootfs/axi_gpio0
[INFO ] pre-build linux/rootfs/autologin
[INFO ] pre-build linux/rootfs/fwupgrade
[INFO ] pre-build linux/rootfs/peekpoke
[INFO ] build linux/kernel
[INFO ] generate linux/u-boot configuration files
[INFO ] update linux/u-boot source
[INFO ] build linux/u-boot
[INFO ] build fs-boot
[INFO ] build kernel in-tree modules
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/axi_gpio0
[INFO ] modules linux/kernel
[INFO ] build linux/rootfs/autologin
[INFO ] build linux/rootfs/fwupgrade
[INFO ] build linux/rootfs/peekpoke
[INFO ] post-build linux/rootfs/axi_gpio0
[INFO ] post-build linux/rootfs/autologin
[INFO ] post-build linux/rootfs/fwupgrade
[INFO ] post-build linux/rootfs/peekpoke
[INFO ] pre-install linux/rootfs/axi_gpio0
[INFO ] pre-install linux/rootfs/autologin
[INFO ] pre-install linux/rootfs/fwupgrade
[INFO ] pre-install linux/rootfs/peekpoke
[INFO ] install system.dtb
[INFO ] install linux/kernel
[INFO ] generate linux/u-boot configuration files
[INFO ] update linux/u-boot source
[INFO ] build linux/u-boot
[INFO ] install linux/u-boot
[INFO ] install sys_init
[INFO ] install kernel in-tree modules
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/axi_gpio0
[INFO ] modules_install linux/kernel
[INFO ] install linux/rootfs/autologin
[INFO ] install linux/rootfs/fwupgrade
[INFO ] install linux/rootfs/peekpoke
[INFO ] post-install linux/rootfs/axi_gpio0
[INFO ] post-install linux/rootfs/autologin
[INFO ] post-install linux/rootfs/fwupgrade
[INFO ] post-install linux/rootfs/peekpoke
[INFO ] package rootfs.cpio to /home/andrei/work/htg_v7_g3/petalinux/peta_test/images/linux
[INFO ] Update and install vmlinux image
[INFO ] vmlinux linux/kernel
[INFO ] install linux/kernel
[INFO ] package simpleImage.mb
[INFO ] simpleImage.mb linux/kernel
[INFO ] install linux/kernel
[INFO ] Package HDF bitstream
webtalk failed:PetaLinux statistics:extra lines detected:notsent_nofile!
webtalk failed:Failed to get PetaLinux usage statistics!
andrei@andrei-pc:~/work/htg_v7_g3/petalinux/peta_test$
andrei@andrei-pc:~/work/htg_v7_g3/petalinux/peta_test$
2) Загрузка ядра в QEMU
CODE
andrei@andrei-pc:~/work/htg_v7_g3/petalinux/peta_test$ petalinux-boot --qemu --kernelqemu_cmd=qemu-system-microblazeel
--------------------------------------------------------------------
Xilinx QEMU Dec 10 2015 13:38:20.
--------------------------------------------------------------------
INFO: TCP PORT is free
INFO: Starting microblaze QEMU
INFO: qemu-system-microblazeel -L /opt/pkg/petalinux-v2015.4-final/etc/qemu -M microblaze-fdt-plnx -m 256 -serial mon:stdio -serial /dev/null -display none -kernel /home/andrei/work/htg_v7_g3/petalinux/peta_test/images/linux/image.elf -gdb tcp::9000 -dtb /tmp/tmp.ggssIoMAoO -tftp /tftpboot
--------------------------------------------------------------------
Xilinx QEMU Dec 10 2015 13:38:20.
--------------------------------------------------------------------
Ramdisk addr 0x00000000,
FDT at 0x40b11668
Linux version 4.0.0 (andrei@andrei-pc) (gcc version 4.9.2 (crosstool-NG 1.20.0) ) #170 Mon Apr 11 09:02:31 MSK 2016
setup_cpuinfo: initialising
setup_cpuinfo: No PVR support. Using static CPU info from FDT
wt_msr_noirq
setup_memory: max_mapnr: 0x40000
setup_memory: min_low_pfn: 0x40000
setup_memory: max_low_pfn: 0x70000
setup_memory: max_pfn: 0x80000
Zone ranges:
DMA [mem 0x0000000040000000-0x000000006fffffff]
Normal empty
HighMem [mem 0x0000000070000000-0x000000007fffffff]
Movable zone start for each node
Early memory node ranges
node 0: [mem 0x0000000040000000-0x000000007fffffff]
Initmem setup node 0 [mem 0x0000000040000000-0x000000007fffffff]
On node 0 totalpages: 262144
free_area_init_node: node 0, pgdat c03d3004, node_mem_map c1000000
DMA zone: 1536 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 196608 pages, LIFO batch:31
HighMem zone: 65536 pages, LIFO batch:15
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260608
Kernel command line: console=ttyUL0,115200 earlyprintk
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1027408K/1048576K available (2965K kernel code, 95K rwdata, 816K rodata, 6856K init, 545K bss, 21168K reserved, 0K cma-reserved, 262144K highmem)
Kernel virtual memory layout:
* 0xfffea000..0xfffff000 : fixmap
* 0xff800000..0xffc00000 : highmem PTEs
* 0xff800000..0xff800000 : early ioremap
* 0xf0000000..0xff800000 : vmalloc & ioremap
NR_IRQS:33
/amba_pl/interrupt-controller@10002000: num_irq=2, edge=0x2
/amba_pl/timer@10000000: irq=1
xilinx_timer_set_mode: shutdown
xilinx_timer_set_mode: periodic
sched_clock: 32 bits at 150MHz, resolution 6ns, wraps every 28633115641ns
Calibrating delay loop... 723.76 BogoMIPS (lpj=3618816)
pid_max: default: 4096 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
devtmpfs: initialized
NET: Registered protocol family 16
Switched to clocksource xilinx_clocksource
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP: reno registered
UDP hash table entries: 512 (order: 2, 24576 bytes)
UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
NET: Registered protocol family 1
Skipping unavailable RESET gpio -2 (reset)
futex hash table entries: 16 (order: -4, 448 bytes)
romfs: ROMFS MTD © 2007 Red Hat, Inc.
bounce: pool size: 64 pages
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
10001000.serial: ttyUL0 at MMIO 0x10001000 (irq = 2, base_baud = 0) is a uartlite
console [ttyUL0] enabled
brd: module loaded
i2c /dev entries driver
TCP: cubic registered
NET: Registered protocol family 17
Key type encrypted registered
Freeing unused kernel memory: 6856K (c03d4000 - c0a86000)
INIT: version 2.88 booting
Creating /dev/flash/* device nodes
random: dd urandom read with 9 bits of entropy available
Starting internet superserver: inetd.
update-rc.d: /etc/init.d/run-postinsts exists during rc.d purge (continuing)
Removing any system startup links for run-postinsts ...
/etc/rcS.d/S99run-postinsts
INIT: Entering runlevel: 5
Configuring network interfaces... ifconfig: SIOCGIFFLAGS: No such device
login[290]: root login on 'console'
-sh: can't access tty; job control turned off
root@peta_test:~#
root@peta_test:~#
root@peta_test:~#
root@peta_test:~#
3)Загрузка модуля ядра (axi_gpio0)
CODE
root@peta_test:~#
root@peta_test:~#
root@peta_test:~#
root@peta_test:~#
root@peta_test:~# cd /lib/modules/4.0.0/extra/
root@peta_test:/lib/modules/4.0.0/extra#
root@peta_test:/lib/modules/4.0.0/extra#
root@peta_test:/lib/modules/4.0.0/extra#
root@peta_test:/lib/modules/4.0.0/extra# insmod axi_gpio0.ko
Ver - 09:01 11.03.2016
Hello module world.
Hello module world.
.compatible = xlnx,xps-gpio-1.00.a
result = 12
axi_gpio0_driver.probe = f00dc000
axi_gpio0_probe = f00dc000
result = 0
test_value = 0
root@peta_test:/lib/modules/4.0.0/extra#
root@peta_test:/lib/modules/4.0.0/extra#
root@peta_test:/lib/modules/4.0.0/extra#
4) Хотим посмотреть device tree
CODE
root@peta_test:/lib/modules/4.0.0/extra# cd /proc/device-tree/
root@peta_test:/sys/firmware/devicetree/base#
root@peta_test:/sys/firmware/devicetree/base# ls -al
-r--r--r-- 1 root root 4 Jan 1 00:01 #address-cells
-r--r--r-- 1 root root 4 Jan 1 00:01 #size-cells
drwxr-xr-x 8 root root 0 Jan 1 00:01 .
drwxr-xr-x 3 root root 0 Jan 1 00:01 ..
drwxr-xr-x 2 root root 0 Jan 1 00:01 aliases
drwxr-xr-x 8 root root 0 Jan 1 00:01 amba_pl
drwxr-xr-x 2 root root 0 Jan 1 00:01 chosen
drwxr-xr-x 4 root root 0 Jan 1 00:01 clocks
-r--r--r-- 1 root root 16 Jan 1 00:01 compatible
drwxr-xr-x 3 root root 0 Jan 1 00:01 cpus
drwxr-xr-x 2 root root 0 Jan 1 00:01 memory
-r--r--r-- 1 root root 10 Jan 1 00:01 model
-r--r--r-- 1 root root 1 Jan 1 00:01 name
root@peta_test:/sys/firmware/devicetree/base#
5) Содержимое директории amba_pl:
CODE
root@peta_test:/sys/firmware/devicetree/base# cd amba_pl/
root@peta_test:/sys/firmware/devicetree/base/amba_pl#
root@peta_test:/sys/firmware/devicetree/base/amba_pl#
root@peta_test:/sys/firmware/devicetree/base/amba_pl# ls -al
-r--r--r-- 1 root root 4 Jan 1 00:01 #address-cells
-r--r--r-- 1 root root 4 Jan 1 00:01 #size-cells
drwxr-xr-x 8 root root 0 Jan 1 00:01 .
drwxr-xr-x 8 root root 0 Jan 1 00:01 ..
-r--r--r-- 1 root root 11 Jan 1 00:01 compatible
drwxr-xr-x 2 root root 0 Jan 1 00:01 gpio@10003000
drwxr-xr-x 2 root root 0 Jan 1 00:01 interrupt-controller@10002000
-r--r--r-- 1 root root 4 Jan 1 00:01 linux,phandle
drwxr-xr-x 2 root root 0 Jan 1 00:01 memory-controller@40000000
-r--r--r-- 1 root root 8 Jan 1 00:01 name
-r--r--r-- 1 root root 4 Jan 1 00:01 phandle
-r--r--r-- 1 root root 0 Jan 1 00:01 ranges
drwxr-xr-x 2 root root 0 Jan 1 00:01 serial@10001000
drwxr-xr-x 2 root root 0 Jan 1 00:01 serial@20000000
drwxr-xr-x 2 root root 0 Jan 1 00:01 timer@10000000
root@peta_test:/sys/firmware/devicetree/base/amba_pl#
6) Содержимое gpio@10003000:
CODE
root@peta_test:/sys/firmware/devicetree/base/amba_pl#
root@peta_test:/sys/firmware/devicetree/base/amba_pl# cd gpio@10003000/
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000# ls -al
-r--r--r-- 1 root root 4 Jan 1 00:02 #gpio-cells
drwxr-xr-x 2 root root 0 Jan 1 00:01 .
drwxr-xr-x 8 root root 0 Jan 1 00:01 ..
-r--r--r-- 1 root root 12 Jan 1 00:02 compatible
-r--r--r-- 1 root root 0 Jan 1 00:02 gpio-controller
-r--r--r-- 1 root root 5 Jan 1 00:02 name
-r--r--r-- 1 root root 8 Jan 1 00:02 reg
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,all-inputs
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,all-inputs-2
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,all-outputs
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,all-outputs-2
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,dout-default
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,dout-default-2
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,gpio-width
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,gpio2-width
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,interrupt-present
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,is-dual
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,tri-default
-r--r--r-- 1 root root 4 Jan 1 00:02 xlnx,tri-default-2
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
7) Содержимое compatible в директории gpio@10003000:
CODE
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000# cat compatible
invalidated
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
root@peta_test:/sys/firmware/devicetree/base/amba_pl/gpio@10003000#
Почему показало "invalidated" вместо "xlnx,xps-gpio-1.00.a", что содержится в конфигурационных файлах для device tree (цеплял выше)?
Цитата(nill @ Apr 10 2016, 09:58)

Проверьте параметр CONFIG_OF в конфигурации ядра.
CONFIG_OF=y