Cannot get Hikey to show /dev/ttyUSB

Hello

I was trying to flash my hikey 960, but instead of setting switch 1 and 3 to ON (with 2 OFF), I set 1 and 2 to ON (with 3 OFF). I ran the flashing command:

$ sudo ./device/linaro/hikey/installer/hikey960/flash-all.sh /dev/ttyUSB0
android out dir:./device/linaro/hikey/installer/hikey960/…/…/…/…/…//out/target/product/hikey960
flashing recovery images… please wait ~10 seconds
Config name: ./device/linaro/hikey/installer/hikey960/config
Port name: /dev/ttyUSB0
0: Image: device/linaro/hikey/installer/hikey960/hisi-sec_usb_xloader.img Downalod Address: 0x20000
1: Image: device/linaro/hikey/installer/hikey960/hisi-sec_uce_boot.img Downalod Address: 0x6a908000
2: Image: device/linaro/hikey/installer/hikey960/recovery.bin Downalod Address: 0x1ac00000
Serial port open successfully!
Start downloading device/linaro/hikey/installer/hikey960/hisi-sec_usb_xloader.img@0x20000…
file total size 99584
downlaod address 0x20000
Finish downloading
Start downloading device/linaro/hikey/installer/hikey960/hisi-sec_uce_boot.img@0x6a908000…
file total size 23680
downlaod address 0x6a908000
Finish downloading
Start downloading device/linaro/hikey/installer/hikey960/recovery.bin@0x1ac00000…
file total size 1179648
downlaod address 0x1ac00000
Finish downloading
set a unique serial number

The terminal remained stuck. I then realized that I may have set to switches incorrectly. In the README file it says “To boot into fastboot mode set switch 1 & 3 to ON state and switch 2 to OFF state.” I set the switch 1 and 3 to ON, with 2 OFF. When I power on with USB plugged in, I don’t see the /dev/ttyUSB* listing anymore, so I’m unable to flash.

How can I fix this ? Please help.

I’m confused.
Are you trying to get into fastboot (1 and 3 on)?
Or are you trying to get into recovery (1 and 2 on)?

Having it appear as ttyUSBx is only in recovery (1 and 2 on).

In fastboot, you need to use “fastboot devices” to detect it, or lsusb. It won’t result in any device file. You would then flash it with “fastboot flash {partition name} {partition.img}”.

Recovery is only needed if you break it so badly that fastboot doesn’t start.

I also suggest that you don’t use flash-all.sh, rather use uefi-flash-all.sh

What is the source of your flash-all.sh script? Your output is not consistent with the one in AOSP.

I am trying to flash using the instructions mentioned in https://optee.readthedocs.io/building/aosp/aosp.html.

The flash_all.sh script is doing steps related to both recovery and fastboot. I am not sure which switches should be set because recovery related steps needs 1 and 2, vs fastboot related steps need 1 and 3.

Current flash_all.sh script:

#!/bin/bash
if [ $# -eq 0 ]
then
echo “Provide the right /dev/ttyUSBX specific to recovery device”
exit
fi

if [ ! -e “${1}” ]
then
echo “device: ${1} does not exist”
exit
fi
DEVICE_PORT="${1}"
PTABLE=prm_ptable.img

INSTALLER_DIR="dirname ${0}"
FIRMWARE_DIR="${INSTALLER_DIR}"

if [ -z “${ANDROID_BUILD_TOP}” ]; then
ANDROID_BUILD_TOP=${INSTALLER_DIR}/…/…/…/…/…/
ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey960"
fi

if [ -z “${DIST_DIR}” ]; then
DIST_DIR="${ANDROID_BUILD_TOP}"/out/dist
fi

#get out directory path
while [ $# -ne 0 ]; do
case “${1}” in
–out) OUT_IMGDIR=${2};shift;;
–use-compiled-binaries) FIRMWARE_DIR="${DIST_DIR}";shift;;
esac
shift
done

