cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
liwenz
Explorer
Explorer
441 Views
Registered: ‎10-09-2017

what's the wrong about the gpio petalinux example?

I follow the ug 1165, chapter 7 page 92-106

Linux-Based Device Driver Development

When I test the app, it stops as follow:

 

root@gpio:/mnt# ./helloa.elf
################################
Blink LED Application device_open(c7c19900)

################################
************************************************
Press '1' to Start Blink LED TEST
Press '0' to Stop Blink LED TEST
************************************************
1
Choice :: 1

Then I can't quit or exit.

 

I make some change to the project.

I only use the gpio axi ip, 4-bit led.

and the address is 

#define BLINK_CTRL_REG 0x43C00000=>

#define BLINK_CTRL_REG 0x41200000

 

I think it block at

ioctl_OFF_LED(file_desc);

 

any idea?

 

-----------------------

petalinux-create -t modules --name blink --enable

cp blink.c blink.h to the files folder, change the bb file to include blink.h

change the address #define BLINK_CTRL_REG 0x41200000

petalinux build

get the blink.ko 

cp to petalinux

insmod blink.ko

mknod /dev/blink_Dev c 245

on SDK, cp linux_blinkled_app.c and blink.h 

Run As

I got helloa.elf at /mnt

in /mnt ./helloa.elf

open device is ok, but I choose 1, it stop at ioctl_OFF_LED(file_desc);

0 Kudos
1 Reply
liwenz
Explorer
Explorer
400 Views
Registered: ‎10-09-2017

I change to use the write function:

for(i=7;i>=0;i--)
{
stringToSend[0]=i%8;
ret = write(fd, stringToSend, 1); // Send the string to the LKM
if (ret < 0){
perror("Failed to write the message to the device.");
return errno;
}
usleep(1000000);
}

 

Then it break like follow:

 

root@gpio:~# ./helloa.elf
Starting device test code example...
device_open(dd1533c0)
Type in a short string to send to the kernel module:
device_write
Unhandled fault: page domain fault (0x01b) at 0xbe944ba4
pgd = c7eb0000
[be944ba4] *pgd=1e58b831, *pte=07b2775f, *ppte=07b27c7f
Internal error: Oops - BUG: 1b [#1] PREEMPT SMP ARM
Modules linked in: blink(O) uio_pdrv_genirq
CPU: 0 PID: 1209 Comm: helloa.elf Tainted: G O 4.14.0-xilinx-v2018.2 #1
Hardware name: Xilinx Zynq Platform
task: de71d380 task.stack: de4f2000
PC is at device_write+0x1c/0x44 [blink]
LR is at device_write+0x10/0x44 [blink]
pc : [<bf010070>] lr : [<bf010064>] psr: 600d0013
sp : de4f3ef8 ip : 00000000 fp : be944cb4
r10: 00000000 r9 : de4f2000 r8 : be944ba4
r7 : de4f3f88 r6 : 00000000 r5 : bf010054 r4 : be944ba4
r3 : bf012440 r2 : e0993000 r1 : 1e288000 r0 : bf0110de
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 18c5387d Table: 07eb004a DAC: 00000051
Process helloa.elf (pid: 1209, stack limit = 0xde4f2210)
Stack: (0xde4f3ef8 to 0xde4f4000)
3ee0: dd1533c0 c01d3c58
3f00: 00000000 00000000 00000000 de4f3f10 00000021 c7e1d540 00000000 c7c52660
3f20: 00000000 c01bc488 00000003 de6d5240 de70c500 de70c540 00000001 dd1533c0
3f40: de4f3f88 00000001 dd1533c0 00000001 00000000 de4f3f88 be944ba4 c01d3ecc
3f60: dd1533c0 be944ba4 00000001 dd1533c0 dd1533c0 be944ba4 00000001 c01071e4
3f80: de4f2000 c01d403c 00000000 00000000 00000001 00010914 00000000 000104dc
3fa0: 00000004 c0107020 00010914 00000000 00000003 be944ba4 00000001 00000000
3fc0: 00010914 00000000 000104dc 00000004 00000000 00000000 b6f04fac be944cb4
3fe0: b6e558ec be944b88 00010668 b6e5590c 600d0010 00000003 cffafdbd ed3d7fd3
[<bf010070>] (device_write [blink]) from [<c01d3c58>] (__vfs_write+0x1c/0x11c)
[<c01d3c58>] (__vfs_write) from [<c01d3ecc>] (vfs_write+0xb8/0x144)
[<c01d3ecc>] (vfs_write) from [<c01d403c>] (SyS_write+0x3c/0x74)
[<c01d403c>] (SyS_write) from [<c0107020>] (ret_fast_syscall+0x0/0x48)
Code: eb4506db e59f3024 e59f0024 e5932000 (e5d43000)
---[ end trace b131d733732f70e8 ]---
device_release(dd06bb30,dd1533c0)
Segmentation fault
root@gpio:~#

0 Kudos