Skip to content

Instantly share code, notes, and snippets.

@jmz-b
Last active September 22, 2022 10:59
Show Gist options
  • Save jmz-b/e82b2e93a4f1a9daf9924e775ace6247 to your computer and use it in GitHub Desktop.
Save jmz-b/e82b2e93a4f1a9daf9924e775ace6247 to your computer and use it in GitHub Desktop.
MiyooCFW create image file

clone sdcard repo

jmz@xthUnk:/tmp$ git clone https://github.com/MiyooCFW/sdcard
Cloning into 'sdcard'...
remote: Enumerating objects: 3518, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 3518 (delta 46), reused 98 (delta 45), pack-reused 3412
Receiving objects: 100% (3518/3518), 115.18 MiB | 4.34 MiB/s, done.
Resolving deltas: 100% (1268/1268), done.
jmz@xthUnk:/tmp$ cd sdcard/
jmz@xthUnk:/tmp/sdcard$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

generate img

jmz@xthUnk:/tmp/sdcard$ sudo ./generate_image_file.sh 
./generate_image_file.sh: Creating image file ...
1179648+0 records in
1179648+0 records out
1207959552 bytes (1.2 GB, 1.1 GiB) copied, 4.93956 s, 245 MB/s
./generate_image_file.sh: Mapping image as a loop device ...
./generate_image_file.sh: Creating partition table ...
Checking that no-one is using this disk right now ... OK

Disk /dev/loop0: 1.13 GiB, 1207959552 bytes, 2359296 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

>>> Created a new DOS disklabel with disk identifier 0x87e4f214.
/dev/loop0p1: Created a new partition 1 of type 'FAT16' and of size 127.5 MiB.
/dev/loop0p2: Created a new partition 2 of type 'Linux' and of size 127.5 MiB.
/dev/loop0p3: Created a new partition 3 of type 'Linux swap / Solaris' and of size 255 MiB.
/dev/loop0p4: Created a new partition 4 of type 'W95 FAT32' and of size 640 MiB.
All partitions used.

New situation:
Disklabel type: dos
Disk identifier: 0x87e4f214

Device       Boot   Start     End Sectors   Size Id Type
/dev/loop0p1         2048  263167  261120 127.5M  6 FAT16
/dev/loop0p2       264192  525311  261120 127.5M 83 Linux
/dev/loop0p3       526336 1048575  522240   255M 82 Linux swap / Solaris
/dev/loop0p4      1048576 2359295 1310720   640M  b W95 FAT32

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
Syncing disks.
./generate_image_file.sh: Remapping the loop device ...
./generate_image_file.sh: Writing u-boot ...
984+0 records in
984+0 records out
1007616 bytes (984.0KB) copied, 0.029853 seconds, 32.2MB/s
./generate_image_file.sh: Formatting partitions ...
mkfs.fat 4.2 (2021-01-31)
mke2fs 1.46.6-rc1 (12-Sep-2022)
Discarding device blocks: done                            
Creating filesystem with 130560 1k blocks and 32640 inodes
Filesystem UUID: 2d40be41-b014-4a79-ad7a-73450d6ed387
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done 

mkfs.fat 4.2 (2021-01-31)
Setting up swapspace version 1, size = 267382784 bytes
UUID=c652443c-ecd9-48c1-a3a2-275f6553b1fe
./generate_image_file.sh: If some the following fails, you may need to 'umount /tmp/tmp.OLFDpe', 'rmdir /tmp/tmp.OLFDpe' and 'losetup -d /dev/loop0' to clean up.
./generate_image_file.sh: Unpacking rootfs ...
./generate_image_file.sh: Copying over etc files ...
./generate_image_file.sh: Copying over boot files ...
./generate_image_file.sh: Writing 2.0.0-alpha-29-gcd6e819 to /boot/version.txt...
./generate_image_file.sh: Copying over main files ...
./generate_image_file.sh: Cleaned up mounts and tempdir.
./generate_image_file.sh: Finished: ./cfw-2.0.0-alpha-29-gcd6e819.img is ready.

write image to disk

jmz@xthUnk:/tmp/sdcard$ sudo dd if=cfw-2.0.0-alpha-29-gcd6e819.img of=/dev/mmcblk0
2359296+0 records in
2359296+0 records out
1207959552 bytes (1.2 GB, 1.1 GiB) copied, 484.9 s, 2.5 MB/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment