内核启动错误Error: unrecognized/unsupported machine ID的解决

本文分析了Linux内核启动过程中遇到的Error: unrecognized/unsupported machine ID错误,解释了该错误产生的原因,并提供了通过修改UBoot或内核来解决问题的方法。

      这段时间调试linux内核,手里拿到的BSP包和uboot有好几个,用错了uboot和kernel后发现报错Error: unrecognized/unsupported machine ID,做一下简单分析。

     linux内核启动时候会读取uboot传来的参数,其中包括MACH_TYPE这个参数,如果uboot传给内核的值与内核定义的不一样,就会报错。解决方法有两个:1.修改uboot, 2.修改内核。

1.修改uboot

这个值在uboot的板级初始化函数内设置。查看Makefile或者boards.cfg查看板级配置文件所在的目录。一般在board/XXX下。

比如u-boot/board/timll/LSDboard/LSDboard.c

45 /*
 46  * Routine: board_init
 47  * Description: Early hardware init.
 48  */
 49 int board_init(void)
 50 {
 51     DECLARE_GLOBAL_DATA_PTR;
 52
 53     gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
 54     /* board id for Linux */
 55     gd->bd->bi_arch_number = MACH_TYPE_OMAP3_LSD;
 56     /* boot param addr */
 57     gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 58
 59     return 0;
 60 }

第55行 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_LSD;就是在设置ID号,修改这里的值和linux内核的相同就可以了。MACH_TYPE_OMAP3_LSD的定义在arch/arm/include/asm/mach-types.h。

2.修改内核

linux内核中MACH_TYPE_XXXX的宏定义在include/asm-arm/mach-types.h内,具体使用哪个,由配置文件决定。

 2535 #define MACH_TYPE_OMAP3_DEVKIT8500     2793
 2536 #define MACH_TYPE_OMAP3_LSD            2794
 2537 #define MACH_TYPE_OMAP3_SBC8510        2795
。。。

。。。

32791 #ifdef CONFIG_MACH_OMAP3_LSD
32792 # ifdef machine_arch_type
32793 #  undef machine_arch_type
32794 #  define machine_arch_type __machine_arch_type
32795 # else
32796 #  define machine_arch_type MACH_TYPE_OMAP3_LSD
32797 # endif
32798 # define machine_is_omap3_LSD() (machine_arch_type == MACH_TYPE_OMAP3_LSD)
32799 #else
32800 # define machine_is_omap3_LSD() (0)
32801 #endif
可以直接修改这边的代码,增加自定义的类型。

