Book Image

Using Yocto Project with BeagleBone Black

By : Hafiz Muhammad I Sadiq, Irfan Sadiq
Book Image

Using Yocto Project with BeagleBone Black

By: Hafiz Muhammad I Sadiq, Irfan Sadiq

Overview of this book

Table of Contents (17 chapters)
Using Yocto Project with BeagleBone Black
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating partitions and formatting the SD card


BeagleBone Black is shipped with Angstrom images by default and partitioned as we require. However, if you have damaged it or don't want to erase the default images, then you should follow these instructions to prepare another BeagleBone for use.

If the card you have inserted has some partitions, they will be mounted automatically. To avoid any surprises like damaging the card, unmount these partitions. If you are using an SD card reader, the device for the card will be /dev/mmcblk*. If you are using some USB card reader, then the device will be something like /dev/sdX, where X is a number. X depends on the SCSI drives that are already connected to your system. We are using the first option, that is, a built-in SD card reader. You can determine which device is created for your card by issuing the dmesg command as follows:

$  dmesg | tail
[27409.486378] mmc0: new high speed SDHC card at address 0007
[27409.486640] mmcblk0: mmc0:0007 SD04G 3.70 GiB 
[27409.488506]  mmcblk0: p1

You can also use fdisk -l to check what device is created for your card. Now, you can use the fdisk utility as root or with sudo to create our required partitions, using the following steps:

  1. Unmount any mounted partition, using the umount command:

    $  umount /dev/mmcblk0p1
    
  2. Launch the fdisk utitility and delete the previous partition(s); in our case, it is just one:

    $  sudo fdisk /dev/mmcblk0
    Command (m for help): d
    Selected partition 1
    
  3. Create new partition called BOOT of 32 MB and type primary:

    Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): 
    Using default response p
    Partition number (1-4, default 1): 
    Using default value 1
    First sector (2048-7774207, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-7774207, default 7774207): +32M
    
  4. Create a second partition to hold rootfs. We will give all the remaining space to this partition:

    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): 
    Using default response p
    Partition number (1-4, default 2): 
    Using default value 2
    First sector (67584-7774207, default 67584): 
    Using default value 67584
    Last sector, +sectors or +size{K,M,G} (67584-7774207, default 7774207): 
    Using default value 7774207
    
  5. Make the first partition bootable by setting the boot flag:

    Command (m for help): a
    Partition number (1-4): 1
    
  6. Set the first partition as WIN95 FAT32 (LBA):

    Command (m for help): t Selected partition 1 Hex code (type L to list codes): c
    
  7. We are done with the filesystem modification. So, let's write it by issuing the w command:

    Command (m for help): w
    The partition table has been altered!
    Calling ioctl() to re-read partition table.
    Syncing disks.
    

    Tip

    Do not forget to set the first partition as WIN95 FAT32 (LBA); otherwise, BeagleBone won't be able to boot from it. In this case, you might end up wasting time figuring out what's going wrong.

  8. Format the first partition as FAT, using the following command. We will set the label as BOOT so that we know what directory it will be mounted to by udisks:

    $  sudo mkfs.vfat -n "BOOT" /dev/mmcblk0p1
    
  9. Format the second partition as an ext4 filesystem, using the following command. The label for this is set to ROOT, as it will contain the extracted image of rootfs.

    $  sudo mkfs.ext4 -L "ROOT" /dev/mmcblk0p2
    

I have created a simple script to perform all the preceding steps. I am listing these steps here for your understanding, so that you can do any adjustments if required.

Tip

Downloading the example code

Most of the implementation code is kept at https://github.com/YoctoForBeaglebone/ and can be pulled directly from there. If you have something to add, feel free to add it. While adding something to any repository, kindly avoid pushing directly to the repository and use Git pull request mechanism supported by GitHub.