sipeed / sipeed_wiki

sipeed wiki:https://wiki.sipeed.com
MIT License
91 stars 131 forks source link

[Gitalk:/hardware/en/lichee/th1520/lpi4a/4_burn_image.html] Flashing an Image - Sipeed Wiki #488

Open andysilva86 opened 1 year ago

andysilva86 commented 1 year ago

https://wiki.sipeed.com/hardware/en/lichee/th1520/lpi4a/4_burn_image.html

andysilva86 commented 1 year ago

Hi, the installation process of Debian itself is very easy, just edit the script with the .bin files and the boot and rootfs, and run burntools .bat, but how to find these files below for the Fedora and Ubuntu images, or the official Debian image?

sudo ./fastboot flash boot ./images/boot_16gddr.ext4 sudo ./fastboot flash root ./images/rootfs-thead-image-linux_sing.ext4.ext4

AKeen12344 commented 10 months ago

@andysilva86 Hi, the installation process of Debian itself is very easy, just edit the script with the .bin files and the boot and rootfs, and run burntools .bat, but how to find these files below for the Fedora and Ubuntu images, or the official Debian image?

sudo ./fastboot flash boot ./images/boot_16gddr.ext4 sudo ./fastboot flash root ./images/rootfs-thead-image-linux_sing.ext4.ext4

Fedora images do exist here for SD cards that you will probably need to change the DIP switches underneath the module to be able to boot, and image availability for distros is very generous at the moment even if they are listed as such.

I'd imagine that reusing the fastboot method of flashing the eMMC would require some transferring of device files and distro specific stuff over to a mounted ext4 file to then be flashed.

ccpster commented 9 months ago

Hi, Is it possible to share the fastboot source code? I am using arm64 box as my main development machine. I think the existing fastboot executable is not for arm64. or if not possible to share the fastboot source code, can Sipeed produce a arm64 executable for download? Thanks!

AKeen12344 commented 9 months ago

Hi, Is it possible to share the fastboot source code? I am using arm64 box as my main development machine. I think the existing fastboot executable is not for arm64. or if not possible to share the fastboot source code, can Sipeed produce a arm64 executable for download? Thanks!

Does this work? https://github.com/nmeum/android-tools/

ccpster commented 9 months ago

@AKeen12344

Hi, Is it possible to share the fastboot source code? I am using arm64 box as my main development machine. I think the existing fastboot executable is not for arm64. or if not possible to share the fastboot source code, can Sipeed produce a arm64 executable for download? Thanks!

Does this work? https://github.com/nmeum/android-tools/

Thank you for the information.

First of all, I managed flash 20231026 from https://mirror.iscas.ac.cn/revyos/extra/images/lpi4a/20231026/. Second, I use fastboot in LPI4A_BASIC_20231023.zip. even thought it is a x86_64 binary I managed use a ubuntu:22.04 linux/amd64 docker image with qemu-x86_64 static binary copy into container. so I was able to use fastboot to flash.

TL;DR

This question started because I was studying the https://github.com/revyos/thead-u-boot/cmd/fastboot.c trying to understand the statment "fastboot flash ram u-boot-with-spl-lpi4a-16g.bin" on how the "ram" work since there is no partition name "ram" so I assume it must mean real memory but I was not able to find in u-boot how the "ram" part in drivers/fastboot/fb_command.c got handled. So I start wonder may be the fastboot client on PC actually send different command when it got argument "ram", so I start look into android-tools fastboot source code, that is when I realized that fastboot included in package is for x86_64, it is not for my platform.

I am on Gentoo, so I got gentoo emerge to build the android-tools package. and I got a fastboot binary native to my arm64 platform.

When I try to use my fastboot to flash use follow the script it always failed when trying to flash "boot-20231026_181638.ext4" with error

Invalid sparse file format at header magic
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::compare: __pos (which is 548882532040) > this->size() (which is 0)
myflash: line 8:  5899 Aborted

