野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 167|回复: 0

[已解决] LBC2第一次上电编译驱动报错——/bin/sh: 1: scripts/basic/fixdep: ...

[复制链接]
发表于 2024-7-6 16:38:58 | 显示全部楼层 |阅读模式
本帖最后由 renzhaomu 于 2024-7-6 16:41 编辑

编译的makefile文件:

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m := hello.o
all:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
编译时报错:

make -C /lib/modules/4.19.232/build M=/home/cat/Desktop/Linux_BSP/1_hello_world modules
make[1]: Entering directory '/usr/src/linux-headers-4.19.232'
CC [M] /home/cat/Desktop/Linux_BSP/1_hello_world/hello_world.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[2]: *** [scripts/Makefile.build:340: /home/cat/Desktop/Linux_BSP/1_hello_world/hello_world.o] Error 2
make[2]: *** Deleting file '/home/cat/Desktop/Linux_BSP/1_hello_world/hello_world.o'
make[1]: *** [Makefile:1676: _module_/home/cat/Desktop/Linux_BSP/1_hello_world] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.19.232'
make: *** [Makefile:7: all] Error 2

主要报错:/bin/sh: 1: scripts/basic/fixdep: Exec format error
file scripts/basic/fixdep该文件发现该文件为x86文件,但是LBC2为aarch64类型。
解决方法:
cd到/usr/src/linux-headers-4.19.232/scripts/basic目录下执行gcc fixdep,
重新编译该文件为aarch64类型
再次执行make编译
报错:
make -C /lib/modules/4.19.232/build  M=/home/cat/Deskto/Linux_BSP/1_hello_world modules
make[1]: Entering directory
'/usr/src/linux-headers-4.19.232'
CC[M]  /home/cat/Desktop/Linux_BSP/1_hello_world/hello_world.o
  Building modules, stage 2.
  MODPOST 1 modules
/bin/sh: 1: scripts/mod/modpost: Execformat error
make[2]: *** [scripts/Makefile.modpost:108:__modpost] Error 2
make[1]: *** [Makefile:1680: modules] Error2
make[1]: Leaving directory
'/usr/src/linux-headers-4.19.232'

make: *** [Makefile:7: all] Error 2
同样的cd到/usr/src/linux-headers-4.19.232/scripts/mod目录下
执行gcc -o modpost modpost.c file2alias.c sumversion.c -I. -I..

再次编译无报错
/bin/sh: 1: ./scripts/recordmcount: Exec format error同样的原因cd到/usr/src/linux-headers-4.19.232/scripts目录下编译gcc -o recordmcount recordmcount.c再次make编译报错


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-8 11:56 , Processed in 0.101094 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表