先日、先駆者の方々のおかげで、Stock recovery を作ることに成功したわけですが、Custom recovery の作成に少し時間を割いてみた。
recovery.img boot.img を unpack する tool は色々出回っているようですが、試してみたどれもうまく動作しなかった。
一つだけ bzImage と ramdisk.cpio.gz に分解してくれる tool があった。
それが、先日からお世話になっている、Zenfone5 developer shakalaca さんのところにある ZenFone-boot-tools。
GitHub で公開されていたので、ダウンロードして内容を改変してみることで、ME170CX ( ME70C ) K01A で boot.img recovery.img を unpack repack することに成功した。
※注意 custom recovery を詰め込んだ recovery.img or boot.img ファイルを flash すると bootloader が unlock されてないので、FAILED (remote: check_sign_key fail: no allow update MOS image) と暗号キーのチェックに失敗したと忠告されます。 custom recovery を詰め込まなければ、flash できるので、unpack repack tool に問題はないです。
改変した内容と unpack/repack 手順を書き留めてみた
使用するPC と 必要なファイル
- linux PC(ubuntu など)
- ZenFone-boot-tools
まずは shakalaca さんの GitHub にいって ZenFone-boot-tools を zip ファイルでダウンロードしてくる。
1.ダウンロードしてお好みのディレクトリに展開。
2.展開したファイル内にある bootheader.h を下記のように変更
/*
* bootheader.h
*
* Copyright 2012 Emilio Lopez <turl@tuxfamily.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#include <stdint.h>
#ifndef __BOOTHEADER__
#define __BOOTHEADER__
#define MAGIC_SIZE (7)
#define ID_SIZE (0x28)
#define HEADER_SIZE (MAGIC_SIZE + 0x1 + ID_SIZE + 0x4 + 0x4)
#define HEAD_PADDING (0x1c8)
#define UNKNOWN_SIZE (0x1e0)
#define CMDLINE_SIZE (0x400)
#define CMDLINE_END (HEADER_SIZE + HEAD_PADDING + UNKNOWN_SIZE + CMDLINE_SIZE)
// uint32_t * 4 = 0x10, total: 0x410
#define PADDING1_SIZE (0xbf0) // (0x2000-0x410)
#define BOOTSTUBSTACK_SIZE (0x2000)
#define SECTOR_SIZE (0x200) // 512
struct bootheader {
uint8_t magic[MAGIC_SIZE]; // $OS$\0\0\1
uint8_t xor; // XOR of first 56 bytes (without this one)
uint8_t id[ID_SIZE]; // 01 01 38 00 00 00 00 00 00 00 00 00 00 00 00 00
// 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00
// 00 00 10 01 00 10 10 01
uint32_t sectors;
uint32_t imageType;
uint8_t head_padding[HEAD_PADDING]; // FF FF FF FF .... x 96 + 00 00 00 00 .... x 17 + 00 00 55 AA
uint8_t unknown[UNKNOWN_SIZE];
char cmdline[CMDLINE_SIZE];
uint32_t bzImageSize;
uint32_t initrdSize;
uint32_t SPIUARTSuppression; // unused
uint32_t SPIType; // unused
uint8_t padding1[PADDING1_SIZE]; // 00 00 00 00 ...
uint8_t bootstubStack[BOOTSTUBSTACK_SIZE]; // fixed content
};
/* Sanity check for struct size */
typedef char z[(sizeof(struct bootheader) == HEADER_SIZE + HEAD_PADDING + UNKNOWN_SIZE + 0x3000) ? 1 : -1];
// 0x3000 = (size of cmdline + 16 + padding1) + (size of bootstubstack)
#endif
3.変更がおわったら make し recovery.img or boot.img を同ディレクトリに配置して 下記のように unpack_intel ~~~~~~~~ と command すると bzImage と ramdisk.cpio.gz ができあがる。
ME70C-boot-tool # make ME70C-boot-tool # ./unpack_intel boot.img bzImage ramdisk.cpio.gz ME70C-boot-tool # ./pack_intel boot.img bzImage ramdisk.cpio.gz new_boot.img
作成した ME70C Boot-recovery.img tool
Sponsored linksbootloader unlock 未対応機種
上記のように、ここまで問題なくimg file の作成ができるわけですが、そもそも、この ME70C(K01A) は公式の bootloader unlock に対応していないという残念な端末です。custom recovery を 作ったとしても flash できないわけですね。
今までやってきたのはぁ~時間の無駄~っだった?
それとも TETHERED な CWM から flashable な zip ファイルを作ってみる?
さてどうしましょう?
関連記事
Sponsored links



![Lenovo P2 [ P2a42 ] OS 7.0 不具合修正アップデート](https://doroid.org/wp-content/uploads/2017/04/Lenovo_p2_S233_170404_ROW-150x150.jpg)
![[NVIDIA]NVIDIA SHIELD K1 Tablet が Android OS 7.0 Nougat にアップグレード開始!](https://doroid.org/wp-content/uploads/2017/01/NVIDIA_SHIELD_Tablet_K1-150x150.jpg)





