linux-device-driver

What is the minimum amount of RAM required to run Linux kernel on an Embedded device?

人走茶凉 提交于 2019-12-21 04:05:04
问题 What is the minimum amount of RAM required to run Linux kernel on an Embedded device? In Linux-0.11 for 80x86 , the minimum RAM required was 2MB to load the kernel data structures and interrupt vectors. How much is the minimum needed RAM for present Linux-3.18 kernel? Does different architectures like x86 and ARM have different requirements for minimum RAM required for booting? How does one calculates the same? 回答1: It's possible to shrink it down to ~600 KiB. Check the work done by Tom

Enabling write-combining IO access in userspace

天大地大妈咪最大 提交于 2019-12-21 03:55:08
问题 I have a PCIe device with a userspace driver. I'm writing commands to the device through a BAR, the commands are latency sensitive and amount of data is small (~64-bytes) so I don't want to use DMA. If I remap the physical address of the BAR in the kernel using ioremap_wc and then write 64-bytes to the BAR inside the kernel , I can see that the 64-bytes are written as a single TLP over PCIe. If I allow my userspace program to mmap the region with the MAP_SHARED flag and then write 64-bytes I

Linux kernel device driver to DMA into kernel space

为君一笑 提交于 2019-12-20 12:39:10
问题 LDD3 (p:453) demos dma_map_single using a buffer passed in as a parameter. bus_addr = dma_map_single(&dev->pci_dev->dev, buffer, count, dev->dma_dir); Q1 : What/where does this buffer come from? kmalloc ? Q2 : Why does DMA-API-HOWTO.txt state I can use raw kmalloc to DMA into? Form http://www.mjmwired.net/kernel/Documentation/DMA-API-HOWTO.txt L:51 If you acquired your memory via the page allocator kmalloc() then you may DMA to/from that memory using the addresses returned from those routines

mapping memory reserved by mmap kernel boot param into user space

一个人想着一个人 提交于 2019-12-20 10:47:36
问题 As discussed in this question, i am reserving a memory chunk at the boot time using a kernel boot parameter memmap=8G$64G I have written a character driver kernel module which , during initialization does a ioremap of this reserved memory chunk. As explained here , in my driver mmap all i need to do is remap_pfn_range for this memory chunk pointer returned by the ioremap . I am running this on 3.0 linux kernel . My user space application opens this memory chunk as a device mounted by the

How to get linux kernel page size programmatically

走远了吗. 提交于 2019-12-20 09:28:18
问题 I am working on a Linux module for IA64. My current problem is that the driver uses the PAGE_SIZE and PAGE_SHIFT macros for dma page allocation. The problem I am having is that the machine compiling the driver is not the ones that needed to run the driver. So, if the PAGE_SIZE on the compiling machine is 2^14K and the destination machine is 2^16K then the driver fails. I don't want to turn this question into a 'best practice' issue about compiling modules on machines which are not the ones

Function caller in linux kernel

浪子不回头ぞ 提交于 2019-12-20 08:11:11
问题 Is there a way to get function caller in linux kernel? I know __ func __ returns the function name which is executing. I am looking for the function which called " __ func __ " 回答1: You can get the caller with __builtin_return_address(0) . The caller's caller is __builtin_return_address(1) and so on. It's a GCC extension, documented in the gcc manual: http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html Edit: I should probably point out, that gets you the address of the caller. If you want

Function caller in linux kernel

时光毁灭记忆、已成空白 提交于 2019-12-20 08:08:43
问题 Is there a way to get function caller in linux kernel? I know __ func __ returns the function name which is executing. I am looking for the function which called " __ func __ " 回答1: You can get the caller with __builtin_return_address(0) . The caller's caller is __builtin_return_address(1) and so on. It's a GCC extension, documented in the gcc manual: http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html Edit: I should probably point out, that gets you the address of the caller. If you want

How to make a built-in device driver in linux

拜拜、爱过 提交于 2019-12-20 07:45:53
问题 I know how to make loadable kernel modules in Linux. But i want that loadable kernel module to be a part of the kernel , and after booting that driver should automatically load, like most of the other general driver. How to do that? 回答1: There are two ways to do for your query 1) building your module as statically compiled along with kernel (your source code should reside in kernel tree ),so while building build it static which come as a part of kernel, so when kernel boots your module will

How to read data from a serial (SPI) connection in C?

穿精又带淫゛_ 提交于 2019-12-20 04:45:09
问题 I am trying to write a program that will be installed on a Linux MCU (Raspberry Pi) that will read serial data coming to it from yet another MCU (something homegrown that I will build myself). I have researched how to do this and think I have the "big picture" but still missing a few things. For one, I need to enable the kernel module and give myself access to the device: sudo modprobe spi_bcm2708 sudo chown `id -u`.`id -g` /dev/spidev0.* From there I can use this famous C file to test the

Sending a UDP packet within a kernel module

你离开我真会死。 提交于 2019-12-20 04:15:15
问题 Background: I'm a fourth year computer engineering major at UCSB. I've taken networking and operating systems courses. I created a program in userspace that broadcasts UDP packets onto the subnet and receives UDP packets in an adhoc network. What I'm trying to accomplish is to convert this program into a kernel module that will work on an ARM embedded system with Angstrom Linux, kernel version 2.6.39 (the x86 to ARM architecture cross compilation is an issue for another day). The reason for