Block devices
Block devices provide the access to physical or logical drives (e.g. SD card, USB flash drive). They allow to read and write consecutive blocks of bytes of a fixed block size. Circle supports only block devices with a size of 512 bytes. All block devices provide the following methods, which are derived from the class CDevice
. The detailed class descriptions below list additional class-specific methods only.
Method |
Purpose |
Description |
---|---|---|
Read() |
read block(s) from device |
|
Write() |
write block(s) to device |
|
Seek() |
set read/write pointer position |
CEMMCDevice
#include <SDCard/emmc.h>
-
class CEMMCDevice : public CDevice
This class provides the physical access to SD cards and to embedded MMC memory on the Compute Module 4. This class has to be manually instantiated, if an application wants to access one of these devices. This is demonstrated in addon/SDCard/sample. There can be only one instance of this device, which has the name
emmc1
in the device name service.This class has drivers for two different interfaces, the SDHOST interface and the EMMC interface. The SDHOST interface is enabled by default on the Raspberry Pi 1-3 and Zero, when the system option
REALTIME
is not enabled. On the Raspberry Pi 4 the EMMC interface is used in any case, but can be used on the earlier models with the system optionNO_SDHOST
too. This is not possible, when you want to access the on-board WLAN device at the same time. To access the embedded MMC on the Compute Module 4, the system optionUSE_EMBEDDED_MMC_CM4
has to be enabled.
-
CEMMCDevice::CEMMCDevice(CInterruptSystem *pInterruptSystem, CTimer *pTimer, CActLED *pActLED = 0)
Creates the instance of this class.
pInterruptSystem
is a pointer to the system interrupt object.pTimer
is a pointer to the system timer object.pActLED
can be specified to use the green Activity LED to inform the user, when the SD card is currently accessed. This is optional.
-
boolean CEMMCDevice::Initialize(void)
Initializes the EMMC or SDHOST device and detects the inserted SD card. Returns
TRUE
on success.
-
const u32 *CEMMCDevice::GetID(void)
Returns a pointer to the 32 byte (four
u32
words) long identifier of the inserted SD card. This information can be used to recognize a specific SD card again and is only valid, whenInitialize()
was successfully called before.
CUSBBulkOnlyMassStorageDevice
#include <circle/usb/usbmassdevice.h>
-
class CUSBBulkOnlyMassStorageDevice : public CUSBFunction
This class provides the physical access to USB mass-storage devices (e.g. flash drive, hard disk), which support the USB Mass Storage Bulk Only 1.0 specification. An instance of this class is automatically created in the USB device enumeration process, when a compatible USB device (interface 8-6-50) is found. These devices have the name
umsdN
(N >= 1) in the device name service.
-
unsigned CUSBBulkOnlyMassStorageDevice::GetCapacity(void) const
Returns the capacity of the device in number of 512 Byte blocks.
Note
Circle supports USB mass-storage devices with up to 2 TBytes capacity.
CPartition
#include <circle/fs/partition.h>
-
class CPartition : public CDevice
This class encapsulates one primary partition of a block device with Master Boot Record (MBR). An instance of this class is automatically created, when a block device object is initialized and a primary partition is found, when the MBR is scanned. Extended partitions (partition types 0x05 and 0x0F) and EFI partitions (type 0xEF) will be ignored in this process. These partition devices have the name
DEV-N
(N >= 1) in the device name service, where DEV is the name of the physical block device. For example the first found partition on a SD card has the nameemmc1-1
. This class only supports the standard methods of theCDevice
class.
Note
These partition devices are only accessed by the Circle-native FAT filesystem support (class CFATFileSystem
), but not by the FatFs library, which implements its own MBR management.