This commit is contained in:
chenyf 2024-01-30 21:39:31 +08:00
commit b097d854bd
75 changed files with 7999 additions and 0 deletions

1
1-chr-dev/.drv.ko.cmd Normal file
View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.ko := arm-none-linux-gnueabihf-ld -r -EL --build-id -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds -o /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.ko /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.o /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o; true

1
1-chr-dev/.drv.mod.cmd Normal file
View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod := { echo /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.o; echo; } > /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod

537
1-chr-dev/.drv.mod.o.cmd Normal file
View File

@ -0,0 +1,537 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o := arm-none-linux-gnueabihf-gcc -Wp,-MD,/home/chenyf/desktop/stm32mp157/driver/chr-dev/.drv.mod.o.d -nostdinc -isystem /home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -fno-inline-functions-called-once -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME='"drv.mod"' -DKBUILD_MODNAME='"drv"' -c -o /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.c
source_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o := /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.c
deps_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o := \
$(wildcard include/config/module/unload.h) \
$(wildcard include/config/retpoline.h) \
include/linux/kconfig.h \
$(wildcard include/config/cpu/big/endian.h) \
$(wildcard include/config/booger.h) \
$(wildcard include/config/foo.h) \
include/linux/compiler_types.h \
$(wildcard include/config/have/arch/compiler/h.h) \
$(wildcard include/config/enable/must/check.h) \
$(wildcard include/config/optimize/inlining.h) \
$(wildcard include/config/cc/has/asm/inline.h) \
include/linux/compiler_attributes.h \
include/linux/compiler-gcc.h \
$(wildcard include/config/arch/use/builtin/bswap.h) \
include/linux/build-salt.h \
$(wildcard include/config/build/salt.h) \
include/linux/elfnote.h \
include/linux/elf.h \
arch/arm/include/asm/elf.h \
$(wildcard include/config/mmu.h) \
$(wildcard include/config/vdso.h) \
arch/arm/include/asm/auxvec.h \
arch/arm/include/uapi/asm/auxvec.h \
arch/arm/include/asm/hwcap.h \
arch/arm/include/uapi/asm/hwcap.h \
arch/arm/include/asm/vdso_datapage.h \
arch/arm/include/asm/page.h \
$(wildcard include/config/cpu/copy/v4wt.h) \
$(wildcard include/config/cpu/copy/v4wb.h) \
$(wildcard include/config/cpu/copy/feroceon.h) \
$(wildcard include/config/cpu/copy/fa.h) \
$(wildcard include/config/cpu/sa1100.h) \
$(wildcard include/config/cpu/xscale.h) \
$(wildcard include/config/cpu/xsc3.h) \
$(wildcard include/config/cpu/copy/v6.h) \
$(wildcard include/config/kuser/helpers.h) \
$(wildcard include/config/arm/lpae.h) \
$(wildcard include/config/have/arch/pfn/valid.h) \
arch/arm/include/asm/glue.h \
arch/arm/include/asm/pgtable-2level-types.h \
arch/arm/include/uapi/asm/types.h \
include/asm-generic/int-ll64.h \
include/uapi/asm-generic/int-ll64.h \
arch/arm/include/generated/uapi/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h \
$(wildcard include/config/64bit.h) \
include/uapi/asm-generic/bitsperlong.h \
arch/arm/include/asm/memory.h \
$(wildcard include/config/need/mach/memory/h.h) \
$(wildcard include/config/page/offset.h) \
$(wildcard include/config/thumb2/kernel.h) \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/smp.h) \
$(wildcard include/config/dram/base.h) \
$(wildcard include/config/dram/size.h) \
$(wildcard include/config/xip/kernel.h) \
$(wildcard include/config/have/tcm.h) \
$(wildcard include/config/arm/patch/phys/virt.h) \
$(wildcard include/config/phys/offset.h) \
$(wildcard include/config/xip/phys/addr.h) \
$(wildcard include/config/debug/virtual.h) \
include/linux/compiler.h \
$(wildcard include/config/trace/branch/profiling.h) \
$(wildcard include/config/profile/all/branches.h) \
$(wildcard include/config/stack/validation.h) \
$(wildcard include/config/kasan.h) \
include/linux/compiler_types.h \
include/uapi/linux/types.h \
include/uapi/linux/posix_types.h \
include/linux/stddef.h \
include/uapi/linux/stddef.h \
arch/arm/include/uapi/asm/posix_types.h \
include/uapi/asm-generic/posix_types.h \
arch/arm/include/asm/barrier.h \
$(wildcard include/config/cpu/32v6k.h) \
$(wildcard include/config/cpu/fa526.h) \
$(wildcard include/config/arm/heavy/mb.h) \
$(wildcard include/config/arm/dma/mem/bufferable.h) \
$(wildcard include/config/cpu/spectre.h) \
include/asm-generic/barrier.h \
include/linux/kasan-checks.h \
include/linux/types.h \
$(wildcard include/config/have/uid16.h) \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/arch/dma/addr/t/64bit.h) \
$(wildcard include/config/phys/addr/t/64bit.h) \
include/linux/const.h \
include/uapi/linux/const.h \
include/linux/sizes.h \
include/asm-generic/memory_model.h \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/sparsemem/vmemmap.h) \
$(wildcard include/config/sparsemem.h) \
include/linux/pfn.h \
include/asm-generic/getorder.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/bitops.h \
include/linux/bits.h \
arch/arm/include/asm/bitops.h \
include/linux/irqflags.h \
$(wildcard include/config/prove/locking.h) \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/irqsoff/tracer.h) \
$(wildcard include/config/preempt/tracer.h) \
$(wildcard include/config/trace/irqflags/support.h) \
include/linux/typecheck.h \
arch/arm/include/asm/irqflags.h \
$(wildcard include/config/cpu/v7m.h) \
arch/arm/include/asm/ptrace.h \
$(wildcard include/config/arm/thumb.h) \
arch/arm/include/uapi/asm/ptrace.h \
$(wildcard include/config/cpu/endian/be8.h) \
include/asm-generic/irqflags.h \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/builtin-__fls.h \
include/asm-generic/bitops/builtin-__ffs.h \
include/asm-generic/bitops/builtin-fls.h \
include/asm-generic/bitops/builtin-ffs.h \
include/asm-generic/bitops/ffz.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h \
include/linux/atomic.h \
arch/arm/include/asm/atomic.h \
$(wildcard include/config/generic/atomic64.h) \
include/linux/prefetch.h \
arch/arm/include/asm/processor.h \
$(wildcard include/config/have/hw/breakpoint.h) \
$(wildcard include/config/binfmt/elf/fdpic.h) \
$(wildcard include/config/arm/errata/754327.h) \
arch/arm/include/asm/hw_breakpoint.h \
arch/arm/include/asm/unified.h \
arch/arm/include/asm/cache.h \
$(wildcard include/config/arm/l1/cache/shift.h) \
$(wildcard include/config/aeabi.h) \
arch/arm/include/asm/cmpxchg.h \
$(wildcard include/config/cpu/sa110.h) \
$(wildcard include/config/cpu/v6.h) \
include/asm-generic/cmpxchg-local.h \
include/linux/atomic-fallback.h \
include/asm-generic/atomic-long.h \
include/asm-generic/bitops/find.h \
$(wildcard include/config/generic/find/first/bit.h) \
include/asm-generic/bitops/le.h \
arch/arm/include/uapi/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/uapi/linux/byteorder/little_endian.h \
include/linux/swab.h \
include/uapi/linux/swab.h \
arch/arm/include/asm/swab.h \
arch/arm/include/uapi/asm/swab.h \
include/linux/byteorder/generic.h \
include/asm-generic/bitops/ext2-atomic-setbit.h \
arch/arm/include/asm/user.h \
include/uapi/linux/elf.h \
include/uapi/linux/elf-em.h \
include/linux/module.h \
$(wildcard include/config/modules.h) \
$(wildcard include/config/sysfs.h) \
$(wildcard include/config/modules/tree/lookup.h) \
$(wildcard include/config/livepatch.h) \
$(wildcard include/config/unused/symbols.h) \
$(wildcard include/config/module/sig.h) \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/kallsyms.h) \
$(wildcard include/config/tracepoints.h) \
$(wildcard include/config/tree/srcu.h) \
$(wildcard include/config/bpf/events.h) \
$(wildcard include/config/jump/label.h) \
$(wildcard include/config/tracing.h) \
$(wildcard include/config/event/tracing.h) \
$(wildcard include/config/ftrace/mcount/record.h) \
$(wildcard include/config/constructors.h) \
$(wildcard include/config/function/error/injection.h) \
$(wildcard include/config/strict/module/rwx.h) \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/poison.h \
$(wildcard include/config/illegal/pointer/value.h) \
$(wildcard include/config/page/poisoning/zero.h) \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/atomic/sleep.h) \
$(wildcard include/config/arch/has/refcount.h) \
$(wildcard include/config/panic/timeout.h) \
/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/9.2.1/include/stdarg.h \
include/linux/limits.h \
include/uapi/linux/limits.h \
include/linux/linkage.h \
include/linux/stringify.h \
include/linux/export.h \
$(wildcard include/config/modversions.h) \
$(wildcard include/config/module/rel/crcs.h) \
$(wildcard include/config/have/arch/prel32/relocations.h) \
$(wildcard include/config/trim/unused/ksyms.h) \
arch/arm/include/asm/linkage.h \
include/linux/printk.h \
$(wildcard include/config/message/loglevel/default.h) \
$(wildcard include/config/console/loglevel/default.h) \
$(wildcard include/config/console/loglevel/quiet.h) \
$(wildcard include/config/early/printk.h) \
$(wildcard include/config/printk/nmi.h) \
$(wildcard include/config/printk.h) \
$(wildcard include/config/dynamic/debug.h) \
include/linux/init.h \
$(wildcard include/config/strict/kernel/rwx.h) \
include/linux/kern_levels.h \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/uapi/linux/kernel.h \
include/uapi/linux/sysinfo.h \
include/linux/dynamic_debug.h \
include/linux/build_bug.h \
arch/arm/include/asm/div64.h \
arch/arm/include/asm/compiler.h \
include/asm-generic/div64.h \
include/linux/stat.h \
arch/arm/include/uapi/asm/stat.h \
include/uapi/linux/stat.h \
include/linux/time.h \
$(wildcard include/config/arch/uses/gettimeoffset.h) \
include/linux/seqlock.h \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/preemption.h) \
include/linux/preempt.h \
$(wildcard include/config/preempt/count.h) \
$(wildcard include/config/debug/preempt.h) \
$(wildcard include/config/trace/preempt/toggle.h) \
$(wildcard include/config/preempt/notifiers.h) \
arch/arm/include/generated/asm/preempt.h \
include/asm-generic/preempt.h \
include/linux/thread_info.h \
$(wildcard include/config/thread/info/in/task.h) \
$(wildcard include/config/have/arch/within/stack/frames.h) \
$(wildcard include/config/hardened/usercopy.h) \
include/linux/bug.h \
$(wildcard include/config/bug/on/data/corruption.h) \
arch/arm/include/asm/bug.h \
$(wildcard include/config/debug/bugverbose.h) \
arch/arm/include/asm/opcodes.h \
$(wildcard include/config/cpu/endian/be32.h) \
include/asm-generic/bug.h \
$(wildcard include/config/bug.h) \
$(wildcard include/config/generic/bug/relative/pointers.h) \
include/linux/restart_block.h \
include/linux/time64.h \
include/linux/math64.h \
$(wildcard include/config/arch/supports/int128.h) \
include/uapi/linux/time.h \
include/uapi/linux/time_types.h \
arch/arm/include/asm/thread_info.h \
$(wildcard include/config/stackprotector/per/task.h) \
$(wildcard include/config/crunch.h) \
$(wildcard include/config/arm/thumbee.h) \
arch/arm/include/asm/fpstate.h \
$(wildcard include/config/vfpv3.h) \
$(wildcard include/config/iwmmxt.h) \
include/linux/bottom_half.h \
arch/arm/include/generated/asm/mmiowb.h \
include/asm-generic/mmiowb.h \
$(wildcard include/config/mmiowb.h) \
include/linux/spinlock_types.h \
arch/arm/include/asm/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/lock/stat.h) \
include/linux/rwlock_types.h \
arch/arm/include/asm/spinlock.h \
include/linux/rwlock.h \
$(wildcard include/config/preempt.h) \
include/linux/spinlock_api_smp.h \
$(wildcard include/config/inline/spin/lock.h) \
$(wildcard include/config/inline/spin/lock/bh.h) \
$(wildcard include/config/inline/spin/lock/irq.h) \
$(wildcard include/config/inline/spin/lock/irqsave.h) \
$(wildcard include/config/inline/spin/trylock.h) \
$(wildcard include/config/inline/spin/trylock/bh.h) \
$(wildcard include/config/uninline/spin/unlock.h) \
$(wildcard include/config/inline/spin/unlock/bh.h) \
$(wildcard include/config/inline/spin/unlock/irq.h) \
$(wildcard include/config/inline/spin/unlock/irqrestore.h) \
$(wildcard include/config/generic/lockbreak.h) \
include/linux/rwlock_api_smp.h \
$(wildcard include/config/inline/read/lock.h) \
$(wildcard include/config/inline/write/lock.h) \
$(wildcard include/config/inline/read/lock/bh.h) \
$(wildcard include/config/inline/write/lock/bh.h) \
$(wildcard include/config/inline/read/lock/irq.h) \
$(wildcard include/config/inline/write/lock/irq.h) \
$(wildcard include/config/inline/read/lock/irqsave.h) \
$(wildcard include/config/inline/write/lock/irqsave.h) \
$(wildcard include/config/inline/read/trylock.h) \
$(wildcard include/config/inline/write/trylock.h) \
$(wildcard include/config/inline/read/unlock.h) \
$(wildcard include/config/inline/write/unlock.h) \
$(wildcard include/config/inline/read/unlock/bh.h) \
$(wildcard include/config/inline/write/unlock/bh.h) \
$(wildcard include/config/inline/read/unlock/irq.h) \
$(wildcard include/config/inline/write/unlock/irq.h) \
$(wildcard include/config/inline/read/unlock/irqrestore.h) \
$(wildcard include/config/inline/write/unlock/irqrestore.h) \
include/linux/time32.h \
include/linux/timex.h \
include/uapi/linux/timex.h \
include/uapi/linux/param.h \
arch/arm/include/generated/uapi/asm/param.h \
include/asm-generic/param.h \
$(wildcard include/config/hz.h) \
include/uapi/asm-generic/param.h \
arch/arm/include/asm/timex.h \
include/linux/uidgid.h \
$(wildcard include/config/multiuser.h) \
$(wildcard include/config/user/ns.h) \
include/linux/highuid.h \
include/linux/kmod.h \
include/linux/umh.h \
include/linux/gfp.h \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
$(wildcard include/config/zone/device.h) \
$(wildcard include/config/numa.h) \
$(wildcard include/config/pm/sleep.h) \
$(wildcard include/config/contig/alloc.h) \
$(wildcard include/config/cma.h) \
include/linux/mmdebug.h \
$(wildcard include/config/debug/vm.h) \
$(wildcard include/config/debug/vm/pgflags.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/isolation.h) \
$(wildcard include/config/shuffle/page/allocator.h) \
$(wildcard include/config/zsmalloc.h) \
$(wildcard include/config/memcg.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/compaction.h) \
$(wildcard include/config/transparent/hugepage.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/page/extension.h) \
$(wildcard include/config/deferred/struct/page/init.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/have/memoryless/nodes.h) \
$(wildcard include/config/have/memblock/node/map.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/memory/hotremove.h) \
$(wildcard include/config/holes/in/zone.h) \
$(wildcard include/config/arch/has/holes/memorymodel.h) \
include/linux/wait.h \
arch/arm/include/generated/asm/current.h \
include/asm-generic/current.h \
include/uapi/linux/wait.h \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/linux/nodemask.h \
include/linux/bitmap.h \
include/linux/string.h \
$(wildcard include/config/binary/printf.h) \
$(wildcard include/config/fortify/source.h) \
include/uapi/linux/string.h \
arch/arm/include/asm/string.h \
include/linux/pageblock-flags.h \
$(wildcard include/config/hugetlb/page.h) \
$(wildcard include/config/hugetlb/page/size/variable.h) \
include/linux/page-flags-layout.h \
$(wildcard include/config/numa/balancing.h) \
$(wildcard include/config/kasan/sw/tags.h) \
include/generated/bounds.h \
include/linux/mm_types.h \
$(wildcard include/config/have/aligned/struct/page.h) \
$(wildcard include/config/userfaultfd.h) \
$(wildcard include/config/swap.h) \
$(wildcard include/config/have/arch/compat/mmap/bases.h) \
$(wildcard include/config/membarrier.h) \
$(wildcard include/config/aio.h) \
$(wildcard include/config/mmu/notifier.h) \
$(wildcard include/config/arch/want/batched/unmap/tlb/flush.h) \
include/linux/mm_types_task.h \
$(wildcard include/config/split/ptlock/cpus.h) \
$(wildcard include/config/arch/enable/split/pmd/ptlock.h) \
include/linux/cpumask.h \
$(wildcard include/config/cpumask/offstack.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/debug/per/cpu/maps.h) \
include/linux/auxvec.h \
include/uapi/linux/auxvec.h \
include/linux/rbtree.h \
include/linux/rcupdate.h \
$(wildcard include/config/preempt/rcu.h) \
$(wildcard include/config/rcu/stall/common.h) \
$(wildcard include/config/no/hz/full.h) \
$(wildcard include/config/rcu/nocb/cpu.h) \
$(wildcard include/config/tasks/rcu.h) \
$(wildcard include/config/tree/rcu.h) \
$(wildcard include/config/tiny/rcu.h) \
$(wildcard include/config/debug/objects/rcu/head.h) \
$(wildcard include/config/prove/rcu.h) \
$(wildcard include/config/rcu/boost.h) \
$(wildcard include/config/arch/weak/release/acquire.h) \
include/linux/rcutree.h \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/spin/on/owner.h) \
$(wildcard include/config/debug/rwsems.h) \
include/linux/err.h \
arch/arm/include/generated/uapi/asm/errno.h \
include/uapi/asm-generic/errno.h \
include/uapi/asm-generic/errno-base.h \
include/linux/osq_lock.h \
include/linux/completion.h \
include/linux/uprobes.h \
$(wildcard include/config/uprobes.h) \
include/linux/errno.h \
include/uapi/linux/errno.h \
arch/arm/include/asm/uprobes.h \
arch/arm/include/asm/probes.h \
include/linux/workqueue.h \
$(wildcard include/config/debug/objects/work.h) \
$(wildcard include/config/freezer.h) \
$(wildcard include/config/wq/watchdog.h) \
include/linux/timer.h \
$(wildcard include/config/debug/objects/timers.h) \
$(wildcard include/config/preempt/rt.h) \
$(wildcard include/config/no/hz/common.h) \
include/linux/ktime.h \
include/linux/jiffies.h \
include/generated/timeconst.h \
include/linux/timekeeping.h \
include/linux/timekeeping32.h \
include/linux/debugobjects.h \
$(wildcard include/config/debug/objects.h) \
$(wildcard include/config/debug/objects/free.h) \
arch/arm/include/asm/mmu.h \
$(wildcard include/config/cpu/has/asid.h) \
include/linux/page-flags.h \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/idle/page/tracking.h) \
$(wildcard include/config/thp/swap.h) \
$(wildcard include/config/ksm.h) \
include/linux/memory_hotplug.h \
$(wildcard include/config/arch/has/add/pages.h) \
$(wildcard include/config/have/arch/nodedata/extension.h) \
$(wildcard include/config/have/bootmem/info/node.h) \
include/linux/notifier.h \
include/linux/mutex.h \
$(wildcard include/config/mutex/spin/on/owner.h) \
$(wildcard include/config/debug/mutexes.h) \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/srcu.h \
$(wildcard include/config/tiny/srcu.h) \
$(wildcard include/config/srcu.h) \
include/linux/rcu_segcblist.h \
include/linux/srcutree.h \
include/linux/rcu_node_tree.h \
$(wildcard include/config/rcu/fanout.h) \
$(wildcard include/config/rcu/fanout/leaf.h) \
include/linux/topology.h \
$(wildcard include/config/use/percpu/numa/node/id.h) \
$(wildcard include/config/sched/smt.h) \
include/linux/arch_topology.h \
$(wildcard include/config/generic/arch/topology.h) \
include/linux/percpu.h \
$(wildcard include/config/need/per/cpu/embed/first/chunk.h) \
$(wildcard include/config/need/per/cpu/page/first/chunk.h) \
$(wildcard include/config/have/setup/per/cpu/area.h) \
include/linux/smp.h \
$(wildcard include/config/up/late/init.h) \
include/linux/llist.h \
$(wildcard include/config/arch/have/nmi/safe/cmpxchg.h) \
arch/arm/include/asm/smp.h \
arch/arm/include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/percpu-defs.h \
$(wildcard include/config/debug/force/weak/per/cpu.h) \
$(wildcard include/config/amd/mem/encrypt.h) \
arch/arm/include/asm/topology.h \
$(wildcard include/config/arm/cpu/topology.h) \
include/asm-generic/topology.h \
include/linux/sysctl.h \
$(wildcard include/config/sysctl.h) \
include/uapi/linux/sysctl.h \
include/linux/kobject.h \
$(wildcard include/config/uevent/helper.h) \
$(wildcard include/config/debug/kobject/release.h) \
include/linux/sysfs.h \
include/linux/kernfs.h \
$(wildcard include/config/kernfs.h) \
include/linux/idr.h \
include/linux/radix-tree.h \
include/linux/xarray.h \
$(wildcard include/config/xarray/multi.h) \
include/linux/kconfig.h \
include/linux/kobject_ns.h \
include/linux/kref.h \
include/linux/refcount.h \
$(wildcard include/config/refcount/full.h) \
include/linux/moduleparam.h \
$(wildcard include/config/alpha.h) \
$(wildcard include/config/ia64.h) \
$(wildcard include/config/ppc64.h) \
include/linux/jump_label.h \
$(wildcard include/config/have/arch/jump/label/relative.h) \
include/linux/rbtree_latch.h \
include/linux/error-injection.h \
include/asm-generic/error-injection.h \
include/linux/tracepoint-defs.h \
include/linux/static_key.h \
arch/arm/include/asm/module.h \
$(wildcard include/config/arm/unwind.h) \
$(wildcard include/config/arm/module/plts.h) \
include/asm-generic/module.h \
$(wildcard include/config/have/mod/arch/specific.h) \
$(wildcard include/config/modules/use/elf/rel.h) \
$(wildcard include/config/modules/use/elf/rela.h) \
include/linux/vermagic.h \
include/generated/utsrelease.h \
/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o: $(deps_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o)
$(deps_/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.mod.o):

