I am trying to patch the kernel for a Ublox LTE Module (Lara-R6)
I need the patch in the /drivers/usb/serial/option.c file as can also be found here: linux/option.c at master · torvalds/linux · GitHub
If i follow the Building External Kernel Modules With Torizon | Toradex Developer Center instructions there is some parts unclear for me regarding the makefile.
Do I need to tell the makefile the kernel-src or not?
Is it possible to patch this part individually? or do i need to patch all of the files in the serial folder together, as the makefile suggests this: linux-fslc/Makefile at 4.20.x+fslc · toradex/linux-fslc · GitHub
I would be very happy about some insights about how to build the custom image using tcbuild.yaml and my patch in the option.c file.
In the instruction you mentioned it might be possible to build a new module including the newer option.c file? this way more peripheral hardware would be included by default.
Thank you for the help!
Greetings @busssard,
First of all that article you’re referencing that is only for building kernel modules/code that are not already in the Linux kernel source. Here you are trying to build/patch code that is already part of the Linux kernel. Let me preface this by saying this “might” work but, there’s also a good chance it won’t work at all since this was not the intent of the tool.
Unfortunately the only recommended method we have for patching code that is in the Linux kernel source is via a custom build with Yocto.
But first let me try to understand what you’re trying to do here. So you want to patch that file in the Linux kernel in order to add support for this “Ublox LTE Module (Lara-R6)” hardware, correct?
I was taking a look through the kernel history and isn’t this commit what adds support for this hardware: linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules
If so then it seems like our Linux kernel already has this support. Or were you trying to do something different?
Best Regards,
Jeremias
Hello Jeremias,
thank you a lot for your reply!
I still have hope that it might work, so we can skip making a full custom yocto build.
Sadly it is not included, as the Lara module needs the address 0x908b and in the commit is only the 0x90fa.
But yes the change i need to do is exactly in the same manner.
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x908b), /* u-blox LARA-R6 00B */
.driver_info = RSVD(4) },
In case we have to do a custom build with yocto, is there a way to use a prebuild image or do i have to start from scratch? Do you maybe have the right link to get me started?
thank you for the help and have a nice day!
In case we have to do a custom build with yocto, is there a way to use a prebuild image or do i have to start from scratch? Do you maybe have the right link to get me started?
Unfortunately doing a Yocto build usually entails starting from scratch. That said since this looks to be a relatively simple patch, what you can do is start from our reference build for TorizonCore.
We have an article about building TorizonCore from Yocto here: Build Torizon OS from Source With Yocto Project/OpenEmbedded | Toradex Developer Center
This will guide you on how to setup your environment to perform a Yocto build. As for actually applying your patch to the default build, you want to do something like this: Custom meta layers, recipes and images in Yocto Project (hello-world examples) | Toradex Developer Center
Basically just patch the recipe for the Linux kernel to apply your change during the build. Then the resulting TorizonCore image produced should be identical to our pre-built images except for this change of yours.
Best Regards,
Jeremias
thank you Jeremias!
If i do a yocto build, i can also include packages that are not available in the normal Torizon core correct?
Its a bit of a divergence from the original topic, but when going through the effort of doing my own build i might as well include that:
If i do a yocto build, i can also include packages that are not available in the normal Torizon core correct?
I mean yes, Yocto is a build system for images. You can customize your image however you want this way. That is of course assuming you have the knowledge to do so, since Yocto is not the most friendly tool to use and learn.
Keep in mind you’ll be producing a different image than TorizonCore. Meaning the maintenance of this would fall on your shoulders since we have no control on what you customize in Yocto.
Best Regards,
Jeremias
so it turns out at last, that the kernel modification worked. We can access the Lara module by including the following in the tcbuild.yml:
kernel:
modules:
- source-dir: kernel_Mod/
autoload: yes
Then in the kermel_mod folder i just put the options.c file with included Lara address and the not modified include usb-wwan.c and the respective .h files
as well as a Makefile reading
obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
SRC := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
clean:
rm -f *.o ~ core .depend ..cmd *.ko *.mod.c
rm -f Module.markers Module.symvers modules.order
rm -rf .tmp_versions Modules.symvers
So it successfully updates the kernel and allows us to access the module.
Alright glad to hear that worked for you.