├── VFS_Abstraction_Example.png ├── Reference_Use_Case_User_Level_Module_Level.png ├── Virtual_File_System_User_Space_Kernel_Space.png ├── ARMCourse ├── Module05_LinuxKernelModules │ ├── Quiz05_LinuxKernelModules.docx │ ├── Lecture05_LinuxKernelModules.pptx │ └── Lab01_LinuxKernelModulesUnderYocto │ │ ├── Lab01_LinuxKernelModulesUnderYocto.docx │ │ └── hello-mod │ │ ├── hello_1.0.bb │ │ └── files │ │ ├── Makefile │ │ └── hello.c ├── Module03_AnatomyOfLinuxBasedSystem │ ├── Quiz03_AnatomyOfLinuxBasedSystem.docx │ └── Lecture03_AnatomyOfLinuxBasedSystem.pptx ├── Module04_ConfigurationAndBuildProcess │ ├── Quiz04_ConfigurationAndBuildProcess.docx │ └── Lecture04_ConfigurationAndBuildProcess.pptx ├── Module01_IntroToLinuxAndEmbeddedSystems │ └── Lecture01_IntroToLinuxAndEmbeddedSystems.pptx ├── Module07_BuildingARangingSensorKernelModule │ ├── Quiz07_BuildingARangingSensorKernelModule.docx │ ├── Lecture07_BuildingARangingSensorKernelModule.pptx │ └── Lab03_BuildingARangingSensorKernelModule │ │ ├── Lab03_HCSR04RangingSensor.docx │ │ └── hcsr04-mod │ │ ├── files │ │ ├── hcsr04_test │ │ ├── Makefile │ │ ├── hcsr04_test.c │ │ └── hcsr04.c │ │ └── hcsr04_1.0.bb ├── Module02_LinuxBasedEmbeddedSystemComponentStack │ ├── Lab00_GettingStarted │ │ └── Lab00_GettingStarted.doc │ ├── Quiz02_LinuxBasedEmbeddedSystemComponentStack.docx │ └── Lecture02_LinuxBasedEmbeddedSystemComponentStack.pptx ├── Module06_CommunicationBetweenKernelAndUserSpace │ ├── Quiz06_CommunicationBetweenKernelAndUserSpace.docx │ ├── Lecture06_CommunicationBetweenKernelAndUserSpace.pptx │ └── Lab02_HandlingGPIOusingLinuxKernelModules │ │ ├── Lab02_HandlingGPIOusingLinuxKernelModules.docx │ │ └── gpio-mod │ │ ├── gpio_1.0.bb │ │ ├── files │ │ ├── Makefile │ │ ├── gpio.c │ │ └── gpiocommented.c │ │ └── test_gpio.c ├── Module08_SystemDebuggingAndProfiling │ ├── Lab04_IntroToCodeDevelopmentUsingYocto │ │ ├── Lab04_IntroToCodeDevelopmentUsingYocto.docx │ │ └── gator │ │ │ ├── files │ │ │ └── 0001-patch-daemon-Makefile.patch │ │ │ └── gator_1.0.bb │ └── Lab05_IntroToLinuxKernelandApplicationProfiling │ │ └── Lab05_IntroToLinuxKernelandApplicationProfiling.docx ├── README.md └── License │ └── LICENSE.md ├── README.md ├── LICENSE └── Notes.txt /VFS_Abstraction_Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/VFS_Abstraction_Example.png -------------------------------------------------------------------------------- /Reference_Use_Case_User_Level_Module_Level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/Reference_Use_Case_User_Level_Module_Level.png -------------------------------------------------------------------------------- /Virtual_File_System_User_Space_Kernel_Space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/Virtual_File_System_User_Space_Kernel_Space.png -------------------------------------------------------------------------------- /ARMCourse/Module05_LinuxKernelModules/Quiz05_LinuxKernelModules.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module05_LinuxKernelModules/Quiz05_LinuxKernelModules.docx -------------------------------------------------------------------------------- /ARMCourse/Module05_LinuxKernelModules/Lecture05_LinuxKernelModules.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module05_LinuxKernelModules/Lecture05_LinuxKernelModules.pptx -------------------------------------------------------------------------------- /ARMCourse/Module03_AnatomyOfLinuxBasedSystem/Quiz03_AnatomyOfLinuxBasedSystem.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module03_AnatomyOfLinuxBasedSystem/Quiz03_AnatomyOfLinuxBasedSystem.docx -------------------------------------------------------------------------------- /ARMCourse/Module03_AnatomyOfLinuxBasedSystem/Lecture03_AnatomyOfLinuxBasedSystem.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module03_AnatomyOfLinuxBasedSystem/Lecture03_AnatomyOfLinuxBasedSystem.pptx -------------------------------------------------------------------------------- /ARMCourse/Module04_ConfigurationAndBuildProcess/Quiz04_ConfigurationAndBuildProcess.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module04_ConfigurationAndBuildProcess/Quiz04_ConfigurationAndBuildProcess.docx -------------------------------------------------------------------------------- /ARMCourse/Module04_ConfigurationAndBuildProcess/Lecture04_ConfigurationAndBuildProcess.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module04_ConfigurationAndBuildProcess/Lecture04_ConfigurationAndBuildProcess.pptx -------------------------------------------------------------------------------- /ARMCourse/Module01_IntroToLinuxAndEmbeddedSystems/Lecture01_IntroToLinuxAndEmbeddedSystems.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module01_IntroToLinuxAndEmbeddedSystems/Lecture01_IntroToLinuxAndEmbeddedSystems.pptx -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Quiz07_BuildingARangingSensorKernelModule.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module07_BuildingARangingSensorKernelModule/Quiz07_BuildingARangingSensorKernelModule.docx -------------------------------------------------------------------------------- /ARMCourse/Module02_LinuxBasedEmbeddedSystemComponentStack/Lab00_GettingStarted/Lab00_GettingStarted.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module02_LinuxBasedEmbeddedSystemComponentStack/Lab00_GettingStarted/Lab00_GettingStarted.doc -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lecture07_BuildingARangingSensorKernelModule.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module07_BuildingARangingSensorKernelModule/Lecture07_BuildingARangingSensorKernelModule.pptx -------------------------------------------------------------------------------- /ARMCourse/Module02_LinuxBasedEmbeddedSystemComponentStack/Quiz02_LinuxBasedEmbeddedSystemComponentStack.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module02_LinuxBasedEmbeddedSystemComponentStack/Quiz02_LinuxBasedEmbeddedSystemComponentStack.docx -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Quiz06_CommunicationBetweenKernelAndUserSpace.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Quiz06_CommunicationBetweenKernelAndUserSpace.docx -------------------------------------------------------------------------------- /ARMCourse/Module02_LinuxBasedEmbeddedSystemComponentStack/Lecture02_LinuxBasedEmbeddedSystemComponentStack.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module02_LinuxBasedEmbeddedSystemComponentStack/Lecture02_LinuxBasedEmbeddedSystemComponentStack.pptx -------------------------------------------------------------------------------- /ARMCourse/Module05_LinuxKernelModules/Lab01_LinuxKernelModulesUnderYocto/Lab01_LinuxKernelModulesUnderYocto.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module05_LinuxKernelModules/Lab01_LinuxKernelModulesUnderYocto/Lab01_LinuxKernelModulesUnderYocto.docx -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lecture06_CommunicationBetweenKernelAndUserSpace.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lecture06_CommunicationBetweenKernelAndUserSpace.pptx -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/Lab03_HCSR04RangingSensor.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/Lab03_HCSR04RangingSensor.docx -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/hcsr04-mod/files/hcsr04_test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/hcsr04-mod/files/hcsr04_test -------------------------------------------------------------------------------- /ARMCourse/Module08_SystemDebuggingAndProfiling/Lab04_IntroToCodeDevelopmentUsingYocto/Lab04_IntroToCodeDevelopmentUsingYocto.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module08_SystemDebuggingAndProfiling/Lab04_IntroToCodeDevelopmentUsingYocto/Lab04_IntroToCodeDevelopmentUsingYocto.docx -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/Lab02_HandlingGPIOusingLinuxKernelModules.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/Lab02_HandlingGPIOusingLinuxKernelModules.docx -------------------------------------------------------------------------------- /ARMCourse/Module08_SystemDebuggingAndProfiling/Lab05_IntroToLinuxKernelandApplicationProfiling/Lab05_IntroToLinuxKernelandApplicationProfiling.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usmn001/EMBEDDED_LINUX/HEAD/ARMCourse/Module08_SystemDebuggingAndProfiling/Lab05_IntroToLinuxKernelandApplicationProfiling/Lab05_IntroToLinuxKernelandApplicationProfiling.docx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EMBEDDED_LINUX 2 | Embedded Linux and Build Systems (Yocto & Build Root) 3 | This repository contains lecture slides, lab assignments from ARM Embedded Linux Course, Notes i made during the course. 4 | ARM Embedded Linux Course data is cloned from https://github.com/arm-university/Embedded-Linux-Education-Kit and contains license. 5 | 6 | -------------------------------------------------------------------------------- /ARMCourse/Module05_LinuxKernelModules/Lab01_LinuxKernelModulesUnderYocto/hello-mod/hello_1.0.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "hello driver" 2 | LICENSE = "GPLv2+" 3 | LIC_FILES_CHKSUM = "file://${BPN}.c;endline=19;md5=4866f9824d27c1cd5324fd5e84caeb6e" 4 | 5 | inherit module 6 | 7 | PR = "r0" 8 | 9 | SRC_URI = "file://Makefile file://${BPN}.c" 10 | S = "${WORKDIR}" 11 | -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/hcsr04-mod/hcsr04_1.0.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "hcsr04 driver" 2 | LICENSE = "GPLv2+" 3 | LIC_FILES_CHKSUM = "file://${BPN}.c;md5=94af90acd77ed5583caa62cbe903e559" 4 | 5 | inherit module 6 | 7 | PR = "r0" 8 | 9 | SRC_URI = "file://Makefile file://${BPN}.c" 10 | S = "${WORKDIR}" 11 | -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/gpio-mod/gpio_1.0.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "gpio driver" 2 | 3 | LICENSE = "GPLv2+" 4 | LIC_FILES_CHKSUM = "file://${BPN}.c;endline=19;md5=02d0f4fb7e7b7125483125efd96a39dc" 5 | 6 | 7 | inherit module 8 | 9 | 10 | PR = "r0" 11 | 12 | 13 | SRC_URI = "file://Makefile file://${BPN}.c" 14 | 15 | S = "${WORKDIR}" 16 | -------------------------------------------------------------------------------- /ARMCourse/Module05_LinuxKernelModules/Lab01_LinuxKernelModulesUnderYocto/hello-mod/files/Makefile: -------------------------------------------------------------------------------- 1 | obj-m := hello.o 2 | SRC := $(shell pwd) 3 | all: 4 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) 5 | modules_install: 6 | $(MAKE) INSTALL_MOD_DIR=kernel/drivers/aup -C $(KERNEL_SRC) M=$(SRC) modules_install 7 | 8 | clean: 9 | rm -f *.o *~core.depend .*.cmd *.ko *.mod.c 10 | rm -f Module.markers Module.symvers modules.order 11 | rm -rf .tmp_versions Modules.symvers 12 | -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/gpio-mod/files/Makefile: -------------------------------------------------------------------------------- 1 | obj-m := gpio.o 2 | 3 | SRC := $(shell pwd) 4 | 5 | all: 6 | 7 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) 8 | 9 | modules_install: 10 | 11 | $(MAKE) INSTALL_MOD_DIR=kernel/drivers/aup -C $(KERNEL_SRC) M=$(SRC) modules_install 12 | 13 | 14 | clean: 15 | 16 | rm -f *.o *~core.depend .*.cmd *.ko *.mod.c 17 | 18 | rm -f Module.markers Module.symvers modules.order 19 | 20 | rm -rf .tmp_versions Modules.symvers 21 | -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/hcsr04-mod/files/Makefile: -------------------------------------------------------------------------------- 1 | CC = arm-linux-gnueabihf-gcc 2 | obj-m := hcsr04.o 3 | SRC := $(shell pwd) 4 | all: 5 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) 6 | 7 | modules_install: 8 | $(MAKE) INSTALL_MOD_DIR=kernel/drivers/aup -C $(KERNEL_SRC) M=$(SRC) modules_install 9 | hcsr04_test:hcsr04_test.c 10 | $(CC) -o $@ $^ 11 | clean: 12 | rm -f *.o *~core.depend .*.cmd *.ko *.mod.c gpio_simple_test 13 | rm -f Module.markers Module.symvers modules.order 14 | rm -rf .tmp_versions Modules.symvers 15 | -------------------------------------------------------------------------------- /ARMCourse/Module08_SystemDebuggingAndProfiling/Lab04_IntroToCodeDevelopmentUsingYocto/gator/files/0001-patch-daemon-Makefile.patch: -------------------------------------------------------------------------------- 1 | --- a/daemon/Makefile 2017-01-23 05:44:19.211481780 -0800 2 | +++ b/daemon/Makefile 2017-01-23 05:47:34.805752423 -0800 3 | @@ -8,8 +8,8 @@ 4 | # targets run 'make SOFTFLOAT=1 SYSROOT=/path/to/sysroot', see 5 | # streamline/gator/README.md for more details 6 | 7 | -CC = $(CROSS_COMPILE)gcc 8 | -CXX = $(CROSS_COMPILE)g++ 9 | +#CC = $(CROSS_COMPILE)gcc 10 | +#CXX = $(CROSS_COMPILE)g++ 11 | 12 | ifeq ($(SOFTFLOAT),1) 13 | CPPFLAGS += -marm -mthumb-interwork -march=armv4t -mfloat-abi=soft 14 | -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/gpio-mod/test_gpio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main(int argc, char **argv) 10 | { 11 | char *app_name = argv[0]; 12 | char *dev_name = "/dev/gpio"; 13 | int fd = -1; 14 | char c;insmo 15 | 16 | if ((fd = open(dev_name, O_RDWR)) < 0) 17 | { 18 | fprintf(stderr, "%s: unable to open %s: %s\n", app_name, dev_name, strerror(errno)); 19 | return( 1 ); 20 | } 21 | 22 | read( fd, &c, 1 ); 23 | 24 | printf( "read: %d\n", c ); 25 | 26 | close( fd ); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/hcsr04-mod/files/hcsr04_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main(int argc, char **argv) 10 | { 11 | char *app_name = argv[0]; 12 | char *dev_name = "/dev/hcsr04"; 13 | int fd = -1; 14 | char c; 15 | int d; 16 | 17 | 18 | if( (fd = open(dev_name, O_RDWR)) < 0 ) 19 | { 20 | fprintf(stderr, "%s: unable to open %s: %s\n", app_name, dev_name, strerror(errno)); 21 | return( 1 ); 22 | } 23 | 24 | c = 1; 25 | write( fd, &c, 1 ); 26 | read( fd, &d, 4 ); 27 | 28 | printf( "%d: %f\n", d, d/58.0 ); 29 | 30 | close( fd ); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /ARMCourse/Module05_LinuxKernelModules/Lab01_LinuxKernelModulesUnderYocto/hello-mod/files/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | static dev_t hello_dev; 9 | struct cdev hello_cdev; 10 | static char buffer[64]; 11 | 12 | struct file_operations hello_fops = { 13 | .owner = THIS_MODULE, 14 | 15 | }; 16 | 17 | static int __init hello_module_init(void) 18 | { 19 | printk(KERN_INFO "Loading HelloWorld_module.\n"); 20 | 21 | alloc_chrdev_region(&hello_dev, 0, 1, "hello_dev"); 22 | printk(KERN_INFO "%s\n", format_dev_t(buffer, hello_dev)); 23 | 24 | cdev_init(&hello_cdev, &hello_fops); 25 | hello_cdev.owner = THIS_MODULE; 26 | cdev_add(&hello_cdev, hello_dev, 1); 27 | 28 | return 0; 29 | } 30 | 31 | static void __exit hello_module_cleanup(void) 32 | { 33 | printk(KERN_INFO "Cleaning-up hello_dev.\n"); 34 | cdev_del(&hello_cdev); 35 | unregister_chrdev_region(hello_dev, 1); 36 | } 37 | 38 | module_init(hello_module_init); 39 | module_exit(hello_module_cleanup); 40 | 41 | MODULE_AUTHOR("Your Name"); 42 | MODULE_LICENSE("GPL"); 43 | 44 | -------------------------------------------------------------------------------- /ARMCourse/Module08_SystemDebuggingAndProfiling/Lab04_IntroToCodeDevelopmentUsingYocto/gator/gator_1.0.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "ARM DS5 Gator kernel module and daemon" 2 | AUTHOR = "Massimo Violante " 3 | SECTION = "kernel" 4 | LICENSE = "GPLv2" 5 | LIC_FILES_CHKSUM="file://driver/COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" 6 | S="${WORKDIR}/git" 7 | BP="${BPN}" 8 | DEPENDS = "linux-raspberrypi" 9 | inherit module 10 | 11 | SRC_URI = "git://github.com/ARM-software/gator.git;protocol=https;rev=6.1 \ 12 | file://0001-patch-daemon-Makefile.patch" 13 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" 14 | INHIBIT_PACKAGE_DEBUG_SPLIT-dev = "1" 15 | 16 | INSANE_SKIP_${PN}-dev += " ldflags" 17 | INSANE_SKIP_${PN} += " ldflags" 18 | 19 | do_compile() { 20 | cd ${S}/driver 21 | ${MAKE} -C ${STAGING_KERNEL_DIR} M=`pwd` ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} modules 22 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE 23 | cd ${S}/daemon 24 | ${MAKE} 25 | } 26 | 27 | do_install() { 28 | INIT_DIR=${D}${sysconfdir}/init.d/ 29 | install -d ${INIT_DIR} 30 | install -m 0644 ${S}/driver/gator.ko ${INIT_DIR} 31 | install -m 0755 ${S}/daemon/gatord ${INIT_DIR}/gatord 32 | echo "#!/bin/bash\n/etc/init.d/gatord &" > ${INIT_DIR}/rungator.sh 33 | chmod a+x ${INIT_DIR}/rungator.sh 34 | } 35 | 36 | FILES_${PN} = "${sysconfdir}/init.d/gator.ko ${sysconfdir}/init.d/gatord ${sysconfdir}/init.d/rungator.sh" 37 | -------------------------------------------------------------------------------- /ARMCourse/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Embedded-Linux-Education-Kit 3 | 4 | Welcome to our Embedded Linux Education Kit! 5 | 6 | ### [Download the EdKit here](https://github.com/arm-university/Embedded-Linux-Education-Kit/archive/refs/heads/main.zip) 7 | 8 | Our flagship offering to universities worldwide is the Arm University Program Education Kit series. 9 | 10 | These self-contained educational materials offered exclusively and at no cost to academics and teaching staff worldwide. They’re designed to support your day-to-day teaching on core electronic engineering and computer science subjects. You have the freedom to choose which modules to teach – you can use all the modules in the Education Kit or only those that are most appropriate to your teaching outcomes. 11 | 12 | Our Embedded Linux Education Kit covers the fundamental knowledge of the Linux architecture, and practical skills involved in configuring and building a full Linux operating system stack. A full description of the education kit can be found [here](https://www.arm.com/resources/education/education-kits/embedded-linux). 13 | 14 | ## Kit specification: 15 | 16 | * A full set of lecture slides, ready for use in a typical 10-12-week undergraduate course (full syllabus below) 17 | * Lab manual with solutions for faculty. Labs are based on low-cost yet powerful Arm-based single board computers donated by partners (subject to availability) 18 | * **Prerequisites:** Basics of operating systems, basics of software programming in C 19 | 20 | ## Course Aim 21 | To produce students who can develop an embedded Linux system on low-cost yet powerful Arm based platforms, including customer peripheral development for various applications using standard software tools. 22 | 23 | ## Syllabus 24 | 1. Introduction to Linux and Embedded Systems 25 | 1. Linux-based Embedded System Component Stack 26 | 1. Anatomy of a Linux-based System 27 | 1. Configuration and Build Process 28 | 1. Linux Kernel Modules 29 | 1. Communication Between Kernel and User Space 30 | 1. Application Demo: Building a Ranging Sensor Kernel Module 31 | 1. System Debugging and Profiling 32 | 33 | ## License 34 | You are free to fork or clone this material. See [LICENSE.md](https://github.com/arm-university/Embedded-Linux-Education-Kit/blob/main/License/LICENSE.md) for the complete license. 35 | 36 | ## Inclusive Language Commitment 37 | Arm is committed to making the language we use inclusive, meaningful, and respectful. Our goal is to remove and replace non-inclusive language from our vocabulary to reflect our values and represent our global ecosystem. 38 | 39 | Arm is working actively with our partners, standards bodies, and the wider ecosystem to adopt a consistent approach to the use of inclusive language and to eradicate and replace offensive terms. We recognise that this will take time. This course may contain references to non-inclusive language; it will be updated with newer terms as those terms are agreed and ratified with the wider community. 40 | 41 | Contact us at education@arm.com with questions or comments about this course. You can also report non-inclusive and offensive terminology usage in Arm content at terms@arm.com. 42 | -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/gpio-mod/files/gpio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #define GPIO_OUT 20 // GPIO_105 16 | #define GPIO_IN 21 // GPIO_148 17 | 18 | static dev_t gpio_dev; 19 | 20 | struct cdev gpio_cdev; 21 | 22 | static int gpio_lock = 0; 23 | 24 | volatile char gpio_in_value = 0; 25 | 26 | static irq_handler_t InterruptHandler( unsigned int irq, struct pt_regs *regs ) 27 | { 28 | gpio_in_value = gpio_get_value( GPIO_IN ); 29 | 30 | printk( KERN_INFO "gpio_dev: %s got GPIO_IN with value %c\n", 31 | __func__, gpio_in_value+'0' ); 32 | 33 | return (irq_handler_t) IRQ_HANDLED; 34 | } 35 | 36 | 37 | int gpio_open(struct inode *inode, struct file *file) 38 | { 39 | int ret = 0; 40 | 41 | printk( KERN_INFO "gpio_dev: %s\n", __func__ ); 42 | if( gpio_lock > 0 ) 43 | { 44 | ret = -EBUSY; 45 | } 46 | else 47 | gpio_lock++; 48 | 49 | return( ret ); 50 | } 51 | 52 | int gpio_close(struct inode *inode, struct file *file) 53 | { 54 | printk( KERN_INFO "gpio_dev: %s\n", __func__ ); 55 | 56 | gpio_lock = 0; 57 | 58 | return( 0 ); 59 | } 60 | 61 | 62 | ssize_t gpio_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) 63 | { 64 | char buffer[2]; 65 | 66 | printk(KERN_INFO "gpio read (count=%d, offset=%d)\n", (int)count, (int)*f_pos ); 67 | 68 | buffer[0] = gpio_in_value; 69 | buffer[1] = 0; 70 | 71 | copy_to_user( buf, buffer, 1 ); 72 | 73 | return 1; 74 | } 75 | 76 | ssize_t gpio_write(struct file *filp, const char *buffer, size_t length, loff_t * offset) 77 | { 78 | int n = 0; 79 | 80 | while( length ) 81 | { 82 | if( *buffer == '0' ) 83 | { 84 | gpio_set_value( GPIO_OUT, 0 ); 85 | printk( KERN_INFO "gpio_dev: %s wrote %c to GPIO_OUT\n", __func__, *buffer ); 86 | } 87 | if( *buffer == '1' ) 88 | { 89 | gpio_set_value( GPIO_OUT, 1 ); 90 | printk( KERN_INFO "gpio_dev: %s wrote %c to GPIO_OUT\n", __func__, *buffer ); 91 | } 92 | buffer++; 93 | length--; 94 | n++; 95 | } 96 | 97 | return( n ); 98 | } 99 | 100 | 101 | struct file_operations gpio_fops = { 102 | .owner = THIS_MODULE, 103 | .read = gpio_read, 104 | .write = gpio_write, 105 | .open = gpio_open, 106 | .release = gpio_close, 107 | }; 108 | 109 | static int __init gpio_module_init(void) 110 | { 111 | char buffer[64]; 112 | int ret = 0; 113 | 114 | printk(KERN_INFO "Loading gpio_module\n"); 115 | 116 | alloc_chrdev_region(&gpio_dev, 0, 1, "gpio_dev"); 117 | printk(KERN_INFO "%s\n", format_dev_t(buffer, gpio_dev)); 118 | 119 | cdev_init(&gpio_cdev, &gpio_fops); 120 | gpio_cdev.owner = THIS_MODULE; 121 | cdev_add(&gpio_cdev, gpio_dev, 1); 122 | 123 | if( gpio_request( GPIO_OUT, "gpio_dev" ) ) 124 | { 125 | printk( KERN_INFO "gpio_dev: %s unable to get GPIO_OUT\n", __func__ ); 126 | ret = -EBUSY; 127 | goto Done; 128 | } 129 | 130 | if( gpio_request( GPIO_IN, "gpio_dev" ) ) 131 | { 132 | printk( KERN_INFO "gpio_dev: %s unable to get GPIO_IN\n", __func__ ); 133 | ret = -EBUSY; 134 | goto Done; 135 | } 136 | 137 | if( gpio_direction_output( GPIO_OUT, 0 ) < 0 ) 138 | { 139 | printk( KERN_INFO "gpio_dev: %s unable to set GPIO_OUT as output\n", __func__ ); 140 | ret = -EBUSY; 141 | goto Done; 142 | } 143 | 144 | if( gpio_direction_input( GPIO_IN ) < 0 ) 145 | { 146 | printk( KERN_INFO "gpio_dev: %s unable to set GPIO_IN as input\n", __func__ ); 147 | ret = -EBUSY; 148 | goto Done; 149 | } 150 | 151 | if( request_irq( gpio_to_irq( GPIO_IN ), (irq_handler_t) InterruptHandler, 152 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "gpio_dev", NULL ) < 0 ) 153 | { 154 | printk( KERN_INFO "gpio_dev: %s unable to register gpio irq for GPIO_IN\n", 155 | __func__ ); 156 | 157 | ret = -EBUSY; 158 | goto Done; 159 | } 160 | 161 | Done: 162 | return ret; 163 | } 164 | 165 | static void __exit gpio_module_cleanup(void) 166 | { 167 | printk(KERN_INFO "Cleaning-up gpio_dev.\n"); 168 | 169 | gpio_free( GPIO_OUT ); 170 | gpio_free( GPIO_IN ); 171 | 172 | free_irq( gpio_to_irq( GPIO_IN ), NULL ); 173 | 174 | gpio_lock = 0; 175 | 176 | cdev_del(&gpio_cdev); 177 | unregister_chrdev_region(gpio_dev, 1); 178 | } 179 | 180 | module_init(gpio_module_init); 181 | module_exit(gpio_module_cleanup); 182 | 183 | MODULE_AUTHOR("Your Name"); 184 | MODULE_LICENSE("GPL"); 185 | -------------------------------------------------------------------------------- /ARMCourse/Module07_BuildingARangingSensorKernelModule/Lab03_BuildingARangingSensorKernelModule/hcsr04-mod/files/hcsr04.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define GPIO_OUT 20 // GPIO20 24 | #define GPIO_IN 21 // GPIO21 25 | 26 | static dev_t hcsr04_dev; //defines structure to hold major and minor number of device// 27 | 28 | struct cdev hcsr04_cdev; //defines structure to hold character device properties// 29 | 30 | static int hcsr04_lock = 0; //flag to show when module is in use// 31 | 32 | static struct kobject *hcsr04_kobject; 33 | 34 | static ktime_t rising, falling; 35 | 36 | int hcsr04_open(struct inode *inode, struct file *file) //opens module connecton, asserts "busy"// 37 | { 38 | int ret = 0; 39 | 40 | printk( KERN_INFO "hcsr04_dev: %s\n", __func__ ); 41 | if( hcsr04_lock > 0 ) 42 | { 43 | ret = -EBUSY; 44 | } 45 | else 46 | hcsr04_lock++; 47 | 48 | return( ret ); 49 | } 50 | 51 | int hcsr04_close(struct inode *inode, struct file *file) //cloeses connection, sets state to not busy// 52 | { 53 | printk( KERN_INFO "hcsr04_dev: %s\n", __func__ ); 54 | 55 | hcsr04_lock = 0; 56 | 57 | return( 0 ); 58 | } 59 | 60 | ssize_t hcsr04_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) 61 | { 62 | int ret; 63 | int pulse; 64 | 65 | printk( KERN_INFO "hcsr04_dev: %s\n", __func__ ); 66 | 67 | pulse = (int)ktime_to_us( ktime_sub( falling, rising ) ); 68 | 69 | ret = copy_to_user( buf, &pulse, 4 ); 70 | 71 | return 4; 72 | } 73 | 74 | ssize_t hcsr04_write(struct file *filp, const char *buffer, size_t length, loff_t * offset) 75 | { 76 | printk( KERN_INFO "hcsr04_dev: %s\n", __func__ ); 77 | 78 | gpio_set_value( GPIO_OUT, 0 ); 79 | gpio_set_value( GPIO_OUT, 1 ); 80 | udelay( 10 ); 81 | gpio_set_value( GPIO_OUT, 0 ); 82 | 83 | while( gpio_get_value( GPIO_IN ) == 0 ) 84 | ; 85 | rising = ktime_get(); 86 | 87 | while( gpio_get_value( GPIO_IN ) == 1 ) 88 | ; 89 | falling = ktime_get(); 90 | 91 | return( 1 ); 92 | } 93 | 94 | 95 | struct file_operations hcsr04_fops = { 96 | .owner = THIS_MODULE, 97 | .read = hcsr04_read, 98 | .write = hcsr04_write, 99 | .open = hcsr04_open, 100 | .release = hcsr04_close, 101 | }; 102 | 103 | static ssize_t hcsr04_show(struct kobject *kobj, struct kobj_attribute *attr, 104 | char *buf) 105 | { 106 | printk( KERN_INFO "hcsr04_dev: %s\n", __func__ ); 107 | 108 | return sprintf(buf, "%d\n", ktime_to_us(ktime_sub(falling,rising))); 109 | } 110 | 111 | static ssize_t hcsr04_store(struct kobject *kobj, struct kobj_attribute *attr, 112 | char *buf, size_t count) 113 | { 114 | printk( KERN_INFO "hcsr04_dev: %s\n", __func__ ); 115 | 116 | return 1; 117 | } 118 | 119 | static struct kobj_attribute hcsr04_attribute =__ATTR(hcsr04, 0660, hcsr04_show, hcsr04_store); 120 | 121 | static int __init hcsr04_module_init(void) 122 | { 123 | char buffer[64]; 124 | int ret = 0; 125 | 126 | printk(KERN_INFO "Loading hcsr04_module\n"); 127 | 128 | alloc_chrdev_region(&hcsr04_dev, 0, 1, "hcsr04_dev"); 129 | printk(KERN_INFO "%s\n", format_dev_t(buffer, hcsr04_dev)); 130 | 131 | cdev_init(&hcsr04_cdev, &hcsr04_fops); 132 | hcsr04_cdev.owner = THIS_MODULE; 133 | cdev_add(&hcsr04_cdev, hcsr04_dev, 1); 134 | 135 | 136 | if( gpio_request( GPIO_OUT, "hcsr04_dev" ) ) 137 | { 138 | printk( KERN_INFO "hcsr04_dev: %s unable to get GPIO_OUT\n", __func__ ); 139 | ret = -EBUSY; 140 | goto Done; 141 | } 142 | 143 | if( gpio_request( GPIO_IN, "hcsr04_dev" ) ) 144 | { 145 | printk( KERN_INFO "hcsr04_dev: %s unable to get GPIO_IN\n", __func__ ); 146 | ret = -EBUSY; 147 | goto Done; 148 | } 149 | 150 | if( gpio_direction_output( GPIO_OUT, 0 ) < 0 ) 151 | { 152 | printk( KERN_INFO "hcsr04_dev: %s unable to set GPIO_OUT as output\n", __func__ ); 153 | ret = -EBUSY; 154 | goto Done; 155 | } 156 | 157 | if( gpio_direction_input( GPIO_IN ) < 0 ) 158 | { 159 | printk( KERN_INFO "hcsr04_dev: %s unable to set GPIO_IN as input\n", __func__ ); 160 | ret = -EBUSY; 161 | goto Done; 162 | } 163 | 164 | hcsr04_kobject = kobject_create_and_add("hcsr04", kernel_kobj); 165 | if(!hcsr04_kobject) 166 | { 167 | ret = -ENOMEM; 168 | goto Done; 169 | } 170 | ret = sysfs_create_file(hcsr04_kobject, &hcsr04_attribute.attr); 171 | if( ret ) 172 | { 173 | printk( KERN_INFO "failed to create the foo file in /sys/kernel/hcsr04\n"); 174 | ret = -ENOMEM; 175 | goto Done; 176 | } 177 | 178 | 179 | Done: 180 | return ret; 181 | } 182 | 183 | static void __exit hcsr04_module_cleanup(void) 184 | { 185 | printk(KERN_INFO "Cleaning-up hcsr04_dev.\n"); 186 | 187 | gpio_free( GPIO_OUT ); 188 | gpio_free( GPIO_IN ); 189 | 190 | hcsr04_lock = 0; 191 | 192 | cdev_del(&hcsr04_cdev); 193 | unregister_chrdev_region( hcsr04_dev, 1 ); 194 | 195 | kobject_put( hcsr04_kobject ); 196 | } 197 | 198 | module_init(hcsr04_module_init); 199 | module_exit(hcsr04_module_cleanup); 200 | 201 | MODULE_AUTHOR("Your name"); 202 | MODULE_LICENSE("GPL"); 203 | -------------------------------------------------------------------------------- /ARMCourse/Module06_CommunicationBetweenKernelAndUserSpace/Lab02_HandlingGPIOusingLinuxKernelModules/gpio-mod/files/gpiocommented.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #define GPIO_OUT 20 // GPIO_105 15 | #define GPIO_IN 21 // GPIO_148 16 | 17 | static dev_t gpio_dev; //defines structure to hold major and minor number of device// 18 | 19 | struct cdev gpio_cdev; //defines structure to hold character device properties// 20 | 21 | static int gpio_lock = 0; //flag to show when module is in use// 22 | 23 | volatile char gpio_in_value = 0; //defines structure to hold value from GPIO_IN-volatile as it's written by interrupt// 24 | 25 | static irq_handler_t InterruptHandler( unsigned int irq, struct pt_regs *regs ) //defines function of the interrupt// 26 | { 27 | gpio_in_value = gpio_get_value( GPIO_IN ); //reads gpio value, places value in gpio_in_vaule// 28 | 29 | printk( KERN_INFO "gpio_dev: %s got GPIO_IN with value %c\n", 30 | __func__, gpio_in_value+'0' ); 31 | 32 | return (irq_handler_t) IRQ_HANDLED; 33 | } 34 | 35 | 36 | int gpio_open(struct inode *inode, struct file *file) //opens connection to module// 37 | { 38 | int ret = 0; 39 | 40 | printk( KERN_INFO "gpio_dev: %s\n", __func__ ); 41 | if( gpio_lock > 0 ) //checks if module is already in use// 42 | { 43 | ret = -EBUSY; //EBUSY = error code for device locked or busy// 44 | } 45 | else 46 | gpio_lock++; //sets flag to busy// 47 | 48 | return( ret ); 49 | } 50 | 51 | int gpio_close(struct inode *inode, struct file *file) //closes connection to module// 52 | { 53 | printk( KERN_INFO "gpio_dev: %s\n", __func__ ); 54 | 55 | gpio_lock = 0; //sets flag to not busy// 56 | 57 | return( 0 ); 58 | } 59 | 60 | 61 | ssize_t gpio_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) //reads value from device// 62 | { 63 | char buffer[2]; 64 | 65 | printk(KERN_INFO "gpio read (count=%d, offset=%d)\n", (int)count, (int)*f_pos ); 66 | 67 | buffer[0] = gpio_in_value; 68 | buffer[1] = 0; 69 | 70 | copy_to_user( buf, buffer, 1 ); 71 | 72 | return 1; 73 | } 74 | 75 | ssize_t gpio_write(struct file *filp, const char *buffer, size_t length, loff_t * offset) //writes value to device// 76 | { 77 | int n = 0; 78 | 79 | while( length ) 80 | { 81 | if( *buffer == '0' ) 82 | { 83 | gpio_set_value( GPIO_OUT, 0 ); 84 | printk( KERN_INFO "gpio_dev: %s wrote %c to GPIO_OUT\n", __func__, *buffer ); 85 | } 86 | if( *buffer == '1' ) 87 | { 88 | gpio_set_value( GPIO_OUT, 1 ); 89 | printk( KERN_INFO "gpio_dev: %s wrote %c to GPIO_OUT\n", __func__, *buffer ); 90 | } 91 | buffer++; 92 | length--; 93 | n++; 94 | } 95 | 96 | return( n ); 97 | } 98 | 99 | 100 | struct file_operations gpio_fops = { //fops structure links device functions to virtual file system functions// 101 | .owner = THIS_MODULE, 102 | .read = gpio_read, 103 | .write = gpio_write, 104 | .open = gpio_open, 105 | .release = gpio_close, 106 | }; 107 | 108 | static int __init gpio_module_init(void) //Module initialisation function// 109 | { 110 | char buffer[64]; //to hold messages to send to command line// 111 | int ret = 0; //return value....??????????????????????????????????????????????????????// 112 | 113 | printk(KERN_INFO "Loading gpio_module\n"); //Prints each time module is loaded// 114 | 115 | alloc_chrdev_region(&gpio_dev, 0, 1, "gpio_dev"); //allocates a major and minor number to the device// 116 | printk(KERN_INFO "%s\n", format_dev_t(buffer, gpio_dev)); //prints major and minor number to cmdline// 117 | 118 | cdev_init(&gpio_cdev, &gpio_fops); //initialises a character device structure// 119 | gpio_cdev.owner = THIS_MODULE; // 120 | cdev_add(&gpio_cdev, gpio_dev, 1); //adds the cdev structure to the system// 121 | 122 | if( gpio_request( GPIO_OUT, "gpio_dev" ) ) //checks whether GPIO_OUT (gpio 20) is available// 123 | { 124 | printk( KERN_INFO "gpio_dev: %s unable to get GPIO_OUT\n", __func__ ); //tells user GPIO unavailable// 125 | ret = -EBUSY; //what is ret and ebusy???????????????????????????????????????// 126 | goto Done; //breaks from if statements to "done:" case below// 127 | } 128 | 129 | if( gpio_request( GPIO_IN, "gpio_dev" ) ) //checks whether GPIO_IN (gpio 21) is available// 130 | { 131 | printk( KERN_INFO "gpio_dev: %s unable to get GPIO_IN\n", __func__ ); 132 | ret = -EBUSY; 133 | goto Done; 134 | } 135 | 136 | if( gpio_direction_output( GPIO_OUT, 0 ) < 0 ) //Changes GPIO_OUT to output(if not already), returns negative if it can't// 137 | { 138 | printk( KERN_INFO "gpio_dev: %s unable to set GPIO_OUT as output\n", __func__ ); 139 | ret = -EBUSY; 140 | goto Done; 141 | } 142 | 143 | if( gpio_direction_input( GPIO_IN ) < 0 ) //changes GPIO_IN to input...see output// 144 | { 145 | printk( KERN_INFO "gpio_dev: %s unable to set GPIO_IN as input\n", __func__ ); 146 | ret = -EBUSY; 147 | goto Done; 148 | } 149 | 150 | if( request_irq( gpio_to_irq( GPIO_IN ), (irq_handler_t) InterruptHandler, //allocates interrupt line to GPIO_IN, invokes the interrupt...// 151 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "gpio_dev", NULL ) < 0 ) //...handler, error gives negative return value// 152 | { 153 | printk( KERN_INFO "gpio_dev: %s unable to register gpio irq for GPIO_IN\n", 154 | __func__ ); 155 | 156 | ret = -EBUSY; 157 | goto Done; 158 | } 159 | 160 | Done: 161 | return ret; 162 | } 163 | 164 | static void __exit gpio_module_cleanup(void) //module exit functon// 165 | { 166 | printk(KERN_INFO "Cleaning-up gpio_dev.\n"); 167 | 168 | gpio_free( GPIO_OUT ); //releases GPIO 20 from GPIO_OUT// 169 | gpio_free( GPIO_IN ); //releases GPIO 21 from GPIO_IN// 170 | 171 | free_irq( gpio_to_irq( GPIO_IN ), NULL ); //releases interrupt request line// 172 | 173 | gpio_lock = 0; //sets module count flag back to 0 (shows not in use)// 174 | 175 | cdev_del(&gpio_cdev); //removes the character device fromt he system// 176 | unregister_chrdev_region(gpio_dev, 1); //frees character device major and minor numbers// 177 | } 178 | 179 | module_init(gpio_module_init); //renames initialisation function "gpio_module_init"// 180 | module_exit(gpio_module_cleanup); //renames exit fucntion "gpio_module_cleanup"// 181 | MODULE_AUTHOR("Your Name"); //states authors name// 182 | MODULE_LICENSE("GPL"); //shows resource is open source// 183 | 184 | 185 | //Useful links: 186 | https://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html#AEN40 187 | https://www.kernel.org/doc/htmldocs/kernel-api/chrdev.html 188 | http://www.zilogic.com/releases/bsp-1.5.1/doc/zdev-user-manual/_gpio.html 189 | // -------------------------------------------------------------------------------- /ARMCourse/License/LICENSE.md: -------------------------------------------------------------------------------- 1 | ## ARM EDUCATION 2 | 3 | ## END USER LICENSE AGREEMENT FOR TEACHING AND LEARNING CONTENT 4 | 5 | 1. These terms are displayed for you to read prior to use of the teaching and learning content and any related documentation and materials (“Materials”) made available to you by Arm Limited (“Arm”). If you choose not to agree with these terms, do not use or access the Materials. 6 | 7 | 2. THESE TERMS AND CONDITIONS CONSTITUTE A LEGALLY BINDING AGREEMENT BETWEEN YOU AND ARM (“AGREEMENT”). The Materials may include third party elements, and/or hardware distributed on behalf of a third party, which may be subject to separate terms of use. You acknowledge that any hardware provided to you is a third-party product and Arm is solely distributing such hardware on behalf of the third party. To the fullest extent permitted by law, Arm shall have no responsibility or liability in respect of any such hardware. 8 | 9 | 3. You acknowledge that the Materials are specifically designed and licensed only for non-commercial, educational purposes. 10 | 11 | 4. INTELLECTUAL PROPERTY. The Materials are protected by copyright laws, international copyright treaties, and trade secret laws, and other intellectual property laws and treaties around the world. The Materials are licensed, not sold, to you, and can only be used in accordance with the terms of this Agreement. Arm and its licensors retain title and ownership of the Materials (other than in respect of any third party elements), including all intellectual property rights in the Materials. Arm reserves all rights not specifically granted under this Agreement. 12 | 13 | 5. LICENCE. Subject to your compliance with this Agreement and unless otherwise specified in Clause 13, Arm hereby grants to you a limited, non-exclusive, non-transferable, royalty-free, licence under its copyright subsisting in the Materials to use, copy and modify the Materials (and if and only if you are a current member of an educational institution, make the Materials available to others within your educational institution) upon the terms of this Agreement, solely for non-commercial educational purposes. For the purposes of these terms, “educational purposes” means internal use in taught classes and related projects at educational institutions, including but not limited to schools, colleges and universities. 14 | Unless otherwise specified in Clause 13: (a) you may refer to and cite the Materials in publications provided that you give a full citation referencing Arm as the author and owner of the Materials; (b) you may not use the Materials for any commercial purpose, except as expressly approved by Arm in writing (contact education@arm.com to request permission); (c) you may not remove any proprietary notice(s) contained in the Materials; (d) you may not use the Materials to design or to manufacture Arm-based processors, or use the Materials for the purposes of adapting or developing resources or educational materials relating to non-Arm based architectures and platforms; and (e) you may not modify the Materials for use with non-Arm-based architectures. You may not use the Materials for any unlawful purpose, you may not (except as far as permitted by applicable law) reverse engineer or decompile any software tools delivered as part of the Materials, and you may not use the Materials in any way that may damage Arm’s reputation or bring Arm into disrepute. The licence granted by Arm pursuant to this Clause 5 is effective until terminated. Without prejudice to any other rights, Arm may terminate this Agreement and your right to use the Materials if you are in material breach of any of these terms or if you do anything that infringes Arm’s intellectual property rights. Termination will be effective immediately on the service of Arm’s notice of termination to you. In the event of termination, you shall destroy all copies of the Materials, including all portions and derivatives of them, and cease all use of the Materials immediately. Clauses impliedly or expressly intended to survive termination shall continue in full force and effect. 15 | 16 | 6. WARRANTIES AND LIMITATIONS. a. THE MATERIALS ARE PROVIDED “AS IS”. ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED OR STATUTORY, ARE HEREBY EXCLUDED, INCLUDING, WITHOUT LIMITATION, THOSE RELATING TO MERCHANTABILITY, SATISFACTORY QUALITY, FREEDOM FROM DEFECTS, RELIABILITY, AVAILABILITY, ACCURACY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE. 17 | 18 | b. IN NO EVENT SHALL ARM BE LIABLE UNDER THIS AGREEMENT OR OTHERWISE IN CONNECTION WITH THE MATERIALS FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES WHETHER SUCH DAMAGES ARE ALLEGED AS A RESULT OF TORTIOUS CONDUCT OR BREACH OF CONTRACT OR OTHERWISE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 19 | 20 | c. THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST ARM IN CONTRACT, TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THIS AGREEMENT, OR OTHERWISE IN CONNECTION WITH THE MATERIALS SHALL NOT EXCEED THE GREATER OF ONE HUNDRED U.S. DOLLARS ($100 USD) OR THE TOTAL OF SUMS PAID, IF ANY, BY YOU TO ARM UNDER THIS AGREEMENT. 21 | 22 | d. Nothing in this section shall operate to exclude or limit liability for: (i) death or personal injury resulting from either party's negligence; or (ii) fraud; or (iii) any other matters in respect of which by law liability cannot be excluded or limited. 23 | 24 | 7. EXPORT CONTROL. You hereby acknowledge and agree that the Materials are subject to U.S. export control laws, including the U.S. Export Administration Act and its associated regulations, and may be subject to export or import regulations in other countries. You agree to comply fully with all export laws and regulations of the United States and other countries (“Export Laws”) to assure that neither the Materials, nor any direct products of them are; ( i ) exported, directly or indirectly, in violation of Export Laws, either to any countries that are subject to U.S export restrictions or to any end user who has been prohibited from participating in the U.S. export transactions by any federal agency of the U.S. government; or (ii) intended to be used for any purpose prohibited by Export Laws, including, without limitation, nuclear, chemical, or biological weapons proliferation. The Materials consist solely of commercial items. If applicable, your institution shall be responsible for ensuring that any Materials provided to the US Government in accordance with the terms of this Agreement are provided with the rights and subject to restrictions described elsewhere in this Agreement. 25 | 26 | 8. CONTRIBUTIONS, FEEDBACK AND MODIFICATIONS. If you wish to submit any contributions or feedback (“Contributions”) to Arm you may do subject to you granting Arm the license in this Clause 8, You hereby grant to Arm a perpetual, irrevocable, non-exclusive, royalty-free, fully paid-up, worldwide licence under all your intellectual property rights subsisting in the Contributions to (i) use, copy, create derivative works of and modify the Contributions; (ii) sell supply, distribute the Contributions solely as incorporated into or in conjunction with the Materials; and (iii) and sublicense the rights granted in Clause 8(1) to third parties. 27 | To the extent that any claim in any patent application filed by you would not have been conceived by you but for having had access to the Materials, such claim shall be deemed to be feedback and is hereby licensed to Arm in accordance with the provisions of this Clause 8. You represent that you are legally entitled to grant the licence set out in this Clause 8. If your employer has rights to intellectual property that you submit to Arm, you represent that you have permission to make such submissions on behalf of your employer. You further represent that any contribution, suggestion, comment, or feedback you provide to Arm is your original creation. You represent and agree that you will not submit any third-party intellectual property or materials to Arm without Arm’s express prior written approval. You agree to notify Arm promptly of any circumstances or facts of which you become aware that would make any of these representations inaccurate in any respect. If you have any questions or wish to contact Arm in relation to the contribution process, please contact education@arm.com. 28 | 29 | 9. GOVERNING LAW. This Agreement and any disputes or claims arising out of or in connection with it or its subject matter or formation (including non-contractual disputes or claims) are governed by and construed in accordance with the laws of England and Wales. 30 | 31 | 10. PERSONAL DATA. Arm will process any personal data in accordance with its privacy policy: www.arm.com/company/policies/privacy. 32 | 33 | 11. UPDATES. Arm may update this Agreement from time to time. Where appropriate, updates to the Agreement will be notified to you by email. If you do not agree with an update, you should cease use of the Materials. 34 | 35 | 12. CONTACTING US. If you have any queries in relation to this Agreement or the Materials, please email education@arm.com. 36 | 37 | 13. SPECIAL CONDITIONS. The provisions of this Clause 13 shall take precedence in the event of any conflict with the remainder of this Agreement. 38 | Use of the pedagogical processor model provided with the Introduction to Computer Architecture Education Kit (the "Arm Education Core") is subject to the following special conditions: 39 | 40 | (a) you may only refer to or publish the Arm Education Core, or any modifications you make to the Arm Education Core or any results you obtain from its use, in whole or in part if you have first obtained Arm's specific prior written consent by emailing us at the address specified in Clause 12 above; 41 | 42 | (b) you may use the Arm Education Core to synthesize and implement an SoC on FPGA or for an ASIC implementation of the SoC for non-commercial educational purposes (as defined in Clause 5 above); 43 | 44 | (c) you may not make any claims about the Arm Education Core's functionality or otherwise other than those published by Arm. The Arm Education Core is not representative of any commercially available Arm processors and you may not make any statements that indicate or imply the contrary. 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Notes.txt: -------------------------------------------------------------------------------- 1 | Every Embedded Linux Project requires following four components : 2 | 3 | Toolchain : To Compile all the other elements. 4 | Bootloader : To Initialise the board and load kernel(Application,System Programs,Operating System,Device Tree) 5 | Kernel : To manage system resources. 6 | Root filesystem : To Run applications, Container for linux kernel configuration files, system programs, application. 7 | Device Tree : A tree data structure with nodes informing linux kernel about the connected HW devices enabling proper 8 | initialzing of the relevant device drivers. 9 | 10 | A build system such as Yocto or Build root generates the above neccessary components for us. 11 | 12 | 13 | 14 | ---------------------------------------ARM Embedded Linux Online Course----------------------------- 15 | 16 | ----------------Lec 1 : Introduction------------------ 17 | 18 | Operating system provides following services : 19 | System call interface, 20 | Process Management, 21 | Memory Management, 22 | Virtual File System, 23 | Device Drivers for I/O Management. 24 | 25 | Linux Kernel also provides above same services. 26 | 27 | We will prefer LTS i.e. Long terms kernels having long term maintainence. 28 | 29 | 30 | ---------------------Lec 2 : Linux Based Embedded Systems-------------------------- 31 | 32 | The difference between MCU and SoC is that in MCU RAM,ROM(Bootflash),CPU, I/O are all on the same chip . 33 | In SoC RAM Memory and additional component Mass Memory are not present on the same chip 34 | while CPI, I/O, Bootflash are present on the same chip. 35 | 36 | The kernel modules are loaded into kernel using commands such as insmod or modprobe or maybe autoloaded through modifying a file of Embedded Linux distro. 37 | 38 | In Linux based embedded system following components are mandatory : 39 | 40 | Bootloader : To Initialise the board and load kernel(Application,System Programs,Operating System,Device Tree). 41 | Bootloader is a software executed at startup , it copies the Application,System Programs,Operating System, 42 | Device Tree from Mass Memory Flash to RAM and also initializes RAM Memory controller. 43 | 44 | Device Tree : A tree data structure with nodes informing linux kernel about the connected HW devices enabling proper 45 | initialzing of the relevant device drivers. This information is provided to the kernel through 46 | device tree blob file produced from Device tree source file. 47 | 48 | Kernel : To manage system resources and provide services : Process Management, Memory Management, Scheduling, 49 | Inter process communication, I/O Management, File Syste, Networking. 50 | Kernel code is Architecture-independent operating system code. 51 | 52 | 53 | System Programs : Provide Status Information, File Modification, Programming Language support, program loading and execution, 54 | Communications, application programs. 55 | 56 | Application : Software required to provide end user service . 57 | 58 | Root filesystem : To Run applications, Container for linux kernel configuration files, system programs, application. 59 | Contains first user-level process init. 60 | 61 | / # Disk root 62 | /bin # Repository for binary files 63 | /lib # Repository for library files 64 | /dev # Repository for device files 65 | console c 5 1 # Console device file 66 | null c 1 3 # Null device file 67 | zero c 1 5 # All-zero device file 68 | tty c 5 0 # Serial console device file 69 | tty0 c 4 0 # Serial terminal device file 70 | tty1 c 4 1 # 71 | tty2 c 4 2 # 72 | tty3 c 4 3 # 73 | tty4 c 4 4 # 74 | tty5 c 4 5 # 75 | /etc # Repository for config files 76 | inittab # The inittab 77 | /init.d # Repository for init config files 78 | rcS # The script run at sysinit 79 | /proc # The /proc file system 80 | /sbin # Repository for accessory binary files 81 | /tmp # Repository for temporary files 82 | /var # Repository for optional config files 83 | /usr # Repository for user files 84 | /sys # Repository for system service files 85 | /media # Mount point for removable storage 86 | 87 | ------------------------Lecture 3 : Anatomy Of Linux Based Embedded System------------------------- 88 | 89 | Linux kernel is Monolithic Kernel separated into User and Kernel Space. User and Kernel Space communicate through system calls. 90 | 91 | The Kernel can be divided in five subsystems: 92 | Process scheduler 93 | Memory manager 94 | Virtual file system 95 | Inter-process communication 96 | Network 97 | Most of them are composed of: 98 | Hardware-independent code 99 | Hardware-dependent code 100 | 101 | The MMU (Memory Management Unit Part Of Linux Kernel) detects when a user process accesses a memory address that is not currently mapped to a physical memory location. The MMU notifies the Linux Kernel the event known as page fault 102 | 103 | -----Memory Manager External Interfaces------ 104 | 105 | System call interface: 106 | malloc()/free(): allocate or free a region of memory for the process's use 107 | mmap()/munmap()/msync()/mremap(): map files into virtual memory regions 108 | mprotect(): change the protection on a region of virtual memory 109 | mlock()/mlockall()/munlock()/munlockall(): super-user routines to prevent memory being swapped 110 | swapon()/swapoff(): super-user routines to add and remove swap files for the system 111 | 112 | 113 | Intra-Kernel interface: 114 | kmalloc()/kfree(): allocate and free memory for use by the kernel’s data structures 115 | verify_area(): verify that a region of user memory is mapped with required permissions 116 | get_free_page()/free_page(): allocate and free physical memory pages. 117 | 118 | 119 | ---------Virtugal File System (VFS)-------------- 120 | 121 | VFS is responsible for providing : 122 | High Speed access to files 123 | Enforces policies not to loose or corrupt data. 124 | enforces policies to grant access to files only to allowed users, and it restricts user total file size with quotas. 125 | External interface: 126 | System-call interface based on normal operations on file from the POSIX standard (e.g. open/close/read/write) 127 | Intra-kernel interface based on i-node interface and file interface. 128 | The i-node stores all information about a file except it´s data and name, Whenever a file is created it is assigned a name 129 | and a unique i-node number. 130 | 131 | VFS I- Node Interface Provided Functions/API´s : 132 | 133 | create(): creates a file in a directory 134 | lookup(): finds a file by name within a directory 135 | link()/symlink()/unlink()/readlink()/follow_link(): manages file system links 136 | mkdir()/rmdir(): creates or removes sub-directories 137 | mknod(): creates a directory, special file, or regular file 138 | 139 | readpage()/writepage(): reads or writes a page of physical memory 140 | truncate(): sets the length of a file to zero 141 | permission(): checks to see if a user process has permission to execute an operation 142 | smap(): maps a logical file block to a physical device sector 143 | bmap(): maps a logical file block to a physical device block 144 | rename(): renames a file or directory 145 | 146 | 147 | VFS File Interface Functions/API´s : 148 | 149 | open()/release(): opens or closes the file 150 | read()/write(): reads or writes the file 151 | select(): waits until the file is in a particular state (readable or writeable) 152 | lseek(): moves to a particular offset in the file 153 | mmap(): maps a region of the file onto the virtual memory of a user process. 154 | 155 | fsync()/fasync(): synchronizes any memory buffers with the physical device 156 | readdir(): reads the files that are pointed to by a directory file 157 | ioctl(): sets file attributes 158 | check_media_change(): checks to see if a removable media has been removed 159 | revalidate(): verifies that all cached information is valid 160 | 161 | 162 | ---Device Drivers---- 163 | Device drivers provide a uniform interface to access hardware devices: 164 | 165 | Character-based devices are hardware devices accessed sequentially (e.g. serial port). 166 | Block-based devices are devices that are accessed randomly and whose data is read/written in blocks (e.g. hard disk unit). 167 | 168 | Device drivers use the file interface abstraction of VFS for accessing deice drivers in user space : 169 | Each device can be accessed as a file in the file system through a special file, the device file, associated with it. 170 | A new device driver is a new implementing of the hardware-specific code to customize the file interface abstraction 171 | 172 | 173 | -----Device Trees-------- 174 | 175 | In Arm architecture, all device tree source files are now located in either arch/arm/boot/dts or arch/arm64/boot/dts. 176 | .dts files for board-level definitions 177 | .dtsi files for included files 178 | 179 | A tool, the device tree compiler, compiles the source into a binary form: the device tree blob (DTB). 180 | The DTB is loaded by the bootloader and parsed by the kernel at boot time. 181 | Device tree files are not monolithic. They can be split in several files, including each other. 182 | 183 | 184 | 185 | ------------------------Lec 4 : Configuration and Build Process-------------- 186 | 187 | 188 | Building an embedded Linux system is a complex operation. 189 | 190 | Multiple sources shall be configured and compiled. 191 | Root file system shall be updated at each build through a non-trivial task. 192 | In cases of multiple hw and multiple hw configurations, manual iteration is needed. 193 | 194 | Tools, known as build systems, are available to automate such operations. 195 | 196 | Build systems takes care of: 197 | 198 | Building the cross compiler for the selected embedded system CPU 199 | Managing bootloader/kernel/system programs configuration 200 | Managing bootloader/kernel/system program build 201 | Preparation of the root file system and boot device image preparation 202 | 203 | 204 | ----------------Yocto--------------------- 205 | 206 | Yocto has following features : 207 | Provides core recipes and use layers to get support for more packages and more machines. 208 | In Yocto Custom modifications should stay in a separate layer. 209 | Versatile build system: tries to be as flexible as possible and to handle most use cases. 210 | Open community but governed by the Yocto Project Advisory Board. 211 | 212 | 213 | In Yocto the configuration is separated in multiple parts: 214 | 215 | .Distribution configuration (general configuration, toolchain selection, etc.) 216 | 217 | .Machine configuration (defines the hw architecture, hw features, BSP) 218 | 219 | .Image recipe (what system programs should be installed on the target) 220 | 221 | .Local configuration (e.g., how many threads to use when compiling, whether to remove build artifacts, etc.) 222 | 223 | .Allows to build the same image for different machines or using different distributions or different images for one machine 224 | 225 | 226 | Yocto is Collaboration of multiple projects that make up the “Yocto Project” 227 | 228 | Bitbake: build tool. 229 | 230 | OpenEmbedded core: software framework used for creating Linux distributions. 231 | 232 | Poky: a reference distribution of the Yocto Project, containing the OpenEmbedded Build System (BitBake and OpenEmbedded Core) and a set of metadata to start building custom embedded Linux systems . 233 | 234 | Application Development Toolkit: provides application developer a way to write sw running on the custom-built embedded Linux system without the need for knowing build systems. 235 | 236 | ---------Yocto Build System------------------ 237 | 238 | Yocto is composed of several layers : Developer Specific Layer. 239 | Commercial Layer from operating system vendor. 240 | User interface-specific layer. 241 | Board Support Package layer. 242 | Yocto-specific layer metadata (meta-yocto). 243 | OpenEmbedded core metadata (oe-core) 244 | 245 | These layers are containers for building blocks of the system. 246 | These yocto layers do not contain components source code but only meta data i.e. recipes which define how to build outputs 247 | called packages. 248 | 249 | ------------Yocto Build System Configuration Files------------- 250 | 251 | meta/conf/bitbake.conf – default configuration. 252 | 253 | build/conf/bblayers.conf – layers to be used during build process. 254 | 255 | */conf/layers.conf – layer configuration. 256 | 257 | 258 | -----build/conf/local.confl file----------- 259 | 260 | used to override the default configuration and define what to build. 261 | BB_NUMBER_THREADS and PARALLEL_MAKE 262 | MACHINE settings 263 | DISTRO settings 264 | INCOMPATIBLE_LICENSE = “GPLv3” 265 | EXTRA_IMAGE_FEATURES 266 | 267 | Example : MACHINE ?= "raspberrypi3" 268 | PREFERRED_VERSION_linux-raspberrypi = "4.%" 269 | DISTRO_FEATURES:remove = "x11 wayland" 270 | DISTRO_FEATURES:append = " systemd" 271 | VIRTUAL-RUNTIME_init_manager = "systemd" 272 | ENABLE_UART = "1 273 | 274 | --------build/conf/bblayers.conf file--------- 275 | 276 | Used to configure which layers to use. 277 | Add Yocto Project Compatible layers to the BBLAYERS 278 | Default: meta (oe-core), meta-yocto, and meta-yocto-bsp 279 | 280 | Example : 281 | 282 | bblayer.conf (fragment) 283 | 284 | BBLAYERS = " \ 285 | ${BSPDIR}/sources/poky/meta \ 286 | ${BSPDIR}/sources/poky/meta-yocto \ 287 | ${BSPDIR}/sources/poky/meta-yocto-bsp \ 288 | \ 289 | ${BSPDIR}/sources/meta-openembedded/meta-oe \ 290 | ${BSPDIR}/sources/meta-openembedded/meta-multimedia \ 291 | ${BSPDIR}/sources/meta-openembedded/meta-networking \ 292 | ${BSPDIR}/sources/meta-openembedded/meta-python \ 293 | \ 294 | ${BSPDIR}/sources/meta-fsl-arm \ 295 | ${BSPDIR}/sources/meta-fsl-arm-extra \ 296 | ${BSPDIR}/sources/meta-fsl-demos \ 297 | ${BSPDIR}/sources/meta-raspberrypi \ 298 | 299 | 300 | The above Recipes inherit the system configuration and adjust it to describe how to build and package the software. 301 | Can be extended and enhanced via layers 302 | Compatible with OpenEmbedded 303 | 304 | Example : 305 | 306 | rpi-basic-image.bb (fragment) 307 | 308 | # Base this image on rpi-hwup-image 309 | include rpi-hwup-image.bb 310 | 311 | SPLASH = "psplash-raspberrypi" 312 | 313 | IMAGE_FEATURES += "ssh-server-dropbear splash" 314 | 315 | ---------------meta-yocto/conf/distro/poky.conf – distribution policy----------- 316 | 317 | ----------------meta-yocto-bsp/conf/machine/board-name.conf ----------- 318 | Defines configuration of the board support pacakge. ( Here we add our developed kernel Module) 319 | Define board specific kernel configuration 320 | Processor/SOC Tuning files. 321 | Machine configuration refers to kernel sources. 322 | Compatible with OpenEmbedded. 323 | 324 | Example : 325 | raspberrypi3.conf (fragment) 326 | 327 | #@TYPE: Machine 328 | #@NAME: RaspberryPi 3 Development Board 329 | #@DESCRIPTION: Machine configuration for the RaspberryPi 3 330 | 331 | MACHINEOVERRIDES = "raspberrypi2:${MACHINE}" 332 | 333 | MACHINE_EXTRA_RRECOMMENDS += " kernel-modules wl18xx-conf 334 | uim-sysfs bt-firmware gator" 335 | 336 | include conf/machine/raspberrypi2.conf 337 | 338 | SERIAL_CONSOLE = "115200 ttyS0" 339 | 340 | KERNEL_MODULE_AUTOLOAD += "g_serial hello" 341 | 342 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-module-gator" 343 | 344 | 345 | ----------meta/conf/machine/include/tune-CPU-name.inc – CPU-specific configuration----------- 346 | 347 | 348 | 349 | ------------Build System Workflow Distribution Policy------------------- 350 | 351 | Defines distribution policies that affect the way individual recipes are built 352 | May set alternative preferred versions of recipes 353 | May enable/disable features 354 | May configure specific package rules 355 | May adjust image deployment settings 356 | Enabled via the DISTRO setting 357 | 358 | Four predefined settings: 359 | poky-bleeding: enables bleeding edge packages 360 | poky: core distribution definition, defines the base 361 | poky-lsb: enable items required for LSB support 362 | poky-tiny: construct a smaller than normal system 363 | 364 | 365 | ----------Build System Workflow : Source Fetching-------------- 366 | 367 | Recipes tell the location of all sources, patches, and files. 368 | These may exist on the internet or be local (See SRC_URI in the *.bb files). 369 | Bitbake can get the sources from git, svn, bzr, or tarballs. 370 | Versions of packages can be fixed or updated automatically (Add SRCREV_pn-PN = “${AUTOREV}” to local.conf). 371 | 372 | ----------Build System Workflow : Patching-------------- 373 | 374 | Once sources are obtained, they are extracted. 375 | Patches are applied in the order they appear in SRC_URI. 376 | In this stage, application-specific patches are applied. 377 | Custom modifications to the open-source code that are mandated by the specific application for which the embedded system is intended for. 378 | 379 | --------Build System Workflow : Output Analysis------------ 380 | Support the popular formats: RPM, Debian, and ipk. 381 | Set preferred format using PACKAGE_CLASSES in local.conf 382 | Package files can be manually defined to override automatic settings 383 | 384 | 385 | **********Setting Up Yocto In Development PC For Raspberry Pi3************* 386 | 387 | We will need to follow same steps if we had other board or any other SoC processor, Following commands download the packages,software,utilties required by Yocto. In the end we clone 388 | the Yocto poky repository git://git.yoctoproject.org/poky, open-embedded layer repo git://git.openembedded.org/meta-openembedded , meta-raspberrypi layer from git://git.yoctoproject.org/meta-raspberrypi , for other board we will clone other relevant repo. 389 | 390 | 391 | sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib build-essential 392 | 393 | Where "gawk" is a programming language to manipulate or extract data, generate reports, match patterns, perform 394 | calculations, and more, with great flexibility. https://www.redhat.com/sysadmin/beginners-guide-gawk 395 | 396 | "wget" is a program for retrieves content from web servers. 397 | "diffstat" is a program that is useful for reviewing large, complex patch files. 398 | "texinfo" generating documentation in both on-line and printed form with a single source file. 399 | "gcc-multilib" useful for cross-compiling a program to run on a different processor architecture. 400 | "build-essential" form of meta-packages that are essential to compile software. They contain the GNU/g++ compiler 401 | collection, GNU debugger, and a few more libraries and tools that are needed for compiling a program. 402 | https://packages.ubuntu.com/focal/build-essential 403 | 404 | sudo apt-get install chrpath socat libsdl1.2-dev xterm ncurses-dev lzop 405 | 406 | Where "chrpath" Allows you to modify the dynamic library load path (rpath and runpath) of compiled programs and libraries. 407 | "socat" Allows for bidirectional data transfers from one location to another. https://www.redhat.com/sysadmin/getting-started-socat 408 | "libsdl1.2" A cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. 409 | https://github.com/libsdl-org/SDL 410 | 411 | "xterm" Standard terminal emulator of the X Window System, providing a command-line interface within a window. 412 | "ncurses-dev" A programming library providing an application programming interface (API) that allows the programmer to write text-based user interfaces (TUI) in a terminal- 413 | independent manner. 414 | "lzop" A file compressor which is very similar to gzip. https://www.lzop.org/ 415 | 416 | sudo apt-get install minicom u-boot-tools curl 417 | 418 | Where "minicom" A serial communication program that connects to devices through a GNU/Linux PC's serial ports. https://wiki.emacinc.com/wiki/Getting_Started_With_Minicom 419 | "u-boot-tools" Includes programs for generating and listing U-Boot(Bootloader) images in various formats: - mkimage - dumpimage - mksunxiboot - mkenvimage 420 | https://packages.debian.org/sid/u-boot-tools 421 | 422 | "curl" Library and command-line tool for transferring data using various network protocols. https://curl.se/ 423 | 424 | 425 | mkdir ~/bin 426 | Install the repo Utility : curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 427 | 428 | Where "repo" Utility is used To simplify fetching sources and setting up the Yocto build environment we have decided to use the Google repo 248 tool, which allows fetching 429 | sources from multiple location in a single command based on manifest files (xml). https://hub.mender.io/t/google-repo/58 430 | 431 | 432 | 433 | ***************Setting Up Yocto*************** 434 | 435 | The following steps information is also available here : https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html 436 | https://docs.yoctoproject.org/brief-yoctoprojectqs/ 437 | 438 | i). git clone git://git.yoctoproject.org/poky 439 | 440 | Where "poky" is a reference distribution provided by Yocto, it can be customized through recipes according to a certain application and target hardware. 441 | 442 | ii). git clone git://git.openembedded.org/meta-openembedded 443 | 444 | Where "OpenEmbedded" is a build framework of recipes and packages. OpenEmbedded supports many hardware architectures with cross-compilation infrastructure. 445 | 446 | iii). git clone git://git.yoctoproject.org/meta-raspberrypi 447 | 448 | Where meta-raspberrypi is a layer providing recipe for generating embedded linux targetting raspberry pi SoC and board. 449 | 450 | *********To establish Ethernet Connection With Our Raspberry Pi Board ******** 451 | 452 | Edit the poky/meta/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces file and add following lines 453 | 454 | iface eth0 inet static 455 | address 192.168.1.2 456 | netmask 255.255.255.0 457 | gateway 192.168.1.1 458 | network 192.168.1.0 459 | 460 | 461 | iv). source poky/oe-init-build-env rpi-build 462 | Configured the Yocto environment to build the poky (embedded linux ) source for Raspberry Pi3, Where we are already in Yocto directory containing all the layers. 463 | 464 | The mentioned poky source was cloned earlier from git clone git://git.yoctoproject.org/poky 465 | The Yocto Project has extensive documentation about OE including a reference 466 | manual which can be found at: 467 | https://docs.yoctoproject.org 468 | 469 | For more information about OpenEmbedded see the website: 470 | https://www.openembedded.org/ 471 | 472 | 473 | ### Shell environment set up for builds. ### 474 | 475 | You can now run 'bitbake ' 476 | 477 | Common targets are: 478 | core-image-minimal 479 | core-image-full-cmdline 480 | core-image-sato 481 | core-image-weston 482 | meta-toolchain 483 | meta-ide-support 484 | 485 | You can also run generated qemu images with a command like 'runqemu qemux86-64'. 486 | 487 | Other commonly useful commands are: 488 | - 'devtool' and 'recipetool' handle common recipe tasks 489 | - 'bitbake-layers' handles common layer tasks 490 | - 'oe-pkgdata-util' handles common target package tasks 491 | 492 | v) . Edit the local.conf file accordingly 493 | 494 | Example : 495 | MACHINE ?= "raspberrypi3" 496 | PREFERRED_VERSION_linux-raspberrypi = "4.%" 497 | DISTRO_FEATURES:append = " systemd x11 wayland" 498 | VIRTUAL-RUNTIME_init_manager = "systemd" 499 | ENABLE_UART = "1 500 | 501 | vi). Add the relevant layers in bblayers.conf file 502 | 503 | Example : 504 | POKY_BBLAYERS_CONF_VERSION = "2" 505 | 506 | BBPATH = "${TOPDIR}" 507 | BBFILES ?= "" 508 | 509 | BBLAYERS ?= " \ 510 | /opt/Yocto/poky/meta \ 511 | /opt/Yocto/poky/meta-poky \ 512 | /opt/Yocto/poky/meta-yocto-bsp \ 513 | /opt/Yocto/meta-openembedded/meta-oe \ 514 | /opt/Yocto/meta-openembedded/meta-python \ 515 | /opt/Yocto/meta-openembedded/meta-multimedia \ 516 | /opt/Yocto/meta-raspberrypi \ 517 | : 518 | 519 | Where meta-raspberrypi : layer is used to build embedded linux image for raspberry pi board . https://meta-raspberrypi.readthedocs.io/en/latest/readme.html 520 | 521 | vii). Building the image for raspberry pi 3 522 | bibake core-image-sato 523 | 524 | 525 | Encountered Issues During Yocto Based Linux Image Build For Raspberry Pi3 : https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue 526 | https://askubuntu.com/questions/599808/cannot-set-lc-ctype-to-default-locale-no-such-file-or-directory 527 | https://github.com/crops/poky-container/issues/67 528 | https://docs.yoctoproject.org/next/migration-guides/migration-3.4.html 529 | Yocto is migrated : https://low-level.wiki/yocto/honister-upgrade.html 530 | After stopping bitbake in the middle , it won´t work to resolve it do : rm bitbake.lock 531 | 532 | 533 | ---------------------------------Lecture 5 : Linux Kernel Modules------------------------------------------- 534 | 535 | Linux provides an abstraction to make communication with I/O easy. 536 | Software developer does not need to know every detail of the physical device. 537 | Portability can be increased by using the same abstraction for different I/O devices. 538 | 539 | Linux recognizes three classes of devices: 540 | 541 | Character devices, which are devices that can be accessed as stream of words (e.g., 8-/16-/32-/… bits) as in a file; reading word n requires reading all the preceding words from 0 to n-1. 542 | 543 | Block devices, which are devices that can be accessed only as multiples of one block, where a block is 512 bytes of data or more. Typically, block devices host file systems. 544 | 545 | Network interfaces, which are in charge of sending and receiving data packets through the network subsystem of the kernel. 546 | 547 | ----------Virtual File System Abstraction--------------- 548 | 549 | Character/block devices are accessed as files stored in the file system, as each device is associated with a device file. 550 | Typical usage: 551 | 552 | Open the device file. 553 | Read/Write data from/to device file. 554 | Close the device file. 555 | Linux forwards the open/read/write/close operations to the I/O device associated to the device file. 556 | The operations for each I/O device are implemented by a custom piece of software in the Linux kernel: the device driver. 557 | 558 | The VFS functions available to a user application are declared in the file fs.h include/linux/fs.h , In user level application we will need to include this file. 559 | 560 | 561 | include/linux/fs.h : 562 | 563 | struct file_operations { 564 | struct module *owner; 565 | loff_t (*llseek) (struct file *, loff_t, int); 566 | ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 567 | ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 568 | ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); 569 | ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); 570 | int (*iterate) (struct file *, struct dir_context *); 571 | int (*iterate_shared) (struct file *, struct dir_context *); 572 | unsigned int (*poll) (struct file *, struct poll_table_struct *); 573 | long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 574 | long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 575 | int (*mmap) (struct file *, struct vm_area_struct *); 576 | int (*open) (struct inode *, struct file *); 577 | int (*flush) (struct file *, fl_owner_t id); 578 | int (*release) (struct inode *, struct file *); 579 | int (*fsync) (struct file *, loff_t, loff_t, int datasync); 580 | int (*aio_fsync) (struct kiocb *, int datasync); 581 | int (*fasync) (int, struct file *, int); 582 | int (*lock) (struct file *, int, struct file_lock *); 583 | ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 584 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 585 | int (*check_flags)(int); 586 | int (*flock) (struct file *, int, struct file_lock *); 587 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 588 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 589 | int (*setlease)(struct file *, long, struct file_lock **, void **); 590 | long (*fallocate)(struct file *file, int mode, loff_t offset, 591 | loff_t len); 592 | void (*show_fdinfo)(struct seq_file *m, struct file *f); 593 | #ifndef CONFIG_MMU 594 | unsigned (*mmap_capabilities)(struct file *); 595 | #endif 596 | ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, 597 | loff_t, size_t, unsigned int); 598 | int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, 599 | u64); 600 | ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, 601 | u64); 602 | }; 603 | 604 | 605 | 606 | For character devices the most commonly used VFS functions are the following: 607 | 608 | ssize_t (*read) (struct file *, char *__user, size_t, loff_t *): it reads data from a file. 609 | 610 | ssize_t (*write) (struct file *, const char *__user, size_t, loff_t *): it writes data to a file. 611 | 612 | int (*ioctl) (struct *inode, struct file *, unsigned int, unsigned long): it performs custom operations to the file. 613 | 614 | int (*open) ( struct *inode, struct file * ): it prepares a file for use. 615 | 616 | int (*release) ( struct inode *, struct file * ): it indicates the file is no longer in use. 617 | 618 | 619 | 620 | ---------------The Device File Concept-------------- 621 | 622 | The device file is the intermediator through which a user application can exchange data with a device driver. 623 | 624 | The device file does not contain any data, while its descriptor contains the relevant information to identify the corresponding driver: 625 | 626 | The device file type, which could be either c = character device, b = block device, or p = named pipe (inter-process communication mechanism) 627 | 628 | The major number, which is an integer number that identifies univocally a device driver in the Linux kernel 629 | 630 | The minor number, which is used to discriminate among multiple instances of I/O devices handled by the same device driver 631 | 632 | --------------The Linux Kernel Modules--------------- 633 | 634 | A device driver provides an I/O-device specific implementation of the Virtual File System abstraction, and it is located in the kernel space. 635 | 636 | A device driver can be: Linked with the Linux Kernel and executed at system bootstrap. 637 | 638 | Kernel module, which is loaded at runtime through suitable system programs, after the Linux Kernel is booted. 639 | 640 | 641 | We use the following system programs for performing certian operations of : 642 | mknod for Creating a Device File. 643 | insmod for Adding Kernel Module In Linux Kernel. 644 | rmmod for Removing Kernel Module From Linux Kernel. 645 | lsmod for Listing Kernel Modules. 646 | 647 | Functions provided by a kernel module: 648 | 649 | Initialization function, called upon the execution of the insmod system program, takes care of making Linux aware that a new device driver is available. 650 | 651 | Clean-up function, called upon the execution of rmmod, to remove the device driver from the Linux Kernel. 652 | 653 | Custom-specific implementations of the VFS abstraction 654 | 655 | 656 | ----Linux Kernel Module Initialization Function-------- 657 | 658 | 659 | static dev_t dummy_dev; // Data structure containing the major number and the first minor number for the module. It identifies 660 | // univocally the module in the kernel. It shall be used when creating the device file associated with 661 | // the module. 662 | 663 | 664 | struct cdev dummy_cdev; // Data structure used to describe the properties of a character device 665 | 666 | static char buffer[64]; // Buffer used for displaying output messages on the Linux console 667 | 668 | 669 | struct file_operations dummy_fops = { // Data structure used to associate the VFS functions to their module-specific implementations. 670 | // In this example, the read() VFS function is implemented by the dummy_read() function. 671 | 672 | .owner = THIS_MODULE, 673 | .read = dummy_read, // read() VFS function is implemented by dummy_read() function. 674 | }; // read() VFS function is used at User level application. 675 | 676 | static int __init dummy_module_init(void) 677 | { 678 | printk(KERN_INFO "Loading dummy_module\n"); // Kernel equivalent of the printf(). 679 | 680 | alloc_chrdev_region(&dummy_dev, 0, 1, "dummy_dev"); // The module initialization function. It is executed as soon as the module enters the Linux kernel and // takes care of making the Kernel aware that the new module is available. 681 | // Where : dev is the dynamically-selected major number of the module; 682 | // 0 here is first minor number for the module; 683 | // 1 here is count, informing kernel to reserve above minor number for only this module. 684 | // dummy_dev is the name of kernel module. 685 | 686 | printk(KERN_INFO "%s\n", format_dev_t(buffer, dummy_dev)); // prints on the Linux console the major number and the minor number associated with the just-registered character device. 687 | 688 | cdev_init(&dummy_cdev, &dummy_fops); // Initializing the character device data structure 689 | // where: cdev is the structure to initialize 690 | dummy_fops is the file_operations for the device. 691 | 692 | dummy_cdev.owner = THIS_MODULE; // Setting the owner of the module using the THIS_MODULE macro. 693 | 694 | cdev_add(&dummy_cdev, dummy_dev, 1); // Adding the character device to the Linux Kernel. 695 | // Where dummy_cdev is a pointer to character device structure which is already initialized 696 | // dummy_dev is major number of the device. 697 | // 1 is showing that only one i.e. this module is assocaited with this minor number. 698 | 699 | return 0; // Indicating the function terminated correctly. A non zero value indicates an error occurred. 700 | 701 | 702 | } 703 | 704 | 705 | 706 | --------Linux Kernel Module : The Clean Up Function------------ 707 | 708 | static void __exit dummy_module_cleanup(void) 709 | { 710 | printk(KERN_INFO "Cleaning-up dummy_dev.\n"); 711 | 712 | cdev_del(&dummy_cdev); // Removing the character device from the Linux kernel. 713 | unregister_chrdev_region(dummy_dev, 1); // Freeing the range of major/minor numbers previously registered. 714 | } 715 | 716 | 717 | 718 | -------Linux Kernel Module : Implementation of Read VFS Function In Kernel Module--------- 719 | 720 | ssize_t dummy_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) // Where filp is the pointer to the data structure describing the opened file; 721 | // buf is the bufer to fill with the data read from the file; 722 | // count is the size of the buffer // f_pos is the current reading position in the file. 723 | 724 | { 725 | printk(KERN_INFO "Dummy read (count=%d, offser=%d)\n", (int)count, (int)*f_pos ); // printing a message to show that the read functions has been executed. 726 | 727 | return 1; // Returning the number of byte read from the file. 728 | // Returning 0 will block the caller application, which will wait until at least 729 | // one byte is returned. 730 | 731 | } 732 | 733 | 734 | -----------------------------------------------Lecture 6 : Communication Between Kernel and User Space-------------------------------------------------- 735 | 736 | When designing an application that communicates with custom hardware, two levels shall be considered: 737 | 738 | User level, where the behavior of the application is defined using virtual file system (VFS) calls to communicate with the hardware. 739 | Module level, where the behavior of each VFS function is implemented based upon the functionalities the hardware implements. 740 | 741 | Different hardware may require different implementations of the same VFS function. 742 | At the user-level, the programmer shall be aware of the functionalities the hardware provides, and shall use the VFS calls accordingly. 743 | 744 | -------------The CPU/Device Interface----------- 745 | 746 | Memory mapped: each register is associated to an address. 747 | Through GPIO, where each register is associated to a set of GPIOs. 748 | 749 | The module-level implementation will be affected by the adopted CPU/Device Interface. 750 | The user-level implementation will abstract these details 751 | 752 | ------------The Module Level---------------- 753 | 754 | At this level, the different functionalities of the device shall be enumerated, and an association shall be established with the VFS functionalities. 755 | In our example, the device L supports the following functionalities: 756 | 757 | Reset: L is disabled, and the blink rate register is set to zero. 758 | Here Both the blink rate and enable registers are set to zero. This operation is done once, when starting using the device. 759 | 760 | Program: The blink rate register is set to a user-defined value. 761 | The blink rate register is set to a user defined value. This operation can be done multiple times, during the device usage 762 | 763 | Enable: L is enabled. 764 | The enable register is set to one. This operation can be done multiple times, during the device usage 765 | 766 | Disable: L is disabled. 767 | The enable register is set to zero. This operation can be done multiple times, during the device usage 768 | 769 | Poll rate: L returns the content of the blink rate register. 770 | The blink rate register content is provided to the user level. This operation can be done multiple times, during the device usage. 771 | 772 | 773 | Poll state: L returns the content of the enable register. 774 | The enable register content is provided to the user level. This operation can be done multiple times, during the device usage 775 | 776 | Power-off: L terminates its operation and starts waiting for the next reset. 777 | The enable register content is set to zero. This operation is done once, after the last usage of the device. 778 | 779 | 780 | The virtual file system functions that are typically used are: 781 | 782 | open, which initiates the operations with the device 783 | 784 | release, which terminates the operation with the device 785 | 786 | write, which sends data coming from the user space to the device 787 | 788 | read, which reads from the device and send them to the user space 789 | 790 | ioctl, which performs custom operations 791 | 792 | 793 | Relationship Between VFS Functions and Module Level Functions is : 794 | 795 | Device Function VFS Function 796 | 797 | Reset <----------> Open Used for establishing connection with the device. 798 | 799 | Power-off <----------> release for terminating the connection with device. 800 | 801 | Poll state <----------> read Used to send data from device to application, Enable register is selected as target for read operation using ioctl() function. 802 | 803 | Poll rate <----------> read Used to send data from device to application, Blink rate register is selected as target for read operation using ioctl() function. 804 | 805 | Disable <----------> write Used to send data to the device and Enable register is selected as target for read operation using ioctl() function. 806 | 807 | Enable <----------> write Used to send data to the device and Enable register is selected as target for write operation using ioctl() function. 808 | 809 | Program <----------> write Used to send data to the device and Blink Rate register is selected as target for write operation using ioctl() function. 810 | 811 | 812 | ----------Structure for definining File Operations In Kernel Module----------- 813 | 814 | static dev_t L_dev; 815 | 816 | struct cdev L_cdev; 817 | 818 | struct file_operations L_fops = { 819 | 820 | .owner = THIS_MODULE, 821 | .open = L_open_close, 822 | .release = L_open_close, 823 | .write = L_write, 824 | .read = L_read, 825 | .ioctl = L_ioctl, 826 | 827 | }; 828 | 829 | 830 | -------The Module Level: ioctl() Implementation----------- 831 | 832 | static ssize_t L_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg) 833 | { 834 | switch( cmd ) 835 | { 836 | case BLINK_RATE: // global symbol previously defined 837 | selected_register = BLINK_RATE; // global variable previously defined 838 | break; 839 | case ENABLE: // global symbol previously defined 840 | selected_register = ENABLE; 841 | break; 842 | } 843 | 844 | return 0; 845 | } 846 | ----------------The Module Level: open()/release() Implementation---------- 847 | 848 | It disables the device and sets the blink rate to zero. The same operations are valid for open() and release() functions. 849 | 850 | static int L_open_close(struct inode *inode, struct file *file) 851 | { 852 | selected_register = ENABLE; // it selects the target for read/write operation. 853 | WRITE_DATA_TO_THE_HW( 0 ); // it sends 0 to the enable register. 854 | // it abstracts the low-level CPU/device L interface. 855 | 856 | selected_register = BLINK_RATE; // it selects the target for read/write operation. 857 | WRITE_DATA_TO_THE_HW( 0 ); // it sends 0 to the blink register. 858 | 859 | return 0; 860 | } 861 | ----------------------The Module Level: read() Implementation-------------------- 862 | 863 | It reads from the ioctl() selected register and pass the data to the user. 864 | 865 | static ssize_t L_read(struct file *filp, char *buffer, size_t length, loff_t * offset) 866 | { 867 | int data; 868 | 869 | READ_DATA_FROM_THE_HW( &data ); // it abstracts the low-level CPU/device L interface. 870 | copy_to_user(buffer, &data, 4 ); // see next slide 871 | 872 | return 4; // it returns the number of bytes read. 873 | } 874 | 875 | 876 | ------------------Passing Data to/from the Kernel---------------- 877 | 878 | Kernel and application are running in two different memory spaces. 879 | Specific functions are needed to move data between them. 880 | 881 | copy_to_user(void __user *to, const void *from, unsigned long n); //Move data from kernel space to user space. 882 | 883 | 884 | --------------The Module Level: write() Implementation--------------- 885 | 886 | static ssize_t L_write(struct file *filp, char *buffer, size_t length, loff_t * offset) // writes to ioctl() selected register 887 | { 888 | WRITE_DATA_TO_THE_HW( buffer ); 889 | 890 | return 1; 891 | } 892 | 893 | 894 | -----------------The Module Level: Communication with the Device-------------------- 895 | 896 | Hidden in implementation of functions : READ_DATA_FROM_THE_HW() , WRITE_DATA_TO_HW() 897 | 898 | Implementation depends on the CPU/Device L connection 899 | 900 | Memory mapped example: 901 | Blink rate register: 0xf0080000 902 | Enable register: 0xf0080004 903 | 904 | GPIO example: 905 | Blink rate register: GPIO(0-31) (MSB first) 906 | Enable register: GPIO(32) 907 | 908 | 909 | ----------------------Memory Mapped I/0 Implementation Of Kernel Module Device Read, Write Funtions--------------------------- 910 | 911 | 912 | Memory areas can be used if: 913 | Available 914 | Reserved 915 | 916 | Following Functions required for Memory Mapped I/O based Implementation of read and write data to/from device at kernel Module level 917 | 918 | int check_region( unsigned long first, unsigned long n) //It checks whether the desired addresses are available 919 | int request_region( unsigned long first, unsigned long n, const char *name) // It reserves the desired addresses 920 | int release_region( unsigned long first, unsigned long n) // It sets the desired addresses free 921 | 922 | 923 | ----------Memory Mapped I/O Module Initialization Function------------ 924 | 925 | static int __init L_module_init(void) 926 | { 927 | int res; 928 | alloc_chrdev_region(&L_dev, 0, 1, ”L_dev"); 929 | printk(KERN_INFO "%s\n", format_dev_t(buffer, L_dev)); 930 | cdev_init(&L_cdev, &L_fops); 931 | L_cdev.owner = THIS_MODULE; 932 | cdev_add(&L_cdev, L_dev, 1); 933 | 934 | r = check_region( ioremap(0xf0080000, 4 ), 8 ); // ioremap() Translates the physical address of the device (as defined by the memory map) into the corresponding virtual address. 935 | if(r) { 936 | printk( KERN_ALERT ”Unable to reserve I/O memory\n"); 937 | return –EINVAL; 938 | } 939 | request_region(ioremap(0xf0080000, 4), 8, ”DevL"); 940 | return 0; 941 | } 942 | 943 | 944 | ---------Mmeory Mapped I/O Clean Up Function------------- 945 | 946 | static void __exit L_module_cleanup(void) 947 | { 948 | cdev_del(&L_cdev); 949 | unregister_chrdev_region(L_dev, 1); 950 | 951 | release_region(ioremap(0xf0080000, 4 ), 8); 952 | } 953 | 954 | ---------Mmeory Mapped I/O Read Function------------- 955 | 956 | int READ_DATA_FROM_THE_HW( int *data ) 957 | { 958 | int tmp; 959 | 960 | switch( selected_register ) 961 | { 962 | case BLINK_RATE: 963 | tmp = inl( ioremap(0xf0080000, 4) ); // inl(): it reads 32-bit words, 964 | // inw(): it reads 16-bit words. 965 | // inb(): it reads 8-bit words. 966 | break; 967 | case ENABLE: 968 | tmp = inl( ioremap(0xf0080000, 4)+4 ); 969 | break; 970 | } 971 | *data = tmp; 972 | 973 | return 4; 974 | } 975 | 976 | 977 | ---------Mmeory Mapped I/O Write Function------------- 978 | 979 | int WRITE_DATA_TO_THE_HW( char *data ) 980 | { 981 | switch( selected_register ) 982 | { 983 | case BLINK_RATE: 984 | outl( (int)*data, ioremap(0xf0080000, 4) ); // outl(): it write 32-bit words, 985 | // outw(): it write 16-bit words. 986 | // outb(): it writes 8-bit words. 987 | break; 988 | case ENABLE: 989 | outl( (int)*data, ioremap(0xf0080000, 4)+4 ); 990 | break; 991 | } 992 | 993 | return 4; 994 | } 995 | 996 | 997 | ----------------------GPIO I/0 Implementation Of Kernel Module Device Read, Write Funtions--------------------------- 998 | 999 | Prior to GPIO use, it shall be reserved for the module. 1000 | 1001 | int gpio_request(unsigned gpio, const char *label) //It checks whether the desired GPIO is available, and if yes, reserves it. 1002 | void gpio_free(unsigned gpio) // It sets the desired GPIO free. 1003 | 1004 | ----------GPIO I/O Module Initialization Function------------ 1005 | 1006 | static int __init L_module_init(void) 1007 | { 1008 | int i, r; 1009 | alloc_chrdev_region(&L_dev, 0, 1, ”L_dev"); 1010 | printk(KERN_INFO "%s\n", format_dev_t(buffer, L_dev)); 1011 | cdev_init(&L_cdev, &L_fops); 1012 | L_cdev.owner = THIS_MODULE; 1013 | cdev_add(&L_cdev, L_dev, 1); 1014 | 1015 | for( i = 0; i < 32; i++ ) { 1016 | 1017 | r = gpio_request( i ); // GPIO shall be checked and reserved one by one. 1018 | if (r) { 1019 | printk( KERN_ALERT ”Unable to reserve GPIO\n"); 1020 | return –EINVAL; 1021 | } 1022 | } 1023 | return 0; 1024 | } 1025 | 1026 | 1027 | ----------GPIO I/O Module Clean Up Function------------ 1028 | 1029 | static void __exit L_module_cleanup(void) 1030 | { 1031 | int i; 1032 | 1033 | cdev_del(&L_cdev); 1034 | unregister_chrdev_region(L_dev, 1); 1035 | 1036 | for( i = 0; i < 32; i++ ) 1037 | gpio_free( i ); // GPIO shall be freed one by one. 1038 | 1039 | } 1040 | 1041 | ----------GPIO I/O Module Read() Function------------ 1042 | 1043 | 1044 | 1045 | int READ_DATA_FROM_THE_HW( int *data ) 1046 | { 1047 | int tmp = 0, i; 1048 | 1049 | switch( selected_register ) 1050 | { 1051 | case BLINK_RATE: 1052 | for( i = 0; i < 31; i++ ) { 1053 | gpio_direction_input( i ); // GPIO direction shall be set to input. 1054 | 1055 | tmp = (tmp << 1) | gpio_get_value( i ); // GPIO value shall be read one by one. The resulting word is built MSB first. 1056 | 1057 | } 1058 | break; 1059 | case ENABLE: 1060 | gpio_direction_input( 32 ); 1061 | tmp |= gpio_get_value( 32 ) 1062 | break; 1063 | } 1064 | *data = tmp; 1065 | 1066 | return 4; 1067 | } 1068 | 1069 | ----------GPIO I/O Module Write() Function------------ 1070 | 1071 | int WRITE_DATA_TO_THE_HW( int data ) 1072 | { 1073 | int i; 1074 | switch( selected_register ) { 1075 | case BLINK_RATE: 1076 | for( i = 0; i < 31; i++ ) { 1077 | gpio_direction_output( i, 0 ); // GPIO direction shall be set to output, with default value on the GPIO set to 0. 1078 | 1079 | gpio_set_value( i, (data & (1 << i)) ); // GPIO value shall be written one by one. 1080 | 1081 | } 1082 | break; 1083 | case ENABLE: 1084 | gpio_direction_output( 32, 0 ); 1085 | gpio_set_value( 32, data & 0x00000001 ); 1086 | break; 1087 | } 1088 | 1089 | return 4; 1090 | } 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | --------------------------------------------------------------------------------