superna9999 / pyamlboot

Amlogic USB Boot Protocol Library
https://pypi.org/project/pyamlboot/
Apache License 2.0
71 stars 27 forks source link

uboot tpl write fail #12

Closed godbin1990 closed 3 years ago

godbin1990 commented 3 years ago

I used the tool to unbrick my s905x box on ubuntu 20.04.1.Fisrt I confirm it's into the usb burning status.The command is "sudo boot.py p212", but it fails when writing to tpl file,it seems reboot on UART,lose USB control,others work OK. The only info "GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;" on UART. I tried to change the addr of the tpl writing from 0x200c000 to other(eg.0x0000c200), it shows writen done, also the running done. But nothing output on UART. Please tell me what's the problem?what should I do?Thank you!

here is the normal UART log from another OK same box: GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;0.0;CHK:0; TE: 153699

BL2 Built : 11:26:24, Jun 28 2016. gxl gc783966 - dianzhong.huo@droid08

set vcck to 1120 mv set vddee to 1000 mv Board ID = 2 CPU clk: 1200MHz DDR3 chl: Rank0+1 @ 912MHz - FAIL DDR3 chl: Rank0 @ 912MHz - PASS DQS-corr enabled DDR scramble enabled Rank0: 1024MB(auto)-2T-13 DataBus test pass! AddrBus test pass! -s Load fip header from eMMC, src: 0x0000c200, des: 0x01400000, size: 0x00004000 aml log : R1024 check pass! New fip structure! Load bl30 from eMMC, src: 0x00010200, des: 0x01700000, size: 0x0000d600 aml log : R1024 check pass! Load bl31 from eMMC, src: 0x00020200, des: 0x01700000, size: 0x00014400 aml log : R1024 check pass! Load bl33 from eMMC, src: 0x00038200, des: 0x01700000, size: 0x000a8a00 aml log : R1024 check pass! NOTICE: BL3-1: v1.0(debug):46845bf NOTICE: BL3-1: Built : 14:27:39, Sep 30 2016 aml log : bl31 detect secure boot ! [Image: gxl_v1.1.3139-ea96ccc 2017-03-16 14:05:55 qiufang.dai@droid07] OPS=0x82 1f c2 1a 4 b3 13 fc 8f 29 36 60 b3 [0.696079 Inits done] secure task start! high task start! low task start! INFO: BL3-1: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader ERROR: Error initializing runtime service opteed_fast INFO: BL3-1: Preparing for EL3 exit to normal world INFO: BL3-1: Next image address = 0x1000000 INFO: BL3-1: Next image spsr = 0x3c9

U-Boot 2015.01 (Jul 06 2020 - 22:15:28)

DRAM: 1 GiB Relocation Offset is: 36eca000 register usb cfg[0][1] = 0000000037f5eec8 vpu: clk_level = 7 vpu: set clk: 666667000Hz, readback: 666660000Hz(0x300) vpp: vpp_init boot_device_flag : 1 Nand PHY Ver:1.01.001.0006 (c) 2013 Amlogic Inc. init bus_cycle=6, bus_timing=7, system=5.0ns reset failed chip detect failed and ret:fffffffe nandphy_init failed and ret=0xfffffff1 MMC: aml_priv->desc_buf = 0x0000000033eca6b0 aml_priv->desc_buf = 0x0000000033ecc9d0 SDIO Port B: 0, SDIO Port C: 1 emmc/sd response timeout, cmd8, status=0x1ff2800 emmc/sd response timeout, cmd55, status=0x1ff2800 [mmc_startup] mmc refix success [mmc_init] mmc init success Support 2 dtbs. aml_dt soc: gxl platform: p212 variant: 1g dtb 0 soc: gxl plat: p212 vari: 1g dtb 1 soc: gxl plat: p212 vari: 2g Find match dtb: 0 get_dtb_struct: Get emmc dtb OK! mmc_read_partition_tbl: mmc read partition OK! eMMC/TSD partition table have been checked OK! mmc env offset: 0x6c00000 In: serial Out: serial Err: serial reboot_mode=cold_boot hpd_state=0 cvbs performance type = 6, table = 0 Support 2 dtbs. aml_dt soc: gxl platform: p212 variant: 1g dtb 0 soc: gxl plat: p212 vari: 1g dtb 1 soc: gxl plat: p212 vari: 2g Find match dtb: 0 Net: dwmac.c9410000 get_cpu_id flag_12bit=1 saradc - saradc sub-system

