暂未分类 暂未分类 希捷powerchoice磁盘休眠功能arm打包 zphj1987 2020-08-25 2024-01-05 官方只提供了x86下面的包,没有提供arm下面的包,而我们的arm机器是32位的,需要编译一个支持armhf的二进制文件,这个文件只需要一个即可,但是编译是整套编译的,并且我们需要选定指定的版本,关闭nvme的支持(arm的缺库,也用不上),不带debug信息的
准备编译环境 编译环境选择的是ubuntu 18.04 (X86),在centos下面编译可能出现arm库不对的情况,通常情况下,ubuntu的跨平台编译要好一些,并且我们的arm也是ubuntu的
安装编译软件
1 apt-get install gcc-arm-linux-gnueabihf
支持arm的编译环境
下载代码 注意要下载这个版本的,其它版本可能发生命令变化,这个无法去一个个确认,这个版本确认可以的
1 git clone --recursive -b Release-19.06.02 https://github.com/Seagate/openSeaChest.git
进入执行编译命令的目录
1 2 root@ubuntu-KVM:~/sea root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc
修改Makefile-方便调试编译
1 2 3 4 5 clean: rm -f *.o *.a $(FILE_OUTPUT_ 改成 clean: rm -rf *.o *.a $(FILE_OUTPUT_
这个是可以让每次编译的时候能够清理好环境,有个是目录,这个需要改成r才能删除
报错
1 2 3 4 5 6 7 In file included from ../../include/platform_helper.h:22:0, from ../../src/cmds.c:21: ../../include/sg_helper.h:68:35: error: Please define one of the following to include the correct NVMe header: SEA_NVME_IOCTL_H, SEA_NVME_H, or SEA_UAPI_NVME_H These specify whether the NVMe IOCTL is in /usr/include/linux/nvme_ioctl.h, /usr/include/linux/nvme.h, or /usr/include/uapi/nvme.h ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Makefile:99: recipe for target '../../src/cmds.o' failed
这个报错是出现在编译opensea-transport里面的,我们检查下编译opensea-transport的Makefile
vim ./opensea-transport/Make/gcc/Makefile
1 2 3 4 NVME_IOCTL_H = /usr/include/linux/nvme_ioctl.h NVME_H = /usr/include/linux/nvme.h UAPI_NVME_H = /usr/include/uapi/nvme.h
可以看到这个地方是引用了本地的头文件,而我们的编译环境是跨平台编译,肯定没这个的arm的引用的,我们可以屏蔽掉这个nvme相关的,这个里面是提供了屏蔽的参数的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc PROJECT_DEFINES += -DDISABLE_TCG_SUPPORT ifeq ($(UNAME),FreeBSD) PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH endif 修改为 PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH -DDISABLE_TCG_SUPPORT ifeq ($(UNAME),FreeBSD) PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH endif
再次编译
1 root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc
报错如下
1 2 3 4 5 6 7 8 make[1]: Entering directory '/root/sea/openSeaChest/Make/gcc' mkdir -p openseachest_exesgcc -Wall -c -std=gnu99 -g -I../../opensea-common/include -I../../opensea-transport/include -I../../opensea-transport/include/vendor -I../../include -I../../opensea-operations/include -DDISABLE_NVME_PASSTHROUGH -DDISABLE_TCG_SUPPORT -D_DEBUG -D_DEBUG ../../utils/C/openSeaChest/openSeaChest_Firmware.c -o ../../utils/C/openSeaChest/openSeaChest_Firmware.o make[1]: gcc: Command not found Makefile.openSeaChest_firmware:109: recipe for target '../../utils/C/openSeaChest/openSeaChest_Firmware.o' failed make[1]: *** [../../utils/C/openSeaChest/openSeaChest_Firmware.o] Error 127 make[1]: Leaving directory '/root/sea/openSeaChest/Make/gcc' Makefile:210: recipe for target 'openSeaChest_Firmware' failed
可以看到上面出现了gcc,并且有openseachest_exes,这个是调用的另外一个makefile文件出现的,我们检查下makefile文件
1 2 3 4 5 root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc 可以看到写死了两个值 CC = gcc STRIP = strip
我们修改为我们想编译的平台的
1 2 CC = arm-linux-gnueabihf-gcc STRIP = arm-linux-gnueabihf-strip
再次编译,顺利编译成功
1 root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc
这里编译完成的时候,默认开启了debug,我们需要有个没有debug信息的版本
再次编译
1 root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc
注意我们的命令发生了变化,加上了release的后缀,这个是能够提供两个二进制文件的,一个是dbg的一个是剥离了dbg的
检查生成的文件
1 2 3 4 5 6 root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc -rwxr-xr-x 1 root root 822808 8月 24 17:55 openseachest_exes/openSeaChest_PowerControl* -rwxr-xr-x 1 root root 1872988 8月 24 17:49 openseachest_exes/openSeaChest_PowerControl_dbg* root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc openseachest_exes/openSeaChest_PowerControl: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=400fe0fa246e1b57115f6b7a3ea70569fd64efae, with debug_info, not stripped
我们把openSeaChest_PowerControl拷贝到arm的机器上面执行
1 2 3 4 5 6 7 8 9 10 11 root@arm23:~ ========================================================================================== openSeaChest_PowerControl - openSeaChest drive utilities Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates, All Rights Reserved openSeaChest_PowerControl Version: 1.10.0-1_19_24 ARM Build Date: Aug 24 2020 Today: Mon Aug 24 18:01:55 2020 ========================================================================================== /dev/sdb - ST10000NM0016-1TT101 - ZA2CS3KZ - ATA Device is in the PM1: Idle state and the device is in the Idle_b power condition
可以看到命令可以执行成功,并且上面也显示的是arm的版本,剩下的具体的设置根据配置文档进行设置即可
变更记录
Why
Who
When
创建
武汉-运维-磨渣
2020-08-25