Sdcard.img creation for BeagleBone AI

Hello, I’m trying to create .img file and using this as reference: Debian: Getting Started with the BeagleBone-AI (“Setup microSD card” section).

Create .img file
sudo dd if=/dev/zero of=bbai.img bs=1G count=1

sudo losetup -f --show bbai.img
Then I see it as /dev/loop0

The I do:

sudo dd if=./u-boot/MLO of=/dev/loop0 count=2 seek=1 bs=128k
sudo dd if=./u-boot/u-boot.img of=/dev/loop0 count=4 seek=1 bs=384k

With this command:
sudo sfdisk /dev/loop0 <<-EOF
4M,L,*
EOF
I get:
Disk /dev/loop0: 1 GiB, 1073741824 bytes, 2097152 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 0x151d49cf.
/dev/loop0p1: Created a new partition 1 of type ‘Linux’ and of size 1020 MiB.
/dev/loop0p2: Done.

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

Device Boot Start End Sectors Size Id Type
/dev/loop0p1 * 8192 2097151 2088960 1020M 83 Linux

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 kpartx(8).
Syncing disks.
The I do:
sudo kpartx -av /dev/loop0
after this command
sudo mkfs.ext4 -L rootfs /dev/loop0

bbai.img loosing its partition ? :

sudo fdisk -l bbai.img
Disk bbai.img: 1 GiB, 1073741824 bytes, 2097152 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
after doing this command
sudo tar xfv ./ti-linux-kernel-dev/deploy/${kernel_version}-modules.tar.gz -C /mnt/rootfs/

I get many errors : Cannot mkdir: No space left on device. etc

How can be created .img file with this instruction ?

Yeah, this doesn’t work…

After running

sudo losetup -f --show bbai.img

Grab the /dev/loopX value and run:

kpartx -av /dev/loop1

Then use /dev/mapper/(drive) with sfdisk/etc…

For more detail here’s relevant section in the script that generateds BeagleBoard.org *.img’s

Regards,