1027
1-chr-dev/.drv.o.cmd Normal file

File diff suppressed because it is too large Load Diff

230
1-chr-dev/.drv_test.o.d Normal file
View File

@ -0,0 +1,230 @@
drv_test.o: /home/chenyf/desktop/stm32mp157/driver/chr-dev/drv_test.c \
include/linux/kconfig.h include/generated/autoconf.h \
include/linux/compiler_types.h include/linux/compiler_attributes.h \
include/linux/compiler-gcc.h include/linux/types.h \
include/uapi/linux/types.h arch/arm/include/uapi/asm/types.h \
include/asm-generic/int-ll64.h include/uapi/asm-generic/int-ll64.h \
arch/arm/include/generated/uapi/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h include/uapi/asm-generic/bitsperlong.h \
include/uapi/linux/posix_types.h include/linux/stddef.h \
include/uapi/linux/stddef.h include/linux/compiler_types.h \
arch/arm/include/uapi/asm/posix_types.h \
include/uapi/asm-generic/posix_types.h include/linux/kernel.h \
/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/9.2.1/include/stdarg.h \
include/linux/limits.h include/uapi/linux/limits.h \
include/linux/linkage.h include/linux/stringify.h include/linux/export.h \
arch/arm/include/asm/linkage.h include/linux/compiler.h \
arch/arm/include/asm/barrier.h include/asm-generic/barrier.h \
include/linux/kasan-checks.h include/linux/bitops.h include/linux/bits.h \
include/linux/const.h include/uapi/linux/const.h \
arch/arm/include/asm/bitops.h include/linux/irqflags.h \
include/linux/typecheck.h arch/arm/include/asm/irqflags.h \
arch/arm/include/asm/ptrace.h arch/arm/include/uapi/asm/ptrace.h \
arch/arm/include/asm/hwcap.h arch/arm/include/uapi/asm/hwcap.h \
include/asm-generic/irqflags.h include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/builtin-__fls.h \
include/asm-generic/bitops/builtin-__ffs.h \
include/asm-generic/bitops/builtin-fls.h \
include/asm-generic/bitops/builtin-ffs.h \
include/asm-generic/bitops/ffz.h include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h include/linux/atomic.h \
arch/arm/include/asm/atomic.h include/linux/prefetch.h \
arch/arm/include/asm/processor.h arch/arm/include/asm/hw_breakpoint.h \
arch/arm/include/asm/unified.h arch/arm/include/asm/cache.h \
arch/arm/include/asm/cmpxchg.h include/asm-generic/cmpxchg-local.h \
include/linux/atomic-fallback.h include/asm-generic/atomic-long.h \
include/asm-generic/bitops/find.h include/asm-generic/bitops/le.h \
arch/arm/include/uapi/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/uapi/linux/byteorder/little_endian.h include/linux/swab.h \
include/uapi/linux/swab.h arch/arm/include/asm/swab.h \
arch/arm/include/uapi/asm/swab.h include/linux/byteorder/generic.h \
include/asm-generic/bitops/ext2-atomic-setbit.h include/linux/log2.h \
include/linux/printk.h include/linux/init.h include/linux/kern_levels.h \
include/linux/cache.h include/uapi/linux/kernel.h \
include/uapi/linux/sysinfo.h include/linux/dynamic_debug.h \
include/linux/build_bug.h arch/arm/include/asm/div64.h \
arch/arm/include/asm/compiler.h include/asm-generic/div64.h \
include/linux/delay.h arch/arm/include/asm/delay.h \
arch/arm/include/asm/memory.h include/linux/sizes.h \
include/asm-generic/memory_model.h include/linux/pfn.h \
arch/arm/include/generated/uapi/asm/param.h include/asm-generic/param.h \
include/uapi/asm-generic/param.h include/linux/ide.h \
include/linux/ioport.h include/linux/ata.h include/linux/string.h \
include/uapi/linux/string.h arch/arm/include/asm/string.h \
include/linux/blk-mq.h include/linux/blkdev.h include/linux/sched.h \
include/uapi/linux/sched.h arch/arm/include/generated/asm/current.h \
include/asm-generic/current.h include/linux/thread_info.h \
include/linux/bug.h arch/arm/include/asm/bug.h \
arch/arm/include/asm/opcodes.h include/asm-generic/bug.h \
include/linux/restart_block.h include/linux/time64.h \
include/linux/math64.h include/uapi/linux/time.h \
include/uapi/linux/time_types.h arch/arm/include/asm/thread_info.h \
arch/arm/include/asm/fpstate.h arch/arm/include/asm/page.h \
arch/arm/include/asm/glue.h arch/arm/include/asm/pgtable-2level-types.h \
include/asm-generic/getorder.h include/linux/pid.h \
include/linux/rculist.h include/linux/list.h include/linux/poison.h \
include/linux/rcupdate.h include/linux/preempt.h \
arch/arm/include/generated/asm/preempt.h include/asm-generic/preempt.h \
include/linux/bottom_half.h include/linux/lockdep.h \
include/linux/cpumask.h include/linux/threads.h include/linux/bitmap.h \
include/linux/rcutree.h include/linux/wait.h include/linux/spinlock.h \
arch/arm/include/generated/asm/mmiowb.h include/asm-generic/mmiowb.h \
include/linux/spinlock_types.h arch/arm/include/asm/spinlock_types.h \
include/linux/rwlock_types.h arch/arm/include/asm/spinlock.h \
include/linux/rwlock.h include/linux/spinlock_api_smp.h \
include/linux/rwlock_api_smp.h include/uapi/linux/wait.h \
include/linux/refcount.h include/linux/sem.h include/uapi/linux/sem.h \
include/linux/ipc.h include/linux/uidgid.h include/linux/highuid.h \
include/linux/rhashtable-types.h include/linux/mutex.h \
include/linux/osq_lock.h include/linux/debug_locks.h \
include/linux/workqueue.h include/linux/timer.h include/linux/ktime.h \
include/linux/time.h include/linux/seqlock.h include/linux/time32.h \
include/linux/timex.h include/uapi/linux/timex.h \
include/uapi/linux/param.h arch/arm/include/asm/timex.h \
include/linux/jiffies.h include/generated/timeconst.h \
include/linux/timekeeping.h include/linux/errno.h \
include/uapi/linux/errno.h arch/arm/include/generated/uapi/asm/errno.h \
include/uapi/asm-generic/errno.h include/uapi/asm-generic/errno-base.h \
include/linux/timekeeping32.h include/linux/debugobjects.h \
include/uapi/linux/ipc.h arch/arm/include/generated/uapi/asm/ipcbuf.h \
include/uapi/asm-generic/ipcbuf.h \
arch/arm/include/generated/uapi/asm/sembuf.h \
include/uapi/asm-generic/sembuf.h include/linux/shm.h \
include/uapi/linux/shm.h include/uapi/asm-generic/hugetlb_encode.h \
arch/arm/include/generated/uapi/asm/shmbuf.h \
include/uapi/asm-generic/shmbuf.h arch/arm/include/asm/shmparam.h \
include/linux/kcov.h include/uapi/linux/kcov.h include/linux/plist.h \
include/linux/hrtimer.h include/linux/hrtimer_defs.h \
include/linux/rbtree.h include/linux/percpu.h include/linux/mmdebug.h \
include/linux/smp.h include/linux/llist.h arch/arm/include/asm/smp.h \
arch/arm/include/asm/percpu.h include/asm-generic/percpu.h \
include/linux/percpu-defs.h include/linux/timerqueue.h \
include/linux/seccomp.h include/uapi/linux/seccomp.h \
arch/arm/include/generated/asm/seccomp.h include/asm-generic/seccomp.h \
include/uapi/linux/unistd.h arch/arm/include/asm/unistd.h \
arch/arm/include/uapi/asm/unistd.h \
arch/arm/include/generated/uapi/asm/unistd-eabi.h \
arch/arm/include/generated/uapi/asm/unistd-common.h \
arch/arm/include/generated/asm/unistd-nr.h include/linux/nodemask.h \
include/linux/numa.h include/linux/resource.h \
include/uapi/linux/resource.h \
arch/arm/include/generated/uapi/asm/resource.h \
include/asm-generic/resource.h include/uapi/asm-generic/resource.h \
include/linux/latencytop.h include/linux/sched/prio.h \
include/linux/sched/types.h include/linux/signal_types.h \
include/uapi/linux/signal.h arch/arm/include/asm/signal.h \
arch/arm/include/uapi/asm/signal.h \
include/uapi/asm-generic/signal-defs.h \
arch/arm/include/uapi/asm/sigcontext.h \
arch/arm/include/generated/uapi/asm/siginfo.h \
include/uapi/asm-generic/siginfo.h include/linux/mm_types_task.h \
include/linux/task_io_accounting.h include/linux/posix-timers.h \
include/linux/alarmtimer.h include/uapi/linux/rseq.h \
include/linux/sched/clock.h include/uapi/linux/major.h \
include/linux/genhd.h include/linux/kdev_t.h include/uapi/linux/kdev_t.h \
include/linux/slab.h include/linux/gfp.h include/linux/mmzone.h \
include/linux/pageblock-flags.h include/linux/page-flags-layout.h \
include/generated/bounds.h include/linux/mm_types.h \
include/linux/auxvec.h include/uapi/linux/auxvec.h \
arch/arm/include/asm/auxvec.h arch/arm/include/uapi/asm/auxvec.h \
include/linux/rwsem.h include/linux/err.h include/linux/completion.h \
include/linux/uprobes.h arch/arm/include/asm/uprobes.h \
arch/arm/include/asm/probes.h arch/arm/include/asm/mmu.h \
include/linux/page-flags.h include/linux/memory_hotplug.h \
include/linux/notifier.h include/linux/srcu.h \
include/linux/rcu_segcblist.h include/linux/srcutree.h \
include/linux/rcu_node_tree.h include/linux/topology.h \
include/linux/arch_topology.h arch/arm/include/asm/topology.h \
include/asm-generic/topology.h include/linux/overflow.h \
include/linux/percpu-refcount.h include/linux/kasan.h \
include/linux/uuid.h include/uapi/linux/uuid.h include/linux/blk_types.h \
include/linux/bvec.h include/linux/mm.h include/linux/range.h \
include/linux/bit_spinlock.h include/linux/shrinker.h \
include/linux/page_ext.h include/linux/stacktrace.h \
include/linux/stackdepot.h include/linux/page_ref.h \
include/linux/tracepoint-defs.h include/linux/static_key.h \
include/linux/jump_label.h include/linux/memremap.h \
arch/arm/include/asm/pgtable.h arch/arm/include/asm/proc-fns.h \
arch/arm/include/asm/glue-proc.h include/asm-generic/pgtable-nopud.h \
include/asm-generic/pgtable-nop4d-hack.h \
include/asm-generic/5level-fixup.h arch/arm/include/asm/pgtable-hwdef.h \
arch/arm/include/asm/pgtable-2level-hwdef.h \
arch/arm/include/asm/tlbflush.h arch/arm/include/asm/pgtable-2level.h \
include/asm-generic/pgtable.h include/linux/huge_mm.h \
include/linux/sched/coredump.h include/linux/fs.h \
include/linux/wait_bit.h include/linux/dcache.h \
include/linux/rculist_bl.h include/linux/list_bl.h \
include/linux/lockref.h include/linux/stringhash.h include/linux/hash.h \
include/linux/path.h include/linux/stat.h \
arch/arm/include/uapi/asm/stat.h include/uapi/linux/stat.h \
include/linux/list_lru.h include/linux/radix-tree.h \
include/linux/xarray.h include/linux/kconfig.h \
include/linux/capability.h include/uapi/linux/capability.h \
include/linux/semaphore.h include/linux/fcntl.h \
include/uapi/linux/fcntl.h arch/arm/include/uapi/asm/fcntl.h \
include/uapi/asm-generic/fcntl.h include/uapi/linux/fiemap.h \
include/linux/migrate_mode.h include/linux/percpu-rwsem.h \
include/linux/rcuwait.h include/linux/rcu_sync.h \
include/linux/delayed_call.h include/linux/errseq.h \
include/linux/ioprio.h include/linux/sched/rt.h \
include/linux/iocontext.h include/linux/fs_types.h \
include/uapi/linux/fs.h include/uapi/linux/ioctl.h \
arch/arm/include/generated/uapi/asm/ioctl.h include/asm-generic/ioctl.h \
include/uapi/asm-generic/ioctl.h include/linux/quota.h \
include/linux/percpu_counter.h include/uapi/linux/dqblk_xfs.h \
include/linux/dqblk_v1.h include/linux/dqblk_v2.h \
include/linux/dqblk_qtree.h include/linux/projid.h \
include/uapi/linux/quota.h include/linux/nfs_fs_i.h \
include/linux/vmstat.h include/linux/vm_event_item.h \
arch/arm/include/generated/asm/local.h include/asm-generic/local.h \
include/linux/device.h include/linux/kobject.h include/linux/sysfs.h \
include/linux/kernfs.h include/linux/idr.h include/linux/kobject_ns.h \
include/linux/kref.h include/linux/klist.h include/linux/pm.h \
include/linux/ratelimit.h arch/arm/include/asm/device.h \
include/linux/pm_wakeup.h include/linux/pagemap.h \
include/linux/highmem.h include/linux/uaccess.h \
arch/arm/include/asm/uaccess.h arch/arm/include/asm/domain.h \
arch/arm/include/generated/asm/extable.h include/asm-generic/extable.h \
include/linux/hardirq.h include/linux/ftrace_irq.h include/linux/vtime.h \
include/linux/context_tracking_state.h arch/arm/include/asm/hardirq.h \
arch/arm/include/asm/irq.h include/linux/irq_cpustat.h \
arch/arm/include/asm/cacheflush.h arch/arm/include/asm/glue-cache.h \
arch/arm/include/asm/cachetype.h arch/arm/include/asm/outercache.h \
arch/arm/include/asm/kmap_types.h arch/arm/include/asm/highmem.h \
include/linux/hugetlb_inline.h include/linux/backing-dev-defs.h \
include/linux/flex_proportions.h include/linux/mempool.h \
include/linux/bio.h include/linux/bsg.h include/uapi/linux/bsg.h \
include/linux/scatterlist.h arch/arm/include/asm/io.h \
include/asm-generic/pci_iomap.h include/asm-generic/io.h \
include/linux/logic_pio.h include/linux/fwnode.h include/linux/vmalloc.h \
include/uapi/linux/blkzoned.h include/linux/elevator.h \
include/linux/hashtable.h include/linux/sbitmap.h \
include/linux/proc_fs.h include/linux/interrupt.h \
include/linux/irqreturn.h include/linux/irqnr.h \
include/uapi/linux/irqnr.h arch/arm/include/asm/sections.h \
include/asm-generic/sections.h include/linux/pci.h \
include/linux/mod_devicetable.h include/linux/io.h \
include/linux/resource_ext.h include/uapi/linux/pci.h \
include/uapi/linux/pci_regs.h include/linux/pci_ids.h \
arch/arm/include/asm/pci.h arch/arm/include/asm/mach/pci.h \
include/linux/pci-dma-compat.h include/linux/dma-mapping.h \
include/linux/dma-debug.h include/linux/dma-direction.h \
include/linux/mem_encrypt.h arch/arm/include/asm/dma-mapping.h \
include/xen/xen.h include/xen/interface/hvm/start_info.h \
arch/arm/include/asm/xen/hypervisor.h include/xen/arm/hypervisor.h \
include/linux/cdrom.h include/scsi/scsi_common.h \
include/scsi/scsi_proto.h include/uapi/linux/cdrom.h \
include/scsi/scsi_cmnd.h include/linux/t10-pi.h \
include/scsi/scsi_device.h include/scsi/scsi.h \
include/scsi/scsi_request.h include/linux/module.h include/linux/kmod.h \
include/linux/umh.h include/linux/sysctl.h include/uapi/linux/sysctl.h \
include/linux/elf.h arch/arm/include/asm/elf.h \
arch/arm/include/asm/vdso_datapage.h arch/arm/include/asm/user.h \
include/uapi/linux/elf.h include/uapi/linux/elf-em.h \
include/linux/moduleparam.h include/linux/rbtree_latch.h \
include/linux/error-injection.h include/asm-generic/error-injection.h \
arch/arm/include/asm/module.h include/asm-generic/module.h

