移植编译bcm sdk6.4.8 过程-平台arm-linux cortex-a9双核,系xilinx soc

技术积累,移植编译bcm sdk6.4.8 过程记录

北京华环电子:任晓亮 2015-10-20

                                                                                             一句话总结:代码都是人写的,不试试怎么知道不行

目标平台:BCM-SDK-6.4.8

                   Linux kernel version-3-14-0

                   Xilinx znyq 7020 cortex-a9 双核

                   Zedboard

Sdk 修改内容:

renxl@icserver:~/sdk-xgs-robo-6.4.8/systems/linux/user/xilinx-3_14_0$make

1.  添加version.h文件。文件内容如下:

renxl@icserver:~/linux-xlnx-xilinx-v2014.2/include/linux$ cat version.h

#ifndef_VERSION_H

#define_VERSION_H

 

#ifndefLINUX_VERSION_CODE

#defineLINUX_VERSION_CODE 200192 ##这数字需经过实际v3.14.0,带入下面公式计算

#endif

 

#ifndefKERNEL_VERSION

#defineKERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

#endif

 

#endif

2.  修改复制文件

linux-xlnx-xilinx-v2014.2archarmincludeasmbitsperlong.h到linux-xlnx-xilinx-v2014.2include

 

3.  修改Makefile.linux-xilinx-3_14_0

87 ifeq (,$(KFLAGS))

 88 KFLAGS :=-D__KERNEL__  -nostdinc 

 89         -isystem $(KFLAG_INCLD)

 90         -I$(LINUX_INCLUDE)

 91         -include$(LINUX_INCLUDE)/linux/version.h

 92         -include$(LINUX_INCLUDE)/generated/autoconf.h

 93         -I$(KERNDIR)/arch/arm

 94         -I$(KERNDIR)/include/uapi

 95        -I$(KERNDIR)/arch/arm/include

 96        -I$(KERNDIR)/arch/arm/include/uapi

 97        -I$(KERNDIR)/arch/arm/include/generated

 98        -I$(KERNDIR)/arch/arm/mach-zynq/include

 99         -Wall -Wundef -Wstrict-prototypes-Wno-trigraphs -fno-strict-aliasing -fno-common-Werror-implicit-function-declarat    ion-Wno-format-security -fno-delete-null-pointer-checks -O2 -marm-mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D    __LINUX_ARM_ARCH__=5 -march=armv5te-mtune=arm9tdmi -msoft-float -Uarm -fno-stack-protector -fomit-frame-pointer-Wdeclarati    on-after-statement-Wno-pointer-sign -fno-strict-overflow

100 endif

 

4.  修改Makefile.linux-kernel-3_14_0 去掉告警错误中断,-Werror

141 ifndef BCM_CFLAGS

142#BCM_CFLAGS   = -Wall -Werror

143 BCM_CFLAGS   = -Wall

144 endif

5.修改

vi include/generated/autoconf.h

注释掉:

482 //#define CONFIG_SMP 1:

 

6.错误

/home/renxl/work/nios-kernel/arm_linux/fae-sdk-robo-6.3.6/src/sal/core/linux/alloc.c:In function 'sal_alloc':

/home/renxl/work/nios-kernel/arm_linux/fae-sdk-robo-6.3.6/src/sal/core/linux/alloc.c:169:5:error: implicit declaration of function 'kmalloc'[-Werror=implicit-function-declaration]

/home/renxl/work/nios-kernel/arm_linux/fae-sdk-robo-6.3.6/src/sal/core/linux/alloc.c:169:13:warning: assignment makes pointer from integer without a cast [enabled bydefault]

/home/renxl/work/nios-kernel/arm_linux/fae-sdk-robo-6.3.6/src/sal/core/linux/alloc.c:In function 'sal_free':

/home/renxl/work/nios-kernel/arm_linux/fae-sdk-robo-6.3.6/src/sal/core/linux/alloc.c:259:9:error: implicit declaration of function 'kfree'[-Werror=implicit-function-declaration]

cc1: some warnings being treated as errors

在alloc.c添加这个头文件:

#include <linux/slab.h>

7.错误

