Linux Device Driver Programming Lecture 7- Preparing Micro SD card for SD boot

  • Post author:
  • Post category:Blog

 

Preparing Micro SD card for SD boot

 

 

In this session, let’s prepare a Micro SD card for SD boot. First of all, we have to do Micro SD card preparation.

These are the steps you have to follow,

  1. Use 8/16/32 GB Micro SD card.
  2. Connect the Micro SD card to the PC using a card reader.
  3. Launch the GParted application.
  4. Make two partitions(fat16 and ext4).
  5. Copy boot images on fat16 partition(BOOT partition).
  6. Copy Debian root file system on ext4 partition.
  7. Configure the boot,lba flags on the boot partition.
  8. Unmount and remove the Micro SD card from the PC.
  9. Insert the Micro SD card into the BBB Micro SD card slot.
  10. Boot from SD card interface (mmc0 interface).

I will guide you step by step.

For this exercise, you should have a Micro SD card of 8 or 16 or 32GB (Figure 1), and you need a card reader (Figure 2).

 

First, you have to connect the Micro SD card to the PC using a card reader, as shown in Figure 3.

Figure 3. Inserting SD card into PC
Figure 3. Inserting SD card into PC

 

And after that, we launch the Gparted application, which we installed in the earlier part of the sessions. After that, it will ask for authentication (Figure 4) permission. Let’s enter the password.

Figure 4. Authentication required window
Figure 4. Authentication required window

 

Figure 5. Launched GParted application
Figure 5. Launched GParted application

 

Now, the very important step is to select the device here. Otherwise, you may mess up with your hard disk.  sda is the hard disk, and sdb is the SD card as shown in Figure 6 what I connected.

Figure 6. Selection of device
Figure 6. Selection of device

 

If you are not sure, then don’t worry; open the command prompt.

You can just run the command dmesg. Here you can see that the device file which is created for the SD card is sdb, as shown in Figure 7.

Figure 7.dmesg execution
Figure 7.dmesg execution

 

It could be sdc or something different in your case. But you have to run  the dmesg and you have to see the recent activities, and you have to select the appropriate device file. In my case it is sdb. That’s why we should be very careful here. 

I would select sdb, which is my 16 GB SD card; now, we are going to create two partitions here. First, right-click , and let’s delete everything if any partitions before. 

 

Here 14GB is available for us. Right-click and create a new, select primary partition here(As shown in Figure 8).

And after that, here you give the size. Size  I would give a 4095MB or something like that. It should be a fat16.Give the label for this partition as BOOT. And make sure that this is the primary partition; click add.

Figure 8. Creating fat16(BOOT) partition
Figure 8. Creating fat16(BOOT) partition

 

We created the first partition boot of 4095MB.

Let’s create another partition, right-click, new, and you need not change anything, the remaining will be used for the next partition. Select ext4, make it a primary partition, and label it ROOTFS. Then add (as shown in Figure 9).

Figure 9. Creation of ext4(ROOTFS)partition.
Figure 9. Creation of ext4(ROOTFS)partition.

 

And after that, click apply. If you click apply here, all the data of the SD card will be deleted, and the SD card will be formatted into two partitions, fat16 and ext4.

If you are sure about that, then go and click the apply button here (As shown in Figure 10). Apply.

Let’s wait for some time, the operations have been completed, close. 

Preparing Micro SD card for SD boot
Figure 10. Applying partitions

 

And after that, you have to manage some flags for this boot partition,

To make it bootable, you have to set some flags, select the BOOT  partition and right click-manage flags, and select boot here and lba, as shown in Figure 11, and close. After that, close this application.

Preparing Micro SD card for SD boot
Figure 11. Managing Flags

 

You can see that two partitions have been mounted, BOOT and ROOTFS.

Preparing Micro SD card for SD boot
Figure 12. BOOT and ROOTFS partitions

 

For some people, the partitions may not get mounted automatically.

In that case, you would see two device files here on your terminal. In the dev directory you will see sdb1 and sdb2, as shown in Figure 13. These are the two partitions that we just created.

Preparing Micro SD card for SD boot
Figure 13.Device files

 

If you don’t see these mounted directories, then no problem; just remove the SD card and reconnect.  And we have to copy the BOOT and ROOTFS images into it (Figure 14).

Preparing Micro SD card for SD boot
Figure 14. Copying BOOT images and ROOTFS

 

That I will cover in the following sessions, make sure that you complete up to here, and I’ll see you in the upcoming articles.

 

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.