20
1-chr-dev/.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include/generated"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

7
1-chr-dev/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"files.associations": {
"ide.h": "c",
"delay.h": "c",
"types.h": "c"
}
}

11
1-chr-dev/Makefile Normal file
View File

@ -0,0 +1,11 @@
Kernel_dir := /home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31
current_dir := $(shell pwd)
obj-m := drv.o
build: kernel_modules
kernel_modules:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) modules
clean:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) clean

0
1-chr-dev/Module.symvers Normal file
View File

BIN
1-chr-dev/app Executable file

Binary file not shown.

43
1-chr-dev/app.c Normal file
View File

@ -0,0 +1,43 @@
#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"
/***************************************************************
Copyright © ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
: chrdevbaseApp.c
:
: V1.0
: chrdevbase驱测试APP
: 使./chrdevbase /dev/chrdevbase <1>|<2>
argv[2] 1:
argv[2] 2:
: www.openedv.com
: V1.0 2019/1/30
***************************************************************/
static char usrdata[] = {"usr data!"};
/*
* @description : main主程序
* @param - argc : argv数组元素个数
* @param - argv :
* @return : 0 ;
*/
int main(int argc, char *argv[])
{
int file;
file = open("/dev/test_dev",O_RDWR);
char a[]="hello";
write(file,a,sizeof(a));
char b[1024];
read(file,b,sizeof(a));
printf("%s\n",b);
close(file);
return 0;
}

3
1-chr-dev/build Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

3
1-chr-dev/build.sh Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

3
1-chr-dev/build_app.sh Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
arm-none-linux-gnueabihf-gcc app.c -o app

71
1-chr-dev/drv.c Normal file
View File

@ -0,0 +1,71 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
/***************************************************************
Copyright © ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
: chrdevbase.c
:
: V1.0
: chrdevbase驱动文件
:
: www.openedv.com
: V1.0 2020/12/26
***************************************************************/
#define major_dev_id 80
#define dev_name "test_dev"
static char cache[1024];
static int tis_module_open(struct inode *inode, struct file *file)
{
printk("%s: module open\n", dev_name);
return 0;
}
static int tis_module_release(struct inode *inode, struct file *file)
{
printk("%s: module open\n", dev_name);
return 0;
}
static ssize_t tis_module_read(struct file *file, char __user *out, size_t size, loff_t *offt)
{
int ret = 0;
ret = copy_to_user(out, cache, size);
return 0;
}
static ssize_t tis_module_write(struct file *file, const char __user *in, size_t size, loff_t *offt)
{
int ret = 0;
ret = copy_from_user(cache, in, size);
if (ret == 0)
{
printk("user out : %s\n", cache);
}
return 0;
}
static struct file_operations tis_module_f = {
.owner = THIS_MODULE,
.write = tis_module_write,
.read = tis_module_read,
.open = tis_module_open,
.release = tis_module_release,
};
static int __init tis_module_init(void)
{
register_chrdev(major_dev_id, dev_name, &tis_module_f);
printk("module init\n");
return 0;
}
static void __exit tis_module_exit(void)
{
unregister_chrdev(major_dev_id, dev_name);
printk("module exit\n");
}
module_init(tis_module_init);
module_exit(tis_module_exit);
MODULE_LICENSE("GPL v3.0");
MODULE_AUTHOR("Chenyf");

BIN
1-chr-dev/drv.ko Normal file

Binary file not shown.

2
1-chr-dev/drv.mod Normal file
View File

@ -0,0 +1,2 @@
/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.o

39
1-chr-dev/drv.mod.c Normal file
View File

@ -0,0 +1,39 @@
#include <linux/build-salt.h>
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
BUILD_SALT;
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_INFO(name, KBUILD_MODNAME);
__visible struct module __this_module
__section(.gnu.linkonce.this_module) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
#ifdef CONFIG_RETPOLINE
MODULE_INFO(retpoline, "Y");
#endif
static const struct modversion_info ____versions[]
__used __section(__versions) = {
{ 0x4b3323eb, "module_layout" },
{ 0x6bc3fbc0, "__unregister_chrdev" },
{ 0x636855de, "__register_chrdev" },
{ 0x189c5980, "arm_copy_to_user" },
{ 0x5f754e5a, "memset" },
{ 0x2cfde9a2, "warn_slowpath_fmt" },
{ 0x514cc273, "arm_copy_from_user" },
{ 0xefd6cf06, "__aeabi_unwind_cpp_pr0" },
{ 0xc5850110, "printk" },
};
MODULE_INFO(depends, "");

BIN
1-chr-dev/drv.mod.o Normal file

Binary file not shown.

BIN
1-chr-dev/drv.o Normal file

Binary file not shown.

1
1-chr-dev/modules.order Normal file
View File

@ -0,0 +1 @@
/home/chenyf/desktop/stm32mp157/driver/chr-dev/drv.ko

1
2-led/.led.ko.cmd Normal file
View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/2-led/led.ko := arm-none-linux-gnueabihf-ld -r -EL --build-id -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds -o /home/chenyf/desktop/stm32mp157/driver/2-led/led.ko /home/chenyf/desktop/stm32mp157/driver/2-led/led.o /home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o; true

1
2-led/.led.mod.cmd Normal file
View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod := { echo /home/chenyf/desktop/stm32mp157/driver/2-led/led.o; echo; } > /home/chenyf/desktop/stm32mp157/driver/2-led/led.mod

537
2-led/.led.mod.o.cmd Normal file
View File

