Skip to content

Instantly share code, notes, and snippets.

Last active January 10, 2024 14:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sxing/f02a4a1703b16803a7d4 to your computer and use it in GitHub Desktop.
Save sxing/f02a4a1703b16803a7d4 to your computer and use it in GitHub Desktop.
Cloning Edisons by making a flashable image from an existing Edison

This’ll make a flashable clone of an existing Intel Edison (with Yocto... Ubilinux here: I've wanted to extract a flashable image from my Edisons for a while; I usually hack straight on my Edison until something works and don't want to porting to the Yocto build process afterwards. To clone Edisons, I've been using rubidium's commands from the Intel forums, but I wanted a method that worked on top of the Phone Flash Tool used for flashing Edison since it'll be easier to distribute images. I've tested this for flashing Edisons from ww36 (1.0), ww05-2015 (2.0), and ww25.5-2015 (2.1) firmwares to an ww25.5-2015 (2.1) based clone image.

NOTE: I've noticed that this doesn't work well with Edisons that are cloned copies that were produced through copying the entire mmcblk0 block as done in the Intel forum thread referenced above. I've built a workaround for that, but it is a bit longer:

NOTE2: The "systemctl enable post-install" commands will reset your Edison access point name and access point password. If you have to preserve your AP settings, I recommend taking that line out. If not, I've noticed that enabling post-install to run after a flash usually takes cares of resizeing the root partition to the proper size.

  1. PREP EDISON: Prepare an Edison you want to copy. Make sure none of the files you want to copy are in the /home directory. /home isn't copied in the Phone Flash Tools process. Please let me know if it can be done, though!

  2. COPY EDISON: Now, we make a copy of the / partition. There’s a few ways of doing this, depending on how you want to transfer the generated file to your computer:

    1. Transfer through SCP. Run the following command in your Edison’s shell to generate a compressed image:

      systemctl enable post-install
      rm -rf /home/root/* && dd bs=4M if=/dev/mmcblk0p8 | gzip > /home/root/edison-image-edison.ext4.gz
    2. Transfer through SD card. This is the easiest in my opinion. Connect a 2GB or greater microSD card to your Edison and run:

      systemctl enable post-install
      dd bs=4M if=/dev/mmcblk0p8 of=/media/sdcard/edison-image-edison.ext4
      resize2fs -M edison-image-edison.ext4
    3. Transfer through USB key. This is not as easy as the SD card. Connect a 2GB or greater USB key to your Edison. In the case of the Arduino breakout, make sure to have an external power supply connected to the power jack and to have the microswitch switched towards the big USB type-A connector and away from the microUSB port. Then, run the following command:

      ls /dev/sda*

      Note what returns. This should be your USB drive device. It’s usually /dev/sda or /dev/sda1 for me, but that will vary across USB drives. If you get multiple devices, not a problem. You’ll just have to try all to see what sticks. Afterwards, run:

      mkdir /media/usb
      mount /dev/< change this with sda device name> /media/usb

      If you want to check to see if this is the right path to the drive, create a dummy file in /media/usb. If you move the drive from the Edison to your computer, you should see the file you created. To finish up, run:

      systemctl enable post-install
      dd bs=4M if=/dev/mmcblk0p8 of=/media/usb/edison-image-edison.ext4
      resize2fs -M edison-image-edison.ext4

    Afterwards, copy the file to your computer. If you have a gzipped image, un-archive it.

  3. MAKE FLASHING PACKAGE: Now that you have a copy of the edison-image-edison.ext4 file, download the latest Edison firmware. Once downloaded, unzip it and replace the edison-image-edison.ext4 file with the new one that you’ve generated. You now have a flashable Edison image!

  4. TEST PACKAGE: Now we have to test. Grab a new Edison to make into a clone and flash it!

  5. CHECK PACKAGE: Serial into your Edison after flashing. It should be an exact copy of your previous Edison, except for the files in the /home directory, which aren’t changed in the flash process. If you get an error that says “No directory, logging in with HOME=/”, making a new /home/root directory will fix the issue:

    mkdir /home/root

Hope this helps! Let me know if I should add anything or clarify stuff by messaging me on twitter @stevencrossing or emailing me at Comments are cool too, but I don't think I get the notifications for comments on a Gist.

Copy link

i cant use systemctl enable post-install in my edison. How can I fix it ? root@ubilinux:# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION="7 (wheezy)"
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezy
root@ubilinux:# uname -r
# uname -m
root@ubilinux:~# lscpu
Architecture: i686
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 74
Stepping: 8
CPU MHz: 500.000
BogoMIPS: 998.40
Virtualization: VT-x
L1d cache: 24K
L1i cache: 32K
L2 cache: 1024K

Copy link

sxing commented Jan 4, 2024

You're on Ubilinux and not the base Yocto build, so you'll need to do the Ubilinux equivalent instead if there is one. The systemctl enable post-install is not something I'd recommend skipping on the base Yocto build, but it'll possibly work fine without having that enabled - especially if there isn't an equivalent.

Copy link

what ‘s your post-install file looks like ? I can not find systemctl enable post-install in my OS.

Copy link

root@jubilinux:# systemctl enable post-install
Failed to enable unit: File post-install.service: No such file or directory
# uname -a
Linux jubilinux 3.10.98-jubilinux-edison #3 SMP PREEMPT Sun Aug 13 04:22:45 EDT 2017 i686 GNU/Linux

Copy link

sxing commented Jan 10, 2024

I already explained this to you. You're using a different distribution. Go look into the official distro or figure it out yourself.

Also, there's a snippet above in what's written that has been in there that specifically talks about Ubilinux. Go run that path instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment