Jump to content
OMRON Forums

Using kmalloc() in user servo algorithm


maartenvervelde
 Share

Recommended Posts

Hi,

 

I want to use the kmalloc funtion in my own user servo algorithm but the compiler can't find the flags. When I try to call it like this: (struct variable*)kmalloc(sizeof (struct variables), GFP_KERNEL); the compiler says that GFP_KERNEL undefined is.

 

It should be defined because it should be included already.

I tried to include linux/gfp.h but then I got the following errors.

user_servo.c(28,0): Warning : in file included from user_servo.c
usr\local\bin\..\lib\gcc\powerpc-405-linux-gnu\4.2.2\..\..\..\..\powerpc-405-linux-gnu\sys-include\linux\gfp.h(4,0): Error :  linux/mmzone.h
user_servo.c(28,0): Warning : in file included from  user_servo.c
usr\local\bin\..\lib\gcc\powerpc-405-linux-gnu\4.2.2\..\..\..\..\powerpc-405-linux-gnu\sys-include\linux\gfp.h(89,0): Error :  'MAX_ORDER' undeclared (first use in this function)
usr\local\bin\..\lib\gcc\powerpc-405-linux-gnu\4.2.2\..\..\..\..\powerpc-405-linux-gnu\sys-include\linux\gfp.h(89,0): Error :  (Each undeclared identifier is reported only once
usr\local\bin\..\lib\gcc\powerpc-405-linux-gnu\4.2.2\..\..\..\..\powerpc-405-linux-gnu\sys-include\linux\gfp.h(89,0): Error :  for each function it appears in.)
usr\local\bin\..\lib\gcc\powerpc-405-linux-gnu\4.2.2\..\..\..\..\powerpc-405-linux-gnu\sys-include\linux\gfp.h(93,0): Error :  invalid type argument of '->'
usr\local\bin\..\lib\gcc\powerpc-405-linux-gnu\4.2.2\..\..\..\..\powerpc-405-linux-gnu\sys-include\linux\gfp.h(93,0): Error :  'GFP_ZONEMASK' undeclared (first use in this function)

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

I am using kmalloc in one of my kernel modules, so this definitely can be done. I am #include'ing to get the GFP_KERNEL flag, but I am also compiling with my own makefile outside of the IDE.

 

All of the errors except the first are caused by the compiler failing to find linux/mmzone.h, which defines the macros that you are missing. It looks like it is grabbing the wrong linux/gfp.h. For the user servo code, you want:

 

"\opt\eldk-4.2\debian_rootfs\usr\src\\include\linux\gfp.h"

 

Instead, the IDE is including:

"\usr\local\powerpc-405-linux-gnu\sys-include\linux\gfp.h"

 

I don't know if there is a way to fix this other than manually editing the makefile. Perhaps someone else knows?

Link to comment
Share on other sites

Thank you for your response.

 

I am trying to make a makefile myself for the power brick to compile it with the correct header.

 

I also found the makefile used by the IDE, but it is generated every time the program is build. Is there a way to change the code generation to include the other files, or should I just keep on focussing on making my own makefile?

 

I am using kmalloc in one of my kernel modules, so this definitely can be done. I am #include'ing to get the GFP_KERNEL flag, but I am also compiling with my own makefile outside of the IDE.

 

All of the errors except the first are caused by the compiler failing to find linux/mmzone.h, which defines the macros that you are missing. It looks like it is grabbing the wrong linux/gfp.h. For the user servo code, you want:

 

"\opt\eldk-4.2\debian_rootfs\usr\src\\include\linux\gfp.h"

 

Instead, the IDE is including:

"\usr\local\powerpc-405-linux-gnu\sys-include\linux\gfp.h"

 

I don't know if there is a way to fix this other than manually editing the makefile. Perhaps someone else knows?

Link to comment
Share on other sites

Making your own makefile is not the way most Delta Tau users use the software, so it is up to you if you want to pursue that path or not. I have used my own makefiles for many years, but I also don't use the IDE so I don't have to code in Windows!

 

I do recall that the IDE regenerates the makefiles during each compile, but I don't know if there is a way to suppress this or add your own includes into the auto-generated makefile via the IDE. Someone who is more familiar with the IDE will have to answer this question.

 

For now, you could use the auto-generated makefile as a starting place and simply change the include statement to point to the correct folder. To do this you will need to compile (in the IDE), let it fail, then modify the makefile, then manually compile from the cygwin bash shell by issuing 'make all'.

Link to comment
Share on other sites

When I try to use the cygwin terminal to makt the servo loop, I get the error:

make[1]: powerpc-405-linux-gnu-gcc: Command not found

 

Do I have to make my own cross compiler or is there a way to link the crosscompiler from Delta Tau to the terminal?

 

Also, when I try to run the make all command, I get some error because the paths to the files contain spaces. I'm fixing this right now by giving the full path on my C:/, but thats not a usefull option if I want to use it to create programs, is there a way to fix that?

 

Making your own makefile is not the way most Delta Tau users use the software, so it is up to you if you want to pursue that path or not. I have used my own makefiles for many years, but I also don't use the IDE so I don't have to code in Windows!

 

I do recall that the IDE regenerates the makefiles during each compile, but I don't know if there is a way to suppress this or add your own includes into the auto-generated makefile via the IDE. Someone who is more familiar with the IDE will have to answer this question.

 

For now, you could use the auto-generated makefile as a starting place and simply change the include statement to point to the correct folder. To do this you will need to compile (in the IDE), let it fail, then modify the makefile, then manually compile from the cygwin bash shell by issuing 'make all'.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...