@ -0,0 +1,537 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o := arm-none-linux-gnueabihf-gcc -Wp,-MD,/home/chenyf/desktop/stm32mp157/driver/2-led/.led.mod.o.d -nostdinc -isystem /home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -fno-inline-functions-called-once -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME='"led.mod"' -DKBUILD_MODNAME='"led"' -c -o /home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o /home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.c
source_/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o := /home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.c
deps_/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o := \
$(wildcard include/config/module/unload.h) \
$(wildcard include/config/retpoline.h) \
include/linux/kconfig.h \
$(wildcard include/config/cpu/big/endian.h) \
$(wildcard include/config/booger.h) \
$(wildcard include/config/foo.h) \
include/linux/compiler_types.h \
$(wildcard include/config/have/arch/compiler/h.h) \
$(wildcard include/config/enable/must/check.h) \
$(wildcard include/config/optimize/inlining.h) \
$(wildcard include/config/cc/has/asm/inline.h) \
include/linux/compiler_attributes.h \
include/linux/compiler-gcc.h \
$(wildcard include/config/arch/use/builtin/bswap.h) \
include/linux/build-salt.h \
$(wildcard include/config/build/salt.h) \
include/linux/elfnote.h \
include/linux/elf.h \
arch/arm/include/asm/elf.h \
$(wildcard include/config/mmu.h) \
$(wildcard include/config/vdso.h) \
arch/arm/include/asm/auxvec.h \
arch/arm/include/uapi/asm/auxvec.h \
arch/arm/include/asm/hwcap.h \
arch/arm/include/uapi/asm/hwcap.h \
arch/arm/include/asm/vdso_datapage.h \
arch/arm/include/asm/page.h \
$(wildcard include/config/cpu/copy/v4wt.h) \
$(wildcard include/config/cpu/copy/v4wb.h) \
$(wildcard include/config/cpu/copy/feroceon.h) \
$(wildcard include/config/cpu/copy/fa.h) \
$(wildcard include/config/cpu/sa1100.h) \
$(wildcard include/config/cpu/xscale.h) \
$(wildcard include/config/cpu/xsc3.h) \
$(wildcard include/config/cpu/copy/v6.h) \
$(wildcard include/config/kuser/helpers.h) \
$(wildcard include/config/arm/lpae.h) \
$(wildcard include/config/have/arch/pfn/valid.h) \
arch/arm/include/asm/glue.h \
arch/arm/include/asm/pgtable-2level-types.h \
arch/arm/include/uapi/asm/types.h \
include/asm-generic/int-ll64.h \
include/uapi/asm-generic/int-ll64.h \
arch/arm/include/generated/uapi/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h \
$(wildcard include/config/64bit.h) \
include/uapi/asm-generic/bitsperlong.h \
arch/arm/include/asm/memory.h \
$(wildcard include/config/need/mach/memory/h.h) \
$(wildcard include/config/page/offset.h) \
$(wildcard include/config/thumb2/kernel.h) \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/smp.h) \
$(wildcard include/config/dram/base.h) \
$(wildcard include/config/dram/size.h) \
$(wildcard include/config/xip/kernel.h) \
$(wildcard include/config/have/tcm.h) \
$(wildcard include/config/arm/patch/phys/virt.h) \
$(wildcard include/config/phys/offset.h) \
$(wildcard include/config/xip/phys/addr.h) \
$(wildcard include/config/debug/virtual.h) \
include/linux/compiler.h \
$(wildcard include/config/trace/branch/profiling.h) \
$(wildcard include/config/profile/all/branches.h) \
$(wildcard include/config/stack/validation.h) \
$(wildcard include/config/kasan.h) \
include/linux/compiler_types.h \
include/uapi/linux/types.h \
include/uapi/linux/posix_types.h \
include/linux/stddef.h \
include/uapi/linux/stddef.h \
arch/arm/include/uapi/asm/posix_types.h \
include/uapi/asm-generic/posix_types.h \
arch/arm/include/asm/barrier.h \
$(wildcard include/config/cpu/32v6k.h) \
$(wildcard include/config/cpu/fa526.h) \
$(wildcard include/config/arm/heavy/mb.h) \
$(wildcard include/config/arm/dma/mem/bufferable.h) \
$(wildcard include/config/cpu/spectre.h) \
include/asm-generic/barrier.h \
include/linux/kasan-checks.h \
include/linux/types.h \
$(wildcard include/config/have/uid16.h) \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/arch/dma/addr/t/64bit.h) \
$(wildcard include/config/phys/addr/t/64bit.h) \
include/linux/const.h \
include/uapi/linux/const.h \
include/linux/sizes.h \
include/asm-generic/memory_model.h \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/sparsemem/vmemmap.h) \
$(wildcard include/config/sparsemem.h) \
include/linux/pfn.h \
include/asm-generic/getorder.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/bitops.h \
include/linux/bits.h \
arch/arm/include/asm/bitops.h \
include/linux/irqflags.h \
$(wildcard include/config/prove/locking.h) \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/irqsoff/tracer.h) \
$(wildcard include/config/preempt/tracer.h) \
$(wildcard include/config/trace/irqflags/support.h) \
include/linux/typecheck.h \
arch/arm/include/asm/irqflags.h \
$(wildcard include/config/cpu/v7m.h) \
arch/arm/include/asm/ptrace.h \
$(wildcard include/config/arm/thumb.h) \
arch/arm/include/uapi/asm/ptrace.h \
$(wildcard include/config/cpu/endian/be8.h) \
include/asm-generic/irqflags.h \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/builtin-__fls.h \
include/asm-generic/bitops/builtin-__ffs.h \
include/asm-generic/bitops/builtin-fls.h \
include/asm-generic/bitops/builtin-ffs.h \
include/asm-generic/bitops/ffz.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h \
include/linux/atomic.h \
arch/arm/include/asm/atomic.h \
$(wildcard include/config/generic/atomic64.h) \
include/linux/prefetch.h \
arch/arm/include/asm/processor.h \
$(wildcard include/config/have/hw/breakpoint.h) \
$(wildcard include/config/binfmt/elf/fdpic.h) \
$(wildcard include/config/arm/errata/754327.h) \
arch/arm/include/asm/hw_breakpoint.h \
arch/arm/include/asm/unified.h \
arch/arm/include/asm/cache.h \
$(wildcard include/config/arm/l1/cache/shift.h) \
$(wildcard include/config/aeabi.h) \
arch/arm/include/asm/cmpxchg.h \
$(wildcard include/config/cpu/sa110.h) \
$(wildcard include/config/cpu/v6.h) \
include/asm-generic/cmpxchg-local.h \
include/linux/atomic-fallback.h \
include/asm-generic/atomic-long.h \
include/asm-generic/bitops/find.h \
$(wildcard include/config/generic/find/first/bit.h) \
include/asm-generic/bitops/le.h \
arch/arm/include/uapi/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/uapi/linux/byteorder/little_endian.h \
include/linux/swab.h \
include/uapi/linux/swab.h \
arch/arm/include/asm/swab.h \
arch/arm/include/uapi/asm/swab.h \
include/linux/byteorder/generic.h \
include/asm-generic/bitops/ext2-atomic-setbit.h \
arch/arm/include/asm/user.h \
include/uapi/linux/elf.h \
include/uapi/linux/elf-em.h \
include/linux/module.h \
$(wildcard include/config/modules.h) \
$(wildcard include/config/sysfs.h) \
$(wildcard include/config/modules/tree/lookup.h) \
$(wildcard include/config/livepatch.h) \
$(wildcard include/config/unused/symbols.h) \
$(wildcard include/config/module/sig.h) \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/kallsyms.h) \
$(wildcard include/config/tracepoints.h) \
$(wildcard include/config/tree/srcu.h) \
$(wildcard include/config/bpf/events.h) \
$(wildcard include/config/jump/label.h) \
$(wildcard include/config/tracing.h) \
$(wildcard include/config/event/tracing.h) \
$(wildcard include/config/ftrace/mcount/record.h) \
$(wildcard include/config/constructors.h) \
$(wildcard include/config/function/error/injection.h) \
$(wildcard include/config/strict/module/rwx.h) \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/poison.h \
$(wildcard include/config/illegal/pointer/value.h) \
$(wildcard include/config/page/poisoning/zero.h) \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/atomic/sleep.h) \
$(wildcard include/config/arch/has/refcount.h) \
$(wildcard include/config/panic/timeout.h) \
/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/9.2.1/include/stdarg.h \
include/linux/limits.h \
include/uapi/linux/limits.h \
include/linux/linkage.h \
include/linux/stringify.h \
include/linux/export.h \
$(wildcard include/config/modversions.h) \
$(wildcard include/config/module/rel/crcs.h) \
$(wildcard include/config/have/arch/prel32/relocations.h) \
$(wildcard include/config/trim/unused/ksyms.h) \
arch/arm/include/asm/linkage.h \
include/linux/printk.h \
$(wildcard include/config/message/loglevel/default.h) \
$(wildcard include/config/console/loglevel/default.h) \
$(wildcard include/config/console/loglevel/quiet.h) \
$(wildcard include/config/early/printk.h) \
$(wildcard include/config/printk/nmi.h) \
$(wildcard include/config/printk.h) \
$(wildcard include/config/dynamic/debug.h) \
include/linux/init.h \
$(wildcard include/config/strict/kernel/rwx.h) \
include/linux/kern_levels.h \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/uapi/linux/kernel.h \
include/uapi/linux/sysinfo.h \
include/linux/dynamic_debug.h \
include/linux/build_bug.h \
arch/arm/include/asm/div64.h \
arch/arm/include/asm/compiler.h \
include/asm-generic/div64.h \
include/linux/stat.h \
arch/arm/include/uapi/asm/stat.h \
include/uapi/linux/stat.h \
include/linux/time.h \
$(wildcard include/config/arch/uses/gettimeoffset.h) \
include/linux/seqlock.h \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/preemption.h) \
include/linux/preempt.h \
$(wildcard include/config/preempt/count.h) \
$(wildcard include/config/debug/preempt.h) \
$(wildcard include/config/trace/preempt/toggle.h) \
$(wildcard include/config/preempt/notifiers.h) \
arch/arm/include/generated/asm/preempt.h \
include/asm-generic/preempt.h \
include/linux/thread_info.h \
$(wildcard include/config/thread/info/in/task.h) \
$(wildcard include/config/have/arch/within/stack/frames.h) \
$(wildcard include/config/hardened/usercopy.h) \
include/linux/bug.h \
$(wildcard include/config/bug/on/data/corruption.h) \
arch/arm/include/asm/bug.h \
$(wildcard include/config/debug/bugverbose.h) \
arch/arm/include/asm/opcodes.h \
$(wildcard include/config/cpu/endian/be32.h) \
include/asm-generic/bug.h \
$(wildcard include/config/bug.h) \
$(wildcard include/config/generic/bug/relative/pointers.h) \
include/linux/restart_block.h \
include/linux/time64.h \
include/linux/math64.h \
$(wildcard include/config/arch/supports/int128.h) \
include/uapi/linux/time.h \
include/uapi/linux/time_types.h \
arch/arm/include/asm/thread_info.h \
$(wildcard include/config/stackprotector/per/task.h) \
$(wildcard include/config/crunch.h) \
$(wildcard include/config/arm/thumbee.h) \
arch/arm/include/asm/fpstate.h \
$(wildcard include/config/vfpv3.h) \
$(wildcard include/config/iwmmxt.h) \
include/linux/bottom_half.h \
arch/arm/include/generated/asm/mmiowb.h \
include/asm-generic/mmiowb.h \
$(wildcard include/config/mmiowb.h) \
include/linux/spinlock_types.h \
arch/arm/include/asm/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/lock/stat.h) \
include/linux/rwlock_types.h \
arch/arm/include/asm/spinlock.h \
include/linux/rwlock.h \
$(wildcard include/config/preempt.h) \
include/linux/spinlock_api_smp.h \
$(wildcard include/config/inline/spin/lock.h) \
$(wildcard include/config/inline/spin/lock/bh.h) \
$(wildcard include/config/inline/spin/lock/irq.h) \
$(wildcard include/config/inline/spin/lock/irqsave.h) \
$(wildcard include/config/inline/spin/trylock.h) \
$(wildcard include/config/inline/spin/trylock/bh.h) \
$(wildcard include/config/uninline/spin/unlock.h) \
$(wildcard include/config/inline/spin/unlock/bh.h) \
$(wildcard include/config/inline/spin/unlock/irq.h) \
$(wildcard include/config/inline/spin/unlock/irqrestore.h) \
$(wildcard include/config/generic/lockbreak.h) \
include/linux/rwlock_api_smp.h \
$(wildcard include/config/inline/read/lock.h) \
$(wildcard include/config/inline/write/lock.h) \
$(wildcard include/config/inline/read/lock/bh.h) \
$(wildcard include/config/inline/write/lock/bh.h) \
$(wildcard include/config/inline/read/lock/irq.h) \
$(wildcard include/config/inline/write/lock/irq.h) \
$(wildcard include/config/inline/read/lock/irqsave.h) \
$(wildcard include/config/inline/write/lock/irqsave.h) \
$(wildcard include/config/inline/read/trylock.h) \
$(wildcard include/config/inline/write/trylock.h) \
$(wildcard include/config/inline/read/unlock.h) \
$(wildcard include/config/inline/write/unlock.h) \
$(wildcard include/config/inline/read/unlock/bh.h) \
$(wildcard include/config/inline/write/unlock/bh.h) \
$(wildcard include/config/inline/read/unlock/irq.h) \
$(wildcard include/config/inline/write/unlock/irq.h) \
$(wildcard include/config/inline/read/unlock/irqrestore.h) \
$(wildcard include/config/inline/write/unlock/irqrestore.h) \
include/linux/time32.h \
include/linux/timex.h \
include/uapi/linux/timex.h \
include/uapi/linux/param.h \
arch/arm/include/generated/uapi/asm/param.h \
include/asm-generic/param.h \
$(wildcard include/config/hz.h) \
include/uapi/asm-generic/param.h \
arch/arm/include/asm/timex.h \
include/linux/uidgid.h \
$(wildcard include/config/multiuser.h) \
$(wildcard include/config/user/ns.h) \
include/linux/highuid.h \
include/linux/kmod.h \
include/linux/umh.h \
include/linux/gfp.h \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
$(wildcard include/config/zone/device.h) \
$(wildcard include/config/numa.h) \
$(wildcard include/config/pm/sleep.h) \
$(wildcard include/config/contig/alloc.h) \
$(wildcard include/config/cma.h) \
include/linux/mmdebug.h \
$(wildcard include/config/debug/vm.h) \
$(wildcard include/config/debug/vm/pgflags.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/isolation.h) \
$(wildcard include/config/shuffle/page/allocator.h) \
$(wildcard include/config/zsmalloc.h) \
$(wildcard include/config/memcg.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/compaction.h) \
$(wildcard include/config/transparent/hugepage.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/page/extension.h) \
$(wildcard include/config/deferred/struct/page/init.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/have/memoryless/nodes.h) \
$(wildcard include/config/have/memblock/node/map.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/memory/hotremove.h) \
$(wildcard include/config/holes/in/zone.h) \
$(wildcard include/config/arch/has/holes/memorymodel.h) \
include/linux/wait.h \
arch/arm/include/generated/asm/current.h \
include/asm-generic/current.h \
include/uapi/linux/wait.h \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/linux/nodemask.h \
include/linux/bitmap.h \
include/linux/string.h \
$(wildcard include/config/binary/printf.h) \
$(wildcard include/config/fortify/source.h) \
include/uapi/linux/string.h \
arch/arm/include/asm/string.h \
include/linux/pageblock-flags.h \
$(wildcard include/config/hugetlb/page.h) \
$(wildcard include/config/hugetlb/page/size/variable.h) \
include/linux/page-flags-layout.h \
$(wildcard include/config/numa/balancing.h) \
$(wildcard include/config/kasan/sw/tags.h) \
include/generated/bounds.h \
include/linux/mm_types.h \
$(wildcard include/config/have/aligned/struct/page.h) \
$(wildcard include/config/userfaultfd.h) \
$(wildcard include/config/swap.h) \
$(wildcard include/config/have/arch/compat/mmap/bases.h) \
$(wildcard include/config/membarrier.h) \
$(wildcard include/config/aio.h) \
$(wildcard include/config/mmu/notifier.h) \
$(wildcard include/config/arch/want/batched/unmap/tlb/flush.h) \
include/linux/mm_types_task.h \
$(wildcard include/config/split/ptlock/cpus.h) \
$(wildcard include/config/arch/enable/split/pmd/ptlock.h) \
include/linux/cpumask.h \
$(wildcard include/config/cpumask/offstack.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/debug/per/cpu/maps.h) \
include/linux/auxvec.h \
include/uapi/linux/auxvec.h \
include/linux/rbtree.h \
include/linux/rcupdate.h \
$(wildcard include/config/preempt/rcu.h) \
$(wildcard include/config/rcu/stall/common.h) \
$(wildcard include/config/no/hz/full.h) \
$(wildcard include/config/rcu/nocb/cpu.h) \
$(wildcard include/config/tasks/rcu.h) \
$(wildcard include/config/tree/rcu.h) \
$(wildcard include/config/tiny/rcu.h) \
$(wildcard include/config/debug/objects/rcu/head.h) \
$(wildcard include/config/prove/rcu.h) \
$(wildcard include/config/rcu/boost.h) \
$(wildcard include/config/arch/weak/release/acquire.h) \
include/linux/rcutree.h \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/spin/on/owner.h) \
$(wildcard include/config/debug/rwsems.h) \
include/linux/err.h \
arch/arm/include/generated/uapi/asm/errno.h \
include/uapi/asm-generic/errno.h \
include/uapi/asm-generic/errno-base.h \
include/linux/osq_lock.h \
include/linux/completion.h \
include/linux/uprobes.h \
$(wildcard include/config/uprobes.h) \
include/linux/errno.h \
include/uapi/linux/errno.h \
arch/arm/include/asm/uprobes.h \
arch/arm/include/asm/probes.h \
include/linux/workqueue.h \
$(wildcard include/config/debug/objects/work.h) \
$(wildcard include/config/freezer.h) \
$(wildcard include/config/wq/watchdog.h) \
include/linux/timer.h \
$(wildcard include/config/debug/objects/timers.h) \
$(wildcard include/config/preempt/rt.h) \
$(wildcard include/config/no/hz/common.h) \
include/linux/ktime.h \
include/linux/jiffies.h \
include/generated/timeconst.h \
include/linux/timekeeping.h \
include/linux/timekeeping32.h \
include/linux/debugobjects.h \
$(wildcard include/config/debug/objects.h) \
$(wildcard include/config/debug/objects/free.h) \
arch/arm/include/asm/mmu.h \
$(wildcard include/config/cpu/has/asid.h) \
include/linux/page-flags.h \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/idle/page/tracking.h) \
$(wildcard include/config/thp/swap.h) \
$(wildcard include/config/ksm.h) \
include/linux/memory_hotplug.h \
$(wildcard include/config/arch/has/add/pages.h) \
$(wildcard include/config/have/arch/nodedata/extension.h) \
$(wildcard include/config/have/bootmem/info/node.h) \
include/linux/notifier.h \
include/linux/mutex.h \
$(wildcard include/config/mutex/spin/on/owner.h) \
$(wildcard include/config/debug/mutexes.h) \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/srcu.h \
$(wildcard include/config/tiny/srcu.h) \
$(wildcard include/config/srcu.h) \
include/linux/rcu_segcblist.h \
include/linux/srcutree.h \
include/linux/rcu_node_tree.h \
$(wildcard include/config/rcu/fanout.h) \
$(wildcard include/config/rcu/fanout/leaf.h) \
include/linux/topology.h \
$(wildcard include/config/use/percpu/numa/node/id.h) \
$(wildcard include/config/sched/smt.h) \
include/linux/arch_topology.h \
$(wildcard include/config/generic/arch/topology.h) \
include/linux/percpu.h \
$(wildcard include/config/need/per/cpu/embed/first/chunk.h) \
$(wildcard include/config/need/per/cpu/page/first/chunk.h) \
$(wildcard include/config/have/setup/per/cpu/area.h) \
include/linux/smp.h \
$(wildcard include/config/up/late/init.h) \
include/linux/llist.h \
$(wildcard include/config/arch/have/nmi/safe/cmpxchg.h) \
arch/arm/include/asm/smp.h \
arch/arm/include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/percpu-defs.h \
$(wildcard include/config/debug/force/weak/per/cpu.h) \
$(wildcard include/config/amd/mem/encrypt.h) \
arch/arm/include/asm/topology.h \
$(wildcard include/config/arm/cpu/topology.h) \
include/asm-generic/topology.h \
include/linux/sysctl.h \
$(wildcard include/config/sysctl.h) \
include/uapi/linux/sysctl.h \
include/linux/kobject.h \
$(wildcard include/config/uevent/helper.h) \
$(wildcard include/config/debug/kobject/release.h) \
include/linux/sysfs.h \
include/linux/kernfs.h \
$(wildcard include/config/kernfs.h) \
include/linux/idr.h \
include/linux/radix-tree.h \
include/linux/xarray.h \
$(wildcard include/config/xarray/multi.h) \
include/linux/kconfig.h \
include/linux/kobject_ns.h \
include/linux/kref.h \
include/linux/refcount.h \
$(wildcard include/config/refcount/full.h) \
include/linux/moduleparam.h \
$(wildcard include/config/alpha.h) \
$(wildcard include/config/ia64.h) \
$(wildcard include/config/ppc64.h) \
include/linux/jump_label.h \
$(wildcard include/config/have/arch/jump/label/relative.h) \
include/linux/rbtree_latch.h \
include/linux/error-injection.h \
include/asm-generic/error-injection.h \
include/linux/tracepoint-defs.h \
include/linux/static_key.h \
arch/arm/include/asm/module.h \
$(wildcard include/config/arm/unwind.h) \
$(wildcard include/config/arm/module/plts.h) \
include/asm-generic/module.h \
$(wildcard include/config/have/mod/arch/specific.h) \
$(wildcard include/config/modules/use/elf/rel.h) \
$(wildcard include/config/modules/use/elf/rela.h) \
include/linux/vermagic.h \
include/generated/utsrelease.h \
/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o: $(deps_/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o)
$(deps_/home/chenyf/desktop/stm32mp157/driver/2-led/led.mod.o):

1088
2-led/.led.o.cmd Normal file

File diff suppressed because it is too large Load Diff

20
2-led/.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include/generated"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

11
2-led/Makefile Normal file
View File

@ -0,0 +1,11 @@
Kernel_dir := /home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31
current_dir := $(shell pwd)
obj-m := led.o
build: kernel_modules
kernel_modules:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) modules
clean:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) clean

0
2-led/Module.symvers Normal file
View File

3
2-led/build Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

3
2-led/build.sh Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

171
2-led/led.c Normal file
View File

@ -0,0 +1,171 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <asm/mach/map.h>
#include <asm/uaccess.h>
#include <asm/io.h>
/***************************************************************
Copyright © ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
: chrdevbase.c
:
: V1.0
: chrdevbase驱动文件
:
: www.openedv.com
: V1.0 2020/12/26
***************************************************************/
#define major_dev_id 80
#define dev_name "led"
#define PERIPH_BASE (0x40000000)
#define MPU_AHB4_PERIPH_BASE (PERIPH_BASE + 0x10000000)
#define RCC_BASE (MPU_AHB4_PERIPH_BASE + 0x0000)
#define RCC_MP_AHB4ENSETR (RCC_BASE + 0XA28)
#define GPIOI_BASE (MPU_AHB4_PERIPH_BASE + 0xA000)
#define GPIOI_MODER (GPIOI_BASE + 0x0000)
#define GPIOI_OTYPER (GPIOI_BASE + 0x0004)
#define GPIOI_OSPEEDR (GPIOI_BASE + 0x0008)
#define GPIOI_PUPDR (GPIOI_BASE + 0x000C)
#define GPIOI_BSRR (GPIOI_BASE + 0x0018)
/* 映射后的寄存器虚拟地址指针 */
static void __iomem *MPU_AHB4_PERIPH_RCC_PI;
static void __iomem *GPIOI_MODER_PI;
static void __iomem *GPIOI_OTYPER_PI;
static void __iomem *GPIOI_OSPEEDR_PI;
static void __iomem *GPIOI_PUPDR_PI;
static void __iomem *GPIOI_BSRR_PI;
char led_sta = '0';
static ssize_t tis_module_read(struct file *file, char __user *out, size_t size, loff_t *offt)
{
int ret = 0;
ret = copy_to_user(out,&led_sta,1);
return 0;
}
static ssize_t tis_module_write(struct file *file, const char __user *in, size_t size, loff_t *offt)
{
int ret = 0;
char sta;
unsigned int val;
ret = copy_from_user(&sta, in, 1);
if (ret < 0)
{
return ret;
}
if (sta!='0'&&sta!='1')
{
printk("led module should input 0/1, your input is %c\n");
return 0;
}
led_sta = sta;
switch (sta)
{
case '1':
val = readl(GPIOI_BSRR_PI);
val |= (1 << 16);
writel(val, GPIOI_BSRR_PI);
break;
case '0':
val = readl(GPIOI_BSRR_PI);
val |= (1 << 0);
writel(val, GPIOI_BSRR_PI);
break;
default:
break;
}
return 0;
}
static int tis_module_open(struct inode *inode, struct file *file)
{
printk("%s: module open\n", dev_name);
return 0;
}
static int tis_module_release(struct inode *inode, struct file *file)
{
printk("%s: module release\n", dev_name);
return 0;
}
static struct file_operations tis_module_f = {
.owner = THIS_MODULE,
.write = tis_module_write,
.read = tis_module_read,
.open = tis_module_open,
.release = tis_module_release,
};
static void led_init(void)
{
MPU_AHB4_PERIPH_RCC_PI = ioremap(RCC_MP_AHB4ENSETR, 4);
GPIOI_MODER_PI = ioremap(GPIOI_MODER, 4);
GPIOI_OTYPER_PI = ioremap(GPIOI_OTYPER, 4);
GPIOI_OSPEEDR_PI = ioremap(GPIOI_OSPEEDR, 4);
GPIOI_PUPDR_PI = ioremap(GPIOI_PUPDR, 4);
GPIOI_BSRR_PI = ioremap(GPIOI_BSRR, 4);
unsigned int val;
/* 2、使能PI时钟 */
val = readl(MPU_AHB4_PERIPH_RCC_PI);
val &= ~(0X1 << 8); /* 清除以前的设置 */
val |= (0X1 << 8); /* 设置新值 */
writel(val, MPU_AHB4_PERIPH_RCC_PI);
/* 3、设置PI0通用的输出模式。*/
val = readl(GPIOI_MODER_PI);
val &= ~(0X3 << 0); /* bit0:1清零 */
val |= (0X1 << 0); /* bit0:1设置01 */
writel(val, GPIOI_MODER_PI);
/* 3、设置PI0为推挽模式。*/
val = readl(GPIOI_OTYPER_PI);
val &= ~(0X1 << 0); /* bit0清零设置为上拉*/
writel(val, GPIOI_OTYPER_PI);
/* 4、设置PI0为高速。*/
val = readl(GPIOI_OSPEEDR_PI);
val &= ~(0X3 << 0); /* bit0:1 清零 */
val |= (0x2 << 0); /* bit0:1 设置为10*/
writel(val, GPIOI_OSPEEDR_PI);
/* 5、设置PI0为上拉。*/
val = readl(GPIOI_PUPDR_PI);
val &= ~(0X3 << 0); /* bit0:1 清零*/
val |= (0x1 << 0); /*bit0:1 设置为01*/
writel(val, GPIOI_PUPDR_PI);
/* 6、默认关闭LED */
val = readl(GPIOI_BSRR_PI);
val |= (0x1 << 0);
writel(val, GPIOI_BSRR_PI);
led_sta = '0';
}
static void led_io_unmap(void)
{
iounmap(MPU_AHB4_PERIPH_RCC_PI);
iounmap(GPIOI_MODER_PI);
iounmap(GPIOI_OTYPER_PI);
iounmap(GPIOI_OSPEEDR_PI);
iounmap(GPIOI_PUPDR_PI);
iounmap(GPIOI_BSRR_PI);
}
static int __init tis_module_init(void)
{
register_chrdev(major_dev_id, dev_name, &tis_module_f);
printk("%s init\n", dev_name);
led_init();
return 0;
}
static void __exit tis_module_exit(void)
{
unregister_chrdev(major_dev_id, dev_name);
led_io_unmap();
printk("%s exit\n", dev_name);
}
module_init(tis_module_init);
module_exit(tis_module_exit);
MODULE_LICENSE("GPL v3.0");
MODULE_AUTHOR("Chenyf");

BIN
2-led/led.ko Normal file

