OpenIPC / firmware

Alternative IP Camera firmware from an open community
https://openipc.org
MIT License
1.21k stars 232 forks source link

Bootloader flashing failed at 98% #250

Closed KanG00 closed 2 years ago

KanG00 commented 2 years ago

I have done BOOT loader flashing as per instructions for my HI3518EV200 and it failed at 98%. Now it is bricked. Could you please tell me what I did wrong and support in recovery.

Logs below:

hisilicon # sf probe 0 ; sf lock 0 16384 KiB hi_fmc at 0:0 is now current device unlock all block. hisilicon # mw.b 0x82000000 ff 0x50000 hisilicon # tftp 0x82000000 openwrt-hi35xx-18ev200-u-boot.bin Hisilicon ETH net controler MAC: 00-00-23-34-45-66 eth0 : phy status change : LINK=UP : DUPLEX=FULL : SPEED=100M TFTP from server 192.168.1.7; our IP address is 192.168.1.9 Download Filename 'openwrt-hi35xx-18ev200-u-boot.bin'. Download to address: 0x82000000 Downloading: ################################################# done Bytes transferred = 123532 (1e28c hex) hisilicon # sf erase 0x0 0x50000 Erasing at 0x50000 -- 100% complete. hisilicon # sf write 0x820000000 0x0 123532 Writing at 0x120000 -- 98% complete.

Now it stuck and there is no fedback on UART. Only blank messages

p0i5k commented 2 years ago

Should have rounded 0x1e28c to 0x20000. Do you have programmer? You can flash it and try again

KanG00 commented 2 years ago

I have USB to UART converter connected to board only + USBASP AVR programmer if needed. What kind of programmer would I need to recover it ?

widgetii commented 2 years ago

There is a good choice https://aliexpress.com/item/32902635911.html But you may also try to use 'unbrick' tool for HiSilicon https://github.com/openipc/burn to do recover

KanG00 commented 2 years ago

I’ll check this promissing tool first for sure, but could you please advice the exact command that I should use for my chip? Don’t wan’t to get it worse :) Can I use directly OpenWRT U-boot, or shall I look for some special one?

widgetii commented 2 years ago

./hi35xx-tool --chip hi3518ev200 --file=u-boot-hi3518ev200-universal.bin

Download u-boot-hi3518ev200-universal.bin file first

KanG00 commented 2 years ago

After several failed tries I've moved to raspberry and it seemed to work, but when connecting again to terminal it behaves exactly the same:

burn $ ./hi35xx-tool --chip hi3518ev200 --file=u-boot-hi3518ev200-universal.bin opts: [('--chip', 'hi3518ev200'), ('--file', 'u-boot-hi3518ev200-universal.bin')] args: [] Trying open /dev/ttyUSB0 Welcome to boot-mode

{'name': 'hi3516cv200', 'DDRSTEP0': [4, 224, 45, 229, 36, 0, 159, 229, 36, 16, 159, 229, 0, 16, 128, 229, 32, 0, 159, 229, 32, 16, 159, 229, 4, 16, 128, 228, 0, 224, 128, 229, 4, 240, 157, 228, 239, 190, 173, 222, 239, 190, 173, 222, 239, 190, 173, 222, 60, 1, 5, 32, 120, 86, 52, 18, 64, 1, 5, 32, 117, 106, 105, 122], 'ADDRESS': ['4013000', '4010500', '0x81000000'], 'FILELEN': ['040', '0x3b00'], 'STEPLEN': ['040', '060']}

Sending u-boot-hi3518ev200-universal.bin ... Send DDRSTEP frame... Send HEAD frame... Send TAIL frame... Send HEAD frame... Send DATA frame[===========================================================================================================================================================================]15104 of 15104 Send TAIL frame... Send HEAD frame... Send DATA frame[=========================================================================================================================================================================]135808 of 135808 Send TAIL frame... Done

Exiting...

Why is it recognized as hi3516cv200 ?

KanG00 commented 2 years ago

