khadas / utils

Utils/Tools for development
141 stars 75 forks source link

Error while flash Ubuntu image "Running u-boot [KO]" #22

Open chiragpatelmn opened 3 months ago

chiragpatelmn commented 3 months ago

Hello, I am trying to flash the ubuntu-22.04-gnome-linux image in the VIM3 board but am facing an error. Can you help me know the reason for the error and the solution?

[Environment details] OS: Ubuntu 22.04.4 LTS

[Steps Followed] $ sudo apt-get install libusb-dev git parted $ git clone https://github.com/khadas/utils $ cd utils $ git pull $ sudo ./INSTALL Connected board using a USB cable and put the VIM3 board into Upgrade Mode. $ lsusb | grep Amlogic Bus 001 Device 017: ID 1b8e:c003 Amlogic, Inc. GX-CHIP $ sudo aml-burn-tool -b VIM3 -i /home/usr/Documents/khadas/VIM3/OS/ubuntu/emmc/ubuntu_22_04/vim3-ubuntu-22.04-gnome-linux-5.15-fenix-1.6.9-240618-emmc.img Burning image '/home/usr/Documents/khadas/VIM3/OS/ubuntu/emmc/ubuntu_22_04/vim3-ubuntu-22.04-gnome-linux-5.15-fenix-1.6.9-240618-emmc.img' for 'VIM3/VIM3L' to eMMC... Unpacking image [OK] Initializing ddr ........[OK] Running u-boot [KO]

I have also tried using burn-tool with and without sudo but getting the same output. $ sudo burn-tool -v aml -b VIM3 -i /home/usr/Documents/khadas/VIM3/OS/ubuntu/emmc/ubuntu_22_04/vim3-ubuntu-22.04-gnome-linux-5.15-fenix-1.6.9-240618-emmc.img

fsheikh commented 2 months ago

I see a very similar issue but with host machine Ubuntu 20.04. I have followed the installation guide steps similar to reported by @chiragpatelmn above. Image tried is android PIE. Results are same with either of burn-tool or aml-burn-tool. However later has a debug option which emits more information showing a USB data transfer error during update of bl2_boot

aml-burn-tool -b VIM3 -i update.img -D
Burning image 'update.img' for 'VIM3/VIM3L' to eMMC...
host_os      = Linux cmucl1010638 5.15.0-119-generic #129~20.04.1-Ubuntu SMP Wed Aug 7 13:07:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
host_machine = Linux cmucl1010638 5.15.0-119-generic #129~20.04.1-Ubuntu SMP Wed Aug 7 13:07:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
SYSTEM       = linux-x86
EXE          = 

Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null identify 7 
- Results ---------------------------------------------------
 AmlUsbIdentifyHost
This firmware version is 3-2-0-0-0-1-0 
-------------------------------------------------------------

Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null identify 7 
- Results ---------------------------------------------------
 AmlUsbIdentifyHost
This firmware version is 3-2-0-0-0-1-0 
-------------------------------------------------------------

Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null bulkcmd "     echo 12345" 
- Results ---------------------------------------------------
 AmlUsbBulkCmd[     echo 12345]
[AmlUsbRom]Err:return len=0 < strLenBusy 11
[AmlUsbRom]Inf:bulkInReply 
ERR: AmlUsbBulkCmd failed! 
-------------------------------------------------------------

Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null identify 7 
- Results ---------------------------------------------------
 AmlUsbIdentifyHost
This firmware version is 3-2-0-0-0-1-0 
-------------------------------------------------------------

Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null rreg 4 0xff800228 
- Results ---------------------------------------------------
 [update]Total tansfer size 0x4

FF800228: e0f83180  
-------------------------------------------------------------