In file included from/home/renxl/work/nios-kernel/arm_linux/xilinx/linux-xlnx-xilinx-v2014.2/include/linux/kmemcheck.h:4:0,

                 from/home/renxl/work/nios-kernel/arm_linux/xilinx/linux-xlnx-xilinx-v2014.2/include/linux/net.h:25,

                 from/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/src/appl/diag/esw/txrx.c:65:

/home/renxl/work/nios-kernel/arm_linux/xilinx/linux-xlnx-xilinx-v2014.2/include/linux/mm_types.h:144:45: error: missing binary operator before token "("

/home/renxl/work/nios-kernel/arm_linux/xilinx/linux-xlnx-xilinx-v2014.2/include/linux/mm_types.h:427:46: error: missing binary operator before token "("

make[5]: ***[/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/build/linux-xilinx-3_14_0/src/appl/diag/esw/txrx.o]Error 1

修改:

vi include/linux/mm_types.h (内存页映射数据结构,错误提示这个宏定义有问题,注释掉宏开关)

144// #ifdefined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS

145                 pgtable_t pmd_huge_pte; /*protected by page->ptl */

146// #endif

427 行同样修改

 

8.错误

/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/systems/bde/linux/kernel/linux-kernel-bde.c:In function '_sinval':

/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/systems/bde/linux/kernel/linux-kernel-bde.c:4207:5:error: implicit declaration of function 'dma_cache_sync'[-Werror=implicit-function-declaration]

cc1: some warnings being treated as errors

 

9.错误,GPL开源协议错误

FATAL: modpost: GPL-incompatible modulelinux-uk-proxy.ko uses GPL-only symbol 'lockdep_init_map'

make[6]: *** [__modpost] Error 1

make[5]: *** [modules] Error 2

 

MODULE_LICENSE("Proprietary");  --------à>>>>>>>>>MODULE_LICENSE("GPL");

10.错误


Arm options:

https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

-Wall

-Wundef

-Wstrict-prototypes

-Wno-trigraphs

-fno-strict-aliasing

-fno-common

-Wno-format-security

-fno-delete-null-pointer-checks

-O2

-marm

-mabi=aapcs-linux

-mno-thumb-interwork

-funwind-tables

-D__LINUX_ARM_ARCH__=7

-march=armv7-a

-mtune=cortex-a9

-msoft-float

-Uarm

-fno-stack-protector

-fomit-frame-pointer

-Wdeclaration-after-statement

-Wno-pointer-sign

-fno-strict-overflow

-mfpu=vfp===== 硬件浮点运算

11.错误  sdk-6.3.6

[root@GXR05/usr/app]$insmod linux-kernel-bde.ko

[85743.129419] linux_kernel_bde: Unknown symbol dma_cache_sync (err 0)

insmod: can't insert 'linux-kernel-bde.ko': unknown symbol in module orinvalid parameter

./systems/bde/linux/kernel/linux-kernel-bde.c:4207:    dma_cache_sync(NULL, ptr, length,DMA_BIDIRECTIONAL);

./systems/bde/linux/kernel/linux-kernel-bde.c:4223:    dma_cache_sync(NULL, ptr, length,DMA_BIDIRECTIONAL);

 注释掉:=====//dma_cache_sync(NULL,ptr, length, DMA_BIDIRECTIONAL);

In file included from/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/systems/linux/kernel/modules/bcm-core/bcm-core.c:747:0:

/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/systems/linux/kernel/modules/bcm-core/bcm-core-symbols.h:At top level:

/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/systems/linux/kernel/modules/bcm-core/bcm-core-symbols.h:920:1:error: 'is_eyescan_algorithm_legacy_mode' undeclaredhere (not in a function)

make[3]: ***[/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/build/linux-xilinx-3_14_0/systems/linux/kernel/modules/bcm-core/bcm-core.o]Error 1

make[2]: *** [bcm-core] Error 2

make[1]: *** [kernel_modules] Error 2

