We have moved to a new Sailfish OS Forum. Please start new discussions there.
2

flash.sh syntax error, keeps running/hanging, but zero or slow progress [answered]

asked 2019-10-05 22:58:07 +0300

pilino gravatar image

updated 2019-10-07 20:02:20 +0300

I'm trying to flash a new Xperia XA2 devices with the latest Sailfish X version. During the flashing process I'm running into this issue:

> bash flash.sh 
Detected Linux
Searching device to flash..
Found 1 devices: CQ3001HC3L 
Fastboot command: fastboot -s CQ3001HC3L  
flash.sh: line 135: ((: FAILED > 50 || FAILED == 50 &&  > 1 : syntax error: operand expected (error token is "> 1 ")

However, the script keeps running despite the syntax error. But when it starts flashing, nothing happens:

> bash flash.sh 
Detected Linux
Searching device to flash..
Found 1 devices: CQ3001HC3L 
Fastboot command: fastboot -s CQ3001HC3L  
flash.sh: line 135: ((: FAILED > 50 || FAILED == 50 &&  > 1 : syntax error: operand expected (error token is "> 1 ")
Flashing boot_a partition..
Sending 'boot_a' (18464 KB)

It has been setting at this stage for 20 minutes.

I turned the device off, booted into Android once, turned it off again, put it back into fastboot mode and tried again with the exact same result.

I've tested several different USB ports and cables on two computers, always getting the same result.

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by peterleinchen
close date 2019-10-06 16:05:12.984330

Comments

That does fix the syntax error, but flashing doesn't even find the device now. Instead, the device reboots at this point, and the script exits with the following message:

Searching device to flash..
No device that can be flashed found. Please connect your device in fastboot mode before running this script.

The device is in fastboot mode and connected. In another terminal I can find it without problems:

# ./fastboot devices -l
CQ3001HC3L             fastboot usb:3-13.1
pilino ( 2019-10-06 00:22:11 +0300 )edit

Not really having an idea but it could it be USB 3 issue? https://together.jolla.com/question/193348/xa2-flashing-issues/

And where did you get that erroneous flashing script from?

peterleinchen ( 2019-10-06 11:15:34 +0300 )edit

@peterleinchen Yes, I had that suspicion as well, especially since dmesg would report the device as a USB3 devices even though the port is usb 2.... So I applied the workaround listed on the helpdesk article about USB3 flashing to downgrade all ports to USB2. The issue remains...

The flashing script with the error is the one included with the latest download version of Sailfish X for Xperia XA2 devices :/

pilino ( 2019-10-06 14:02:05 +0300 )edit

Strange.

I downloaded the 3.1.0.11 for H4113 few weeks ago and my flash script does not contain mentioned lines.

Are you sure you followed all steps? Install required dependences, extract the downloaded zip, change to that extracted directory... start command with prepended ".\"

Else I just do not know :(

peterleinchen ( 2019-10-06 15:05:27 +0300 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2019-10-06 15:24:48 +0300

pilino gravatar image

After trying to use the flashing script that @coderus linked me at https://github.com/mer-hybris/droid-config-sony-nile/blob/master/sparse/boot/flash.sh the syntax error went away.

However, the device would still not flash properly; the script would tell me

> ./flash_upstream.sh 
Detected Linux
Searching device to flash..
No device that can be flashed found. Please connect your device in fastboot mode before running this script.

In a different terminal, I ran the following:

# ./fastboot devices -l
CQ3001HC3L             fastboot usb:3-13.1

so the device obviously isconnected in fastboot mode. Next, I realized that the fastboot "address" starts with usb:3, so I decided to test the proposed workaround in the helpdesk article about flashing from USB3 ports: https://jolla.zendesk.com/hc/en-us/articles/360012031854

I ran the following command as root:

lspci -nn | grep USB | cut -d '[' -f3 | cut -d ']' -f1 | xargs -I@ sudo setpci -H1 -d @ d0.l=0

which turned all ports into USB2 ports temporarily. Now, when connecting the device, both dmesg and fastboot list the device as a USB2 device. But the flashing script still would not work on the device.

In the meantime, I had found that the device sometimes randomly restarts when issuing a fastboot command to it. I would hit enter in the terminal, the command would begin running, then the device would turn off and restart, and the command would hang forever. This happened randomly, and I was not able to identify some regular behaviour or pattern, or steps to reproduce it systematically.

I kept poking in the flashing script, and found that it essentially runs a number of fastboot flash [partition] [image file] commands. So, I decided to start running these manually. Without much success at first, the behaviour was still the same as described in the original post in this thread. The flashing command would just hang after sending.

Then, I came up with this idea: When I issue a fastboot command and the device reboots, I'll hold the Volume-Up button at the same time, so that it reboots back into fastboot mode. So, here are the steps:

  1. Run the flash command for the first partition fastboot flash boot_a ${SAILFISH_IMAGE_PATH}hybris-boot.img as root.
  2. The device decides to reboot (you can see this when the blue LED turns off). The fastboot flash command will hang, do not interrupt it.
  3. Hold the volume up button while it does this, it will reboot back into fastboot mode.
  4. Once the device is back into fastboot mode, the flashing command will continue running and succeed!

I repeated this procedure several times for the other partitions that are flashed by the script:

  1. fastboot flash boot_a ${SAILFISH_IMAGE_PATH}hybris-boot.img
  2. fastboot flash boot_b ${SAILFISH_IMAGE_PATH}hybris-boot.img
  3. fastboot flash userdata ${SAILFISH_IMAGE_PATH}sailfish.img001
  4. fastboot flash system_b ${SAILFISH_IMAGE_PATH}fimage.img001
  5. fastboot flash vendor_a ${SAILFISH_IMAGE_PATH}vendor.img001
  6. fastboot flash vendor_b ${SAILFISH_IMAGE_PATH}vendor.img001
  7. fastboot flash oem_a ${SAILFISH_IMAGE_PATH}SW_binaries_for_Xperia_Android_8.1.6.4_r1_v17_nile.img (this is the vendor binary downloaded from the Sony website)

And it works.

If you, as a future reader, found this post because you have a similar issue, I'm sorry for the vague problem description and solution; I neither know what's actually going wrong nor why this fix works. But it did work for me, so I'm writing it up anyway, in case someone else actually ever encounters this same problem :D

edit flag offensive delete publish link more

Comments

Well done!

description of Jolla: to flash you will need some skills (or similar) :D

peterleinchen ( 2019-10-06 16:03:20 +0300 )edit
0

answered 2019-10-06 01:31:34 +0300

WT.Sane gravatar image

updated 2019-10-06 01:34:00 +0300

If you have a dual sim model you will have to do step 4:

  1. Unlock your bootloader

for both IMEIs. Otherwise the correct device won't be found.

(And btw: It's volume up only and not volume up plus on like for the Xperia X).

Good Luck!

edit flag offensive delete publish link more

Comments

Thanks for your answer! It's a single SIM model, bootloader is unlocked and I can read that from the device using fastboot. But flashing is eternally stuck.

pilino ( 2019-10-06 01:47:11 +0300 )edit

Are you running that script as root?

WT.Sane ( 2019-10-06 02:52:27 +0300 )edit

And... it really takes some time to flash the XA2.

WT.Sane ( 2019-10-06 02:55:56 +0300 )edit

I've tried lots of things at this point, including running the script as root, as well as running the individual fastboot flash commands that the script ultimately runs. I left the flashing command for the boot_a partition running over night, and there is still no progress.

pilino ( 2019-10-06 10:30:14 +0300 )edit
1

That (unlocking for both SIMs sounds) like non-sense to me. I unlocked the bootloader by using the IMEI of first tray (as described) and succeeded.

Only thing was (bit I do not remember exactly) that on first try the flash.sh claimed that the bootloader were not unlocked. But (iirc) I just shut down the device completely and restarted into flashing mode and tada...

peterleinchen ( 2019-10-06 11:13:51 +0300 )edit

Question tools

Follow
4 followers

Stats

Asked: 2019-10-05 22:58:07 +0300

Seen: 603 times

Last updated: Oct 06 '19