Libre Computer AML-S905X-CC eMMC Flashing Steps from Linux with pyamlboot

Try plugging in to the USB ports on the back of the machine. Works on my AMD…

I’ve encounter an error while trying to flash the eMMC, I can’t mount as virtual flash drive nor delete user partition due to the next error:

Sweet Potato
Libre 16GB eMMC

~$ sudo pyamlboot/run.sh aml-s905x-cc erase-emmc
Using GX Family boot parameters
ROM: 2.4 Stage: 0.0
Writing /home/robert/pyamlboot/files/libretech-cc/u-boot.bin.usb.bl2 at 0xd9000000…
[DONE]
Writing /home/robert/pyamlboot/files/usbbl2runpara_ddrinit.bin at 0xd900c000…
[DONE]
Running at 0xd9000000…
[DONE]
Waiting…
[DONE]
ROM: 2.2 Stage: 0.8
Running at 0xd900c000…
[DONE]
Waiting…
[DONE]
Writing /home/robert/pyamlboot/files/libretech-cc/u-boot.bin.usb.bl2 at 0xd9000000…
Traceback (most recent call last):
File “/home/robert/pyamlboot/./boot.py”, line 132, in
usb.load_uboot()
File “/home/robert/pyamlboot/./boot.py”, line 87, in load_uboot
self.write_file(os.path.join(self.bpath, self.BL2_FILE), self.DDR_LOAD, large = 64)
File “/home/robert/pyamlboot/./boot.py”, line 63, in write_file
self.dev.writeLargeMemory(addr, b, large, fill)
File “/home/robert/pyamlboot/pyamlboot/pyamlboot.py”, line 241, in writeLargeMemory
self._writeLargeMemory(address+offset, data[offset:offset+writeLength],
File “/home/robert/pyamlboot/pyamlboot/pyamlboot.py”, line 215, in _writeLargeMemory
self.dev.ctrl_transfer(bmRequestType = 0x40,
File “/usr/lib/python3/dist-packages/usb/core.py”, line 1082, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File “/usr/lib/python3/dist-packages/usb/backend/libusb1.py”, line 893, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File “/usr/lib/python3/dist-packages/usb/backend/libusb1.py”, line 604, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 19] No such device (it may have been disconnected)

I made sure to hold the boot button.
I added a 5W power supply to the USB C port
No dice

Use the ums 0 mmc 0 u-boot method or flash from a booted OS on SD card.

The pyamlboot README.md mentions the A311D.

Will this method work with the Alta AML-A311D-CC?
If yes, is the USB port the same as step 3 (top left) or a different port?

Thank you

We recommend programming eMMC from Linux as it’s the fastest method. u-boot is a limited OS so it’s relatively slow. The USB device mode port is also the power port on Alta.

Reiterating so I understand.

  1. The alternate method described above (using pyamlboot) can be used for the Alta AML-A311D-CC, use a Linux machine as it’s faster and more reliable.

  2. Or you’re saying stay with the recommended way described here.

The second one. pyamlboot method was one of the older methods. The Linux method is the current one. We will eventually have an even faster way of flashing but it’s not ready yet.

2 Likes

Depending on what you measure as ‘faster’, these are the 2 methods that I can see:

M1: update via linux

  1. flash new OS to uSD card
  2. erase eMMC boot block to force uSD boot
    2a. if eMMC is bootable but unusable (aka raspbian12), use uboot button instructions to pyamlboot/run.sh aml-s905x-cc erase-emmc
  3. boot uSD
  4. flash new OS to eMMC

M2: update via pyamlboot

  1. use uboot button instructions to pyamlboot/run.sh aml-s905x-cc ums-emmc
  2. flash new OS to eMMC

M2 might take longer to write, but only involves writing once. M1 involves writing twice, even if it is faster each write, I’ve found is slower overall.

And until it is default in every image, always after an eMMC flash:

echo "boot_targets=usb mmc1 mmc0" > /boot/efi/boot.ini
echo "boot_targets=usb mmc1 mmc0" > /media/pi/bootfs/boot.ini

To make it much easier to recover from a bad eMMC system.

Yes, we will make it easier in the future by providing a 16MB Linux based deployment OS available.

We do not modify the boot_targets order for a lot of reasons. You can recover from u-boot prompt.

That is true… if you have the ability to view and interact with the uboot prompt.

There are many home hobbyists that lack the tools and knowledge to do so. Yes, it is a learning experience, and yes, it is quite frustrating when the process could clearly be better.

Am newbie with Libre Computer products (AML-S905X-CC-V2, Libre Computer 16GB eMMC).

So far, everything has been working “as advertised” with my new board. Performance is very solid, repeatable. Really like having Unix on a SBC and your implementation will be perfect for my needs, projects going forward.

Initially, used a SanDisk Ultra 16GB to dd “xxx”.img onto eMMC. Got error message when tried to boot on eMMC; so used the ums 0 mmc 0 command in U-boot console to clear and restart. Once the “=> ums 0 mmc 0” was entered, the boot continued = loaded linux from initial SanDisk dd install, requested normal linux setup info & has been solid since.

Now, I would like to reinitialize everything and start over in order to clean things up. This time, I would like to use your “eMMC Flashing Steps for Linux with pyamlboot”.

Have used the USB A to USB A cable included in the EMMC box to try to establish comms with my main Linux PC (main PC is running Ubuntu 22.04.4, Python 3.10.12, usb directory is showing in usr/lib/python3/dist-packages). Followed your instructions to "press black button next to usb header on AML board while plugging into usb port top left next to ethernet (= red and blue led’s remain lit continuously on sweet potato, no green ever). Also, plugged the sweet potato into its dedicated 5v power supply after releasing its boot button.

However can’t find the sweet potato plugged into main PC USB anywhere. From libretech-flash-tool, ‘./lft.sh dev-list’ only shows the other mounted drives. Can’t get any of the standard linux USB device recognition tools to find new devices, either (lsblk…). Also, plugged another SSD into same USB port on main PC & it was found by main PC.

When I try “sudo pyamlboot/run.sh aml-s905x-cc ums-emmc” command it produces errors identical to the ones shown in Eli Weaver’s October '23 message, except that the last four lines of my error message reference Python 3 not 3.9
My last four error message lines are =
{File “/usr/lib/python3/dist-packages/usb/core.py”, line 1082, in ctrl_transfer
ret = self._ctx.backend.ctrl_transfer(
File “/usr/lib/python3/dist-packages/usb/backend/libusb1.py”, line 893, in ctrl_transfer
ret = _check(self.lib.libusb_control_transfer(
File “/usr/lib/python3/dist-packages/usb/backend/libusb1.py”, line 604, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 19] No such device (it may have been disconnected)}

I have assumed a new binding took effect for my eMMC when I did the U-boot ums 0 mmc 0 command, and that I now should be able to use pamylboot to access the sweet potato as a mass storage device from my main PC???

Next step would be to replace sweet potato board and try again. But concerned that I may have missed or misinterpreted some of your troubleshooting instructions - any advice would be appreciated…

Thank you

The board must be completely unpowered. Press and hold the button while connecting the USB will cause the board to go into USB ROM mode. In this mode, it can receive boot information over USB. If it does not register a device in lsusb, the board has either booted or had residual power elsewhere and failed to go into USB ROM mode.

From USB ROM mode, pyamlboot sends the board the bootloader over USB. The board will boot into u-boot and then run a script that calls ums 0 mmc 0 which turns the device into a flash drive.

Alternatively, you can flash the eMMC using the instructions here: Libre Computer eMMC Flash Tool (LEFT) for Rapid OS Deployment

Thanks very much for your quick response = will try again tomorrow.

Believe I was pretty careful to follow all of your guidelines about the USB boot (hold down black button when connecting board to PC USB, board wasn’t powered, did try lsusb ++ & nothing showed new USB device…)

But it looks like your attachment showing how to create a deployment key may be the best approach!!! Can certainly follow your Linux instructions to flash the original distro key onto a MicroSD or USB stick. How do I implement the key once it is flashed?? Can I re-write over an existing eMMS image, or do I need to start with a new, blank eMMS for each new key?

See how to change the boot device, skip to 18 minutes in:

Really like this approach.
Followed the video instructions but on Linux instead of Windows.

  • Used the “left” loader in partition #1 installed directly on USB using your download (found balernaEtcher for linux = got it from github → couldn’t get their Appimage version to work even with fuse for Ubuntu)
  • Then added 2nd partition labeled D and copied your linux image onto it (didn’t use dd).
  • Used the video approach of stopping the U-boot; =>“env set boot_targets usb”; =>“boot” to replace the image on my eMMC card.
  • Noticed that the video used Debian which has smaller, faster footprint than Ubuntu. So, I am using Debian 12 on my “Sweet Potato”.
  • Really like using your “Sweet Potato”; it’s almost fast enough to use for my normal daily PC tasks. Am already considering an upgrade to AML-A311D-CC to be able to replace even more routine PC functions.
    Thoughts, recommendations?

Thanks -

1 Like

Alta is around 5x faster than Le Potato. LEFT is already integrated with LFT. Libre Computer eMMC Flash Tool (LEFT) for Rapid OS Deployment

1 Like