make[1]: Leaving directory`/home/renxl/work/nios-kernel/arm_linux/sdk-xgs-robo-6.4.8/systems/linux/kernel/common'

make: *** [build] Error 2

 

屏蔽掉bcm-core-symbols.h:920 //EXPORT_SYMBOL(is_eyescan_algorithm_legacy_mode);

 

13.错误 insmod error;

(1)内核版本不一致导致:下面错误

[  59.053845] linux_bcm_diag_full: disagrees about version of symbolmodule_layout

insmod: can't insert'linux-bcm-diag-full.ko': invalid module format

(2)insmod: can't insert 'linux-bcm-diag-full.ko': invalid module format

Busybox:insmod 错误提示位置:

renxl@icserver:~/work/nios-kernel/busybox-1.20.2$grep -r -n "invalid module format" ./*

Binary file ./busybox matches

Binary file ./busybox_unstripped matches

./modutils/modprobe-small.c:164:          return "debug--164=invalid moduleformat";

Binary file ./modutils/modutils.o matches

Binary file ./modutils/lib.a matches

Binary file ./modutils/modprobe-small.omatches

./modutils/modutils.c:191:               return "debug--191-invalid moduleformat";


14:操作顺序

[root@GXR05/mnt]$insmod linux-uk-proxy.ko

[root@GXR05/mnt]$insmod linux-kernel-bde.ko

[root@GXR05/mnt]$insmodlinux-bcm-diag-full.ko

[root@GXR05/mnt]$mknod/dev/linux-uk-proxy c 125 0

15.核心模块error

       这个问题可能跟内核有关,需要深入研究,内核模块太大,申请内存出现错误:

 

Linux 3.0对应修改源码:的memory.h里面的

1.  /*

2.  * PAGE_OFFSET - the virtual address of thestart of the kernel image

3.  * TASK_SIZE - the maximum size of a userspace task.

4.  * TASK_UNMAPPED_BASE - the lower boundaryof the mmap VM area

5.  */

6.  #define PAGE_OFFSET               UL(CONFIG_PAGE_OFFSET)

7.  #define TASK_SIZE               (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))

8.  #define TASK_UNMAPPED_BASE       (UL(CONFIG_PAGE_OFFSET) / 3)

9.   

10. /*

11. * The maximum size of a 26-bit user spacetask.

12. */

13. #define TASK_SIZE_26               UL(0x04000000)

14.  

15. /*

16. * The module space lives between theaddresses given by TASK_SIZE

17. * and PAGE_OFFSET - it must be within 32MBof the kernel text.

18. */

19. #ifndef CONFIG_THUMB2_KERNEL

20. #define MODULES_VADDR               (PAGE_OFFSET - 16*1024*1024)

21. #else

22. /* smaller range for Thumb-2 symbolsrelocation (2^24)*/

23. #define MODULES_VADDR               (PAGE_OFFSET - 8*1024*1024)

24. #endif

25.  

26. #if TASK_SIZE > MODULES_VADDR

27. #error Top of user space clashes withstart of module space

28. #endif

29.  

30. /*

31. * The highmem pkmap virtual space sharesthe end of the module area.

32. */

33. #ifdef CONFIG_HIGHMEM

34. #define MODULES_END               (PAGE_OFFSET - PMD_SIZE)

35. #else

36. #define MODULES_END               (PAGE_OFFSET)

37. #endif

16, error for insmod linux-bcm-core.ko

[root@GXR05/mnt]$insmod linux-bcm-core.ko

[   76.334104] linux_bcm_core:Unknown symbol soc_mem_array_write (err 0)

[   76.342565] linux_bcm_core:Unknown symbol soc_phy_set_verbose (err 0)

[   76.352435] linux_bcm_core:Unknown symbol soc_custom_reg_above_64_set (err 0)

[   76.360465] linux_bcm_core:Unknown symbol soc_mem_array_read_flags (err 0)

[   76.370004] linux_bcm_core:Unknown symbol bcm5324_trunk_patch_linkscan (err 0)

[   76.382773] linux_bcm_core:Unknown symbol soc_mem_array_read (err 0)

[   76.391729] linux_bcm_core:Unknown symbol soc_custom_reg_above_64_get (err 0)

[   76.399626] linux_bcm_core:Unknown symbol soc_mem_array_write_extended (err 0)

insmod: can't insert 'linux-bcm-core.ko': unknown symbol in module orinvalid parameter

修改:

./systems/linux/kernel/modules/bcm-core/bcm-core-symbols.h:871:EXPORT_SYMBOL(soc_mem_array_write);

相关内容推荐