Device driver initialization sequence
Ярослав Лещинский
midniwalker at gmail.com
Sun Nov 11 12:50:47 UTC 2018
Also:
R0 = 0x2000125c R8 = 0x00000000
R1 = 0x0000f7d0 R9 = 0x00000000
R2 = 0x200033c8 R10 = 0x00000000
R3 = 0x20001084 R11 = 0x00000000
R4 = 0x024010e8 R12 = 0x00008b00
R5 = 0x00006301 SP = 0xffffff04
R6 = 0x00000001 LR = 0x00007791
R7 = 0x00000000 PC = 0x0000631e
XPSR = 0x21000000 VEC = 0x00000003
RTEMS version: 5.0.0.6ade69e777ed678d9776956dbe32e858232f915e-modified
RTEMS tools: 7.3.0 20180125 (RTEMS 5, RSB
f07d2b6e9ad70d62eb617a9f5515c5045ee0c119, Newlib
08eab6396f678cf5e5968acaed0bae9fd129983b)
executing thread ID: 0x089010001
executing thread name: IDLE
Checking the PC pointed to _Thread_queue_Enqueue:
0000630c <_Thread_queue_Enqueue>:
630c: e92d 41f0 stmdb sp!, {r4, r5, r6, r7, r8, lr}
6310: 4604 mov r4, r0
6312: 6550 str r0, [r2, #84] ; 0x54
6314: e003 b.n *631e* <_Thread_queue_Enqueue+0x12>
6316: 42a2 cmp r2, r4
6318: d04c beq.n 63b4 <_Thread_queue_Enqueue+0xa8>
631a: 6d64 ldr r4, [r4, #84] ; 0x54
631c: b114 cbz r4, 6324 <_Thread_queue_Enqueue+0x18>
*631e*: 6864 ldr r4, [r4, #4]
Digging into the close function I found that fatal occurred when I try to
get inside rtems_libio_free. If I try to get just an address of that
function fatal occurred also. Maybe I corrupt some addresses by stack
overflow? But my program doesn't do anything, just created node, open it,
cal ioctl and than try to close with corresponding fd. I have no debugger
right now, maybe someone can give me some advice how I can debug this
problem without debugger?
Thank you.
On Fri, 9 Nov 2018 at 18:02, Ярослав Лещинский <midniwalker at gmail.com>
wrote:
> I've tried the variant with posix descriptor and got an error when trying
> to call close(fd). Program crashed with RTEMS_FATAL_SOURCE_EXCEPTION.
>
> 107 rv = IMFS_make_generic_node(
> 108 "/dev/gpio",
> 109 S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
> 110 &gpio_node_control,
> 111 NULL);
> 112
> 113 assert(rv == 0);
> 114
> 115 fd = open("/dev/gpio", O_RDWR);
> 116
> 117 if(fd < 0)
> 118 {
> 119 printf("stderr:[%s] at: [%d]\n", strerror (errno), __LINE__);
> 120 }
> 121
> 122 rv = ioctl(fd, SET_HIGH, NULL);
> 123
> 124 if(rv < 0)
> 125 {
> 126 printf("stderr:[%s] at: [%d]\n", strerror (errno), __LINE__);
> 127 }
> 128 */* Everything was ok until now*/*
> 129 rv = close(fd);
> 130 if(rv != 0)
> 131 {
> 132 printf("stderr:[%s] at: [%d]\n", strerror (errno), __LINE__);
> 133 }
>
> It even didn't enter inside the if block line:132.
> For test purpose I'm using such declaration of file handlers:
>
> static const rtems_filesystem_file_handlers_r gpio_node_handlers = {
> .open_h = rtems_filesystem_default_open,
> .close_h = rtems_filesystem_default_close,
> .read_h = NULL,
> .write_h = NULL,
> .ioctl_h = gpio_bus_ioctl,
> .lseek_h = rtems_filesystem_default_lseek,
> .fstat_h = IMFS_stat,
> .ftruncate_h = rtems_filesystem_default_ftruncate,
> .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
> .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
> .fcntl_h = rtems_filesystem_default_fcntl,
> .kqfilter_h = rtems_filesystem_default_kqfilter,
> .mmap_h = rtems_filesystem_default_mmap,
> .poll_h = rtems_filesystem_default_poll,
> .readv_h = rtems_filesystem_default_readv,
> .writev_h = rtems_filesystem_default_writev
> };
>
> Could someone take a look and give some advice, seems like I made some
> silly mistake.
>
> On Fri, 9 Nov 2018 at 16:26, Ярослав Лещинский <midniwalker at gmail.com>
> wrote:
>
>> Hello Sebastian,
>>
>> Thank you. This looks like what I needed.
>>
>> On Fri, 9 Nov 2018 at 13:32, Sebastian Huber <
>> sebastian.huber at embedded-brains.de> wrote:
>>
>>> Hello Yaroslav,
>>>
>>> the initialization sequence is documented here:
>>>
>>>
>>> https://docs.rtems.org/branches/master/c-user/initialization.html#initializing-rtems
>>>
>>> I would not use the I/O Manager. Working with major/minor numbers is
>>> quite painful. I would initialize custom devices in the initialization
>>> task. If you need the POSIX file descriptor API for your devices, then I
>>> would use IMFS_make_generic_node() to register them.
>>>
>>> On 09/11/2018 11:25, Ярослав Лещинский wrote:
>>> > Hello,
>>> >
>>> > I read the documentation about I/O Manager, found different source
>>> > codes where mentioning not only rtems_io_* functionality but also
>>> > drvmgr*, rtems_libio* and another mechanisms which are referred to
>>> > device driver topic and I have a feeling that I'm missing something.
>>> >
>>> > Could you please correct me if I'm wrong in the following steps of
>>> > initialization of device driver:
>>> >
>>> > 1. define *CONFIGURE_MAXIMUM_DRIVERS* macro
>>> > 1. Create *rtems_driver_address_table *and register it via
>>> > *register_io_register_driver*
>>> > 2. Write all necessary functions for *rtems_io_initialize,
>>> > rtems_io_open, etc*
>>> > 3. Associate name with major:minor pair using *rtems_register_name*
>>> > *
>>> > *
>>> > As I understood there are can be a lot of different device drivers
>>> > tables and I should somehow get the right major:minor driver from the
>>> > right table. How I can do this?
>>> >
>>> > --
>>> > --
>>> > Kind regards,
>>> > *Yaroslav Leshchinsky*
>>> >
>>> > _______________________________________________
>>> > users mailing list
>>> > users at rtems.org
>>> > http://lists.rtems.org/mailman/listinfo/users
>>>
>>> --
>>> Sebastian Huber, embedded brains GmbH
>>>
>>> Address : Dornierstr. 4, D-82178 Puchheim, Germany
>>> Phone : +49 89 189 47 41-16
>>> Fax : +49 89 189 47 41-09
>>> E-Mail : sebastian.huber at embedded-brains.de
>>> PGP : Public key available on request.
>>>
>>> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>>>
>>>
>>
>> --
>> --
>> Kind regards,
>> *Yaroslav Leshchinsky*
>>
>
>
> --
> --
> Kind regards,
> *Yaroslav Leshchinsky*
>
--
--
Kind regards,
*Yaroslav Leshchinsky*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20181111/f25708fb/attachment-0002.html>
More information about the users
mailing list