希捷powerchoice磁盘休眠功能arm打包

官方只提供了x86下面的包,没有提供arm下面的包,而我们的arm机器是32位的,需要编译一个支持armhf的二进制文件,这个文件只需要一个即可,但是编译是整套编译的,并且我们需要选定指定的版本,关闭nvme的支持(arm的缺库,也用不上),不带debug信息的

准备编译环境

编译环境选择的是ubuntu 18.04 (X86),在centos下面编译可能出现arm库不对的情况,通常情况下,ubuntu的跨平台编译要好一些,并且我们的arm也是ubuntu的

安装编译软件

apt-get install gcc-arm-linux-gnueabihf

支持arm的编译环境

下载代码

注意要下载这个版本的,其它版本可能发生命令变化,这个无法去一个个确认,这个版本确认可以的

git clone --recursive -b  Release-19.06.02 https://github.com/Seagate/openSeaChest.git

进入执行编译命令的目录

root@ubuntu-KVM:~/sea# cd openSeaChest/Make/gcc
root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc# CC=arm-linux-gnueabihf-gcc make

修改Makefile-方便调试编译

clean:
        rm -f *.o *.a $(FILE_OUTPUT_
改成
clean:
        rm -rf *.o *.a $(FILE_OUTPUT_

这个是可以让每次编译的时候能够清理好环境,有个是目录,这个需要改成r才能删除

报错

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
                 #pragma GCC 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\nThese 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

#determine the proper NVMe include file. SEA_NVME_IOCTL_H, SEA_NVME_H, or SEA_UAPI_NVME_H
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相关的,这个里面是提供了屏蔽的参数的

root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc# vim Makefile
#add any defines needed for tool release.
#PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH -DDISABLE_TCG_SUPPORT
PROJECT_DEFINES += -DDISABLE_TCG_SUPPORT
ifeq ($(UNAME),FreeBSD)
PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH
endif
修改为
#add any defines needed for tool release.
PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH -DDISABLE_TCG_SUPPORT
#PROJECT_DEFINES += -DDISABLE_TCG_SUPPORT
ifeq ($(UNAME),FreeBSD)
PROJECT_DEFINES += -DDISABLE_NVME_PASSTHROUGH
endif

再次编译

root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc#  CC=arm-linux-gnueabihf-gcc make

报错如下

make[1]: Entering directory '/root/sea/openSeaChest/Make/gcc'
mkdir -p openseachest_exes
gcc -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文件

root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc# vim Makefile.openSeaChest_firmware 
可以看到写死了两个值
CC = gcc

STRIP = strip

我们修改为我们想编译的平台的

CC = arm-linux-gnueabihf-gcc
STRIP = arm-linux-gnueabihf-strip

再次编译,顺利编译成功

root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc#  CC=arm-linux-gnueabihf-gcc make 

这里编译完成的时候,默认开启了debug,我们需要有个没有debug信息的版本

再次编译

root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc#  CC=arm-linux-gnueabihf-gcc make release

注意我们的命令发生了变化,加上了release的后缀,这个是能够提供两个二进制文件的,一个是dbg的一个是剥离了dbg的

检查生成的文件

root@ubuntu-KVM:~/sea/openSeaChest/Make/gcc# ll openseachest_exes/openSeaChest_PowerControl*
-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# file openseachest_exes/openSeaChest_PowerControl
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的机器上面执行

root@arm23:~# ./openSeaChest_PowerControl -d /dev/sdb  --checkPowerMode
==========================================================================================
 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
posted @ 2020-08-25 15:10  武汉-磨渣  阅读(524)  评论(0编辑  收藏  举报