Usage: saradc saradc open - open a SARADC channel saradc close - close the SARADC saradc getval - get the value in current channel saradc get_in_range - return 0 if current value in the range of current channel

wipe_data=successful wipe_cache=successful upgrade_step=2 [OSD]failed to get fb addr for logo [OSD]use default fb_addr parameters [OSD]failed to get fb addr for logo [OSD]use default fb_addr parameters InUsbBurn noSof Hit Enter or space or Ctrl+C key to stop autoboot -- : 0

here is the boot.py log: Using GX Family boot parameters ROM: 2.2 Stage: 0.0 Writing /usr/local/lib/python3.8/dist-packages/files/p212/u-boot.bin.usb.bl2 at 0xd9000000... [DONE] Writing /usr/local/lib/python3.8/dist-packages/files/usbbl2runpara_ddrinit.bin at 0xd900c000... [DONE] Running at 0xd9000000... [DONE] Waiting... [DONE] ROM: 2.2 Stage: 0.0 Writing /usr/local/lib/python3.8/dist-packages/files/p212/u-boot.bin.usb.bl2 at 0xd9000000... [DONE] Writing /usr/local/lib/python3.8/dist-packages/files/usbbl2runpara_runfipimg.bin at 0xd900c000... [DONE] Writing /usr/local/lib/python3.8/dist-packages/files/p212/u-boot.bin.usb.tpl at 0x200c000... Traceback (most recent call last): File "./boot.py", line 132, in usb.load_uboot() File "./boot.py", line 89, in load_uboot self.write_file(os.path.join(self.bpath, self.TPL_FILE), self.UBOOT_LOAD, large = 64, fill = True) File "./boot.py", line 63, in write_file self.dev.writeLargeMemory(addr, b, large, fill) File "/home/bw/pyamlboot/pyamlboot/pyamlboot.py", line 239, in writeLargeMemory self._writeLargeMemory(address+offset, data[offset:offset+writeLength], \ File "/home/bw/pyamlboot/pyamlboot/pyamlboot.py", line 220, in _writeLargeMemory ep.write(data[offset:offset+blockLength], 1000) File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 408, in write return self.device.write(self, data, timeout) File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 979, in write return fn( File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 837, in bulk_write return self.write(self.lib.libusb_bulk_transfer, File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 938, in write _check(retval) File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 602, in _check raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBTimeoutError: [Errno 110] Operation timed out

here is the socid.py log: Firmware Version : ROM: 2.2 Stage: 0.0 Need Password: 0 Password OK: 1

here is the putty log(before plug in USB cable it loops forever,after plug in USB cable it goes into usb burning mode): GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;LOOP:1;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;LOOP:2;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;LOOP:3;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;GXL:BL1:9ac50e:a1974b;FEAT:BDFC31BC;POC:3;RCY:0;EMMC:0;READ:0;CHK:AA;SD:800;USB:8;

superna9999 commented 3 years ago

Hi, I think the p212 binaries I ship do not work on your board.

Could you dump the emmc on the working board ?

superna9999 commented 3 years ago

The boot binary should by at offset 512 (0x200), then you can use the tool at https://github.com/repk/gxlimg

to check the validity, then extract the components:

$ dd if=boot.bin of=u-boot.bin.usb.bl2 bs=49152 count=1 $ dd if=boot.bin of=u-boot.bin.usb.tpl skip=49152 bs=1

and use them with pyamlboot

godbin1990 commented 3 years ago

The boot binary should by at offset 512 (0x200), then you can use the tool at https://github.com/repk/gxlimg

to check the validity, then extract the components:

$ dd if=boot.bin of=u-boot.bin.usb.bl2 bs=49152 count=1 $ dd if=boot.bin of=u-boot.bin.usb.tpl skip=49152 bs=1

and use them with pyamlboot Thanks a lot! I will try it soon.