简体   繁体   English

交叉编译ARM GCC5-正确使用memcpy

[英]Cross compiling for arm gcc5 - Proper use of memcpy

I am trying to compile a kernel (uImage) for the S805/S812 SoC from amlogic. 我正在尝试从amlogic编译S805 / S812 SoC的内核(uImage)。 I have managed to solve all compilation error except for one, probably because my knowledge of c++ and compilers don't reach far enough. 我设法解决了除一个以外的所有编译错误,可能是因为我对c ++和编译器的了解还不够。 Let me explain the problem, which exist in a file phydev.c : 让我解释一下问题,该问题存在于文件phydev.c中:

The line giving the error is : 给出错误的行是:

memcpy(&phydev->name, &dev_para->name, MAX_DEVICE_NAME_LEN*sizeof(char));

These are the (cross)compiler errors: 这些是(交叉)编译器错误:

drivers/amlogic/../../../hardware/amlogic/nand/amlnf/dev/phydev.c: In function ‘amlnand_phydev_init’:

drivers/amlogic/../../../hardware/amlogic/nand/amlnf/dev/phydev.c:1114:10: error: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-array-qualifiers]

   memcpy(&phydev->name, &dev_para->name, MAX_DEVICE_NAME_LEN*sizeof(char));
          ^
In file included from include/linux/string.h:17:0,
                 from include/linux/dynamic_debug.h:111,
                 from include/linux/kernel.h:14,
                 from include/linux/cache.h:4,
                 from include/linux/time.h:4,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from drivers/amlogic/../../../hardware/amlogic/nand/amlnf/dev/../include/../include/amlnf_type.h:18,
                 from drivers/amlogic/../../../hardware/amlogic/nand/amlnf/dev/../include/../include/amlnf_dev.h:4,
                 from drivers/amlogic/../../../hardware/amlogic/nand/amlnf/dev/../include/phynand.h:4,
                 from drivers/amlogic/../../../hardware/amlogic/nand/amlnf/dev/phydev.c:14:
/root/Downloads/Beelink3/arm-src-kernel-2015-01-15-321cfb5a46/arch/arm/include/asm/string.h:16:15:
 note: expected ‘void *’ but argument is of type ‘const char (*)[16]’

 extern void * memcpy(void *, const void *, __kernel_size_t);
               ^

I have been trying to figure this out for several days, also trying direct assignment (which obviously doesn't work on arrays), using strcpy instead and so on, but this only yields more errors and I can't find the exact root cause. 我已经尝试了好几天,也尝试使用直接赋值(这显然不适用于数组),而是使用strcpy等等,但这只会产生更多错误,而且我找不到确切的根本原因。 I think I need some kind of cast or intermediate constant void ptr but I have no clue how to fix this. 我想我需要某种类型的强制转换或中间常量void ptr,但是我不知道如何解决此问题。

Could anyone be as kind as to give me advice on this and how to solve it. 有人可以就此以及如何解决这个问题给我提建议。 The memcpy function is defined in arch/arm/include/asm/string.h But it did not seem a good idea messing with this file. memcpy函数在arch / arm / include / asm / string.h中定义,但是把这个文件弄乱似乎不是一个好主意。

Many thanks, 非常感谢,

Wim 威姆

Indeed someone had been smart enough to : Struct phydev { const char* name; 确实有人足够聪明:Struct phydev {const char * name; ... ...

Removed the const and all was fine (at least the memcpy line. But I could use strcpy or strdup or whatever. It was trying to write to a constant. 删除了const,一切都很好(至少是memcpy行。但是我可以使用strcpy或strdup或其他任何东西。它试图写入常量。

After debugging trough all of the other errors I was able to make the U-Boot Image. 经过调试所有其他错误后,我得以制作U-Boot映像。 Haven't tested it yet. 尚未测试。

Also, made a lot of functions static instead of copying used static variables into local attributes. 同样,将许多函数设为静态,而不是将使用的静态变量复制到局部属性中。 Don't know what it's gonna do... (probably crash with some segmentation fault or something:-). 不知道该怎么办...(可能由于某些分段错误或其他原因而崩溃:-)。

I'll have to wait for my ttl usb adapter now... 我现在必须等待我的ttl usb适配器...

Unless anyone know where to find an adb driver for this thing and it supports fw_setenv or something.... 除非有人知道在哪里可以找到这个东西的adb驱动程序,并且它支持fw_setenv之类的东西。

Guess it will be pressing the space bar on tty1 once the ttl adapter arrives. 猜测一旦ttl适配器到达,它将按下tty1上的空格键。

Thanks guys for all your help. 谢谢大家的帮助。 If I manage to get Ubuntu on this box I'll post a blog about it :-) 如果我设法在此框中安装Ubuntu,那么我会发布一个有关它的博客:-)

Cheers & thanks 欢呼与感谢

Wim 威姆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM