giuliomoro ...definitely more interesting already. I ran these commands...
root@bela:/opt/Bela# mount | grep mmcblk1
/dev/mmcblk1p2 on /tmp type ext4 (rw,relatime,data=ordered)
root@bela:/opt/Bela# umount /dev/mmcblk1p1
umount: /dev/mmcblk1p1: not mounted
root@bela:/opt/Bela# umount /dev/mmcblk1p2
So I guess the eMMC at /dev/mmcblk1p2 was already mounted and that's why I was getting an error trying to flash it earlier?
I run the flash script again and now get the following....
root@bela:/opt/Bela# ./bela_flash_emmc.sh
+ USR1=/sys/class/leds/beaglebone:green:usr1/trigger
+ USR2=/sys/class/leds/beaglebone:green:usr2/trigger
+ USR3=/sys/class/leds/beaglebone:green:usr3/trigger
+ SUCCESS=0
+ trap final_check EXIT
+ make --no-print-directory -C /root/Bela stop
No process to kill
+ echo default-on
+ echo default-on
+ echo default-on
+ sfdisk /dev/mmcblk1
Checking that no-one is using this disk right now ... OK
Disk /dev/mmcblk1: 3.6 GiB, 3825205248 bytes, 7471104 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
Disklabel type: dos
Disk identifier: 0x00000000
Old situation:
Device Boot Start End Sectors Size Id Type
/dev/mmcblk1p1 * 2048 198655 196608 96M e W95 FAT16 (LBA)
/dev/mmcblk1p2 198656 7471103 7272448 3.5G 83 Linux
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x68a0906e.
/dev/mmcblk1p1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 67.4 MiB.
Partition #1 contains a vfat signature.
/dev/mmcblk1p2: Created a new partition 2 of type 'Linux' and of size 3.5 GiB.
/dev/mmcblk1p3: Done.
New situation:
Device Boot Start End Sectors Size Id Type
/dev/mmcblk1p1 * 2048 140000 137953 67.4M c W95 FAT32 (LBA)
/dev/mmcblk1p2 141312 7471103 7329792 3.5G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
Syncing disks.
+ mkfs.vfat /dev/mmcblk1p1
mkfs.fat 4.1 (2017-01-24)
+ mkfs.ext4 -F /dev/mmcblk1p2
mke2fs 1.43.4 (31-Jan-2017)
/dev/mmcblk1p2 contains a ext4 file system labelled 'rootfs'
last mounted on /tmp on Sun May 26 16:59:59 2019
Discarding device blocks: done
Creating filesystem with 909056 4k blocks and 227584 inodes
Filesystem UUID: f64ddad1-1caa-4793-a2b0-5f73f1d2c846
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
+ dosfslabel /dev/mmcblk1p1 BELABOOT
+ e2label /dev/mmcblk1p2 BELAROOTFS
+ mkdir -p /mnt/emmc_boot
+ mkdir -p /mnt/root
+ mount /dev/mmcblk1p1 /mnt/emmc_boot
+ mount /dev/mmcblk1p2 /mnt/root
+ echo 'copying files, this may take a few minutes...'
copying files, this may take a few minutes...
+ cp /mnt/boot/MLO /mnt/emmc_boot
+ sync
+ cp /mnt/boot/u-boot.img /mnt/emmc_boot
+ sync
+ rsync -r --exclude=/mnt/boot/MLO,/mnt/boot/u-boot.img /mnt/boot/MLO /mnt/boot/bela.version /mnt/boot/drivers /mnt/boot/u-boot.img /mnt/boot/uEnv.txt /mnt/emmc_boot
+ cp -a /opt/Bela/uEnv-emmc.txt /mnt/emmc_boot/uEnv.txt
+ cp -a /bin/ /boot/ /dev/ /etc/ /home/ /lib/ /opt/ /root/ /sbin/ /srv/ /usr/ /var/ /mnt/root
...at this point the status lights are blinking again in the familiar pattern from before. The three LEDs left of the status LED are blinking in unison around once per second while the status LED gives a heartbeat.
I'm hoping that now this is the indicator for the eMMC flashing process? :-)
...and then about 10 minutes later...
+ mkdir -p /mnt/root/media /mnt/root/mnt /mnt/root/proc /mnt/root/run/ /mnt/root/sys /mnt/root/tmp
+ cp -a /opt/Bela/fstab-emmc /mnt/root/etc/fstab
+ echo /dev/mmcblk1
+ rm /mnt/root/etc/systemd/system/default.target.wants/bela_flash_emmc.service
rm: cannot remove '/mnt/root/etc/systemd/system/default.target.wants/bela_flash_emmc.service': No such file or directory
+ true
+ rm /mnt/root/etc/cpsw_0_mac /mnt/root/etc/cpsw_1_mac /mnt/root/etc/cpsw_2_mac /mnt/root/etc/cpsw_3_mac /mnt/root/etc/cpsw_4_mac /mnt/root/etc/cpsw_5_mac
+ sync
+ umount /mnt/emmc_boot
+ umount /mnt/root
+ echo 'Done!'
Done!
+ echo mmc0
+ echo none
+ echo mmc1
+ SUCCESS=1
+ final_check
+ '[' 1 -eq 0 ']'
root@bela:/opt/Bela#