root@a75a3e7a0dd1:/opt/sdkv4_addon/application/x86_app/xdp_app# readelf -a syn_counter.o ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: REL (Relocatable file) Machine: Linux BPF Version: 0x1 Entry point address: 0x0 Start of program headers: 0 (bytes into file) Start of section headers: 4464 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 0 (bytes) Number of program headers: 0 Size of section headers: 64 (bytes) Number of section headers: 22 Section header string table index: 1 Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .strtab STRTAB 0000000000000000 00001090 00000000000000df 0000000000000000 0 0 1 [ 2] .text PROGBITS 0000000000000000 00000040 0000000000000000 0000000000000000 AX 0 0 4 [ 3] classifier PROGBITS 0000000000000000 00000040 0000000000000010 0000000000000000 AX 0 0 8 [ 4] maps PROGBITS 0000000000000000 00000050 0000000000000014 0000000000000000 WA 0 0 4 [ 5] license PROGBITS 0000000000000000 00000064 0000000000000004 0000000000000000 WA 0 0 1 [ 6] .debug_str PROGBITS 0000000000000000 00000068 000000000000020f 0000000000000001 MS 0 0 1 [ 7] .debug_loc PROGBITS 0000000000000000 00000277 0000000000000000 0000000000000000 0 0 1 [ 8] .debug_abbrev PROGBITS 0000000000000000 00000277 00000000000000cf 0000000000000000 0 0 1 [ 9] .debug_info PROGBITS 0000000000000000 00000346 0000000000000277 0000000000000000 0 0 1 [10] .rel.debug_info REL 0000000000000000 00000ce0 0000000000000360 0000000000000010 21 9 8 [11] .debug_ranges PROGBITS 0000000000000000 000005bd 0000000000000000 0000000000000000 0 0 1 [12] .debug_macinfo PROGBITS 0000000000000000 000005bd 0000000000000001 0000000000000000 0 0 1 [13] .debug_pubnames PROGBITS 0000000000000000 000005be 000000000000003c 0000000000000000 0 0 1 [14] .rel.debug_pubnam REL 0000000000000000 00001040 0000000000000010 0000000000000010 21 13 8 [15] .debug_pubtypes PROGBITS 0000000000000000 000005fa 00000000000000ae 0000000000000000 0 0 1 [16] .rel.debug_pubtyp REL 0000000000000000 00001050 0000000000000010 0000000000000010 21 15 8 [17] .debug_frame PROGBITS 0000000000000000 000006a8 0000000000000028 0000000000000000 0 0 8 [18] .rel.debug_frame REL 0000000000000000 00001060 0000000000000020 0000000000000010 21 17 8 [19] .debug_line PROGBITS 0000000000000000 000006d0 00000000000000e3 0000000000000000 0 0 1 [20] .rel.debug_line REL 0000000000000000 00001080 0000000000000010 0000000000000010 21 19 8 [21] .symtab SYMTAB 0000000000000000 000007b8 0000000000000528 0000000000000018 1 52 8 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), p (processor specific) There are no section groups in this file. There are no program headers in this file. There is no dynamic section in this file. Relocation section '.rel.debug_info' at offset 0xce0 contains 54 entries: Offset Info Type Sym. Value Sym. Name 000000000006 00300000000a unrecognized: a 0000000000000000 .debug_abbrev 00000000000c 00010000000a unrecognized: a 0000000000000000 000000000012 00020000000a unrecognized: a 0000000000000030 000000000016 00330000000a unrecognized: a 0000000000000000 .debug_line 00000000001a 00030000000a unrecognized: a 000000000000006b 00000000001e 002f00000001 unrecognized: 1 0000000000000000 classifier 00000000002b 00040000000a unrecognized: a 0000000000000098 000000000037 003500000001 unrecognized: 1 0000000000000000 counter_map 000000000040 000b0000000a unrecognized: a 00000000000000e0 000000000048 00050000000a unrecognized: a 00000000000000a4 000000000054 00070000000a unrecognized: a 00000000000000b6 000000000060 00080000000a unrecognized: a 00000000000000bf 00000000006c 00090000000a unrecognized: a 00000000000000ca 000000000078 000a0000000a unrecognized: a 00000000000000d6 000000000085 00060000000a unrecognized: a 00000000000000a9 00000000008c 000c0000000a unrecognized: a 00000000000000ec 000000000098 003400000001 unrecognized: 1 0000000000000000 _license 0000000000ad 000d0000000a unrecognized: a 00000000000000f5 0000000000b4 000e0000000a unrecognized: a 00000000000000fa 0000000000bc 000f0000000a unrecognized: a 0000000000000103 0000000000c3 002f00000001 unrecognized: 1 0000000000000000 classifier 0000000000d1 00100000000a unrecognized: a 000000000000010c 0000000000de 00120000000a unrecognized: a 0000000000000119 0000000000e9 00230000000a unrecognized: a 00000000000001aa 0000000000f4 00240000000a unrecognized: a 00000000000001af 0000000000ff 00260000000a unrecognized: a 00000000000001c2 00000000010b 00110000000a unrecognized: a 0000000000000115 000000000117 00250000000a unrecognized: a 00000000000001b8 000000000120 00130000000a unrecognized: a 000000000000011d 00000000012d 00150000000a unrecognized: a 0000000000000127 00000000013a 00160000000a unrecognized: a 0000000000000130 000000000147 00170000000a unrecognized: a 0000000000000135 000000000154 00180000000a unrecognized: a 0000000000000143 000000000161 00190000000a unrecognized: a 000000000000014c 00000000016e 001a0000000a unrecognized: a 0000000000000159 00000000017b 001b0000000a unrecognized: a 0000000000000162 000000000188 001c0000000a unrecognized: a 000000000000016d 000000000195 001d0000000a unrecognized: a 0000000000000176 0000000001a2 001e0000000a unrecognized: a 0000000000000186 0000000001af 001f0000000a unrecognized: a 000000000000018e 0000000001bc 00200000000a unrecognized: a 0000000000000197 0000000001c9 00210000000a unrecognized: a 000000000000019a 0000000001d6 00220000000a unrecognized: a 000000000000019f 0000000001e3 00230000000a unrecognized: a 00000000000001aa 0000000001f0 00240000000a unrecognized: a 00000000000001af 000000000202 00140000000a unrecognized: a 0000000000000121 00000000021a 002e0000000a unrecognized: a 0000000000000208 000000000222 00270000000a unrecognized: a 00000000000001c6 00000000022e 00290000000a unrecognized: a 00000000000001db 00000000023a 002a0000000a unrecognized: a 00000000000001e4 000000000253 00280000000a unrecognized: a 00000000000001cd 00000000025e 002d0000000a unrecognized: a 0000000000000201 000000000269 002c0000000a unrecognized: a 00000000000001fb 000000000270 002b0000000a unrecognized: a 00000000000001ec Relocation section '.rel.debug_pubnames' at offset 0x1040 contains 1 entry: Offset Info Type Sym. Value Sym. Name 000000000006 00310000000a unrecognized: a 0000000000000000 .debug_info Relocation section '.rel.debug_pubtypes' at offset 0x1050 contains 1 entry: Offset Info Type Sym. Value Sym. Name 000000000006 00310000000a unrecognized: a 0000000000000000 .debug_info Relocation section '.rel.debug_frame' at offset 0x1060 contains 2 entries: Offset Info Type Sym. Value Sym. Name 000000000014 00320000000a unrecognized: a 0000000000000000 .debug_frame 000000000018 002f00000001 unrecognized: 1 0000000000000000 classifier Relocation section '.rel.debug_line' at offset 0x1080 contains 1 entry: Offset Info Type Sym. Value Sym. Name 0000000000cd 002f00000001 unrecognized: 1 0000000000000000 classifier The decoding of unwind sections for machine type Linux BPF is not currently supported. Symbol table '.symtab' contains 55 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 NOTYPE LOCAL DEFAULT 6 2: 0000000000000030 0 NOTYPE LOCAL DEFAULT 6 3: 000000000000006b 0 NOTYPE LOCAL DEFAULT 6 4: 0000000000000098 0 NOTYPE LOCAL DEFAULT 6 5: 00000000000000a4 0 NOTYPE LOCAL DEFAULT 6 6: 00000000000000a9 0 NOTYPE LOCAL DEFAULT 6 7: 00000000000000b6 0 NOTYPE LOCAL DEFAULT 6 8: 00000000000000bf 0 NOTYPE LOCAL DEFAULT 6 9: 00000000000000ca 0 NOTYPE LOCAL DEFAULT 6 10: 00000000000000d6 0 NOTYPE LOCAL DEFAULT 6 11: 00000000000000e0 0 NOTYPE LOCAL DEFAULT 6 12: 00000000000000ec 0 NOTYPE LOCAL DEFAULT 6 13: 00000000000000f5 0 NOTYPE LOCAL DEFAULT 6 14: 00000000000000fa 0 NOTYPE LOCAL DEFAULT 6 15: 0000000000000103 0 NOTYPE LOCAL DEFAULT 6 16: 000000000000010c 0 NOTYPE LOCAL DEFAULT 6 17: 0000000000000115 0 NOTYPE LOCAL DEFAULT 6 18: 0000000000000119 0 NOTYPE LOCAL DEFAULT 6 19: 000000000000011d 0 NOTYPE LOCAL DEFAULT 6 20: 0000000000000121 0 NOTYPE LOCAL DEFAULT 6 21: 0000000000000127 0 NOTYPE LOCAL DEFAULT 6 22: 0000000000000130 0 NOTYPE LOCAL DEFAULT 6 23: 0000000000000135 0 NOTYPE LOCAL DEFAULT 6 24: 0000000000000143 0 NOTYPE LOCAL DEFAULT 6 25: 000000000000014c 0 NOTYPE LOCAL DEFAULT 6 26: 0000000000000159 0 NOTYPE LOCAL DEFAULT 6 27: 0000000000000162 0 NOTYPE LOCAL DEFAULT 6 28: 000000000000016d 0 NOTYPE LOCAL DEFAULT 6 29: 0000000000000176 0 NOTYPE LOCAL DEFAULT 6 30: 0000000000000186 0 NOTYPE LOCAL DEFAULT 6 31: 000000000000018e 0 NOTYPE LOCAL DEFAULT 6 32: 0000000000000197 0 NOTYPE LOCAL DEFAULT 6 33: 000000000000019a 0 NOTYPE LOCAL DEFAULT 6 34: 000000000000019f 0 NOTYPE LOCAL DEFAULT 6 35: 00000000000001aa 0 NOTYPE LOCAL DEFAULT 6 36: 00000000000001af 0 NOTYPE LOCAL DEFAULT 6 37: 00000000000001b8 0 NOTYPE LOCAL DEFAULT 6 38: 00000000000001c2 0 NOTYPE LOCAL DEFAULT 6 39: 00000000000001c6 0 NOTYPE LOCAL DEFAULT 6 40: 00000000000001cd 0 NOTYPE LOCAL DEFAULT 6 41: 00000000000001db 0 NOTYPE LOCAL DEFAULT 6 42: 00000000000001e4 0 NOTYPE LOCAL DEFAULT 6 43: 00000000000001ec 0 NOTYPE LOCAL DEFAULT 6 44: 00000000000001fb 0 NOTYPE LOCAL DEFAULT 6 45: 0000000000000201 0 NOTYPE LOCAL DEFAULT 6 46: 0000000000000208 0 NOTYPE LOCAL DEFAULT 6 47: 0000000000000000 0 SECTION LOCAL DEFAULT 3 48: 0000000000000000 0 SECTION LOCAL DEFAULT 8 49: 0000000000000000 0 SECTION LOCAL DEFAULT 9 50: 0000000000000000 0 SECTION LOCAL DEFAULT 17 51: 0000000000000000 0 SECTION LOCAL DEFAULT 19 52: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 5 _license 53: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 4 counter_map 54: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 3 simplest No version information found in this file. readelf: Error: Missing knowledge of 32-bit reloc types used in DWARF sections of machine number 247 readelf: Warning: unable to apply unsupported reloc type 10 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 1 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 10 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 1 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 10 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 1 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 10 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 1 to section .debug_info readelf: Warning: unable to apply unsupported reloc type 10 to section .debug_info / # /var/tmp/tc filter add dev eth0 ingress bpf obj /var/tmp/syn_counter.o sec classifier direct-action Error parsing section 4! Perhaps check with readelf -a? Error fetching ELF ancillary data! Failed to retrieve (e)BPF data! 如何解决内核版本linux 4.9.0 / # /var/tmp/tc -V tc utility, iproute2-ss161212
最新发布
10-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值