Linux Device Driver Programming Lecture 10- Making SD boot default on BBB by erasing eMMC MBR

  • Post author:
  • Post category:Blog

 

Making SD boot default on BBB by erasing eMMC MBR

 

 

If you are using a newer eMMC flasher image on the eMMC memory of the Beaglebone black hardware, then you don’t see two partitions of the eMMC. 

For example, if I just run the command lsblk here. You see here mmcblk0, this is nothing but your SD card, which has got two partitions, P1 and P2. And this is the on-board eMMC.

The newer eMMC flash images of beagleboard.org, it creates only one partition here, mmcblk1p1, as shown in Figure 1. You don’t see p2.

Figure 1.Newer eMMC flash images creates only mmcblk1p1 partition
Figure 1.Newer eMMC flash images creates only mmcblk1p1 partition

 

And you cannot locate the MLO in this partition.

Let’s mount that, mount/dev/mmcblk1p1, let’s mount to some mount point. And here, if you go inside the boot, you don’t see MLO here, as shown in Figure 2.

Figure 2. MLO is not found in boot directory
Figure 2. MLO is not found in boot directory

 

That’s because the newer eMMC flasher Debian images of beagleboard.org, it creates only one partition, mmcblk1p1, and this is of type EXT4.

And it doesn’t copy the boot images such as  MLO and U-boot into this partition.

Figure 3. BBB eMMC partitions after using eMMC flasher Debian image
Figure 3. BBB eMMC partitions after using eMMC flasher Debian image

 

It actually creates 1MB of MBR(master boot record), as shown in Figure 3. So, it stores the MLO and U-boot into this MBR. There is no file system on the MBR; you cannot mount the MBR. These MLO and U-boot are hardcoded onto this MBR. 

And now, if you want to force your Beaglebone hardware to boot from the SD card by default, then you have to erase this MBR.

You can recover it when you want. We will see that later. Let’s erase that MBR.

Let’s get back to the Beaglebone. So, go to the beagle bone command prompt here, and let’s first unmount this partition as shown in Figure 4.

Figure 4. Unmount the partition
Figure 4. Unmount the partition

 

Let’s use the dd command to first take the snapshot of the MBR, as shown in Figure 5.

Making SD boot default on BBB by erasing eMMC MBR
Figure 5. Taking MBR snapshot

 

Let’s save that into some file. Because we may want to recover it later.

That’s why I’m going to use the dd command, input file= dev/mmcblk1 and the output file is equal to let me call it as emmc boot. img.

We are copying some data, that is, MBR, into this file. This is a local file. And the block size is equal to 1MB we are copying and count = 1 time. Hit enter. Now you see here this file gets created, which has the snapshot of the MBR.

 

Now we are going to zero out the MBR. Let’s again use the dd command dd; the input file is equal to dev/zero, output five is equal to dev mmcblk1, And bs is equal to 1 megabytes, the count is equal to 1. We zeroed out the MBR, as shown in Figure 6.

Making SD boot default on BBB by erasing eMMC MBR
Figure 6. Zeroed out MBR

 

To test this, you have to remove the power from the Beagle bone black hardware. You just disconnect the USB cable from your computer and connect the USB cable back to your computer to give power to your board.

You can see that the board is booting from an SD card, as shown in Figure 7. It is not trying to boot from the eMMC.

Booting from SD card
Figure 7. Booting from SD card

 

Let’s see  how to recover the MBR as shown in Figure 8.

Let’s login and use the dd command, input file. The input file will be emmcboot.img what we saved earlier, and the output file is equal to dev/mmcblk1. And bs is equal to1 megabyte, count = 1.

Recovering MBR using dd command
Figure 8. Recovering MBR using dd command

 

To test this, just remove power from your Beagle bone black hardware by disconnecting the USB cable and connecting it back, it is booting from the eMMC.

I hope you can reproduce this at your desk and I will see you in the following article.

 

Get the Full course on Linux  Device Driver Here.

FastBit Embedded Brain Academy Courses

click here: https://fastbitlab.com/course1

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.