Itron Riva Kernel Module Building

Similar documents
Itron Riva Dev Software Development Getting Started Guide

7.3 Simplest module for embedded Linux drivers

Linux Kernel Module Programming. Tushar B. Kute,

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Instructions for setting up to compile and run OSGPS code under Linux

Loadable Kernel Modules

Exercise 1: Basic Tools

Linux drivers - Exercise

Scrivere device driver su Linux. Better Embedded 2012 Andrea Righi

Introduction of Linux

Abstraction via the OS. Device Drivers. Software Layers. Device Drivers. Types of Devices. Mechanism vs. Policy. Jonathan Misurda

CMPT 300. Operating Systems. Brief Intro to UNIX and C

Introduction to Supercomputing

CS Lab 1 Linux/Shell Basic commands Introduction. Teaching Assistant Henrique Potter

CS 261 Recitation 1 Compiling C on UNIX

Software Layers. Device Drivers 4/15/2013. User

Working with Kernel Modules Lab Wind River Systems, Inc

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

EE516: Embedded Software Project 1. Setting Up Environment for Projects

GDB and Makefile. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Introduction to Linux

CS 143A. Principles of Operating Systems. Instructor : Prof. Anton Burtsev

Intermediate Programming, Spring Misha Kazhdan

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

Setting up cross compiling environment & Qt/X11 for the DXSERIES with the ELDK cross compiler

Lab 1 Introduction to UNIX and C

Lab 6: OS Security for the Internet of Things

You should see something like this, called the prompt :

Lab 6: OS Security for the Internet of Things

Introduction to the Itron Riva Dev Kits

Makefiles SE 2XA3. Term I, 2018/19

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

University of Colorado at Colorado Springs CS4500/ Fall 2018 Operating Systems Project 1 - System Calls and Processes

SuSE Labs / Novell.

CSE 351. Introduction & Course Tools

Programming the DMCC in C

Zephyr Kernel Installation & Setup Manual

Itron Riva Dev Mini Kit Getting Started Guide

Building RPMs for Native Application Hosting

HPC User Environment

Introduction to the UNIX command line

Linux Systems Administration Shell Scripting Basics. Mike Jager Network Startup Resource Center

Virtual File System (VFS) Implementation in Linux. Tushar B. Kute,

Introduction to Linux

Section 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2

2 Compiling a C program

Introduction to Linux

Laboratory 1 Semester 1 11/12

15-122: Principles of Imperative Computation

Lec 1 add-on: Linux Intro

Kernel Modules. Kartik Gopalan

Development Environment Embedded Linux Primer Ch 1&2

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Pengwyn Documentation

Working with Basic Linux. Daniel Balagué

Introduction to Linux

IoT with Intel Galileo Gerardo Carmona. makerobots.tk

[Software Development] Makefiles. Davide Balzarotti. Eurecom Sophia Antipolis, France

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

RTAI 3.8 ON Ubuntu(9.10)-Linux-kernel :

Software Development With Emacs: The Edit-Compile-Debug Cycle

CS Basics 15) Compiling a C prog.

Linux Tutorial. Ken-ichi Nomura. 3 rd Magics Materials Software Workshop. Gaithersburg Marriott Washingtonian Center November 11-13, 2018

Loadable Kernel Module

CS101 Linux Shell Handout

Embedded Linux. A Tour inside ARM's Kernel

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Kurt Schmidt. May 23, 2018

/dev/hello_world: A Simple Introduction to Device Drivers under Linux

Linux Kernel Modules & Device Drivers April 9, 2012

CPSC Tutorial 17

Introduction to Linux

The Unix Shell & Shell Scripts

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Command Line Interface The basics

Using the Unix system. UNIX Introduction

Creating a system call in Linux. Tushar B. Kute,

Parallel Programming Pre-Assignment. Setting up the Software Environment

CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A)

LAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER

Continue: How do I learn C? C Primer Continued (Makefiles, debugging, and more ) Last Time: A Simple(st) C Program 1-hello-world.c!

Introduction: What is Unix?

Linux Shell Script. J. K. Mandal

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

The Linux Programming Environment. Computer Science Department Texas State University

Coding in C at Home. Part 2 Computational Physics. April 21, 2016

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

INd_rasN SOME SHELL SCRIPTING PROGRAMS. 1. Write a shell script to check whether the name passed as first argument is the name of a file or directory.

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

CISC 220 fall 2011, set 1: Linux basics

Lab 1 Introduction to UNIX and C

CS CS Tutorial 2 2 Winter 2018

ENERGY 211 / CME 211. Evolution

Lab2 - Bootloader. Conventions. Department of Computer Science and Information Engineering National Taiwan University


Introduction to Linux. Fundamentals of Computer Science

bwunicluster Tutorial Access, Data Transfer, Compiling, Modulefiles, Batch Jobs

Lab 1: Loadable Kernel Modules (LKMs)

Transcription:

Itron Riva Kernel Module Building Table of Contents Introduction... 2 Creating the Project Directory... 2 Creating the Makefile... 3 Creating main.c... 5 Building The Kernel Module... 6 1

