Cross-compiling device driver with Visual Studio Code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cross-compiling device driver with Visual Studio Code

1,853 Views
hello-world123
Contributor II

Hello, My name is john. I'm currently building cross-compile environment with visual studio code.

With Variscite's document and NXP's i.MX Porting Guide, I successfully built user-space application cross-compile environment with visual studio code. 

The following links are what I referred.

Variscite's document

https://variwiki.com/index.php?title=Yocto_Programming_with_VSCode&release=RELEASE_HARDKNOTT_V1.0_DA...

NXP's document (2.1.1 How to build and load Kernel in standalone environment)

https://www.nxp.com/docs/en/user-guide/IMX_PORTING_GUIDE.pdf

I want to build device driver with the same method, but I have difficulties about setting kernel headers.

When I bitbake, I added the following to my recipe to include kernel source to sdk which generated by populate_sdk.

TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc"

I made dummy device driver 'dummy.c' in https://github.com/PacktPublishing/Mastering-Embedded-Linux-Programming-Second-Edition/blob/master/C...

With dummy.c, I run 'make' and VScode show me lots of errors. I think I have to match kernel header carefully, but I don't know how to do.

 The following figure is errors which VScode shows to me.

Daewoong92_0-1637733707482.png

The following figure is my c_cpp_properties.json in VScode and my SDK's location is '/opt/fsl-imx-wayland/4.14-sumo/sysroots/aarch64-poky-linux/*'.

Daewoong92_1-1637733859981.png

The following figure is my Makefile in VScode.

Daewoong92_2-1637733914999.png

Thanks for your help.

Labels (1)
0 Kudos
5 Replies

1,834 Views
Yuri
NXP Employee
NXP Employee

@hello-world123 
Hello,

   VSCode can be used for development of relatively simple applications.
Hardly it is suitable for Linux driver design, since this area is very kernel / version
sensitive.   I think it makes sense to rely on standard approaches here.

Regards,
Yuri.

0 Kudos

1,829 Views
bladerunner1010
Contributor III

Is there a manual for cross compiling?

0 Kudos

1,811 Views
Yuri
NXP Employee
NXP Employee

@bladerunner1010 
Hello,

   usually driver sources are provided with instructions how to compile them.

Regards,
Yuri.

0 Kudos

1,806 Views
hello-world123
Contributor II

Hi, @Yuri . Thank you for your reply.

Your saying is that typical way to develop device driver is like this?

 

1. Edit/add device driver code and Makefile of kernel source in Yocto build directory with editor like vim.

2. Bitbake to build.

3. Test the device driver

 

If so, I think it's quite inefficient ways for developing.

According to your mention, am I understand right?

 

Thanks in advance.

0 Kudos

1,803 Views
Yuri
NXP Employee
NXP Employee

@hello-world123 
Hello,

  It would be better to build toolchain, build / load Kernel in standalone environment,
as mentioned in "IMX_PORTING_GUIDE.pdf", unpack driver package with sources
and follow driver's documentation. Yocto approach is not used here.

Regards,
Yuri.

0 Kudos