希捷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的版本,剩下的具體的設定根據配置文件進行設定即可