Skip to content

Writing OpenNep4une image without eMMC adapter

MikeNomatter edited this page Dec 29, 2024 · 4 revisions

How to Flash Your 3D Printer directly from USB

WARNING:
This procedure is experimental and potentially dangerous. If an error occurs, the system may become unbootable. Recovery will only be possible with a USB eMMC adapter. Proceed at your own risk.


Image File Preparation:

Download the firmware image file.
Extract the image using the following command:

  • Linux:

    xz -dc -T0 file.img.xz
    
  • Windows: Use 7z

Сopy the extracted image file onto USB flash drive.

Connect via serial

Connect your computer to the printer's USB-C port (1500000 Baud Serial terminal).

  • Windows users can use PuTTY. Here is a useful quick connection Guide.
  • Linux users can use screen for terminal access (linux commands below).
    ls /dev/tty*
    
    Find the relevant ttyACM / ttyUSB device then paste yours into the command below.
    screen /dev/tty* 1500000
    
    To exit screen, press Ctrl + A followed by K, then confirm with Y.

Flashing the System

Step 1: Insert the prepared USB flash drive into the printer's USB port.

Step 2: Run the following command to list all connected drives and partitions:

lsblk

Identify:

  • The USB flash drive partition, usually something like /dev/sda(0-9).
  • The eMMC device of the system, typically /dev/mmcblk(0-9). This device should have two partitions: /boot and /.

Hereinafter, I will use partition and device indices that were relevant to my setup, you will need to replace them with your own values.

Step 3: Create a temporary directory and mount the USB flash drive:

mkdir /tmp/mnt
mount /dev/sda1 /tmp/mnt/
cd /tmp/mnt/

Step 4: Switch to the emergency target to minimize system activity:

sudo systemctl isolate emergency.target

Step 5: Write the image to the system's eMMC storage:

dd if=file.img of=/dev/mmcblk0 bs=4M conv=fsync status=progress

This process will overwrite the current system with the new firmware. Wait until the process completes.

Step 6: After the process finishes, reboot the system(most likely will fail, so just power off):

reboot

In some cases, you might encounter errors while booting the new system. The following steps could help you recover:

Interrupt the boot process by pressing any key immediately after the terminal displays the boot message. You may need to repeatedly press the key to ensure you interrupt the process in time.

  • Once in the U-Boot menu, execute the following commands:
lsblk

To view the files on the eMMC, use:

part list mmc 0
ls mmc 0:1
ls mmc 0:2

Identify the device you want to boot from. This could be either your eMMC if it contains viable data or a USB drive with a recorded image. If booting from eMMC, it will likely be /dev/mmcblk0p2.

  • Set up the environment variables:
setenv fdtaddr 0x10000000    # address in memory for DTB
setenv loadaddr 0x20000000   # address in memory for core
setenv ramdisk_addr 0x30000000  # address in memory for initrd
setenv bootargs root=/dev/mmcblk0p2 rootwait
  • Load the device tree file. For example, if you are using a Neptune 4 Pro board:
fatload mmc 0:1 ${fdtaddr} /dtb/rockchip/n4-n4pro-v1.1.dtb

Replace the filename with the correct one for your hardware. You can locate the file using:

ls mmc 0:2/dtb/rockchip/n4*
  • Continue with the setup by loading the kernel and initrd:
fatload mmc 0:1 ${loadaddr} /Image
fatload mmc 0:1 ${ramdisk_addr} /uInitrd
  • Finally, boot the system:
booti ${loadaddr} ${ramdisk_addr} ${fdtaddr}