Working with Emmc
Total Page:16
File Type:pdf, Size:1020Kb
Working with eMMC Copyright 2020 © Embedded Artists AB Working with embedded MultiMediaCard (eMMC) Working with eMMC Page 2 Embedded Artists AB Jörgen Ankersgatan 12 SE-211 45 Malmö Sweden http://www.EmbeddedArtists.com Copyright 2020 © Embedded Artists AB. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual or otherwise, without the prior written permission of Embedded Artists AB. Disclaimer Embedded Artists AB makes no representation or warranties with respect to the contents hereof and specifically disclaim any implied warranties or merchantability or fitness for any particular purpose. Information in this publication is subject to change without notice and does not represent a commitment on the part of Embedded Artists AB. Feedback We appreciate any feedback you may have for improvements on this document. Send your comments by using the contact form: www.embeddedartists.com/contact. Trademarks All brand and product names mentioned herein are trademarks, services marks, registered trademarks, or registered service marks of their respective owners and should be treated as such. Copyright 2020 © Embedded Artists AB Rev A Working with eMMC Page 3 Table of Contents 1 Document Revision History ................................. 4 2 Introduction ........................................................... 5 2.1 Additional information ................................................................... 5 2.2 Conventions in this document ...................................................... 5 3 Default configuration ............................................ 6 3.1 Memory areas ................................................................................. 6 3.2 Usage of the areas ......................................................................... 6 4 Get information about the eMMC device............. 8 4.1 List MMC devices ........................................................................... 8 4.2 mmc-utils ........................................................................................ 8 4.2.1 Check eMMC version .................................................................... 8 4.2.2 Max Enhanced Area Size .............................................................. 8 4.2.3 Boot partition size .......................................................................... 8 4.2.4 Boot configuration ......................................................................... 8 4.2.5 Life time estimation ....................................................................... 9 4.3 fdisk ................................................................................................. 9 4.4 df ...................................................................................................... 9 4.5 mount ............................................................................................ 10 5 Create / modify partitions ................................... 11 5.1 Partition user area ........................................................................ 11 5.2 Switch boot partition .................................................................... 11 6 Create enhanced mode (SLC) partition ............. 13 6.1 Why enhanced mode? ................................................................. 13 6.2 Create partition from Linux ......................................................... 13 6.2.1 Linux distributions ........................................................................ 13 6.2.2 Yocto configuration ...................................................................... 13 6.2.3 Instructions .................................................................................. 13 6.3 Create partition from u-boot ........................................................ 14 6.3.1 U-boot version ............................................................................. 14 6.3.2 Instructions .................................................................................. 14 Copyright 2020 © Embedded Artists AB Rev A Working with eMMC Page 4 1 Document Revision History Revision Date Description A 2020-04-28 First release Copyright 2020 © Embedded Artists AB Rev A Working with eMMC Page 5 2 Introduction Most embedded devices need some kind of storage area for firmware and data files. Many different solutions exist, but this document will focus on embedded MultiMediaCard normally referred to as eMMC. An eMMC consists of two parts; the flash memory (of type NAND) and the memory controller. Having the memory controller integrated simplifies the usage of the storage device. Without this controller the software driver on the host would have to handle the low-level flash memory management, such as wear levelling and error correction. 2.1 Additional information Additional documentation you might need is. • “TN-52-07: e.MMC Partitioning”, from Micron • “TN-FC-40: Configuring the Embedded e.MMC Device”, from Micron • “TN-FC-06: Booting from Embedded MMC”, from Micron • Introduction of eMMC by Yejin Moon at Samsung Electronics 2.2 Conventions in this document A number of conventions have been used throughout to help the reader better understand the content of the document. Constant width text – is used for file system paths and command, utility and tool names. $ This field illustrates user input in a terminal running on the development workstation, i.e., on the workstation where you edit, configure and build Linux # This field illustrates user input on the target hardware, i.e., input given to the terminal attached to the COM Board This field is used to illustrate example code or excerpt from a document. This field is used for important notes and highlights Copyright 2020 © Embedded Artists AB Rev A Working with eMMC Page 6 3 Default configuration 3.1 Memory areas When the eMMC component is delivered from the manufacturer it is normally divided into four areas as shown in Figure 1 below. Figure 1 - Default memory organization Area Description Boot Typically used to store firmware and data needed during booting of the device. Two boot areas are normally available and these are of type SLC NAND (enhanced mode) RPMB Replay-protected memory-block area. This area is typically used to store secure data such as encryption keys. This area is of type SLC NAND (enhanced mode). User This area is used to store user data such as a file system. This is the area that is normally divided into several partitions. By default, it is of type MLC NAND, but can be changed to SLC NAND (enhanced mode), see chapter 6 3.2 Usage of the areas Figure 2 show the default usage of the eMMC areas on Embedded Artists COM boards. Copyright 2020 © Embedded Artists AB Rev A Working with eMMC Page 7 Figure 2 - Default usage of the eMMC areas Area Description Boot area 1 The bootloader images (such as SPL and u-boot) are stored in this area. The boot area is not formatted and contains no file system. The images are instead stored at fixed offsets. When SPL and u-boot are used SPL will be stored at an offset of 1024 bytes (1 Kbyte) and u-boot will be stored at an offset of 69 Kbytes. The area also contains the u-boot environment which is stored at an offset of 2 Mbytes minus 8 Kbytes (2MB – 8KB). User area The user area is divided into two partitions. The first partition will be FAT32 formatted Partition 1 and contain the Linux kernel and device tree files. User area The second partition contains the root file system and is by default ext3 formatted. Partition 2 Copyright 2020 © Embedded Artists AB Rev A Working with eMMC Page 8 4 Get information about the eMMC device 4.1 List MMC devices In Linux you can list available MMC devices (and partitions) by checking the /dev/ directory # ls -la /dev/mmcblk* brw-rw---- 1 root disk 179, 0 Dec 23 11:57 /dev/mmcblk2 brw-rw---- 1 root disk 179, 32 Dec 23 11:57 /dev/mmcblk2boot0 brw-rw---- 1 root disk 179, 64 Dec 23 11:57 /dev/mmcblk2boot1 brw-rw---- 1 root disk 179, 1 Dec 23 11:57 /dev/mmcblk2p1 brw-rw---- 1 root disk 179, 2 Dec 23 11:57 /dev/mmcblk2p2 brw-rw---- 1 root disk 179, 96 Dec 23 11:57 /dev/mmcblk2rpmb In the above example there is one MMC device (mmcblk2) which has 5 partitions. 4.2 mmc-utils The tool mmc-utils is by default installed in the root file system when using Embedded Artists Yocto image. This tool can be used not only to retrieve information about the eMMC device, but also change its configuration. 4.2.1 Check eMMC version # mmc extcsd read /dev/mmcblk2 | head 2 ============================================= Extended CSD rev 1.8 (MMC 5.1) 4.2.2 Max Enhanced Area Size You can check the maximum enhanced area size that can be used (see chapter 6 for more information about enhanced area). # mmc extcsd read /dev/mmcblk2 | grep -A2 MAX_ENH_SIZE_MULT Max Enhanced Area Size [MAX_ENH_SIZE_MULT]: 0x0001d2 i.e. 3817472 KiB 4.2.3 Boot partition size Check the boot partition size by running the command below. You can then calculate the actual size by 128 KB x BOOT_SIZE_MULTI. In the example below the size is 128 KB x 64 = 8192 KB = 8 MB. # mmc extcsd read /dev/mmcblk2 | grep BOOT_SIZE_MULTI Boot partition size [BOOT_SIZE_MULTI: 0x40] 4.2.4 Boot configuration Check the current boot configuration by running the command below. In this example BOOT_ACK (bit 6) is set and boot partition 1 is enabled (bit 3). See the table below for the field / bit descriptions. # mmc extcsd read /dev/mmcblk2