This lead me search internet for solution, which I found https://community.e.foundation/t/solved-fastboot-flash-boot-shows-uncaught-exception-of-type-std-basic-string/30740/10 But I was not able to get gentoo to build this version quickly.

So I decide to workaround this problem by using docker container with QEMU user static binary. by copy qemu-x86_64 into container, I was able to bring up a linux/amd64 docker image, so I copy the fastboot into the container and start flashing.

roygrubb commented 9 months ago

Just received Lichee Pi, installed in case and connected up and seems fine. Now I'm preparing to load LPI4A_FULL_20231023

I want to be certain about the Boot set switches - both are down (I mean they're both set towards the front of the LPi). Does that mean they're both off, so set to eMMC? I haven't touched them since receiving the LPi.

Thanks

varyhin commented 9 months ago

@roygrubb Just received Lichee Pi, installed in case and connected up and seems fine. Now I'm preparing to load LPI4A_FULL_20231023

I want to be certain about the Boot set switches - both are down (I mean they're both set towards the front of the LPi). Does that mean they're both off, so set to eMMC? I haven't touched them since receiving the LPi.

Thanks

Yes, the switches in the down position mean OFF. This means that the LPi4a will boot from eMMC. https://wiki.sipeed.com/hardware/en/lichee/th1520/lpi4a/4_burn_image.html#Official-Hardware-/-Release-Hardware

roygrubb commented 9 months ago

RESOLVED

Thanks for your earlier reply.

My next problem is installing the driver. I'm using a Windows 10 PC. I've told Windows to bypass driver signature. After restart, I held down BOOT switch on LPi, plugged in USB C cable attached to USB C port on my PC. USB download gadget appears in Device Manager. I went to Update Drivers - USB download gadget / Browse for Drivers on your computer, and entered the address of the folder with fastboot.exe in it.

It says The location that you specified does not contain any driver package (.INF) files. This is true, it contains fastboot.exe, the one from burn_tools_support_bigimage.zip

I'm going wrong somewhere, what should I do, please?

Thanks.

roygrubb commented 9 months ago

OK, resolved that.

I renamed ...\burn_tools\windows\fastboot.exe as XXXfastboot.XXXexe

then copied fastboot.exe from burn_tools_support_bigimage.zip to ...\burn_tools\windows\fastboot.exe

Restarted with driver signature check off and told device manager to look in ...\burn_tools\windows

And the driver was installed.

Will flash OS to LPi later.

roygrubb commented 9 months ago

New OS loaded and running! Yay!

Just for the record in case anyone else makes the same mistakes as me ... I missed that rootfs.ext4 is now called root.ext4 so when I ran the batch file, I got ...

fastboot: error: cannot load 'E:\Users\Roy\Desktop\LicheePiwk\burn_tools\windows\images\rootfs.ext4': No such file or directory

After correcting the batch file, I got this ... E:\Users\Roy\Desktop\LicheePiwk\burn_tools\windows\images\u-boot-with-spl-lpi4a-16g.bin" Warning: skip copying ram image avb footer (ram partition size: 0, ram image size: 963024). Sending 'ram' (940 KB) OKAY [ 0.047s] Writing 'ram' FAILED (remote: 'cannot find partition') fastboot: error: Command failed
[repeats]

I discovered that unplugging LPi, holding down the Boot button and plugging in again reset the part-way completed load and I ran the batch file and it ran through to completion.

moonlight0551 commented 6 months ago

I want to burn the latest image using Windows 10 to my Lichee Pi 4A 8/32GB. Have downloaded and unzipped the image and was about to update burn_lpi4a.bat with the image path. I see two files u-boot-with-spl-lpi4a.bin and u-boot-with-spl-lpi4a- 16g.bin. Which one do I use?

moonlight0551 commented 6 months ago

Found my answer right at the bottom of the image summary. The zip contains two u-boot, note the suffix and device parameters when burning u-boot with 16g suffix is for 16GB memory, no suffix is for 8GB memory