if [[ “${FIRMWARE_DIR}” == “${DIST_DIR}” && ! -e “${DIST_DIR}”/fip.bin && ! -e “${DIST_DIR}”/l-loader.bin ]]; then
echo “No binaries found at ${DIST_DIR}. Please build the bootloader first”
exit
fi

if [ -z “${OUT_IMGDIR}” ]; then
if [ ! -z “${ANDROID_PRODUCT_OUT}” ]; then
OUT_IMGDIR="${ANDROID_PRODUCT_OUT}"
fi
fi
if [ ! -d “${OUT_IMGDIR}” ]; then
echo “error in locating out directory, check if it exist”
exit
fi

echo “android out dir:${OUT_IMGDIR}”

echo “flashing recovery images… please wait ~10 seconds”
sudo “${INSTALLER_DIR}”/hikey_idt -c “${INSTALLER_DIR}”/config -p “${DEVICE_PORT}”
sleep 10
echo “set a unique serial number”
serialno=fastboot getvar serialno 2>&1 > /dev/null
if [ “${serialno:10:6}” == “(null)” ]; then
fastboot oem serialno
else
if [ “${serialno:10:15}” == “0123456789abcde” ]; then
fastboot oem serialno
fi
fi
echo “flashing all other images”
fastboot flash ptable “${INSTALLER_DIR}”/prm_ptable.img
fastboot flash xloader “${INSTALLER_DIR}”/hisi-sec_xloader.img
fastboot flash fastboot “${INSTALLER_DIR}”/l-loader.bin
fastboot flash fip “${INSTALLER_DIR}”/fip.bin
#fastboot flash nvme “${INSTALLER_DIR}”/hisi-nvme.img
fastboot flash boot “${ANDROID_PRODUCT_OUT}”/boot.img
fastboot flash cache “${ANDROID_PRODUCT_OUT}”/cache.img
fastboot flash system “${ANDROID_PRODUCT_OUT}”/system.img
fastboot flash userdata “${ANDROID_PRODUCT_OUT}”/userdata.img
fastboot flash vendor “${ANDROID_PRODUCT_OUT}”/vendor.img

I think you want 1 and 2 on, 3 off.

With 1 and 2 on, the flash script gets stuck after flashing recovery parts. I have to power cycle with 1 and 3 on and flash the remaining parts using fastboot.

Well at least you got it sorted out.

@a2t2 Thanks for reporting the issue. The part to set the serial number has been removed.

@vchong Can you post the updated flash script here ? Thanks

Just delete the lines below from flash_all.sh

echo "set a unique serial number"
serialno=`fastboot getvar serialno 2>&1 > /dev/null`
if [ "${serialno:10:6}" == "(null)" ]; then
    fastboot oem serialno
else
    if [ "${serialno:10:15}" == "0123456789abcde" ]; then
        fastboot oem serialno
    fi
fi

This change didn’t help. The script still gets stuck. I tried using switches 1 and 2 on, and 3 off.

flashing recovery images… please wait ~10 seconds
Config name: ./device/linaro/hikey/installer/hikey960/config
Port name: /dev/ttyUSB0
0: Image: device/linaro/hikey/installer/hikey960/hisi-sec_usb_xloader.img Downalod Address: 0x20000
1: Image: device/linaro/hikey/installer/hikey960/hisi-sec_uce_boot.img Downalod Address: 0x6a908000
2: Image: device/linaro/hikey/installer/hikey960/recovery.bin Downalod Address: 0x1ac00000
Serial port open successfully!
Start downloading device/linaro/hikey/installer/hikey960/hisi-sec_usb_xloader.img@0x20000…
file total size 99584
downlaod address 0x20000
Finish downloading
Start downloading device/linaro/hikey/installer/hikey960/hisi-sec_uce_boot.img@0x6a908000…
file total size 23680
downlaod address 0x6a908000
Finish downloading
Start downloading device/linaro/hikey/installer/hikey960/recovery.bin@0x1ac00000…
file total size 1179648
downlaod address 0x1ac00000
Finish downloading
flashing all other images
< waiting for any device >

For now I will use the two step approach of power cycling to change the switches.