Binary file not shown.

2
2-led/led.mod Normal file
View File

@ -0,0 +1,2 @@
/home/chenyf/desktop/stm32mp157/driver/2-led/led.o

42
2-led/led.mod.c Normal file
View File

@ -0,0 +1,42 @@
#include <linux/build-salt.h>
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
BUILD_SALT;
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_INFO(name, KBUILD_MODNAME);
__visible struct module __this_module
__section(.gnu.linkonce.this_module) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
#ifdef CONFIG_RETPOLINE
MODULE_INFO(retpoline, "Y");
#endif
static const struct modversion_info ____versions[]
__used __section(__versions) = {
{ 0x4b3323eb, "module_layout" },
{ 0xedc03953, "iounmap" },
{ 0x6bc3fbc0, "__unregister_chrdev" },
{ 0xe97c4103, "ioremap" },
{ 0x636855de, "__register_chrdev" },
{ 0xdecd0b29, "__stack_chk_fail" },
{ 0x5f754e5a, "memset" },
{ 0x514cc273, "arm_copy_from_user" },
{ 0x8f678b07, "__stack_chk_guard" },
{ 0x189c5980, "arm_copy_to_user" },
{ 0xefd6cf06, "__aeabi_unwind_cpp_pr0" },
{ 0xc5850110, "printk" },
};
MODULE_INFO(depends, "");

BIN
2-led/led.mod.o Normal file

Binary file not shown.

BIN
2-led/led.o Normal file

Binary file not shown.

10
2-led/led_app.c Normal file
View File

@ -0,0 +1,10 @@
/*
* @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @Date: 2023-08-18 21:46:45
* @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @LastEditTime: 2023-08-18 22:36:46
* @FilePath: /2-led/led_app.c
* @Description: ,`customMade`, koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include "stdio.h"

1
2-led/modules.order Normal file
View File

@ -0,0 +1 @@
/home/chenyf/desktop/stm32mp157/driver/2-led/led.ko

View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.ko := arm-none-linux-gnueabihf-ld -r -EL --build-id -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds -o /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.ko /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.o /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o; true

View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod := { echo /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.o; echo; } > /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod

View File

@ -0,0 +1,537 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o := arm-none-linux-gnueabihf-gcc -Wp,-MD,/home/chenyf/desktop/stm32mp157/driver/3-new-led/.new_char.mod.o.d -nostdinc -isystem /home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -fno-inline-functions-called-once -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME='"new_char.mod"' -DKBUILD_MODNAME='"new_char"' -c -o /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.c
source_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o := /home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.c
deps_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o := \
$(wildcard include/config/module/unload.h) \
$(wildcard include/config/retpoline.h) \
include/linux/kconfig.h \
$(wildcard include/config/cpu/big/endian.h) \
$(wildcard include/config/booger.h) \
$(wildcard include/config/foo.h) \
include/linux/compiler_types.h \
$(wildcard include/config/have/arch/compiler/h.h) \
$(wildcard include/config/enable/must/check.h) \
$(wildcard include/config/optimize/inlining.h) \
$(wildcard include/config/cc/has/asm/inline.h) \
include/linux/compiler_attributes.h \
include/linux/compiler-gcc.h \
$(wildcard include/config/arch/use/builtin/bswap.h) \
include/linux/build-salt.h \
$(wildcard include/config/build/salt.h) \
include/linux/elfnote.h \
include/linux/elf.h \
arch/arm/include/asm/elf.h \
$(wildcard include/config/mmu.h) \
$(wildcard include/config/vdso.h) \
arch/arm/include/asm/auxvec.h \
arch/arm/include/uapi/asm/auxvec.h \
arch/arm/include/asm/hwcap.h \
arch/arm/include/uapi/asm/hwcap.h \
arch/arm/include/asm/vdso_datapage.h \
arch/arm/include/asm/page.h \
$(wildcard include/config/cpu/copy/v4wt.h) \
$(wildcard include/config/cpu/copy/v4wb.h) \
$(wildcard include/config/cpu/copy/feroceon.h) \
$(wildcard include/config/cpu/copy/fa.h) \
$(wildcard include/config/cpu/sa1100.h) \
$(wildcard include/config/cpu/xscale.h) \
$(wildcard include/config/cpu/xsc3.h) \
$(wildcard include/config/cpu/copy/v6.h) \
$(wildcard include/config/kuser/helpers.h) \
$(wildcard include/config/arm/lpae.h) \
$(wildcard include/config/have/arch/pfn/valid.h) \
arch/arm/include/asm/glue.h \
arch/arm/include/asm/pgtable-2level-types.h \
arch/arm/include/uapi/asm/types.h \
include/asm-generic/int-ll64.h \
include/uapi/asm-generic/int-ll64.h \
arch/arm/include/generated/uapi/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h \
$(wildcard include/config/64bit.h) \
include/uapi/asm-generic/bitsperlong.h \
arch/arm/include/asm/memory.h \
$(wildcard include/config/need/mach/memory/h.h) \
$(wildcard include/config/page/offset.h) \
$(wildcard include/config/thumb2/kernel.h) \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/smp.h) \
$(wildcard include/config/dram/base.h) \
$(wildcard include/config/dram/size.h) \
$(wildcard include/config/xip/kernel.h) \
$(wildcard include/config/have/tcm.h) \
$(wildcard include/config/arm/patch/phys/virt.h) \
$(wildcard include/config/phys/offset.h) \
$(wildcard include/config/xip/phys/addr.h) \
$(wildcard include/config/debug/virtual.h) \
include/linux/compiler.h \
$(wildcard include/config/trace/branch/profiling.h) \
$(wildcard include/config/profile/all/branches.h) \
$(wildcard include/config/stack/validation.h) \
$(wildcard include/config/kasan.h) \
include/linux/compiler_types.h \
include/uapi/linux/types.h \
include/uapi/linux/posix_types.h \
include/linux/stddef.h \
include/uapi/linux/stddef.h \
arch/arm/include/uapi/asm/posix_types.h \
include/uapi/asm-generic/posix_types.h \
arch/arm/include/asm/barrier.h \
$(wildcard include/config/cpu/32v6k.h) \
$(wildcard include/config/cpu/fa526.h) \
$(wildcard include/config/arm/heavy/mb.h) \
$(wildcard include/config/arm/dma/mem/bufferable.h) \
$(wildcard include/config/cpu/spectre.h) \
include/asm-generic/barrier.h \
include/linux/kasan-checks.h \
include/linux/types.h \
$(wildcard include/config/have/uid16.h) \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/arch/dma/addr/t/64bit.h) \
$(wildcard include/config/phys/addr/t/64bit.h) \
include/linux/const.h \
include/uapi/linux/const.h \
include/linux/sizes.h \
include/asm-generic/memory_model.h \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/sparsemem/vmemmap.h) \
$(wildcard include/config/sparsemem.h) \
include/linux/pfn.h \
include/asm-generic/getorder.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/bitops.h \
include/linux/bits.h \
arch/arm/include/asm/bitops.h \
include/linux/irqflags.h \
$(wildcard include/config/prove/locking.h) \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/irqsoff/tracer.h) \
$(wildcard include/config/preempt/tracer.h) \
$(wildcard include/config/trace/irqflags/support.h) \
include/linux/typecheck.h \
arch/arm/include/asm/irqflags.h \
$(wildcard include/config/cpu/v7m.h) \
arch/arm/include/asm/ptrace.h \
$(wildcard include/config/arm/thumb.h) \
arch/arm/include/uapi/asm/ptrace.h \
$(wildcard include/config/cpu/endian/be8.h) \
include/asm-generic/irqflags.h \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/builtin-__fls.h \
include/asm-generic/bitops/builtin-__ffs.h \
include/asm-generic/bitops/builtin-fls.h \
include/asm-generic/bitops/builtin-ffs.h \
include/asm-generic/bitops/ffz.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h \
include/linux/atomic.h \
arch/arm/include/asm/atomic.h \
$(wildcard include/config/generic/atomic64.h) \
include/linux/prefetch.h \
arch/arm/include/asm/processor.h \
$(wildcard include/config/have/hw/breakpoint.h) \
$(wildcard include/config/binfmt/elf/fdpic.h) \
$(wildcard include/config/arm/errata/754327.h) \
arch/arm/include/asm/hw_breakpoint.h \
arch/arm/include/asm/unified.h \
arch/arm/include/asm/cache.h \
$(wildcard include/config/arm/l1/cache/shift.h) \
$(wildcard include/config/aeabi.h) \
arch/arm/include/asm/cmpxchg.h \
$(wildcard include/config/cpu/sa110.h) \
$(wildcard include/config/cpu/v6.h) \
include/asm-generic/cmpxchg-local.h \
include/linux/atomic-fallback.h \
include/asm-generic/atomic-long.h \
include/asm-generic/bitops/find.h \
$(wildcard include/config/generic/find/first/bit.h) \
include/asm-generic/bitops/le.h \
arch/arm/include/uapi/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/uapi/linux/byteorder/little_endian.h \
include/linux/swab.h \
include/uapi/linux/swab.h \
arch/arm/include/asm/swab.h \
arch/arm/include/uapi/asm/swab.h \
include/linux/byteorder/generic.h \
include/asm-generic/bitops/ext2-atomic-setbit.h \
arch/arm/include/asm/user.h \
include/uapi/linux/elf.h \
include/uapi/linux/elf-em.h \
include/linux/module.h \
$(wildcard include/config/modules.h) \
$(wildcard include/config/sysfs.h) \
$(wildcard include/config/modules/tree/lookup.h) \
$(wildcard include/config/livepatch.h) \
$(wildcard include/config/unused/symbols.h) \
$(wildcard include/config/module/sig.h) \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/kallsyms.h) \
$(wildcard include/config/tracepoints.h) \
$(wildcard include/config/tree/srcu.h) \
$(wildcard include/config/bpf/events.h) \
$(wildcard include/config/jump/label.h) \
$(wildcard include/config/tracing.h) \
$(wildcard include/config/event/tracing.h) \
$(wildcard include/config/ftrace/mcount/record.h) \
$(wildcard include/config/constructors.h) \
$(wildcard include/config/function/error/injection.h) \
$(wildcard include/config/strict/module/rwx.h) \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/poison.h \
$(wildcard include/config/illegal/pointer/value.h) \
$(wildcard include/config/page/poisoning/zero.h) \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/atomic/sleep.h) \
$(wildcard include/config/arch/has/refcount.h) \
$(wildcard include/config/panic/timeout.h) \
/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/9.2.1/include/stdarg.h \
include/linux/limits.h \
include/uapi/linux/limits.h \
include/linux/linkage.h \
include/linux/stringify.h \
include/linux/export.h \
$(wildcard include/config/modversions.h) \
$(wildcard include/config/module/rel/crcs.h) \
$(wildcard include/config/have/arch/prel32/relocations.h) \
$(wildcard include/config/trim/unused/ksyms.h) \
arch/arm/include/asm/linkage.h \
include/linux/printk.h \
$(wildcard include/config/message/loglevel/default.h) \
$(wildcard include/config/console/loglevel/default.h) \
$(wildcard include/config/console/loglevel/quiet.h) \
$(wildcard include/config/early/printk.h) \
$(wildcard include/config/printk/nmi.h) \
$(wildcard include/config/printk.h) \
$(wildcard include/config/dynamic/debug.h) \
include/linux/init.h \
$(wildcard include/config/strict/kernel/rwx.h) \
include/linux/kern_levels.h \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/uapi/linux/kernel.h \
include/uapi/linux/sysinfo.h \
include/linux/dynamic_debug.h \
include/linux/build_bug.h \
arch/arm/include/asm/div64.h \
arch/arm/include/asm/compiler.h \
include/asm-generic/div64.h \
include/linux/stat.h \
arch/arm/include/uapi/asm/stat.h \
include/uapi/linux/stat.h \
include/linux/time.h \
$(wildcard include/config/arch/uses/gettimeoffset.h) \
include/linux/seqlock.h \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/preemption.h) \
include/linux/preempt.h \
$(wildcard include/config/preempt/count.h) \
$(wildcard include/config/debug/preempt.h) \
$(wildcard include/config/trace/preempt/toggle.h) \
$(wildcard include/config/preempt/notifiers.h) \
arch/arm/include/generated/asm/preempt.h \
include/asm-generic/preempt.h \
include/linux/thread_info.h \
$(wildcard include/config/thread/info/in/task.h) \
$(wildcard include/config/have/arch/within/stack/frames.h) \
$(wildcard include/config/hardened/usercopy.h) \
include/linux/bug.h \
$(wildcard include/config/bug/on/data/corruption.h) \
arch/arm/include/asm/bug.h \
$(wildcard include/config/debug/bugverbose.h) \
arch/arm/include/asm/opcodes.h \
$(wildcard include/config/cpu/endian/be32.h) \
include/asm-generic/bug.h \
$(wildcard include/config/bug.h) \
$(wildcard include/config/generic/bug/relative/pointers.h) \
include/linux/restart_block.h \
include/linux/time64.h \
include/linux/math64.h \
$(wildcard include/config/arch/supports/int128.h) \
include/uapi/linux/time.h \
include/uapi/linux/time_types.h \
arch/arm/include/asm/thread_info.h \
$(wildcard include/config/stackprotector/per/task.h) \
$(wildcard include/config/crunch.h) \
$(wildcard include/config/arm/thumbee.h) \
arch/arm/include/asm/fpstate.h \
$(wildcard include/config/vfpv3.h) \
$(wildcard include/config/iwmmxt.h) \
include/linux/bottom_half.h \
arch/arm/include/generated/asm/mmiowb.h \
include/asm-generic/mmiowb.h \
$(wildcard include/config/mmiowb.h) \
include/linux/spinlock_types.h \
arch/arm/include/asm/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/lock/stat.h) \
include/linux/rwlock_types.h \
arch/arm/include/asm/spinlock.h \
include/linux/rwlock.h \
$(wildcard include/config/preempt.h) \
include/linux/spinlock_api_smp.h \
$(wildcard include/config/inline/spin/lock.h) \
$(wildcard include/config/inline/spin/lock/bh.h) \
$(wildcard include/config/inline/spin/lock/irq.h) \
$(wildcard include/config/inline/spin/lock/irqsave.h) \
$(wildcard include/config/inline/spin/trylock.h) \
$(wildcard include/config/inline/spin/trylock/bh.h) \
$(wildcard include/config/uninline/spin/unlock.h) \
$(wildcard include/config/inline/spin/unlock/bh.h) \
$(wildcard include/config/inline/spin/unlock/irq.h) \
$(wildcard include/config/inline/spin/unlock/irqrestore.h) \
$(wildcard include/config/generic/lockbreak.h) \
include/linux/rwlock_api_smp.h \
$(wildcard include/config/inline/read/lock.h) \
$(wildcard include/config/inline/write/lock.h) \
$(wildcard include/config/inline/read/lock/bh.h) \
$(wildcard include/config/inline/write/lock/bh.h) \
$(wildcard include/config/inline/read/lock/irq.h) \
$(wildcard include/config/inline/write/lock/irq.h) \
$(wildcard include/config/inline/read/lock/irqsave.h) \
$(wildcard include/config/inline/write/lock/irqsave.h) \
$(wildcard include/config/inline/read/trylock.h) \
$(wildcard include/config/inline/write/trylock.h) \
$(wildcard include/config/inline/read/unlock.h) \
$(wildcard include/config/inline/write/unlock.h) \
$(wildcard include/config/inline/read/unlock/bh.h) \
$(wildcard include/config/inline/write/unlock/bh.h) \
$(wildcard include/config/inline/read/unlock/irq.h) \
$(wildcard include/config/inline/write/unlock/irq.h) \
$(wildcard include/config/inline/read/unlock/irqrestore.h) \
$(wildcard include/config/inline/write/unlock/irqrestore.h) \
include/linux/time32.h \
include/linux/timex.h \
include/uapi/linux/timex.h \
include/uapi/linux/param.h \
arch/arm/include/generated/uapi/asm/param.h \
include/asm-generic/param.h \
$(wildcard include/config/hz.h) \
include/uapi/asm-generic/param.h \
arch/arm/include/asm/timex.h \
include/linux/uidgid.h \
$(wildcard include/config/multiuser.h) \
$(wildcard include/config/user/ns.h) \
include/linux/highuid.h \
include/linux/kmod.h \
include/linux/umh.h \
include/linux/gfp.h \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
$(wildcard include/config/zone/device.h) \
$(wildcard include/config/numa.h) \
$(wildcard include/config/pm/sleep.h) \
$(wildcard include/config/contig/alloc.h) \
$(wildcard include/config/cma.h) \
include/linux/mmdebug.h \
$(wildcard include/config/debug/vm.h) \
$(wildcard include/config/debug/vm/pgflags.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/isolation.h) \
$(wildcard include/config/shuffle/page/allocator.h) \
$(wildcard include/config/zsmalloc.h) \
$(wildcard include/config/memcg.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/compaction.h) \
$(wildcard include/config/transparent/hugepage.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/page/extension.h) \
$(wildcard include/config/deferred/struct/page/init.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/have/memoryless/nodes.h) \
$(wildcard include/config/have/memblock/node/map.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/memory/hotremove.h) \
$(wildcard include/config/holes/in/zone.h) \
$(wildcard include/config/arch/has/holes/memorymodel.h) \
include/linux/wait.h \
arch/arm/include/generated/asm/current.h \
include/asm-generic/current.h \
include/uapi/linux/wait.h \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/linux/nodemask.h \
include/linux/bitmap.h \
include/linux/string.h \
$(wildcard include/config/binary/printf.h) \
$(wildcard include/config/fortify/source.h) \
include/uapi/linux/string.h \
arch/arm/include/asm/string.h \
include/linux/pageblock-flags.h \
$(wildcard include/config/hugetlb/page.h) \
$(wildcard include/config/hugetlb/page/size/variable.h) \
include/linux/page-flags-layout.h \
$(wildcard include/config/numa/balancing.h) \
$(wildcard include/config/kasan/sw/tags.h) \
include/generated/bounds.h \
include/linux/mm_types.h \
$(wildcard include/config/have/aligned/struct/page.h) \
$(wildcard include/config/userfaultfd.h) \
$(wildcard include/config/swap.h) \
$(wildcard include/config/have/arch/compat/mmap/bases.h) \
$(wildcard include/config/membarrier.h) \
$(wildcard include/config/aio.h) \
$(wildcard include/config/mmu/notifier.h) \
$(wildcard include/config/arch/want/batched/unmap/tlb/flush.h) \
include/linux/mm_types_task.h \
$(wildcard include/config/split/ptlock/cpus.h) \
$(wildcard include/config/arch/enable/split/pmd/ptlock.h) \
include/linux/cpumask.h \
$(wildcard include/config/cpumask/offstack.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/debug/per/cpu/maps.h) \
include/linux/auxvec.h \
include/uapi/linux/auxvec.h \
include/linux/rbtree.h \
include/linux/rcupdate.h \
$(wildcard include/config/preempt/rcu.h) \
$(wildcard include/config/rcu/stall/common.h) \
$(wildcard include/config/no/hz/full.h) \
$(wildcard include/config/rcu/nocb/cpu.h) \
$(wildcard include/config/tasks/rcu.h) \
$(wildcard include/config/tree/rcu.h) \
$(wildcard include/config/tiny/rcu.h) \
$(wildcard include/config/debug/objects/rcu/head.h) \
$(wildcard include/config/prove/rcu.h) \
$(wildcard include/config/rcu/boost.h) \
$(wildcard include/config/arch/weak/release/acquire.h) \
include/linux/rcutree.h \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/spin/on/owner.h) \
$(wildcard include/config/debug/rwsems.h) \
include/linux/err.h \
arch/arm/include/generated/uapi/asm/errno.h \
include/uapi/asm-generic/errno.h \
include/uapi/asm-generic/errno-base.h \
include/linux/osq_lock.h \
include/linux/completion.h \
include/linux/uprobes.h \
$(wildcard include/config/uprobes.h) \
include/linux/errno.h \
include/uapi/linux/errno.h \
arch/arm/include/asm/uprobes.h \
arch/arm/include/asm/probes.h \
include/linux/workqueue.h \
$(wildcard include/config/debug/objects/work.h) \
$(wildcard include/config/freezer.h) \
$(wildcard include/config/wq/watchdog.h) \
include/linux/timer.h \
$(wildcard include/config/debug/objects/timers.h) \
$(wildcard include/config/preempt/rt.h) \
$(wildcard include/config/no/hz/common.h) \
include/linux/ktime.h \
include/linux/jiffies.h \
include/generated/timeconst.h \
include/linux/timekeeping.h \
include/linux/timekeeping32.h \
include/linux/debugobjects.h \
$(wildcard include/config/debug/objects.h) \
$(wildcard include/config/debug/objects/free.h) \
arch/arm/include/asm/mmu.h \
$(wildcard include/config/cpu/has/asid.h) \
include/linux/page-flags.h \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/idle/page/tracking.h) \
$(wildcard include/config/thp/swap.h) \
$(wildcard include/config/ksm.h) \
include/linux/memory_hotplug.h \
$(wildcard include/config/arch/has/add/pages.h) \
$(wildcard include/config/have/arch/nodedata/extension.h) \
$(wildcard include/config/have/bootmem/info/node.h) \
include/linux/notifier.h \
include/linux/mutex.h \
$(wildcard include/config/mutex/spin/on/owner.h) \
$(wildcard include/config/debug/mutexes.h) \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/srcu.h \
$(wildcard include/config/tiny/srcu.h) \
$(wildcard include/config/srcu.h) \
include/linux/rcu_segcblist.h \
include/linux/srcutree.h \
include/linux/rcu_node_tree.h \
$(wildcard include/config/rcu/fanout.h) \
$(wildcard include/config/rcu/fanout/leaf.h) \
include/linux/topology.h \
$(wildcard include/config/use/percpu/numa/node/id.h) \
$(wildcard include/config/sched/smt.h) \
include/linux/arch_topology.h \
$(wildcard include/config/generic/arch/topology.h) \
include/linux/percpu.h \
$(wildcard include/config/need/per/cpu/embed/first/chunk.h) \
$(wildcard include/config/need/per/cpu/page/first/chunk.h) \
$(wildcard include/config/have/setup/per/cpu/area.h) \
include/linux/smp.h \
$(wildcard include/config/up/late/init.h) \
include/linux/llist.h \
$(wildcard include/config/arch/have/nmi/safe/cmpxchg.h) \
arch/arm/include/asm/smp.h \
arch/arm/include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/percpu-defs.h \
$(wildcard include/config/debug/force/weak/per/cpu.h) \
$(wildcard include/config/amd/mem/encrypt.h) \
arch/arm/include/asm/topology.h \
$(wildcard include/config/arm/cpu/topology.h) \
include/asm-generic/topology.h \
include/linux/sysctl.h \
$(wildcard include/config/sysctl.h) \
include/uapi/linux/sysctl.h \
include/linux/kobject.h \
$(wildcard include/config/uevent/helper.h) \
$(wildcard include/config/debug/kobject/release.h) \
include/linux/sysfs.h \
include/linux/kernfs.h \
$(wildcard include/config/kernfs.h) \
include/linux/idr.h \
include/linux/radix-tree.h \
include/linux/xarray.h \
$(wildcard include/config/xarray/multi.h) \
include/linux/kconfig.h \
include/linux/kobject_ns.h \
include/linux/kref.h \
include/linux/refcount.h \
$(wildcard include/config/refcount/full.h) \
include/linux/moduleparam.h \
$(wildcard include/config/alpha.h) \
$(wildcard include/config/ia64.h) \
$(wildcard include/config/ppc64.h) \
include/linux/jump_label.h \
$(wildcard include/config/have/arch/jump/label/relative.h) \
include/linux/rbtree_latch.h \
include/linux/error-injection.h \
include/asm-generic/error-injection.h \
include/linux/tracepoint-defs.h \
include/linux/static_key.h \
arch/arm/include/asm/module.h \
$(wildcard include/config/arm/unwind.h) \
$(wildcard include/config/arm/module/plts.h) \
include/asm-generic/module.h \
$(wildcard include/config/have/mod/arch/specific.h) \
$(wildcard include/config/modules/use/elf/rel.h) \
$(wildcard include/config/modules/use/elf/rela.h) \
include/linux/vermagic.h \
include/generated/utsrelease.h \
/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o: $(deps_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o)
$(deps_/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.mod.o):

1089
3-new-led/.new_char.o.cmd Normal file

File diff suppressed because it is too large Load Diff

20
3-new-led/.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include/generated"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

11
3-new-led/Makefile Normal file
View File

@ -0,0 +1,11 @@
Kernel_dir := /home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31
current_dir := $(shell pwd)
obj-m := new_char.o
build: kernel_modules
kernel_modules:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) modules
clean:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) clean

0
3-new-led/Module.symvers Normal file
View File

3
3-new-led/build Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

3
3-new-led/build.sh Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

1
3-new-led/modules.order Normal file
View File

@ -0,0 +1 @@
/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.ko

139
3-new-led/new_char.c Normal file
View File

@ -0,0 +1,139 @@
/*
* @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @Date: 2023-08-19 09:31:52
* @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @LastEditTime: 2023-08-19 10:42:49
* @FilePath: /3-new-led/led.c
* @Description: ,`customMade`, koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <asm/mach/map.h>
#include <asm/uaccess.h>
#include <asm/io.h>
/***
* configuration
*/
// DEV_NAME
#define dev_name "newchr"
// DEV_ID配置
#define DEV_ID_STATIC 1
#if DEV_ID_STATIC
#define DEV_ID_MAJOR 80
#define DEV_ID_MINOR 0
#endif
struct _dev_info
{
dev_t dev_id;
struct cdev cdev;
struct class *class;
struct device *device;
} dev_info = {0};
/***
* code
*/
static ssize_t tis_module_read(struct file *file, char __user *out, size_t size, loff_t *offt)
{
printk("%s: module read\n", dev_name);
return 0;
}
static ssize_t tis_module_write(struct file *file, const char __user *in, size_t size, loff_t *offt)
{
printk("%s: module write\n", dev_name);
return 0;
}
static int tis_module_open(struct inode *inode, struct file *file)
{
printk("%s: module open\n", dev_name);
return 0;
}
static int tis_module_release(struct inode *inode, struct file *file)
{
printk("%s: module release\n", dev_name);
return 0;
}
static struct file_operations tis_module_f = {
.owner = THIS_MODULE,
.write = tis_module_write,
.read = tis_module_read,
.open = tis_module_open,
.release = tis_module_release,
};
static int __init tis_module_init(void)
{
int ret;
// 申请dev id
#if (DEV_ID_STATIC)
dev_info.dev_id = MKDEV(DEV_ID_MAJOR, DEV_ID_MINOR);
ret = register_chrdev_region(dev_info.dev_id, 1, dev_name);
if (ret < 0)
{
printk("[%s] dev_id get failed\n",dev_name);
return ret;
}
#else
ret = alloc_chrdev_region(&dev_info.dev_id, 0, 1, dev_name);
if (ret)
{
printk("[%s] dev_id get failed\n");
return ret;
}
#endif
// 注册设备
dev_info.cdev.owner = THIS_MODULE;
cdev_init(&dev_info.cdev, &tis_module_f);
ret = cdev_add(&dev_info.cdev, dev_info.dev_id, 1);
if (ret < 0)
{
printk("[%s] cdev_add failed\n", dev_name);
goto del_unregister;
}
// 创建设备
dev_info.class = class_create(THIS_MODULE, dev_name);
if (IS_ERR(dev_info.class))
{
printk("[%s] class create failed\n", dev_name);
goto del_cdev;
}
dev_info.device = device_create(dev_info.class, NULL, dev_info.dev_id, NULL, dev_name);
if (IS_ERR(dev_info.device))
{
printk("[%s] dev create failed\n", dev_name);
goto destroy_class;
}
printk("[%s] init success\n", dev_name);
return 0;
destroy_class:
class_destroy(dev_info.class);
del_cdev:
cdev_del(&dev_info.cdev);
del_unregister:
unregister_chrdev_region(dev_info.dev_id, 1);
return -EIO;
}
static void __exit tis_module_exit(void)
{
/* 注销字符设备驱动 */
cdev_del(&dev_info.cdev); /* 删除cdev */
unregister_chrdev_region(dev_info.dev_id, 1); /* 注销设备号 */
device_destroy(dev_info.class, dev_info.dev_id);
class_destroy(dev_info.class);
printk("[%s] exit success\n", dev_name);
}
module_init(tis_module_init);
module_exit(tis_module_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("chenyf");
MODULE_INFO(intree, "Y");

BIN
3-new-led/new_char.ko Normal file

Binary file not shown.

2
3-new-led/new_char.mod Normal file
View File

@ -0,0 +1,2 @@
/home/chenyf/desktop/stm32mp157/driver/3-new-led/new_char.o

42
3-new-led/new_char.mod.c Normal file
View File

@ -0,0 +1,42 @@
#include <linux/build-salt.h>
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
BUILD_SALT;
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_INFO(name, KBUILD_MODNAME);
__visible struct module __this_module
__section(.gnu.linkonce.this_module) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
#ifdef CONFIG_RETPOLINE
MODULE_INFO(retpoline, "Y");
#endif
static const struct modversion_info ____versions[]
__used __section(__versions) = {
{ 0x4b3323eb, "module_layout" },
{ 0x7e5a3c80, "device_destroy" },
{ 0x6091b333, "unregister_chrdev_region" },
{ 0xff2f3447, "cdev_del" },
{ 0x75736401, "class_destroy" },
{ 0x2131a349, "device_create" },
{ 0x9192c2a4, "__class_create" },
{ 0xdd504b4a, "cdev_add" },
{ 0x294045e0, "cdev_init" },
{ 0x3fd78f3b, "register_chrdev_region" },
{ 0xefd6cf06, "__aeabi_unwind_cpp_pr0" },
{ 0xc5850110, "printk" },
};
MODULE_INFO(depends, "");

BIN
3-new-led/new_char.mod.o Normal file

Binary file not shown.

BIN
3-new-led/new_char.o Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.ko := arm-none-linux-gnueabihf-ld -r -EL --build-id -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds -o /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.ko /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.o /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o; true

View File

@ -0,0 +1 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod := { echo /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.o; echo; } > /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod

View File

@ -0,0 +1,537 @@
cmd_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o := arm-none-linux-gnueabihf-gcc -Wp,-MD,/home/chenyf/desktop/stm32mp157/driver/4-device-tree/.led.mod.o.d -nostdinc -isystem /home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -fno-inline-functions-called-once -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME='"led.mod"' -DKBUILD_MODNAME='"led"' -c -o /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.c
source_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o := /home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.c
deps_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o := \
$(wildcard include/config/module/unload.h) \
$(wildcard include/config/retpoline.h) \
include/linux/kconfig.h \
$(wildcard include/config/cpu/big/endian.h) \
$(wildcard include/config/booger.h) \
$(wildcard include/config/foo.h) \
include/linux/compiler_types.h \
$(wildcard include/config/have/arch/compiler/h.h) \
$(wildcard include/config/enable/must/check.h) \
$(wildcard include/config/optimize/inlining.h) \
$(wildcard include/config/cc/has/asm/inline.h) \
include/linux/compiler_attributes.h \
include/linux/compiler-gcc.h \
$(wildcard include/config/arch/use/builtin/bswap.h) \
include/linux/build-salt.h \
$(wildcard include/config/build/salt.h) \
include/linux/elfnote.h \
include/linux/elf.h \
arch/arm/include/asm/elf.h \
$(wildcard include/config/mmu.h) \
$(wildcard include/config/vdso.h) \
arch/arm/include/asm/auxvec.h \
arch/arm/include/uapi/asm/auxvec.h \
arch/arm/include/asm/hwcap.h \
arch/arm/include/uapi/asm/hwcap.h \
arch/arm/include/asm/vdso_datapage.h \
arch/arm/include/asm/page.h \
$(wildcard include/config/cpu/copy/v4wt.h) \
$(wildcard include/config/cpu/copy/v4wb.h) \
$(wildcard include/config/cpu/copy/feroceon.h) \
$(wildcard include/config/cpu/copy/fa.h) \
$(wildcard include/config/cpu/sa1100.h) \
$(wildcard include/config/cpu/xscale.h) \
$(wildcard include/config/cpu/xsc3.h) \
$(wildcard include/config/cpu/copy/v6.h) \
$(wildcard include/config/kuser/helpers.h) \
$(wildcard include/config/arm/lpae.h) \
$(wildcard include/config/have/arch/pfn/valid.h) \
arch/arm/include/asm/glue.h \
arch/arm/include/asm/pgtable-2level-types.h \
arch/arm/include/uapi/asm/types.h \
include/asm-generic/int-ll64.h \
include/uapi/asm-generic/int-ll64.h \
arch/arm/include/generated/uapi/asm/bitsperlong.h \
include/asm-generic/bitsperlong.h \
$(wildcard include/config/64bit.h) \
include/uapi/asm-generic/bitsperlong.h \
arch/arm/include/asm/memory.h \
$(wildcard include/config/need/mach/memory/h.h) \
$(wildcard include/config/page/offset.h) \
$(wildcard include/config/thumb2/kernel.h) \
$(wildcard include/config/highmem.h) \
$(wildcard include/config/smp.h) \
$(wildcard include/config/dram/base.h) \
$(wildcard include/config/dram/size.h) \
$(wildcard include/config/xip/kernel.h) \
$(wildcard include/config/have/tcm.h) \
$(wildcard include/config/arm/patch/phys/virt.h) \
$(wildcard include/config/phys/offset.h) \
$(wildcard include/config/xip/phys/addr.h) \
$(wildcard include/config/debug/virtual.h) \
include/linux/compiler.h \
$(wildcard include/config/trace/branch/profiling.h) \
$(wildcard include/config/profile/all/branches.h) \
$(wildcard include/config/stack/validation.h) \
$(wildcard include/config/kasan.h) \
include/linux/compiler_types.h \
include/uapi/linux/types.h \
include/uapi/linux/posix_types.h \
include/linux/stddef.h \
include/uapi/linux/stddef.h \
arch/arm/include/uapi/asm/posix_types.h \
include/uapi/asm-generic/posix_types.h \
arch/arm/include/asm/barrier.h \
$(wildcard include/config/cpu/32v6k.h) \
$(wildcard include/config/cpu/fa526.h) \
$(wildcard include/config/arm/heavy/mb.h) \
$(wildcard include/config/arm/dma/mem/bufferable.h) \
$(wildcard include/config/cpu/spectre.h) \
include/asm-generic/barrier.h \
include/linux/kasan-checks.h \
include/linux/types.h \
$(wildcard include/config/have/uid16.h) \
$(wildcard include/config/uid16.h) \
$(wildcard include/config/arch/dma/addr/t/64bit.h) \
$(wildcard include/config/phys/addr/t/64bit.h) \
include/linux/const.h \
include/uapi/linux/const.h \
include/linux/sizes.h \
include/asm-generic/memory_model.h \
$(wildcard include/config/flatmem.h) \
$(wildcard include/config/discontigmem.h) \
$(wildcard include/config/sparsemem/vmemmap.h) \
$(wildcard include/config/sparsemem.h) \
include/linux/pfn.h \
include/asm-generic/getorder.h \
include/linux/log2.h \
$(wildcard include/config/arch/has/ilog2/u32.h) \
$(wildcard include/config/arch/has/ilog2/u64.h) \
include/linux/bitops.h \
include/linux/bits.h \
arch/arm/include/asm/bitops.h \
include/linux/irqflags.h \
$(wildcard include/config/prove/locking.h) \
$(wildcard include/config/trace/irqflags.h) \
$(wildcard include/config/irqsoff/tracer.h) \
$(wildcard include/config/preempt/tracer.h) \
$(wildcard include/config/trace/irqflags/support.h) \
include/linux/typecheck.h \
arch/arm/include/asm/irqflags.h \
$(wildcard include/config/cpu/v7m.h) \
arch/arm/include/asm/ptrace.h \
$(wildcard include/config/arm/thumb.h) \
arch/arm/include/uapi/asm/ptrace.h \
$(wildcard include/config/cpu/endian/be8.h) \
include/asm-generic/irqflags.h \
include/asm-generic/bitops/non-atomic.h \
include/asm-generic/bitops/builtin-__fls.h \
include/asm-generic/bitops/builtin-__ffs.h \
include/asm-generic/bitops/builtin-fls.h \
include/asm-generic/bitops/builtin-ffs.h \
include/asm-generic/bitops/ffz.h \
include/asm-generic/bitops/fls64.h \
include/asm-generic/bitops/sched.h \
include/asm-generic/bitops/hweight.h \
include/asm-generic/bitops/arch_hweight.h \
include/asm-generic/bitops/const_hweight.h \
include/asm-generic/bitops/lock.h \
include/linux/atomic.h \
arch/arm/include/asm/atomic.h \
$(wildcard include/config/generic/atomic64.h) \
include/linux/prefetch.h \
arch/arm/include/asm/processor.h \
$(wildcard include/config/have/hw/breakpoint.h) \
$(wildcard include/config/binfmt/elf/fdpic.h) \
$(wildcard include/config/arm/errata/754327.h) \
arch/arm/include/asm/hw_breakpoint.h \
arch/arm/include/asm/unified.h \
arch/arm/include/asm/cache.h \
$(wildcard include/config/arm/l1/cache/shift.h) \
$(wildcard include/config/aeabi.h) \
arch/arm/include/asm/cmpxchg.h \
$(wildcard include/config/cpu/sa110.h) \
$(wildcard include/config/cpu/v6.h) \
include/asm-generic/cmpxchg-local.h \
include/linux/atomic-fallback.h \
include/asm-generic/atomic-long.h \
include/asm-generic/bitops/find.h \
$(wildcard include/config/generic/find/first/bit.h) \
include/asm-generic/bitops/le.h \
arch/arm/include/uapi/asm/byteorder.h \
include/linux/byteorder/little_endian.h \
include/uapi/linux/byteorder/little_endian.h \
include/linux/swab.h \
include/uapi/linux/swab.h \
arch/arm/include/asm/swab.h \
arch/arm/include/uapi/asm/swab.h \
include/linux/byteorder/generic.h \
include/asm-generic/bitops/ext2-atomic-setbit.h \
arch/arm/include/asm/user.h \
include/uapi/linux/elf.h \
include/uapi/linux/elf-em.h \
include/linux/module.h \
$(wildcard include/config/modules.h) \
$(wildcard include/config/sysfs.h) \
$(wildcard include/config/modules/tree/lookup.h) \
$(wildcard include/config/livepatch.h) \
$(wildcard include/config/unused/symbols.h) \
$(wildcard include/config/module/sig.h) \
$(wildcard include/config/generic/bug.h) \
$(wildcard include/config/kallsyms.h) \
$(wildcard include/config/tracepoints.h) \
$(wildcard include/config/tree/srcu.h) \
$(wildcard include/config/bpf/events.h) \
$(wildcard include/config/jump/label.h) \
$(wildcard include/config/tracing.h) \
$(wildcard include/config/event/tracing.h) \
$(wildcard include/config/ftrace/mcount/record.h) \
$(wildcard include/config/constructors.h) \
$(wildcard include/config/function/error/injection.h) \
$(wildcard include/config/strict/module/rwx.h) \
include/linux/list.h \
$(wildcard include/config/debug/list.h) \
include/linux/poison.h \
$(wildcard include/config/illegal/pointer/value.h) \
$(wildcard include/config/page/poisoning/zero.h) \
include/linux/kernel.h \
$(wildcard include/config/preempt/voluntary.h) \
$(wildcard include/config/debug/atomic/sleep.h) \
$(wildcard include/config/arch/has/refcount.h) \
$(wildcard include/config/panic/timeout.h) \
/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/9.2.1/include/stdarg.h \
include/linux/limits.h \
include/uapi/linux/limits.h \
include/linux/linkage.h \
include/linux/stringify.h \
include/linux/export.h \
$(wildcard include/config/modversions.h) \
$(wildcard include/config/module/rel/crcs.h) \
$(wildcard include/config/have/arch/prel32/relocations.h) \
$(wildcard include/config/trim/unused/ksyms.h) \
arch/arm/include/asm/linkage.h \
include/linux/printk.h \
$(wildcard include/config/message/loglevel/default.h) \
$(wildcard include/config/console/loglevel/default.h) \
$(wildcard include/config/console/loglevel/quiet.h) \
$(wildcard include/config/early/printk.h) \
$(wildcard include/config/printk/nmi.h) \
$(wildcard include/config/printk.h) \
$(wildcard include/config/dynamic/debug.h) \
include/linux/init.h \
$(wildcard include/config/strict/kernel/rwx.h) \
include/linux/kern_levels.h \
include/linux/cache.h \
$(wildcard include/config/arch/has/cache/line/size.h) \
include/uapi/linux/kernel.h \
include/uapi/linux/sysinfo.h \
include/linux/dynamic_debug.h \
include/linux/build_bug.h \
arch/arm/include/asm/div64.h \
arch/arm/include/asm/compiler.h \
include/asm-generic/div64.h \
include/linux/stat.h \
arch/arm/include/uapi/asm/stat.h \
include/uapi/linux/stat.h \
include/linux/time.h \
$(wildcard include/config/arch/uses/gettimeoffset.h) \
include/linux/seqlock.h \
$(wildcard include/config/debug/lock/alloc.h) \
include/linux/spinlock.h \
$(wildcard include/config/debug/spinlock.h) \
$(wildcard include/config/preemption.h) \
include/linux/preempt.h \
$(wildcard include/config/preempt/count.h) \
$(wildcard include/config/debug/preempt.h) \
$(wildcard include/config/trace/preempt/toggle.h) \
$(wildcard include/config/preempt/notifiers.h) \
arch/arm/include/generated/asm/preempt.h \
include/asm-generic/preempt.h \
include/linux/thread_info.h \
$(wildcard include/config/thread/info/in/task.h) \
$(wildcard include/config/have/arch/within/stack/frames.h) \
$(wildcard include/config/hardened/usercopy.h) \
include/linux/bug.h \
$(wildcard include/config/bug/on/data/corruption.h) \
arch/arm/include/asm/bug.h \
$(wildcard include/config/debug/bugverbose.h) \
arch/arm/include/asm/opcodes.h \
$(wildcard include/config/cpu/endian/be32.h) \
include/asm-generic/bug.h \
$(wildcard include/config/bug.h) \
$(wildcard include/config/generic/bug/relative/pointers.h) \
include/linux/restart_block.h \
include/linux/time64.h \
include/linux/math64.h \
$(wildcard include/config/arch/supports/int128.h) \
include/uapi/linux/time.h \
include/uapi/linux/time_types.h \
arch/arm/include/asm/thread_info.h \
$(wildcard include/config/stackprotector/per/task.h) \
$(wildcard include/config/crunch.h) \
$(wildcard include/config/arm/thumbee.h) \
arch/arm/include/asm/fpstate.h \
$(wildcard include/config/vfpv3.h) \
$(wildcard include/config/iwmmxt.h) \
include/linux/bottom_half.h \
arch/arm/include/generated/asm/mmiowb.h \
include/asm-generic/mmiowb.h \
$(wildcard include/config/mmiowb.h) \
include/linux/spinlock_types.h \
arch/arm/include/asm/spinlock_types.h \
include/linux/lockdep.h \
$(wildcard include/config/lockdep.h) \
$(wildcard include/config/lock/stat.h) \
include/linux/rwlock_types.h \
arch/arm/include/asm/spinlock.h \
include/linux/rwlock.h \
$(wildcard include/config/preempt.h) \
include/linux/spinlock_api_smp.h \
$(wildcard include/config/inline/spin/lock.h) \
$(wildcard include/config/inline/spin/lock/bh.h) \
$(wildcard include/config/inline/spin/lock/irq.h) \
$(wildcard include/config/inline/spin/lock/irqsave.h) \
$(wildcard include/config/inline/spin/trylock.h) \
$(wildcard include/config/inline/spin/trylock/bh.h) \
$(wildcard include/config/uninline/spin/unlock.h) \
$(wildcard include/config/inline/spin/unlock/bh.h) \
$(wildcard include/config/inline/spin/unlock/irq.h) \
$(wildcard include/config/inline/spin/unlock/irqrestore.h) \
$(wildcard include/config/generic/lockbreak.h) \
include/linux/rwlock_api_smp.h \
$(wildcard include/config/inline/read/lock.h) \
$(wildcard include/config/inline/write/lock.h) \
$(wildcard include/config/inline/read/lock/bh.h) \
$(wildcard include/config/inline/write/lock/bh.h) \
$(wildcard include/config/inline/read/lock/irq.h) \
$(wildcard include/config/inline/write/lock/irq.h) \
$(wildcard include/config/inline/read/lock/irqsave.h) \
$(wildcard include/config/inline/write/lock/irqsave.h) \
$(wildcard include/config/inline/read/trylock.h) \
$(wildcard include/config/inline/write/trylock.h) \
$(wildcard include/config/inline/read/unlock.h) \
$(wildcard include/config/inline/write/unlock.h) \
$(wildcard include/config/inline/read/unlock/bh.h) \
$(wildcard include/config/inline/write/unlock/bh.h) \
$(wildcard include/config/inline/read/unlock/irq.h) \
$(wildcard include/config/inline/write/unlock/irq.h) \
$(wildcard include/config/inline/read/unlock/irqrestore.h) \
$(wildcard include/config/inline/write/unlock/irqrestore.h) \
include/linux/time32.h \
include/linux/timex.h \
include/uapi/linux/timex.h \
include/uapi/linux/param.h \
arch/arm/include/generated/uapi/asm/param.h \
include/asm-generic/param.h \
$(wildcard include/config/hz.h) \
include/uapi/asm-generic/param.h \
arch/arm/include/asm/timex.h \
include/linux/uidgid.h \
$(wildcard include/config/multiuser.h) \
$(wildcard include/config/user/ns.h) \
include/linux/highuid.h \
include/linux/kmod.h \
include/linux/umh.h \
include/linux/gfp.h \
$(wildcard include/config/zone/dma.h) \
$(wildcard include/config/zone/dma32.h) \
$(wildcard include/config/zone/device.h) \
$(wildcard include/config/numa.h) \
$(wildcard include/config/pm/sleep.h) \
$(wildcard include/config/contig/alloc.h) \
$(wildcard include/config/cma.h) \
include/linux/mmdebug.h \
$(wildcard include/config/debug/vm.h) \
$(wildcard include/config/debug/vm/pgflags.h) \
include/linux/mmzone.h \
$(wildcard include/config/force/max/zoneorder.h) \
$(wildcard include/config/memory/isolation.h) \
$(wildcard include/config/shuffle/page/allocator.h) \
$(wildcard include/config/zsmalloc.h) \
$(wildcard include/config/memcg.h) \
$(wildcard include/config/memory/hotplug.h) \
$(wildcard include/config/compaction.h) \
$(wildcard include/config/transparent/hugepage.h) \
$(wildcard include/config/flat/node/mem/map.h) \
$(wildcard include/config/page/extension.h) \
$(wildcard include/config/deferred/struct/page/init.h) \
$(wildcard include/config/have/memory/present.h) \
$(wildcard include/config/have/memoryless/nodes.h) \
$(wildcard include/config/have/memblock/node/map.h) \
$(wildcard include/config/need/multiple/nodes.h) \
$(wildcard include/config/have/arch/early/pfn/to/nid.h) \
$(wildcard include/config/sparsemem/extreme.h) \
$(wildcard include/config/memory/hotremove.h) \
$(wildcard include/config/holes/in/zone.h) \
$(wildcard include/config/arch/has/holes/memorymodel.h) \
include/linux/wait.h \
arch/arm/include/generated/asm/current.h \
include/asm-generic/current.h \
include/uapi/linux/wait.h \
include/linux/threads.h \
$(wildcard include/config/nr/cpus.h) \
$(wildcard include/config/base/small.h) \
include/linux/numa.h \
$(wildcard include/config/nodes/shift.h) \
include/linux/nodemask.h \
include/linux/bitmap.h \
include/linux/string.h \
$(wildcard include/config/binary/printf.h) \
$(wildcard include/config/fortify/source.h) \
include/uapi/linux/string.h \
arch/arm/include/asm/string.h \
include/linux/pageblock-flags.h \
$(wildcard include/config/hugetlb/page.h) \
$(wildcard include/config/hugetlb/page/size/variable.h) \
include/linux/page-flags-layout.h \
$(wildcard include/config/numa/balancing.h) \
$(wildcard include/config/kasan/sw/tags.h) \
include/generated/bounds.h \
include/linux/mm_types.h \
$(wildcard include/config/have/aligned/struct/page.h) \
$(wildcard include/config/userfaultfd.h) \
$(wildcard include/config/swap.h) \
$(wildcard include/config/have/arch/compat/mmap/bases.h) \
$(wildcard include/config/membarrier.h) \
$(wildcard include/config/aio.h) \
$(wildcard include/config/mmu/notifier.h) \
$(wildcard include/config/arch/want/batched/unmap/tlb/flush.h) \
include/linux/mm_types_task.h \
$(wildcard include/config/split/ptlock/cpus.h) \
$(wildcard include/config/arch/enable/split/pmd/ptlock.h) \
include/linux/cpumask.h \
$(wildcard include/config/cpumask/offstack.h) \
$(wildcard include/config/hotplug/cpu.h) \
$(wildcard include/config/debug/per/cpu/maps.h) \
include/linux/auxvec.h \
include/uapi/linux/auxvec.h \
include/linux/rbtree.h \
include/linux/rcupdate.h \
$(wildcard include/config/preempt/rcu.h) \
$(wildcard include/config/rcu/stall/common.h) \
$(wildcard include/config/no/hz/full.h) \
$(wildcard include/config/rcu/nocb/cpu.h) \
$(wildcard include/config/tasks/rcu.h) \
$(wildcard include/config/tree/rcu.h) \
$(wildcard include/config/tiny/rcu.h) \
$(wildcard include/config/debug/objects/rcu/head.h) \
$(wildcard include/config/prove/rcu.h) \
$(wildcard include/config/rcu/boost.h) \
$(wildcard include/config/arch/weak/release/acquire.h) \
include/linux/rcutree.h \
include/linux/rwsem.h \
$(wildcard include/config/rwsem/spin/on/owner.h) \
$(wildcard include/config/debug/rwsems.h) \
include/linux/err.h \
arch/arm/include/generated/uapi/asm/errno.h \
include/uapi/asm-generic/errno.h \
include/uapi/asm-generic/errno-base.h \
include/linux/osq_lock.h \
include/linux/completion.h \
include/linux/uprobes.h \
$(wildcard include/config/uprobes.h) \
include/linux/errno.h \
include/uapi/linux/errno.h \
arch/arm/include/asm/uprobes.h \
arch/arm/include/asm/probes.h \
include/linux/workqueue.h \
$(wildcard include/config/debug/objects/work.h) \
$(wildcard include/config/freezer.h) \
$(wildcard include/config/wq/watchdog.h) \
include/linux/timer.h \
$(wildcard include/config/debug/objects/timers.h) \
$(wildcard include/config/preempt/rt.h) \
$(wildcard include/config/no/hz/common.h) \
include/linux/ktime.h \
include/linux/jiffies.h \
include/generated/timeconst.h \
include/linux/timekeeping.h \
include/linux/timekeeping32.h \
include/linux/debugobjects.h \
$(wildcard include/config/debug/objects.h) \
$(wildcard include/config/debug/objects/free.h) \
arch/arm/include/asm/mmu.h \
$(wildcard include/config/cpu/has/asid.h) \
include/linux/page-flags.h \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/idle/page/tracking.h) \
$(wildcard include/config/thp/swap.h) \
$(wildcard include/config/ksm.h) \
include/linux/memory_hotplug.h \
$(wildcard include/config/arch/has/add/pages.h) \
$(wildcard include/config/have/arch/nodedata/extension.h) \
$(wildcard include/config/have/bootmem/info/node.h) \
include/linux/notifier.h \
include/linux/mutex.h \
$(wildcard include/config/mutex/spin/on/owner.h) \
$(wildcard include/config/debug/mutexes.h) \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/srcu.h \
$(wildcard include/config/tiny/srcu.h) \
$(wildcard include/config/srcu.h) \
include/linux/rcu_segcblist.h \
include/linux/srcutree.h \
include/linux/rcu_node_tree.h \
$(wildcard include/config/rcu/fanout.h) \
$(wildcard include/config/rcu/fanout/leaf.h) \
include/linux/topology.h \
$(wildcard include/config/use/percpu/numa/node/id.h) \
$(wildcard include/config/sched/smt.h) \
include/linux/arch_topology.h \
$(wildcard include/config/generic/arch/topology.h) \
include/linux/percpu.h \
$(wildcard include/config/need/per/cpu/embed/first/chunk.h) \
$(wildcard include/config/need/per/cpu/page/first/chunk.h) \
$(wildcard include/config/have/setup/per/cpu/area.h) \
include/linux/smp.h \
$(wildcard include/config/up/late/init.h) \
include/linux/llist.h \
$(wildcard include/config/arch/have/nmi/safe/cmpxchg.h) \
arch/arm/include/asm/smp.h \
arch/arm/include/asm/percpu.h \
include/asm-generic/percpu.h \
include/linux/percpu-defs.h \
$(wildcard include/config/debug/force/weak/per/cpu.h) \
$(wildcard include/config/amd/mem/encrypt.h) \
arch/arm/include/asm/topology.h \
$(wildcard include/config/arm/cpu/topology.h) \
include/asm-generic/topology.h \
include/linux/sysctl.h \
$(wildcard include/config/sysctl.h) \
include/uapi/linux/sysctl.h \
include/linux/kobject.h \
$(wildcard include/config/uevent/helper.h) \
$(wildcard include/config/debug/kobject/release.h) \
include/linux/sysfs.h \
include/linux/kernfs.h \
$(wildcard include/config/kernfs.h) \
include/linux/idr.h \
include/linux/radix-tree.h \
include/linux/xarray.h \
$(wildcard include/config/xarray/multi.h) \
include/linux/kconfig.h \
include/linux/kobject_ns.h \
include/linux/kref.h \
include/linux/refcount.h \
$(wildcard include/config/refcount/full.h) \
include/linux/moduleparam.h \
$(wildcard include/config/alpha.h) \
$(wildcard include/config/ia64.h) \
$(wildcard include/config/ppc64.h) \
include/linux/jump_label.h \
$(wildcard include/config/have/arch/jump/label/relative.h) \
include/linux/rbtree_latch.h \
include/linux/error-injection.h \
include/asm-generic/error-injection.h \
include/linux/tracepoint-defs.h \
include/linux/static_key.h \
arch/arm/include/asm/module.h \
$(wildcard include/config/arm/unwind.h) \
$(wildcard include/config/arm/module/plts.h) \
include/asm-generic/module.h \
$(wildcard include/config/have/mod/arch/specific.h) \
$(wildcard include/config/modules/use/elf/rel.h) \
$(wildcard include/config/modules/use/elf/rela.h) \
include/linux/vermagic.h \
include/generated/utsrelease.h \
/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o: $(deps_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o)
$(deps_/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.mod.o):