0xff800228      = 0xe0f83180
Secure boot bit = 0
Unpacking image 
[Msg]Image package version 0x2
[Msg]Unpack item [USB         ,              DDR] to (/tmp/aml-flash-tool-2bOz/DDR.USB) size:1583984 bytes
[Msg]Backup item [USB         ,            UBOOT] backItemId[0][USB, DDR]
[Msg]Unpack item [PARTITION   ,         _aml_dtb] to (/tmp/aml-flash-tool-2bOz/_aml_dtb.PARTITION) size:93274 bytes
[Msg]Unpack item [UBOOT       ,     aml_sdc_burn] to (/tmp/aml-flash-tool-2bOz/aml_sdc_burn.UBOOT) size:1584496 bytes
[Msg]Unpack item [ini         ,     aml_sdc_burn] to (/tmp/aml-flash-tool-2bOz/aml_sdc_burn.ini) size:589 bytes
[Msg]Unpack item [PARTITION   ,             boot] to (/tmp/aml-flash-tool-2bOz/boot.PARTITION) size:9584640 bytes
[Msg]Backup item [PARTITION   ,       bootloader] backItemId[0][USB, DDR]
[Msg]Unpack item [PARTITION   ,             dtbo] to (/tmp/aml-flash-tool-2bOz/dtbo.PARTITION) size:438 bytes
[Msg]Unpack item [PARTITION   ,             logo] to (/tmp/aml-flash-tool-2bOz/logo.PARTITION) size:929424 bytes
[Msg]Backup item [dtb         ,           meson1] backItemId[2][PARTITION, _aml_dtb]
[Msg]Unpack item [PARTITION   ,              odm] to (/tmp/aml-flash-tool-2bOz/odm.PARTITION) size:544844 bytes
[Msg]Unpack item [conf        ,         platform] to (/tmp/aml-flash-tool-2bOz/platform.conf) size:155 bytes
[Msg]Unpack item [PARTITION   ,          product] to (/tmp/aml-flash-tool-2bOz/product.PARTITION) size:14610508 bytes
[Msg]Unpack item [PARTITION   ,         recovery] to (/tmp/aml-flash-tool-2bOz/recovery.PARTITION) size:16277504 bytes
[Msg]Unpack item [PARTITION   ,           system] to (/tmp/aml-flash-tool-2bOz/system.PARTITION) size:1384825076 bytes
[Msg]Unpack item [PARTITION   ,           vbmeta] to (/tmp/aml-flash-tool-2bOz/vbmeta.PARTITION) size:4096 bytes
[Msg]Unpack item [PARTITION   ,           vendor] to (/tmp/aml-flash-tool-2bOz/vendor.PARTITION) size:249520300 bytes
[Msg]Write config file "/tmp/aml-flash-tool-2bOz/image.cfg" OK!
Image unpack OK!
[OK]

Parsing image configuration files
---------------------------------
platform_conf_name  = platform.conf
ddr_filename        = DDR.USB
uboot_filename      = DDR.USB
uboot_comp_filename = 
dtb_meson_filename  = 
dtb_meson1_filename = _aml_dtb.PARTITION
dtb_meson1_enc_filename = 
ddr_enc_filename    = 
uboot_enc_filename  = 
keys_filename       = 
platform            = 0x0811
bin_params          = 
ddr_load            = 0xfffa0000
ddr_run             = 0xfffa0000
uboot_down          = 
uboot_decomp        = 
uboot_enc_down      = 
uboot_enc_run       = 
uboot_load          = 
uboot_run           = 
bl2_params          = 
nb_partitions       = 11

Partition list
--------------
0 _aml_dtb.PARTITION _aml_dtb normal
1 boot.PARTITION boot normal
2 DDR.USB bootloader normal
3 dtbo.PARTITION dtbo normal
4 logo.PARTITION logo normal
5 odm.PARTITION odm sparse
6 product.PARTITION product sparse
7 recovery.PARTITION recovery normal
8 system.PARTITION system sparse
9 vbmeta.PARTITION vbmeta normal
10 vendor.PARTITION vendor sparse