Introduction What follows is a step-by-step introduction to building a Linux kernel module for the Itron Riva platform. Using these steps, you can build Linux kernel modules for any of the following Itron Riva devices: Itron Riva Dev Board Itron Riva Dev Mini Board Itron Riva SmartNIC Itron Riva Electric Meter Itron Riva CAM (CGR ACT Module) The following assumptions are being made: You have at least one Itron Riva Dev boards mentioned above You have installed the Itron Riva SDK (Software Developers Kit) You are using Ubuntu 16.04. Other Linux versions should work, but the steps here were performed on an Ubuntu 16.04 system. You are familiar with using the Linux command-line prompt By following these steps, you will create a Linux kernel module named hello.ko. You will load and unload the kernel module, observing messages from the module by using the dmesg command. Creating the Project Directory The first step is to open a command-line prompt: $ The next step is to change to a directory where you want to create this project. In this case we will put the project in the Documents/Projects directory, so we change to that: $ cd Documents/Projects $ Now create a directory named hello-km. This is the directory where you will create the kernel module. $ mkdir hello-km 2

Finally change into the hello-km directory: $ cd hello-km Creating the Makefile Next you will create a Makefile with the contents shown below. Using the text editor of your choice (e.g. vim or nano), create a file named Makefile that has the following contents: # # Makefile for building Itron Riva Kernel Modules # # For questions/support: norm.mcentire@itron.com # # 2017-09-17 # obj-m := km-module.o #km-module-objs := main.o load.o unload.o km-module-objs := main.o KERNELDIR := /home/nmcentire/documents/p4client/openwayinternational/riva_openway_a RCHIMEDES_SR_4-1/Workspace/ItronRiva-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4 PWD := $(shell pwd) all: 3

$(MAKE) -C $(KERNELDIR) ARCH=arm CROSS_COMPILE=armv7l-timesyslinux-uclibcgnueabi- M=$(PWD) modules clean: rm -rf *.ko *.o *.mod.c core Module.symvers Module.markers modules.order.*.cmd.tmp_versions You can test your Makefile out from the command-line by typing make: $ make make -C /home/nmcentire/documents/p4client/openwayinternational/riva_openway_a RCHIMEDES_SR_4-1/Workspace/SmartNic-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4 ARCH=arm CROSS_COMPILE=armv7l-timesys-linuxuclibcgnueabi- M=/home/nmcentire/Documents/Projects/hello-km modules make[1]: Entering directory '/home/nmcentire/documents/p4client/openwayinternational/riva_openway_a RCHIMEDES_SR_4-1/Workspace/SmartNic-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4' Makefile:669: Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: -fstackprotector not supported by compiler make[1]: armv7l-timesys-linux-uclibcgnueabi-gcc: Command not found make[2]: *** No rule to make target '/home/nmcentire/documents/projects/hellokm/main.o', needed by '/home/nmcentire/documents/projects/hello-km/kmmodule.o'. Stop. Makefile:1404: recipe for target '_module_/home/nmcentire/documents/projects/hello-km' failed 4

make[1]: *** [_module_/home/nmcentire/documents/projects/hello-km] Error 2 make[1]: Leaving directory '/home/nmcentire/documents/p4client/openwayinternational/riva_openway_a RCHIMEDES_SR_4-1/Workspace/SmartNic-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4' Makefile:10: recipe for target 'all' failed make: *** [all] Error 2 From the about above, notice that you will receive an error. This is normal, because you have not yet created the main.c. Creating main.c Next you will create a main.c source file with the contents shown below. Using the text editor of your choice (e.g. vim or nano), create a file named main.c that has the following contents: /* * main.c * * Main file for hello-km kernel module * * For questions/support: norm.mcentire@itron.com * * 2017-09-17 * */ #include <linux/module.h> //#include "load.h" 5

//#include "unload.h" static int init km_hello_module_init(void) { printk(kern_info "km_hello_module_init\n"); return 0; } module_init(km_hello_module_init); static void exit km_hello_module_exit(void) { printk(kern_info "km_hello_module_exit\n"); } module_exit(km_hello_module_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Norm McEntire <norm.mcentire@itron.com>"); MODULE_DESCRIPTION("Itron Riva Dev Hello Kerenel Module"); You are now ready to build the kernel module. Building The Kernel Module You should now have two files in your project: Makefile and main.c: $ ls Makefile main.c To build the project, make sure the cross-compile toolchain is in your path: $ echo $PATH 6

80/toolchain/bin:/home/nmcentire/bin:/home/nmcentire/.local/bin:/usr/local/sbin:/usr /local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin If your toolchain is not in your PATH, you can set it like this: $ export PATH=/home/nmcentire/itron-isom-4-1-80/toolchain/bin:$PATH After making sure your PATH is setup correctly, you can now make your project by typing make: $ make make -C /home/nmcentire/documents/p4client/openwayinternational/riva_openway_a /home/nmcentire/itron-isom-4-1- RCHIMEDES_SR_4-1/Workspace/SmartNic-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4 ARCH=arm CROSS_COMPILE=armv7l-timesys-linuxuclibcgnueabi- M=/home/nmcentire/Documents/Projects/hello-km modules make[1]: Entering directory '/home/nmcentire/documents/p4client/openwayinternational/riva_openway_a RCHIMEDES_SR_4-1/Workspace/SmartNic-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4' CC [M] /home/nmcentire/documents/projects/hello-km/main.o LD [M] /home/nmcentire/documents/projects/hello-km/km-module.o Building modules, stage 2. MODPOST 1 modules CC /home/nmcentire/documents/projects/hello-km/km-module.mod.o LD [M] /home/nmcentire/documents/projects/hello-km/km-module.ko make[1]: Leaving directory '/home/nmcentire/documents/p4client/openwayinternational/riva_openway_a 7

RCHIMEDES_SR_4-1/Workspace/SmartNic-Dev/build_armv7l-timesys-linuxuclibcgnueabi/linux-4.4' 8