rumpeltux / viomi-rooting

Tool for rooting the Xiaomi STYJ02YM (viomi-v7) and Mijia STYTJ02YM (viomi-v8) vacuum robot
100 stars 36 forks source link

Viomi v8 (aka STYTJ02YM) bricked #59

Open emmexx opened 9 months ago

emmexx commented 9 months ago

Before giving in and order a replacement board I'd like to know if I did something wrong or I'm simply unlucky. I followed the directions given in the github page and in itooktheredpill article Before using the viomi-rooting script I tried manually. I detached the battery, connected a usb data cable to the microusb port, pressed the home button, connected the usb cable to my pc, waited about one second, pushed about ten times the power button and so on, to no avail, in dmesg no android device appeared. I tried at least 20 times. At almost every trial I heard the "Turning on", "Device connected" and "Setup completed" voice messages.

After that I tried using the script, I thought I was missing something and the script could help me. I run NEW_V8=1 ./viomi-root.sh and followed the instructions, again to no avail. After some more trials I realized that there were no more voice messages. I checked the cable, turned off and on the vacuum and noticed that the power and home leds were blinking slowly and nothing happened when pushing the buttons, no voice, no poweroff, no vacuum trying to go home. I found out that I could turn off the robot by pressing some random combination of the 2 buttons and of the front bumper button and after that keeping the Power button pushed for at least 10 seconds. I could enter a test mode by pressing the Home and Power buttons together, the leds turned orange and stopped blinking, but still no voice and I'm not sure the test mode was working because without the voice cues is impossible to understand what to do.

I don't understand what happened, the script probably didn't even get to the adb shell part since the right usb device never appeared. Could plugging and unplugging the usb cable damage the software or the board?

I read @mLupine article on unbricking the robot by disassembling it but it is an old article, links to the firmware are broken and even trying to shortcircuit the emmc memory didn't work for me. Anyway I connected the uart pins on the board to a usb to ttl device connected to my pc.

After reading a lot of articles, comments and issues I found out that I could access the U-boot shell but I don't know what can I do from there. I tried fastboot_test and fastboot devices, as suggested by mLupine, and it did work, the device is listed but I don't have the suggested firmware, I can't flash anything and I'm not sure it would be a good idea.

I read articles from @dgiese but they don't seem to apply to my model. This article has some commands that I used to try to bypass the login but, again, I don't know what to do from there.