ok, I've managed to install universal u-boot and stop the boot process. How can I define IP address now to download and flash u-boot again?

tftp 0x82000000 openwrt-hi35xx-18ev200-u-boot.bin Hisilicon ETH net controler MAC: 00-00-23-34-45-66 PHY not link.

OpenIPC # printenv bootcmd=setenv setargs setenv bootargs ${bootargs}; run setargs; sf probe 0; sf read 0x82000000 0x50000 0x200000; bootm 0x82000000 bootdelay=1 baudrate=115200 ethaddr=00:00:23:34:45:66 netmask=255.255.255.0 bootfile="uImage" osmem=32M linux_cmd=version sensor=auto subnetmask=255.255.255.0 telnetctrl=1 stdin=serial stdout=serial stderr=serial totalmem=64M verify=n ver=U-Boot 2010.06-dirty (May 15 2022 - 22:42:24) setargs=setenv bootargs totalmem=$(totalmem) mem=$(osmem) ethaddr=$(ethaddr) phyaddru=$(phyaddru) phyaddrd=$(phyaddrd) sensor=$(sensor) linux_cmd=$(linux_cmd) console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 rootfstype=squashfs mtdparts=hi_sfc:256k(boot),64k(env),2048k(kernel),5120k(rootfs),-(rootfs_data) bootargs=totalmem=$(totalmem) mem=$(osmem) ethaddr=$(ethaddr) phyaddru=$(phyaddru) phyaddrd=$(phyaddrd) sensor=$(sensor) linux_cmd=$(linux_cmd) console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 rootfstype=squashfs mtdparts=hi_sfc:256k(boot),64k(env),2048k(kernel),5120k(rootfs),-(rootfs_data) ipaddr=192.168.1.199 serverip=192.168.100.145

/burn $ screen /dev/ttyUSB0 115200 (2040:2000) 0. 6,13 = b01 speed selection = 100 Mbps (1000:1000) 0.12 = 1 A/N enable (0800:0000) 0.11 = 0 power-down (0400:0000) 0.10 = 0 isolate (0200:0000) 0. 9 = 0 restart A/N (0100:0100) 0. 8 = 1 duplex = full (0080:0000) 0. 7 = 0 collision test enable (003f:0000) 0. 5- 0 = 0 (reserved)

OpenIPC # mii dump 0 1

  1. (786d) -- PHY status register -- (8000:0000) 1.15 = 0 100BASE-T4 able (4000:4000) 1.14 = 1 100BASE-X full duplex able (2000:2000) 1.13 = 1 100BASE-X half duplex able (1000:1000) 1.12 = 1 10 Mbps full duplex able (0800:0800) 1.11 = 1 10 Mbps half duplex able (0400:0000) 1.10 = 0 100BASE-T2 full duplex able (0200:0000) 1. 9 = 0 100BASE-T2 half duplex able (0100:0000) 1. 8 = 0 extended status (0080:0000) 1. 7 = 0 (reserved) (0040:0040) 1. 6 = 1 MF preamble suppression (0020:0020) 1. 5 = 1 A/N complete (0010:0000) 1. 4 = 0 remote fault (0008:0008) 1. 3 = 1 A/N able (0004:0004) 1. 2 = 1 link status (0002:0000) 1. 1 = 0 jabber detect (0001:0001) 1. 0 = 1 extended capabilities
p0i5k commented 2 years ago

Your first steps was right. Except this command: sf write 0x820000000 0x0 123532 Use this: sf write 0x820000000 0x0 0x20000

KanG00 commented 2 years ago

I know but with current bootloader I do not have TFTP available as it is not able to connect to Ethernet PHY adapter. I can copy the files on SDCARD but I don't know the commands to access file directory.

tftp 0x82000000 openwrt-hi35xx-18ev200-u-boot.bin Hisilicon ETH net controler MAC: 00-00-23-34-45-66 PHY not link.

KanG00 commented 2 years ago

I've managed to recover the chip finally by using openwrt-hi35xx-18ev200-u-boot.bin u-boot supporting SD card read as universal u-boot was not able to make use of ethernet port in my device and TFTP download was not working. After flashing from SD I had to change phyaddru and phyaddrd env's to 0 so that ethernet port started working. Now I struggle with making Wifi adapter working and recognizing what sensor does my camera use, but this is the topic for different post. Thank you for th support as "burn" recovery tool was the one that really helped!

dimerr commented 2 years ago

Latest build has mmc support. Also, unlike old boot, new has ability to change various network settings, you just need to see what mode was on original bootloader, MII or RMII

KanG00 commented 2 years ago

I used u-boot given by @widgetii couple posts above. Where is the latest u-boot and firmware to download? I’m having huge problems with self compilation

ZigFisher commented 2 years ago

I used u-boot given by @widgetii couple posts above. Where is the latest u-boot and firmware to download? I’m having huge problems with self compilation

https://github.com/OpenIPC/firmware/releases/tag/latest

KanG00 commented 2 years ago

Sorry for this lame question, but how to flash my camera with this firmware compressed file? I was able to flash it via SERIAL-UART converter but using root and kernel image files. I've tried to update by web gui System/Backup-Flash Firmware section, but after pressing update it gets stuck. SSH is not responding and Web GUI as well.

ZigFisher commented 2 years ago

Good afternoon You need to know which version you currently have installed. Maybe you have the problematic version installed now. You need to run the following command in Linux on the camera curl -s https://raw.githubusercontent.com/OpenIPC/firmware/master/general/overlay/usr/sbin/sysupgrade | sh -s -- -r -k -n

KanG00 commented 2 years ago

I get wrong SoC error:

Kernel Update kernel from /tmp/uImage.hi3518ev200 sh: od: not found Wrong SoC! Aborting.

but SoC is correct and defined as env. below ipctool output:

./ipctool board: vendor: OpenWrt version: 21.04.10.2 chip: vendor: HiSilicon model: 3518EV200 ethernet: mac: "00:00:23:34:45:66" u-mdio-phyaddr: 1 phy-id: 0xffffffff d-mdio-phyaddr: 0 rom:

KanG00 commented 2 years ago

I've managed to install the firmware by extracting files from link and flashing through SD card. But now after booting up I have read-only system that is not allowing me to make any changes. That is most probably because of openwrt u-boot installed or wrong set of environment variables loaded at startup. loading universal boot"(u-boot-hi3518ev200-universal.bin) bricks the bootup process so it is rather faulty or I should use different way of flashing. Please send me the link for u-boot suitable for latest FW release and what env variables shall I put in to get it up and running. Thanks in advance!

KanG00 commented 2 years ago

ok, I solved it but it was a tricky one. Universal u-boot flashing required different steps order to make it working. Not sure why but it worked. After that I have read/write access finally. Now maybe last question or two before closing this thread.

How to add motor support as current status is "Motors not initialized."? And second one. Hot to add wifi support as I have only wired interface available from the command line and my camera does have wifi module?

dimerr commented 2 years ago

oh my... where did you get all that from? starting from old bootloader, now openwrt... jeez.

https://github.com/OpenIPC/firmware/releases/tag/latest

dont use openwrt or anything connected with it

KanG00 commented 2 years ago

