How to find dev/entry after insmod module kernel - c

I developed a module DMA with some functions to be used when interact with kernel (IOCTL Function Usage) of zynq device.
I have inserted a DMA module into the zynq device but i am not sure if the device files have been created.
How can I find or create the corresponding device files in dev directory. Any help appreciated
The generated source code is similar to the following

Related

g_audio module : How does it works?

If we enable gadget_only_mode under CONFIG_USB_MUSB_GADGET in our kernel or linux based device. if it will work as a gadget. Gadget means if I connect my device to my system then my device will listed as a gadget or as a sound card. I get confused because if we do enable any driver support in our kernel that module will be loaded when same supported device driver device will be connect. Please help me out we we do enable gadget only module in our kernel then if our device will work as a gadget??

Modifying DE10-nano default FPGA configuration

I am working with Linux software on DE10-nano board and I need to perform a small modification to default FPGA configuration (add pull-ups on GPIO lines).
The user manual points to DE10-Nano System CD\Demonstrations\FPGA\Default as default project which suppose to produce the factory FPGA configuration.
I compile it, convert SOF to RBF, and put the RBF on SD card for U-Boot to load.
U-Boot programs FPGA (I get orange LED on) and then fails to load Linux device tree (I get ERROR: Did not find a cmdline Flattened Device Tree message via COM port) although the same device tree file is in the same place on SD card.
Am I using the correct Quartus project?
The only solution that worked for me (loading my own .rbf file with the unmodified Linux Angrstrom from Terasic) was to use the SD card images from:
http://download.terasic.com/downloads/cd-rom/de10-nano/linux_BSP/
I used the de10_nano_linux_console image. I used the sof_to_rbf.bat file to generate the .rbf file, ensuring that compression was turned on and the output file name was soc_system.rbf.
Any other method I tried with the SD card resulted in the error message the OP posted relating to the Device Tree.

UART communication in Linux kernel module

I am programming Linux kernel module for communication with device connected through UART, but I don't know how to access UART from kernel module. I don't want to write my own UART driver, I would like to use the existing one and only add communication layer for my device. I saw something similiar done in userspace-like manner, however I read that kernel modules should not access files like that. I am wondering if it could be done using existing driver's structs and functions, because that's how I have already programmed module, which used I2C. Example of a module reading from UART would be very useful.

SPI kernel module, how to istantiate the driver?

I've been tasked to import the spi driver into an existing platform running Openwrt.
After "successfully" build the full Openwrt: packages and the kernel matching the one running into the platform, including the spidev kernel module I run into some trouble in make this module work.
**insmod** of the driver terminates without error, and I see that in the **/sys/class** the creation of the directory **spidev**, but it is empty.
Looking at the code of the spidev kernel module, the function **probe** has caught my eye. My feel is that this function is what actually allocates the minor device number an make the device available to be used. But it's not clear to me who, or what should call it.
Another doubt I have is about the architecture. The spi depends on the underlaying architecture, which in my case is the MT7620 soc which is a mipsel architecture have a specific spi code. In my understanding this SOC specific code is wrapped by the spidev kernel module and the link between these two entities should be
status = spi_register_driver(&spidev_spi_driver);
in the
static int __init spidev_init(void)
function.
Again, I'm far to be sure of what I'm writing and I'm here asking for directions.
First, you may want to read the Linux Device Driver - Chapter 14.
Generally speaking, in the Linux kernel you have devices and drivers on a bus (subsystem). You have to register them using the functions register_device() and register_driver() (the exact name depends on the subsystem). When a device or a driver get registered the subsystem will try to match devices with drivers. If they match, the subsystem calls the driver's function probe(). So, the execution of the probe() function can be triggered by the driver registration or the device registration. This also means that the device exists before the execution of probe()
Back to your specific case: SPI. To register a device instance you need to use spi_alloc_device and spi_add_device, or spi_new_device. Where to put this code? This depends on your need. Typically, the SPI devices are declared in some architecture file or device-tree description. Probably you can also do it in a module (not sure).
The spidev is a Linux device driver that exports the SPI raw interface to the user-space. This means that once you register an SPI device instance the driver spidev take control of it. Actually, the spidev does nothing: it waits for an user-space program to read/write data on the SPI bus. So, you will end up writing the driver for your device in userspace.

Error-aware bootloader for Raspberry Pi

I want to write a simple bootloader for the Raspberry Pi. The main purpose of this bootloader is to enable a Raspberry Pi at a remote location, to recover from kernel updates that make the device unbootable as the result of a kernel panic. The procedure for updating the kernel should be like this:
The default Linux kernel is /boot/rpi-kernel.img and the string 'rpi-kernel.img' is written in /boot/default-kernel.txt. The kernel parameter 'panic=10' has been added to 'cmdline=' in /boot/config.txt.
Connect to the Raspberry Pi over SSH.
Copy /boot/rpi-kernel.img to /boot/rpi-kernel-fallback.img
Create empty file /boot/kernel_update
Download kernel update and move it to /boot/rpi-kernel.img
Reboot
This is the design for the bootloader I have thought up in pseudocode:
read kernel parameters passed from start.elf
if empty file '/boot/kernel_update' does not exists
boot kernel defined in '/boot/default-kernel.txt' with kernel parameters passed from start.elf
else
if empty file '/boot/boot_kernel_update' exists
write string 'rpi-kernel-fallback.img' to file '/boot/default-kernel.txt'
delete file '/boot/kernel_update'
delete file '/boot/boot_kernel_update'
create empty file '/boot/kernel_update_failed'
boot kernel 'rpi-kernel-fallback.img' with kernel parameters passed from start.elf
else
create empty file '/boot/boot_kernel_update'
boot kernel '/boot/rpi-kernel.img' with kernel parameters passed from start.elf
As a last step in the boot process, a shell script will check if the /boot/kernel_update exists and then if network is functional and the environment is sane, before removing /boot/kernel_update.
I want to make the bootloader as clean and simple as possible, with no support for HDMI, USB, Ethernet, serial etc. The problem is that I'm not sure how to get started with this.
The main challenges are to read from and write to the FAT32 filesystem on the SD card, and booting the Linux kernel. Everything has to happen from bare metal on the Raspberry Pi.
Any code examples, resources, suggestions ect. on doing this would be very helpful.

Resources