I even cracked a root password I found in /etc/shadow (it's tina) but it doesn't work when I use it in the shell login.

I'd like to know if there is something I can do to unbrick the robot. As I wrote I can access th U-boot shell, I can access the openwrt terminal by forcing the robot to boot with some wrong parameter, but I don't know what to do from there.

Is there something I can check to try to understand what went wrong? Is there something I can flash (using fastboot) to let the robot start again?

The following is the output in the u-boot shell that I can access using the usb to ttl device

HELLO! BOOT0 is starting!
boot0 version : 4.2.0
boot0 commit : a1ae6c20d88d561753072492191f817d9ff10a36

fel_flag = 0x00000000
rtc[0] value = 0x00000000
rtc[1] value = 0x00000000
rtc[2] value = 0x00000000
rtc[3] value = 0x00000000
DRAM DRIVE INFO: V1.7
DRAM Type =3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM zq value: 00003bbbDRAM CLK =552 MHZ
ID CHECK VERSION: V0.1
using ic R16
USE PLL DDR1
USE PLL NORMAL
PLL FREQUENCE = 1104 MHZ
DRAM PLL DDR1 frequency extend open !
DRAM master priority setting ok.
Auto calculate timing parameter!
para_dram_tpr0 = 0047214f
para_dram_tpr1 = 01c2294b
para_dram_tpr2 = 00061043
tcl = 6,tcwl = 4
DRAM TIMING PARA0 = 0b0e180b
DRAM TIMING PARA1 = 0003040f
DRAM TIMING PARA2 = 0406050a
DRAM TIMING PARA3 = 0000400c
DRAM TIMING PARA4 = 05020405
DRAM TIMING PARA5 = 05050403
DRAM TIMING PARA8 = 90003310
DRAM PHY INTERFACE PARA = 02040102
DRAM VTC is disable
DRAM dynamic DQS/DQ ODT is on
DRAM DQS gate is PD mode.
DRAM one rank training is on,the value is 91003587
DRAM work mode register value = 004318e4
DRAM SIZE =512 M
set one rank ODTMAP
DRAM simple test OK.
dram size =512
NAND_ClkRequest, nand_index: 0x00001000
Reg 0x01c20080: 0x00053de3
Reg 0x01c20060: 0x00053dd6
Reg 0x01c202c0: 0x00053dd6
NAND_SetClk, nand_index: 0x0000000a
Reg 0x01c20080: 0x00053de7
NB0 : nand phy init ok
block from 4 to 39
nand block 4 is bad
nand block 5 is bad
nand block 6 is bad
nand block 7 is bad
current block is 8 and last block is 39.
current block is 9 and last block is 39.
current block is 10 and last block is 39.
current block is 11 and last block is 39.
current block is 12 and last block is 39.
current block is 13 and last block is 39.
current block is 14 and last block is 39.
sum=887f6a46
src_sum=887f6a46
The file stored in start block %u is perfect.
Ready to disable icache.
Jump to secend Boot.
[      0.448]

U-Boot 2011.09-rc1-dirty (Apr 25 2017 - 14:33:40) Allwinner Technology

[      0.456]version: 1.1.0
[      0.459]uboot commit : a1ae6c20d88d561753072492191f817d9ff10a36

[      0.466]pmbus:   normal or secure os
ready
[      0.470]PMU: AXP221
[      0.473]PMU: AXP22x found
bat_vol=5, ratio=100
[      0.478]PMU: dcdc3 1100
[      0.481]PMU: pll1 1008 Mhz,PLL6=600 Mhz
AXI=336 Mhz,AHB=200 Mhz, APB1=100 Mhz
dcdc1_vol = 3000
dcdc2_vol = 1100
dcdc3_vol = 1100
dcdc4_vol = 0
dcdc5_vol = 1500
aldo2_vol = 2500
aldo3_vol = 3000
find power_sply to end
vbus exist
fel key new mode
run key detect
no key found
no key input
dram_para_set start
dram_para_set end
[      1.604]DRAM:  512 MiB
relocation Offset is: 1e1f3000
save config for small mem_size
workmode = 0
[      1.672]NAND: NAND_UbootInit
NAND_UbootInit start
NB1 : enter NAND_LogicInit
uboot:nand version: 3 5003 20170418 1437
nand : get id_number_ctl fail, 1
uboot:nand info: 9590dac2 ffffff06 28c 0 0
nand : get sorting_flag fail, a
nand : get CapacityLevel fail, 5eb96e90
not burn nand partition table!
NB1 : nftl num: 1
 init nftl: 0
 NB1 : NAND_LogicInit ok, result = 0x0
 [      2.230]sunxi flash init ok
 In:    serial
 Out:   serial
 Err:   serial
 --------fastboot partitions--------
 -total partitions:11-
 -name-        -start-       -size-
 boot-res    : 1000000       100000
 env         : 1100000       100000
 boot        : 1200000       a00000
 rootfs      : 1c00000       3000000
 rootfs_data : 4c00000       a00000
 private     : 5600000       100000
 recovery    : 5700000       2000000
 misc        : 7700000       100000
 verity_block: 7800000       100000
 secret      : 7900000       a00000
 UDISK       : 8300000       0
 -----------------------------------
 base bootcmd=run setargs_nand boot_normal
 bootcmd set setargs_nand
 key 0
 cant find rcvy value
 cant find fstbt value
 misc partition found
 to be run cmd=run setargs_nand boot_normal
 sunxi_serial: sn_filename is not exist
 serial is: 2907900c50c9fffff46a
 Net:   usb_etherWarning: failed to set MAC address

 WORK_MODE_BOOT
 board_status_probe
 sunxi_bmp_logo_display
 sunxi secure storage is not supported
 [      2.367]usb burn from boot
 delay time 0
 [      2.438]usb prepare ok
 usb sof ok
 vbus pc exist ,limit to pc
 [      2.812]usb probe ok
 [      2.815]usb setup ok
 ==== try to handshake ====
 set address 0x14
 [      5.817]timer occur
 [      5.852]do_burn_from_boot usb : have no handshake
 [      5.857]Hit any key to stop autoboot:  0
 fatload partition name: boot -> 2
 ## Booting kernel from Legacy Image at 43800000 ...
    Image Name:   ARM OpenWrt Linux-3.4.39
       Image Type:   ARM Linux Kernel Image (uncompressed)
          Data Size:    10432740 Bytes = 9.9 MiB
             Load Address: 40008000
                Entry Point:  40008000
                   Verifying Checksum ... OK
                      Loading Kernel Image ... OK
                      OK
                      [      6.657][mmc]: MMC Device 2 not found
                      [      6.661][mmc]:  mmc  not find,so not exit
                      NAND_UbootExit
                      NB1 : NAND_LogicExit
                      nand release dma:0
                      reload config to 0x43000000
                      [      6.665]
                      Starting kernel ...

                      [    0.078937] hci: ERR: get ehci1 abh clk failed.
                      [    0.079074] hci: ERR: clock_init failed
                      [    0.079213] hci: ERR: get ohci1 abh clk failed.
                      [    0.079442] hci: ERR: clock_init failed
                      [    1.379307] sunxikbd_script_init: key para not found, used default para.
                      [    1.387628] [RTC] WARNING: Rtc time will be wrong!!
                      [    1.405627] [audiocodec] : aif3 not used!
                      [    1.419954] otg_wakelock_init: No USB transceiver found
                      [    1.426023] sunxi-rtc sunxi-rtc: hctosys: unable to read the hardware clock
                      [    1.433916] ths_fetch_sysconfig_para: type err  device_used = 1.
                      mount: mounting proc on /proc failed: Resource busy
                      mount: mounting sysfs on /sys failed: Resource busy
                      mount: mounting none on /dev failed: Resource busy
                      [/init_sunxi]: getty is ttyS2
                      [/init_sunxi]: RootDevice is "/dev/nandd" , GPT_SUPPORT=
                      [/init_sunxi]: verity block is /dev/nandi
                      [/init_sunxi]: rootfstype is
                      [/init_sunxi]: Try to load Nand ...
                      Verified OK
                      formating /secret to do_check_secret...
                      cp: can't stat '/secret/bin': No such file or directory
                      [    3.825348] block: extroot: UUID match (root: d6b0ba18-dbae6922-91790d92-58f94cef, overlay: d6b0ba18-dbae6922-91790d92-58f94cef)
                      [    4.090077] WRN:L2870(drivers/usb/sunxi_usb/udc/sunxi_udc.c):pdev is null

                      TinaLinux login:
                      Login tiPlease press Enter to activate this console.
simonswine commented 7 months ago

@emmexx unsure if you solved your issue in the meantime, but I am in similar position like described in #43, after having flashed the dustbuilder image on a v8 via fastboot.

I do think if you still have the original rootfs.img I could work something out, but unfortunately I managed to overwrite that image backup myself.

So you can't access adb shell, but you have access to uboot shell via pressing S?

emmexx commented 7 months ago

In the meantime I ordered a used board from Aliexpress... It is a v7 version and installing Valetudo was very easy.

I don't know what rootfs.img is, I suppose you mean a backup of the root partition from before bricking the device? I found out I could access the U-boot shell only after bricking the robot, so I don't have any file. If you can give me some directions I can try and make the file available to you.

Yes, I can't access adb shell but I can access u-boot by pressing s after powering up the board. I can access the "linux" shell if I mess with the booting parameters but I don't know what to do from there.

simonswine commented 7 months ago

I suppose you mean a backup of the root partition from before bricking the device?

Yes exactly that.

If you can give me some directions I can try and make the file available to you.

Thank you so much for offering your help. I will try to compile a list of commands, but won't get to it till at least tonight.

simonswine commented 7 months ago

@emmexx

These are the steps that should roughly retrieve images:

## Your machine
# Prepare boot.img for recovery partition
curl -LO https://builder.dontvacuum.me/pkg/firmwares/viomi/v6/3.5.8_0046/c341fa57e47db80bbff2064983b8a4b0_upd_viomi.vacuum.v6.bin
tar xvzf c341fa57e47db80bbff2064983b8a4b0_upd_viomi.vacuum.v6.bin
tar xvzf CRL200S-OTA/target_sys.tar.gz

## TTY Uboot shell, enter fastboot
fastboot_test

## Your machine
# Flash boot.img from v6 onto the recovery partition
fastboot flash recovery target_sys/boot.img

## TTY Uboot shell
# Exit fast boot by CTRL-C
# Now boot recovery
setenv bootargs console=${console} root=${nand_root} rootwait init=/bin/sh ion_cma_list="8m,32m,64m,128m,256m" loglevel=${loglevel} partitions=${partitions}
fatload sunxi_flash recovery 43800000 uImage
bootm 43800000

## TTY once kernel has booted to a shell / #
# Mount file systems
mount -n -t proc none /proc
mount -n -t sysfs none /sys
mount -n -t tmpfs none /tmp
mount -n -t tmpfs none /dev
mkdir -p /dev/pts /dev/shm /tmp/run
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
mknod -m 666 /dev/android_adb c 10 57
/sbin/init &
/sbin/ubusd &
/sbin/procd &
/etc/init.d/adbd start

## Your machine
# Now it should be possible to use adb shell 
adb pull /dev/by-name/boot boot.img
adb pull /dev/by-name/rootfs rootfs.img

To reverse all changes (also the ones most likely that bricked your board):

## TTY Uboot shell, enter fastboot
fastboot_test

## Reset the overlay over rootfs
fastboot erase rootfs_data

We also can sync up on a video call/chat for when you run those commands, just in case anything unexpected happens...

emmexx commented 7 months ago
BusyBox v1.24.1 () built-in shell (ash)

/bin/sh: can't access tty; job control turned off
/ # 
/ # mount -n -t proc none /proc
/ # mount -n -t sysfs none /sys
/ # mount -n -t tmpfs none /tmp
/ # mount -n -t tmpfs none /dev
/ # mkdir -p /dev/pts /dev/shm /tmp/run
/ # mount -vt devpts -o gid=4,mode=620 none /dev/pts
/ # mount -vt tmpfs none /dev/shm
/ # mknod -m 622 /dev/console c 5 1
/ # mknod -m 666 /dev/null c 1 3
/ # mknod -m 666 /dev/zero c 1 5
/ # mknod -m 666 /dev/ptmx c 5 2
/ # mknod -m 666 /dev/tty c 5 0
/ # mknod -m 444 /dev/random c 1 8
/ # mknod -m 444 /dev/urandom c 1 9
/ # mknod -m 666 /dev/android_adb c 10 57
/ # /sbin/init &
/ # formating /secret to do_check_secret...
cp: can't stat '/secret/bin': No such file or directory
/sbin/ubusd &
/ # /sbin/procd &
/ # /etc/init.d/adbd start
/bin/sh: /etc/init.d/adbd: not found

adbd is in /bin/adbd so I changed /etc/init.d/adbd start to /bin/adbd start

but...

adb pull /dev/by-name/boot boot.img
* daemon not running; starting now at tcp:5037
* daemon started successfully
adb: error: failed to get feature set: no devices/emulators found

If I follow the steps I received in the email notification (?), there are different steps after /sbin/procd & I get stuck with a Read-only file system error:

cat > /bin/adb_shell <<"EOF"
> #!/bin/sh
> export ENV='/etc/adb_profile'
> exec /bin/sh "$@"
> EOF
/bin/sh: can't create /bin/adb_shell: Read-only file system
/ # rm /etc/rc.d/S90robotManager
rm: can't remove '/etc/rc.d/S90robotManager': Read-only file system

Concerning the video call, if it can be of any help for you to understand the problem, I live in Italy, let me know when it could be convenient for you.

simonswine commented 7 months ago

@emmexx sorry it has taken a while to get back to you. I do think the root is a bit different to the v6/v7 images.

To start adbd you also need to enable the right android_usb mode.

This should do it (instead of running /etc/init.d/adbd start:

echo 0 > /sys/class/android_usb/android0/enable
echo 18d1 > /sys/class/android_usb/android0/idVendor
echo D002 > /sys/class/android_usb/android0/idProduct
echo adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
/sbin/adbd -D

Then hopefully the adb pull will work on your machine.

Separately I have send you an email with my contact details, we could look into potential issues when you run those commands.

Thank you again!

glanthimos commented 4 weeks ago

In the meantime I ordered a used board from Aliexpress... It is a v7 version and installing Valetudo was very easy.

I don't know what rootfs.img is, I suppose you mean a backup of the root partition from before bricking the device? I found out I could access the U-boot shell only after bricking the robot, so I don't have any file. If you can give me some directions I can try and make the file available to you.

Yes, I can't access adb shell but I can access u-boot by pressing s after powering up the board. I can access the "linux" shell if I mess with the booting parameters but I don't know what to do from there.

Can you please give me details about the used v7 board you bought from aliexpress? I think it is the only solution for my v8 as well unfortunately. How did you search for the board?

emmexx commented 4 weeks ago

@glanthimos

Can you please give me details about the used v7 board you bought from aliexpress? I think it is the only solution for my v8 as well unfortunately. How did you search for the board?

I browsed Aliexpress, read some comments and checked the images to be sure that the board was ok for my robot. This is the link to the aliexpress vendor that I found. The price was reasonable, I paid 18.68€.