1089
4-device-tree/.led.o.cmd Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include",
"/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/arch/arm/include/generated"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

11
4-device-tree/Makefile Normal file
View File

@ -0,0 +1,11 @@
Kernel_dir := /home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31
current_dir := $(shell pwd)
obj-m := led.o
build: kernel_modules
kernel_modules:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) modules
clean:
$(MAKE) -C $(Kernel_dir) M=$(current_dir) clean

View File

3
4-device-tree/build Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

3
4-device-tree/build.sh Executable file
View File

@ -0,0 +1,3 @@
#env var
export PATH=$PATH:/home/chenyf/desktop/stm32mp157/toolchian/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
make

333
4-device-tree/dtsled.c Executable file
View File

@ -0,0 +1,333 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <asm/mach/map.h>
#include <asm/uaccess.h>
#include <asm/io.h>
/***************************************************************
Copyright © ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
: dtsled.c
: Linux团队
: V1.0
: LED驱动文件
:
: www.openedv.com
: V1.0 2020/12/19 Linux团队创建
***************************************************************/
#define DTSLED_CNT 1 /* 设备号个数 */
#define DTSLED_NAME "dtsled" /* 名字 */
#define LEDOFF 0 /* 关灯 */
#define LEDON 1 /* 开灯 */
/* 映射后的寄存器虚拟地址指针 */
static void __iomem *MPU_AHB4_PERIPH_RCC_PI;
static void __iomem *GPIOI_MODER_PI;
static void __iomem *GPIOI_OTYPER_PI;
static void __iomem *GPIOI_OSPEEDR_PI;
static void __iomem *GPIOI_PUPDR_PI;
static void __iomem *GPIOI_BSRR_PI;
/* dtsled设备结构体 */
struct dtsled_dev{
dev_t devid; /* 设备号 */
struct cdev cdev; /* cdev */
struct class *class; /* 类 */
struct device *device; /* 设备 */
int major; /* 主设备号 */
int minor; /* 次设备号 */
struct device_node *nd; /* 设备节点 */
};
struct dtsled_dev dtsled; /* led设备 */
/*
* @description : LED打开/
* @param - sta : LEDON(0) LEDLEDOFF(1) LED
* @return :
*/
void led_switch(u8 sta)
{
u32 val = 0;
if(sta == LEDON) {
val = readl(GPIOI_BSRR_PI);
val |= (1 << 16);
writel(val, GPIOI_BSRR_PI);
}else if(sta == LEDOFF) {
val = readl(GPIOI_BSRR_PI);
val|= (1 << 0);
writel(val, GPIOI_BSRR_PI);
}
}
/*
* @description :
* @return :
*/
void led_unmap(void)
{
/* 取消映射 */
iounmap(MPU_AHB4_PERIPH_RCC_PI);
iounmap(GPIOI_MODER_PI);
iounmap(GPIOI_OTYPER_PI);
iounmap(GPIOI_OSPEEDR_PI);
iounmap(GPIOI_PUPDR_PI);
iounmap(GPIOI_BSRR_PI);
}
/*
* @description :
* @param - inode : inode
* @param - filp : file结构体有个叫做private_data的成员变量
* open的时候将private_data指向设备结构体
* @return : 0 ;
*/
static int led_open(struct inode *inode, struct file *filp)
{
filp->private_data = &dtsled; /* 设置私有数据 */
return 0;
}
/*
* @description :
* @param - filp : ()
* @param - buf :
* @param - cnt :
* @param - offt :
* @return :
*/
static ssize_t led_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt)
{
return 0;
}
/*
* @description :
* @param - filp :
* @param - buf :
* @param - cnt :
* @param - offt :
* @return :
*/
static ssize_t led_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offt)
{
int retvalue;
unsigned char databuf[1];
unsigned char ledstat;
retvalue = copy_from_user(databuf, buf, cnt);
if(retvalue < 0) {
printk("kernel write failed!\r\n");
return -EFAULT;
}
ledstat = databuf[0]; /* 获取状态值 */
if(ledstat == LEDON) {
led_switch(LEDON); /* 打开LED灯 */
} else if(ledstat == LEDOFF) {
led_switch(LEDOFF); /* 关闭LED灯 */
}
return 0;
}
/*
* @description : /
* @param - filp : ()
* @return : 0 ;
*/
static int led_release(struct inode *inode, struct file *filp)
{
return 0;
}
/* 设备操作函数 */
static struct file_operations dtsled_fops = {
.owner = THIS_MODULE,
.open = led_open,
.read = led_read,
.write = led_write,
.release = led_release,
};
/*
* @description :
* @param :
* @return :
*/
static int __init led_init(void)
{
u32 val = 0;
int ret;
u32 regdata[12];
const char *str;
struct property *proper;
/* 获取设备树中的属性数据 */
/* 1、获取设备节点stm32mp1_led */
dtsled.nd = of_find_node_by_path("/stm32mp1_led");
if(dtsled.nd == NULL) {
printk("stm32mp1_led node nost find!\r\n");
return -EINVAL;
} else {
printk("stm32mp1_lcd node find!\r\n");
}
/* 2、获取compatible属性内容 */
proper = of_find_property(dtsled.nd, "compatible", NULL);
if(proper == NULL) {
printk("compatible property find failed\r\n");
} else {
printk("compatible = %s\r\n", (char*)proper->value);
}
/* 3、获取status属性内容 */
ret = of_property_read_string(dtsled.nd, "status", &str);
if(ret < 0){
printk("status read failed!\r\n");
} else {
printk("status = %s\r\n",str);
}
/* 4、获取reg属性内容 */
ret = of_property_read_u32_array(dtsled.nd, "reg", regdata, 12);
if(ret < 0) {
printk("reg property read failed!\r\n");
} else {
u8 i = 0;
printk("reg data:\r\n");
for(i = 0; i < 12; i++)
printk("%#X ", regdata[i]);
printk("\r\n");
}
/* 初始化LED */
/* 1、寄存器地址映射 */
MPU_AHB4_PERIPH_RCC_PI = of_iomap(dtsled.nd, 0);
GPIOI_MODER_PI = of_iomap(dtsled.nd, 1);
GPIOI_OTYPER_PI = of_iomap(dtsled.nd, 2);
GPIOI_OSPEEDR_PI = of_iomap(dtsled.nd, 3);
GPIOI_PUPDR_PI = of_iomap(dtsled.nd, 4);
GPIOI_BSRR_PI = of_iomap(dtsled.nd, 5);
/* 2、使能PI时钟 */
val = readl(MPU_AHB4_PERIPH_RCC_PI);
val &= ~(0X1 << 8); /* 清除以前的设置 */
val |= (0X1 << 8); /* 设置新值 */
writel(val, MPU_AHB4_PERIPH_RCC_PI);
/* 3、设置PI0通用的输出模式。*/
val = readl(GPIOI_MODER_PI);
val &= ~(0X3 << 0); /* bit0:1清零 */
val |= (0X1 << 0); /* bit0:1设置01 */
writel(val, GPIOI_MODER_PI);
/* 3、设置PI0为推挽模式。*/
val = readl(GPIOI_OTYPER_PI);
val &= ~(0X1 << 0); /* bit0清零设置为上拉*/
writel(val, GPIOI_OTYPER_PI);
/* 4、设置PI0为高速。*/
val = readl(GPIOI_OSPEEDR_PI);
val &= ~(0X3 << 0); /* bit0:1 清零 */
val |= (0x2 << 0); /* bit0:1 设置为10*/
writel(val, GPIOI_OSPEEDR_PI);
/* 5、设置PI0为上拉。*/
val = readl(GPIOI_PUPDR_PI);
val &= ~(0X3 << 0); /* bit0:1 清零*/
val |= (0x1 << 0); /*bit0:1 设置为01*/
writel(val,GPIOI_PUPDR_PI);
/* 6、默认关闭LED */
val = readl(GPIOI_BSRR_PI);
val |= (0x1 << 0);
writel(val, GPIOI_BSRR_PI);
/* 注册字符设备驱动 */
/* 1、创建设备号 */
if (dtsled.major) { /* 定义了设备号 */
dtsled.devid = MKDEV(dtsled.major, 0);
ret = register_chrdev_region(dtsled.devid, DTSLED_CNT, DTSLED_NAME);
if(ret < 0) {
pr_err("cannot register %s char driver [ret=%d]\n",DTSLED_NAME, DTSLED_CNT);
goto fail_map;
}
} else { /* 没有定义设备号 */
ret = alloc_chrdev_region(&dtsled.devid, 0, DTSLED_CNT, DTSLED_NAME); /* 申请设备号 */
if(ret < 0) {
pr_err("%s Couldn't alloc_chrdev_region, ret=%d\r\n", DTSLED_NAME, ret);
goto fail_map;
}
dtsled.major = MAJOR(dtsled.devid); /* 获取分配号的主设备号 */
dtsled.minor = MINOR(dtsled.devid); /* 获取分配号的次设备号 */
}
printk("dtsled major=%d,minor=%d\r\n",dtsled.major, dtsled.minor);
/* 2、初始化cdev */
dtsled.cdev.owner = THIS_MODULE;
cdev_init(&dtsled.cdev, &dtsled_fops);
/* 3、添加一个cdev */
ret = cdev_add(&dtsled.cdev, dtsled.devid, DTSLED_CNT);
if(ret < 0)
goto del_unregister;
/* 4、创建类 */
dtsled.class = class_create(THIS_MODULE, DTSLED_NAME);
if (IS_ERR(dtsled.class)) {
goto del_cdev;
}
/* 5、创建设备 */
dtsled.device = device_create(dtsled.class, NULL, dtsled.devid, NULL, DTSLED_NAME);
if (IS_ERR(dtsled.device)) {
goto destroy_class;
}
return 0;
destroy_class:
class_destroy(dtsled.class);
del_cdev:
cdev_del(&dtsled.cdev);
del_unregister:
unregister_chrdev_region(dtsled.devid, DTSLED_CNT);
fail_map:
led_unmap();
return -EIO;
}
/*
* @description :
* @param :
* @return :
*/
static void __exit led_exit(void)
{
/* 取消映射 */
led_unmap();
/* 注销字符设备驱动 */
cdev_del(&dtsled.cdev);/* 删除cdev */
unregister_chrdev_region(dtsled.devid, DTSLED_CNT); /* 注销设备号 */
device_destroy(dtsled.class, dtsled.devid);
class_destroy(dtsled.class);
}
module_init(led_init);
module_exit(led_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ALIENTEK");
MODULE_INFO(intree, "Y");

Binary file not shown.

213
4-device-tree/led.c Normal file
View File

@ -0,0 +1,213 @@
/*
* @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @Date: 2023-08-19 09:31:52
* @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @LastEditTime: 2023-09-16 17:08:09
* @FilePath: /3-new-led/led.c
* @Description: ,`customMade`, koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <asm/mach/map.h>
#include <asm/uaccess.h>
#include <asm/io.h>
/***
* configuration
*/
// DEV_NAME
#define dev_name "newchr"
// DEV_ID配置
#define DEV_ID_STATIC 1
#if DEV_ID_STATIC
#define DEV_ID_MAJOR 80
#define DEV_ID_MINOR 0
#endif
/**
* GPIO Control Code
*/
/* 映射后的寄存器虚拟地址指针 */
static void __iomem *MPU_AHB4_PERIPH_RCC_PI;
static void __iomem *GPIOI_MODER_PI;
static void __iomem *GPIOI_OTYPER_PI;
static void __iomem *GPIOI_OSPEEDR_PI;
static void __iomem *GPIOI_PUPDR_PI;
static void __iomem *GPIOI_BSRR_PI;
void led_unmap(void)
{
/* 取消映射 */
iounmap(MPU_AHB4_PERIPH_RCC_PI);
iounmap(GPIOI_MODER_PI);
iounmap(GPIOI_OTYPER_PI);
iounmap(GPIOI_OSPEEDR_PI);
iounmap(GPIOI_PUPDR_PI);
iounmap(GPIOI_BSRR_PI);
}
void led_switch(u8 sta)
{
u32 val = 0;
if(sta == '1') {
val = readl(GPIOI_BSRR_PI);
val |= (1 << 16);
writel(val, GPIOI_BSRR_PI);
}else if(sta == '0') {
val = readl(GPIOI_BSRR_PI);
val|= (1 << 0);
writel(val, GPIOI_BSRR_PI);
}
}
struct _dev_info
{
dev_t dev_id;
struct cdev cdev;
struct class *class;
struct device *device;
} dev_info = {0};
/***
* code
*/
static ssize_t tis_module_read(struct file *file, char __user *out, size_t size, loff_t *offt)
{
printk("%s: module read\n", dev_name);
return 0;
}
static ssize_t tis_module_write(struct file *file, const char __user *in, size_t size, loff_t *offt)
{
// printk("%s: module write\n", dev_name);
char ch[1];
copy_from_user(ch,in,1);
printk("get data:%d",ch[0]);
led_switch(ch[0]);
return 0;
}
static int tis_module_open(struct inode *inode, struct file *file)
{
printk("%s: module open\n", dev_name);
return 0;
}
static int tis_module_release(struct inode *inode, struct file *file)
{
printk("%s: module release\n", dev_name);
return 0;
}
static struct file_operations tis_module_f = {
.owner = THIS_MODULE,
.write = tis_module_write,
.read = tis_module_read,
.open = tis_module_open,
.release = tis_module_release,
};
void device_tree_test(void){
struct device_node *node;
node = of_find_node_by_path("/tree-test");
if(node == NULL){
printk(" device no find tree-test\n");
}
printk("this node is %s\n",node->full_name);
node = of_find_node_by_path("/tree-test/dev1");
if(node == NULL){
printk(" device no find tree-test/device1\n");
}
struct property *prop ;
prop = of_find_property(node, "compatible", NULL);
if(prop == NULL){
printk("no find property\n");
return ;
}
printk(" device1 compatible is %s\n",(char *)prop->value);
node = of_find_node_by_path("/tree-test/dev2@1122");
if(node == NULL){
printk(" device no find tree-test/device2\n");
}
printk("device found dev2:%s\n",node->name);
}
static int __init tis_module_init(void)
{
int ret;
device_tree_test();
return 0;
// 申请dev id
#if (DEV_ID_STATIC)
dev_info.dev_id = MKDEV(DEV_ID_MAJOR, DEV_ID_MINOR);
ret = register_chrdev_region(dev_info.dev_id, 1, dev_name);
if (ret < 0)
{
printk("[%s] dev_id get failed\n",dev_name);
return ret;
}
#else
ret = alloc_chrdev_region(&dev_info.dev_id, 0, 1, dev_name);
if (ret)
{
printk("[%s] dev_id get failed\n");
return ret;
}
#endif
// 注册设备
dev_info.cdev.owner = THIS_MODULE;
cdev_init(&dev_info.cdev, &tis_module_f);
ret = cdev_add(&dev_info.cdev, dev_info.dev_id, 1);
if (ret < 0)
{
printk("[%s] cdev_add failed\n", dev_name);
goto del_unregister;
}
// 创建设备
dev_info.class = class_create(THIS_MODULE, dev_name);
if (IS_ERR(dev_info.class))
{
printk("[%s] class create failed\n", dev_name);
goto del_cdev;
}
dev_info.device = device_create(dev_info.class, NULL, dev_info.dev_id, NULL, dev_name);
if (IS_ERR(dev_info.device))
{
printk("[%s] dev create failed\n", dev_name);
goto destroy_class;
}
printk("[%s] init success\n", dev_name);
return 0;
destroy_class:
class_destroy(dev_info.class);
del_cdev:
cdev_del(&dev_info.cdev);
del_unregister:
unregister_chrdev_region(dev_info.dev_id, 1);
return -EIO;
}
static void __exit tis_module_exit(void)
{
return;
/* 注销字符设备驱动 */
cdev_del(&dev_info.cdev); /* 删除cdev */
unregister_chrdev_region(dev_info.dev_id, 1); /* 注销设备号 */
device_destroy(dev_info.class, dev_info.dev_id);
class_destroy(dev_info.class);
printk("[%s] exit success\n", dev_name);
}
module_init(tis_module_init);
module_exit(tis_module_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("chenyf");
MODULE_INFO(intree, "Y");

BIN
4-device-tree/led.ko Normal file

Binary file not shown.

2
4-device-tree/led.mod Normal file
View File

@ -0,0 +1,2 @@
/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.o

36
4-device-tree/led.mod.c Normal file
View File

@ -0,0 +1,36 @@
#include <linux/build-salt.h>
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
BUILD_SALT;
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_INFO(name, KBUILD_MODNAME);
__visible struct module __this_module
__section(.gnu.linkonce.this_module) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
#ifdef CONFIG_RETPOLINE
MODULE_INFO(retpoline, "Y");
#endif
static const struct modversion_info ____versions[]
__used __section(__versions) = {
{ 0x4b3323eb, "module_layout" },
{ 0xc546631d, "of_find_property" },
{ 0xc5850110, "printk" },
{ 0x95b97b18, "of_find_node_opts_by_path" },
{ 0xefd6cf06, "__aeabi_unwind_cpp_pr0" },
{ 0xedc03953, "iounmap" },
};
MODULE_INFO(depends, "");

BIN
4-device-tree/led.mod.o Normal file

Binary file not shown.

BIN
4-device-tree/led.o Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
/home/chenyf/desktop/stm32mp157/driver/4-device-tree/led.ko

2
device-tree-test/build.sh Executable file
View File

@ -0,0 +1,2 @@
/home/chenyf/desktop/stm32mp157/linux/linux-stm32mp-5.4.31-r0/linux-5.4.31/scripts/dtc/dtc -I dts -O dtb -o device.dtb device.dts

BIN
device-tree-test/device.dtb Normal file

Binary file not shown.

View File

@ -0,0 +1,9 @@
/dts-v1/;
/{
cpu@0{
#address-cells =<1>
#size-cells = <0>
reg = <>
model = '"123"
};
};