Bootloader/DTB files
--------------------
bootloader_file = /tmp/aml-flash-tool-2bOz/DDR.USB
dtb_file        = /tmp/aml-flash-tool-2bOz/_aml_dtb.PARTITION

Initializing ddr 
Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null write /tmp/aml-flash-tool-2bOz/DDR.USB 0xfffa0000 0x10000 
- Results ---------------------------------------------------
 ..
Transfer Complete! total size is 65536 Bytes 
-------------------------------------------------------------

Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null run 0xfffa0000 
- Results ---------------------------------------------------
 [update]Run at Addr fffa0000
AmlUsbRunBinCode:ram_addr=fffa0000 
-------------------------------------------------------------

........[OK]
Running u-boot 
Command -> /mnt/ssd-p2/fx-wkspace/khadas_vim3/VIM3_Pie_V211220/utils/aml-flash-tool/tools/linux-x86/update 2>/dev/null bl2_boot /tmp/aml-flash-tool-2bOz/DDR.USB 
- Results ---------------------------------------------------
 [LUSB][AMLC]dataSize=16384, offset=65536, seq 0
[LUSB]requestType=0
[LUSB]ERR(L1016):Fail in down data, want 16384, but -110
[LUSB]ERR(L1187):fail in download, sequence 0 
-------------------------------------------------------------

[KO]

Cleanup

Serial console to VIM3 shows the following and then is stuck

 bl2_stage_init 0x01
bl2_stage_init 0x81
hw id: 0x0000 - pwm id 0x01
bl2_stage_init 0xc1
bl2_stage_init 0x02

L0:00000000
L1:20000703
L2:00008067
L3:14000000
B2:00402000
B1:e0f83180

TE: 211185733

BL2 Built : 19:23:21, Sep 18 2020. g12b g9fde858 - gongwei.chen@droid11-sz

Board ID = 10
Set A53 clk to 24M
Set A73 clk to 24M
Set clk81 to 24M
A53 clk: 1200 MHz
A73 clk: 1200 MHz
CLK81: 166.6M
smccc: 0c96ba88
board id: 10
Cfg max: 12, cur: 1. Board id: 255. Force loop cfg

I have the official Khadas USB-C to USB-A cable with USB-C attached to board and USB-A connector directly connected to host machine USB port without any hub in between. The USB storage device is detected correctly and is visible in dmesg

[305360.478307] usb 3-1: new high-speed USB device number 47 using xhci_hcd
[305360.627224] usb 3-1: New USB device found, idVendor=1b8e, idProduct=c003, bcdDevice= 0.20
[305360.627229] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[305360.627230] usb 3-1: Product: GX-CHIP
[305360.627231] usb 3-1: Manufacturer: Amlogic

Also shows up in lsusb

lsusb | grep Amlogic
Bus 003 Device 047: ID 1b8e:c003 Amlogic, Inc. GX-CHIP

With the udev rules looking like below:

cat /etc/udev/rules.d/70-persistent-usb-ubuntu14.rules 

# If not work, reference /lib/udev/rules.d/50-udev-default.rules with keyword 'SUBSYSTEM=="usb"'

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="1b8e", ATTR{idProduct}=="c003", MODE:="0666"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="1b8e", ATTR{idProduct}=="c004", MODE:="0666"

One thing I noticed is that during flashing there are some USB errors appearing in kernel logs

[305571.122398] usb 3-1: usbfs: process 1376772 (update) did not claim interface 0 before use
[305579.153589] usb 3-1: usbfs: process 1376816 (update) did not claim interface 0 before use

Can some developers confirm is the Amlogic burn tools are still expected to work with Ubuntu 20.04/Ubuntu22.04?

fsheikh commented 2 months ago

AMLogic Ubuntu USB driver is definitely flaky if not out-right buggy. I had to resort to connect the VIM3 with exact same cable setup to a Windows machine and follow the steps to recover the board.