Where? From OpenIPC webpage (https://openipc.org) :) https://github.com/OpenIPC/chaos_calmer

Thanks for the link, it is all in there. Universal u-boot is 1kb different one which I've uploaded, but I'm afraid to touch it again if it's finally working :)

Now I need to figure out how to configure rotation motor and wifi and my camera is good to go...

widgetii commented 2 years ago

chaos calmer is deprecated, it's from 2015 (there is a warning in the repo), don't use it anymore

KanG00 commented 2 years ago

So maybe it is good to remove it from https://openipc.org/. I've used it as I'm a bit familiar with OpenWRT so that sounded like a good choice for me.

dimerr commented 2 years ago

Where? From OpenIPC webpage (https://openipc.org) :) https://github.com/OpenIPC/chaos_calmer

Thanks for the link, it is all in there. Universal u-boot is 1kb different one which I've uploaded, but I'm afraid to touch it again if it's finally working :)

Now I need to figure out how to configure rotation motor and wifi and my camera is good to go...

i recommend flashing universal bootloader first of all, then install openipc-2.2 and continue with your experiments

KanG00 commented 2 years ago

That is the status as per the moment. I have universal bootloader and opeipc-2.2 installed. now I'm trying to figure out how to enable wifi and motor.

I've also noticed that any changes made by terminal or web interface are only stored temporarily till next restart. Previously they where not saved at all due to read-only file system. Also SSH hey is generated each time so I need to delete from knownhosts each reboot to be able to login.

ZigFisher commented 2 years ago

Run the firstboot command, it will prepare the partition for saving the changes.

ZigFisher commented 2 years ago

Thanks for the feedback Now we will remove the information about the old development branch under openwrt. Indeed, it has not been supported for more than two years and is misleading.

KanG00 commented 2 years ago

Run the firstboot command, it will prepare the partition for saving the changes.

that causes reboot, and yes, soc is defined in variable:

root@openipc-hi3518ev200:~# firstboot Cannot parse config file '/etc/fw_env.config': No such file or directory SoC is not defined in U-Boot environment Aborting.

Unconditional reboot

Below output of current printenv from u-boot. I can't print env variables from running SW so it seams that opeipc doesn't have access to env var somehow:

OpenIPC # printenv bootargs=mem=${osmem} console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 rootfstype=squashfs init=/init mtdparts=${mtdparts} bootcmd=setenv setargs setenv bootargs ${bootargs}; run setargs; sf probe 0; sf read ${baseaddr} 0x50000 0x200000; bootm ${baseaddr}; reset bootdelay=1 baudrate=115200 ethaddr=00:00:23:34:45:66 ipaddr=192.168.1.10 serverip=192.168.1.1 gatewayip=192.168.1.1 netmask=255.255.255.0 bootfile="uImage" baseaddr=0x82000000 uknor8m=mw.b ${baseaddr} ff 1000000; tftpboot ${baseaddr} uImage.${soc} && sf probe 0; sf erase 0x50000 0x200000; sf write ${baseaddr} 0x50000 ${filesize} uknor16m=mw.b ${baseaddr} ff 1000000; tftpboot ${baseaddr} uImage.${soc} && sf probe 0; sf erase 0x50000 0x300000; sf write ${baseaddr} 0x50000 ${filesize} urnor8m=mw.b ${baseaddr} ff 1000000; tftpboot ${baseaddr} rootfs.squashfs.${soc} && sf probe 0; sf erase 0x250000 0x500000; sf write ${baseaddr} 0x250000 ${filesize} urnor16m=mw.b ${baseaddr} ff 1000000; tftpboot ${baseaddr} rootfs.squashfs.${soc} && sf probe 0; sf erase 0x350000 0xa00000; sf write ${baseaddr} 0x350000 ${filesize} uknand=mw.b ${baseaddr} ff 1000000; tftpboot ${baseaddr} uImage.${soc} && nand erase 0x100000 0x300000; nand write ${baseaddr} 0x100000 0x300000 urnand=mw.b ${baseaddr} ff 1000000; tftpboot ${baseaddr} rootfs.ubi.${soc} && nand erase 0x400000 0x7c00000; nand write ${baseaddr} 0x400000 ${filesize} mtdparts=hi_sfc:256k(boot),64k(env),2048k(kernel),5120k(rootfs),-(rootfs_data) mtdpartsubi=setenv mtdparts hinand:256k(boot),768k(wtf),3072k(kernel),-(ubi) mtdpartsnand=setenv mtdparts hinand:256k(boot),768k(wtf),3072k(kernel),10240k(rootfs),-(rootfs_data) mtdpartsnor8m=setenv mtdparts hi_sfc:256k(boot),64k(env),2048k(kernel),5120k(rootfs),-(rootfs_data) mtdpartsnor16m=setenv mtdparts hi_sfc:256k(boot),64k(env),3072k(kernel),10240k(rootfs),-(rootfs_data) nfsroot=/srv/nfs/hi3518ev200 bootargsnfs=mem=${osmem} console=ttyAMA0,115200 panic=20 root=/dev/nfs rootfstype=nfs ip=${ipaddr}:::255.255.255.0::eth0 nfsroot=${serverip}:${nfsroot},v3,nolock rw bootargsubi=mem=${osmem} console=ttyAMA0,115200 panic=20 init=/init root=ubi0:rootfs rootfstype=ubifs ubi.mtd=3,2048 mtdparts=${mtdparts} bootnfs=setenv setargs setenv bootargs ${bootargsnfs}; run setargs; tftpboot ${baseaddr} uImage.${soc}; bootm ${baseaddr} bootcmdnand=setenv setargs setenv bootargs ${bootargs}; run setargs; nand read ${baseaddr} 0x100000 0x300000; bootm ${baseaddr} bootcmdubi=setenv setargs setenv bootargs ${bootargsubi}; run setargs; nand read ${baseaddr} 0x100000 0x300000; bootm ${baseaddr} bootcmdnor=setenv setargs setenv bootargs ${bootargs}; run setargs; sf probe 0; sf read ${baseaddr} 0x50000 0x200000; bootm ${baseaddr} setnand=run mtdpartsubi; setenv bootcmd ${bootcmdubi}; saveenv; reset setnor8m=run mtdpartsnor8m; setenv bootcmd ${bootcmdnor}; saveenv; reset setnor16m=run mtdpartsnor16m; setenv bootcmd ${bootcmdnor}; saveenv; reset osmem=32M soc=hi3518ev200 stdin=serial stdout=serial stderr=serial totalmem=64M verify=n ver=U-Boot 2010.06-dirty (Jul 04 2022 - 23:19:24)

KanG00 commented 2 years ago

ok, found it. Now SOC variable needs to be in capital leters. with soc it didn't work. After changing soc to SOC /etc/fw_env.config showed up and I was able to make firstboot command :)

KanG00 commented 2 years ago

I've tried to add wifi support based on this instructions (https://github.com/OpenIPC/wiki/blob/master/en/wifi-xm530.md), but first of all I'm not sure if it will suite to my WIFI chip and what is more, I don't have required drivers inside, so it causes this output during boot proces:

insmod: can't insert '/lib/modules/3.10.103+/xiongmai/dwc_common_port_lib.ko': No such file or directory insmod: can't insert '/lib/modules/3.10.103+/xiongmai/dwc_otg.ko': No such file or directory insmod: can't insert '/lib/modules/3.10.103+/xiongmai/wifi_pdn.ko': No such file or directory insmod: can't insert '/lib/modules/3.10.103+/xiongmai/compat.ko': No such file or directory insmod: can't insert '/lib/modules/3.10.103+/xiongmai/xm711.ko': No such file or directory FAIL

Could someone advice how to enable wifi in my device ?

Is there any package manager that I coud use to install any addons ?

dimerr commented 2 years ago

ok, found it. Now SOC variable needs to be in capital leters. with soc it didn't work. After changing soc to SOC /etc/fw_env.config showed up and I was able to make firstboot command :)

what capital letters? now where have you found that? after flashing our bootloader you dont need to set anything at all

KanG00 commented 2 years ago

Please look what I've written three posts above. After running firstboot command I got an error "SoC is not defined in U-Boot environment Aborting." Than I rebooted, stopped u-boot process and added SOC=hi3518ev200 as previously it was soc=hi3518ev200 and it apparently didn't work. Maybe if I remove both env entries it will also work.

dimerr commented 2 years ago

you just did saveenv, thats why "soc' started working, along with whole env.

after installing uboot you need to pick partition layout with run setnor8m which will invoke saveenv also