Restore erased eMMC

Hello, I need some help to restore my eMMC on my BeagleBone Black.
I’ve been running my BBB from a write protected SD-card and to make sure it wouldn’t boot from the onboard eMMC, I erased the the first part of the disk by running command:

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=100

After this the BeagleBone won’t mount the eMMC and /dev/mmcblk1 is missing. Is there some way to restore this eMMC? Any way to force it to mount?

Basically by using the DD command you have erased the partition information.

Use fdisk (or whatever you prefer) to create 1 or more partitions and then format them as desired.
Then you should be able to mount it/them

Thank you, but the problem is that my Beaglebone don’t recognize my eMMC drive anymore. When I run the ‘fdisk -l’ command I just list my SD-Card(/dev/mmcblk0).

sudo fdisk -l
Disk /dev/mmcblk0: 14.6 GiB, 15653142528 bytes, 30572544 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: 0xd58fe190

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 4202495 4194304 2G 83 Linux
/dev/mmcblk0p2 4202496 30572543 26370048 12.6G 83 Linux

if it was blank… it would still show…

debian@21-am335x-bbb:~$ sudo fdisk -l
Disk /dev/mmcblk0: 29.72 GiB, 31914983424 bytes, 62333952 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: 0xb5001fb9

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *     8192 62333918 62325727 29.7G 83 Linux


Disk /dev/mmcblk1: 1.79 GiB, 1920991232 bytes, 3751936 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

Run sudo beagle-version you probally disabled eMMC…

Regards,

Thank you for your answer @RobertCNelson.
One thing I didn’t mention is that I have a custom cape mounted on my BeagleBone, I just realized that I can access the ‘/dev/mmcblk1’ when the cape is not mounted. When I investigate the schematics of the cape I can see that pin P8.24(MMC1_DAT1) and pin P8.25(MMC1_DAT0) is connected as ‘Digital In’-signals. Perhaps this is the problem? If so, is there any way around this?

Regards

If those pins are being used by your cape then no. If you have a custom device tree that is just setting them to digital in, but they are not being used then yes, modify the device tree to not set those pins.

Those pins are not used but the custom cape have some pull-up resistors that is holding them in high state(+3.3V). I have tried to set this pins to GND on the cape, but it seems like they must float free for the eMMC to be found by the kernel…?

Have I maybe chosen the wrong kernel for the BeagleBone Black? Have I chosen a build for BeagleBone AI?
$ cat /proc/version
Linux version 5.4.38-ti-r8 (voodoo@x4-am57xx-beagle-x15-2gb) (gcc version 8.3.0 (Debian 8.3.0-6)) #1buster SMP PREEMPT Sat May 9 09:53:15 UTC 2020

This is what’s making me wonder: (voodoo@x4-am57xx-beagle-x15-2gb)

Regards!
/Olof

If there are pull up resistors just remove them. Certainly do not GND the pins.

That looks like a BeagleBoard-X15 kernel, but I would be surprised that it would even boot if that is the case.

Where did you download it from ?

Ok, thank you. I will try to remove them and see if it works.
As I remember, I think I downloaded the image from: Index of /rootfs/bb.org/testing
I was following this instruction from @RobertCNelson: Readonly root problem - #2 by RobertCNelson but it’s possible that I chose the wrong image…

If I look in my: /var/log/kern.log it seems like the kernel recognize the ARMv7 Processor and my AM335x BeagleBone Black

BeagleBone kernel: [ 0.000000] Booting Linux on physical CPU 0x0
BeagleBone kernel: [ 0.000000] Linux version 5.4.38-ti-r8 (voodoo@x4-am57xx-beagle-x15-2gb) (gcc version 8.3.0 (Debian 8.3.0-6)) #1buster SMP PREEMPT Sat May 9 09:53:15 UTC 2020
BeagleBone kernel: [ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
BeagleBone kernel: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
BeagleBone kernel: [ 0.000000] OF: fdt: Machine model: TI AM335x BeagleBone Black
BeagleBone kernel: [ 0.000000] Memory policy: Data cache writeback
BeagleBone kernel: [ 0.000000] efi: Getting EFI parameters from FDT:
BeagleBone kernel: [ 0.000000] efi: UEFI not found.
BeagleBone kernel: [ 0.000000] cma: Reserved 48 MiB at 0x9c800000
BeagleBone kernel: [ 0.000000] On node 0 totalpages: 130560
BeagleBone kernel: [ 0.000000] Normal zone: 1148 pages used for memmap
BeagleBone kernel: [ 0.000000] Normal zone: 0 pages reserved
BeagleBone kernel: [ 0.000000] Normal zone: 130560 pages, LIFO batch:31
BeagleBone kernel: [ 0.000000] CPU: All CPU(s) started in SVC mode.
BeagleBone kernel: [ 0.000000] AM335X ES2.1 (sgx neon)
BeagleBone kernel: [ 0.000000] percpu: Embedded 20 pages/cpu s53068 r8192 d20660 u81920
BeagleBone kernel: [ 0.000000] pcpu-alloc: s53068 r8192 d20660 u81920 alloc=20*4096
BeagleBone kernel: [ 0.000000] pcpu-alloc: [0] 0
BeagleBone kernel: [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 129412
BeagleBone kernel: [ 0.000000] Kernel command line: console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet

Should i try to change this kernel to one better suited for my AM335x?

I would certainly make sure you have the correct image. Don’t download one that starts am57xx. You would need one that starts bone. At least for newer versions.

But it appears you using something pretty old with Debian 8, so it might be that the image was the same for both boards. The main differences would be in the devicetree being loaded.

All right, thank you for your explanation.
Is there any good method to update my current image? Would it be sufficient to just update the kernel or would it be better to start from the beginning with a newer image built for AM335x?

That’s just the build host of the kernel debian package on that day…

5.4 was short lived 5.10 got much more love.

That erases 100M which means you didn’t merely erase the partition table and bootloader but also a decent chunk of the filesystem.

For future reference, to make the eMMC unbootable on an am335x-based beaglebone (so that bootrom skips to SD) it suffices to wipe sector 256:

sudo dd if=/dev/zero of=/dev/mmcblk1 seek=256 count=1

which always has the same contents so you can restore by copying it from any bootable sd card or image:

sudo dd if=/dev/mmcblk0 skip=256 of=/dev/mmcblk1 seek=256 count=1

(This is assuming it’s not using the ancient layout with a separate FAT boot partition (which beagleboard images haven’t used since the kernel 3.8 days I think); those can be made unbootable by marking the boot partition as non-bootable using fdisk, or by renaming the MLO file on it.)

Beware that even merely having a PCB trace connected to one of the eMMC pins can already degrade signal integrity on that line to the point of causing eMMC communication errors, so it may be prudent to cut those two cape header pins instead.