Re: rtai testsuite make issue (magma kernel)

bhargavb <[email protected]> Fri, 28 Apr 2017 13:46:25 +0530
Newsgroups gmane.linux.real-time.rtai
Message-ID <CA+bpL9LHLtg=M03B7ixxU54nT9wN4un2_E18miufmSvtHh-2Kw@mail.gmail.com>
Dear Paolo,

I am using the magma, branch now.
I could build testsuite and run all tests in the testsuite succesfully,
with no errors. (sudo make, sudo make install in rtai source is done
succesfully).

Still, I am missing something.

*When I am trying to compile a kernel module (Attached Makefile, source,
complete error log), getting below error (.ko file is formed though):*









*- - - - - - Building modules, stage 2.MODPOST 1 modulesWARNING:
"rt_task_delete" [/home/bhargavb/2/p1_rtai.ko] undefined!WARNING:
"rtf_destroy" [/home/bhargavb/2/p1_rtai.ko] undefined!WARNING:
"stop_rt_timer" [/home/bhargavb/2/p1_rtai.ko] undefined!WARNING:
"rt_task_make_periodic" [/home/bhargavb/2/p1_rtai.ko] undefined! - - -- - -*

*Note: *
When I placed Module.symvers file from /usr/realtime/modules to my current
directory of new kernel module build, I am not getting above errors, and
.ko file is formed, but insmod shows the error saying undefined symbols
found, cannot insert.

Kindly guide.

Thanks and regards,
Bhargav

On Fri, Apr 28, 2017 at 12:52 PM, Paolo Mantegazza <
[email protected]> wrote:

> You are likely working with something that is not up to date.
> I do not see any 3.16 patch in the supported stable RTAI version (aka
> Vulcano CVS), where there are patches for 3.10.32, 3.14.44, 3.18.20 and
> 4.1.18.
>
> Paolo.
>
>
> On 04/28/2017 05:47 AM, bhargavb wrote:
>
> Thank you for the responses.
>
> I realized lately that I have not built rtai source (make menuconfig,
> make, install in rtai source folder).
>
> Quick summary of steps I followed as per https://www.rtai.org/
> userfiles/downloads/RTAILAB/RTAI-TARGET-HOWTO.txt ( I excluded MESA lib
> and EFLTK lib installation steps though ie step 7, 8;  executing remaining
> as is).
>
>
>    - I have taken https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.
>    tar.gz
>    - I have taken rtai - magma from https://github.com/ShabbyX/
>    RTAI/tree/magma
>    - Patch  : Tried with hal-linux-3.16-x86-3.patch
>    <https://github.com/ShabbyX/RTAI/blob/magma/base/arch/x86/patches/hal-linux-3.16-x86-3.patch>
>    and hal-linux-3.16-x86-3.patch
>    <https://github.com/ShabbyX/RTAI/blob/magma/base/arch/x86/patches/hal-linux-3.16-x86-3.patch>,
>    facing same issue with both of them.
>    - After building linux kernel source, making modifications as
>    mentioned and rebooting to newly built kernel, Now executing step 9 which
>    builds and install rtai source. *Getting error here as:*
>
> - - - - -
>
> - - - -
>
> config.status: creating rtai-lab/scilab/utility/GNUmakefile
> config.status: creating testsuite/GNUmakefile
> config.status: creating testsuite/kern/GNUmakefile
> config.status: creating testsuite/kern/latency/GNUmakefile
> config.status: creating testsuite/kern/preempt/GNUmakefile
> config.status: creating testsuite/kern/switches/GNUmakefile
> config.status: error: cannot find input file: `testsuite/kthreads/
> GNUmakefile.in'
> makefile:53: recipe for target 'config.status' failed
> make[1]: *** [config.status] Error 1
> make[1]: Leaving directory '/usr/src/rtai'
> GNUmakefile:918: recipe for target 'menuconfig' failed
> make: *** [menuconfig] Error 2
> bhargavb@bhargavb-Latitude-E6500:/usr/src/rtai$
>
> *Note:* I tried in menuconfig by disabling "build rtai test suite" and
> saved it, because the error I got is related to testsuite make files
> generation, but it does'nt have any effect.(Could not figure out whar is
> wrong).
>
> I sincerely request your inputs, as am currently in time critical project
> where I need to port my desktop application to real time. I am unable to
> setup the rtai environment.
>
> Thanks and regards,
>
> Bhargav
>
>
>
>
>
>
>
>
>
>
> On Thu, Apr 27, 2017 at 7:33 PM, Shahbaz Youssefi <[email protected]>
> wrote:
>
>> Make sure to use the `rtai-config` command (try --help for options) to
>> extract compile flags and kernel module symbols (or libraries if building
>> for userspace) required to build with RTAI, and then use them!
>>
>> On Thu, Apr 27, 2017 at 6:24 AM, bhargavb <[email protected]>
>> wrote:
>>
>>> Dear team,
>>>
>>> I could build rtai linux on 3.16 kernel and able to select corresponding
>>> boot option in grub bootloade for the newly built kernel with rtai patch.
>>> Thanks for the guidance.
>>>
>>>
>>>
>>> *I havent built the rtai testsuite yet. Is it mandatory to build rtai
>>> test suite before starting writing rtai kernel modules? *
>>>
>>> *I mean: Do below steps matter to be run, before I start writing and
>>> inserting my rtai kernel modules?  (Asking because am getting error saying
>>> rtai.h not found when I try to build an rtai kernel module, and it seems I
>>> am missing something yet) *
>>>
>>> STEP 9 - Configure and install RTAI
>>> ------------------------------------
>>>     Again, as root :
>>>
>>>     $ cd /usr/src/rtai
>>>     $ make config (or make menuconfig of make xconfig)
>>>
>>>     In the Machine Menu adjust the number of processors.
>>>     Say yes to rtai lab, and leave the efltk folder to /usr/local
>>>     Do not include comedi support at this time even if you plan to use it later.
>>>     Do not change any other default choice unless you know what you are doing.
>>>
>>>     $ make
>>>     $ make install
>>>
>>>     reboot :
>>>
>>>     $ /usr/bin/reboot
>>>
>>> Thank you very much,
>>> Bhargav
>>> _______________________________________________ Rtai mailing list
>>> [email protected] https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
>>
>> --
> Bhargav
>
>


-- 
Bhargav

_______________________________________________
Rtai mailing list
[email protected]
https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
Makefile (application/octet-stream, 753 B) - not displayed
p1_rtai.c (text/x-csrc, 2.9 KB)
/*
FILE: rt_process.c
COPYRIGHT (C) 1999 Paolo Mantegazza ([email protected])
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version

RT Task Programming Basics
29
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
*/

#include <linux/module.h>
#include <asm/io.h>
#include <rtai.h>
#include <rtai_sched.h>
#include <rtai_fifos.h>
#define TIMERTICKS 500000
#define CMDF0 0
#define ONE_SHOT
static RT_TASK Slow_Task;
static RT_TASK Fast_Task;

#define NR_RT_CPUS 1

static int cpu_used[NR_RT_CPUS];
static void Slow_Thread(int t)
{
	static struct 
	{ 
		char task, susres;
		unsigned long flags;
		RTIME time;} msg = {'S',};

		while (1) {
		//cpu_used[hard_cpu_id()]++;
		cpu_used[0] ++;
		msg.time = rt_get_cpu_time_ns();
		msg.susres = 'r';
		rt_global_save_flags(&msg.flags);
		rtf_put(CMDF0, &msg, sizeof(msg));
		rt_busy_sleep(11*TIMERTICKS);
		msg.time = rt_get_cpu_time_ns();
		msg.susres = 's';
		rt_global_save_flags(&msg.flags);
		rtf_put(CMDF0, &msg, sizeof(msg));
		rt_task_wait_period();
	}
}

static void Fast_Thread(int t)
{
	static struct 
	{ 
		char task, susres;
		unsigned long flags;
		RTIME time;
	} msg = {'F',};
	while (1) 
	{
		//cpu_used[hard_cpu_id()]++;
		cpu_used[0]++;
		msg.time = rt_get_time_ns();
		msg.susres = 'r';
		rt_global_sti();
		rt_global_save_flags(&msg.flags);
		rtf_put(CMDF0, &msg, sizeof(msg));
		rt_busy_sleep(2*TIMERTICKS);
		msg.time = rt_get_time_ns();
		msg.susres = 's';
		rt_global_save_flags(&msg.flags);
		rtf_put(CMDF0, &msg, sizeof(msg));
		rt_task_wait_period();
	}
}

int init_module(void)
{
	RTIME tick_period;
	RTIME now;
	rtf_create_using_bh(CMDF0, 20000, 0);
	rt_task_init(&Fast_Task, Fast_Thread, 0, 2000, 0, 0, 0);
	rt_task_init(&Slow_Task, Slow_Thread, 0, 2000, 1, 0, 0);
#ifdef ONE_SHOT
	rt_set_oneshot_mode();
#endif
	tick_period = 4*start_rt_timer(nano2count(TIMERTICKS));
	now = rt_get_time();
	rt_task_make_periodic(&Fast_Task, now + tick_period,tick_period);
	
	rt_task_make_periodic(&Slow_Task, now + tick_period,6*tick_period);
	
	return 0;
}

void cleanup_module(void)
{
	int cpuid;
	stop_rt_timer();
	rt_busy_sleep(10000000);
	rtf_destroy(CMDF0);
	rt_task_delete(&Slow_Task);
	rt_task_delete(&Fast_Task);
	printk("\n\nCPU USE SUMMARY\n");
	for (cpuid = 0; cpuid < NR_RT_CPUS; cpuid++) 
	{
		printk("# %d -> %d\n", cpuid, cpu_used[cpuid]);
	}
	printk("END OF CPU USE SUMMARY\n\n");
}
error.log (text/x-log, 1.2 KB)
make -C /lib/modules/3.16.0/build M=/home/bhargavb/2 modules
make[1]: Entering directory '/usr/src/linux-3.16'
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "rt_task_delete" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rtf_destroy" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "stop_rt_timer" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_task_make_periodic" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_get_time" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "start_rt_timer" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "nano2count" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_set_oneshot_mode" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_task_init" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rtf_create" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_get_time_ns" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_task_wait_period" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_busy_sleep" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rtf_put" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rtai_cpu_lock" [/home/bhargavb/2/p1_rtai.ko] undefined!
WARNING: "rt_get_cpu_time_ns" [/home/bhargavb/2/p1_rtai.ko] undefined!
make[1]: Leaving directory '/usr/src/linux-3.16'