[GSOC 2026] eMMC Storage Support

Hey Haiku Community,

I am Dhruva P V (aka Dhrulian ). I am currently pursuing my 4th year of Engineering in Electronics and Communication . With a strong passion for Embedded Systems , I’m always looking forward to learning, collaborating, and exploring new technologies. I found the Haiku GSoC program to be the perfect opportunity to achieve all of these goals.

I have experience in QEMU, ARM controllers and processors , USB Type-C PD validation.Continuing the protocol hunt :slight_smile: i want to learn and contribute towards the " eMMC Storage Support " project.

My current understanding of the project:
-With the current status the project focuses on implementing the protocol in the kernel
-Adding the eMMC support with the SDHCI driver and for advanced DMA

Questions:

  1. For gsoc project discussions should i use the mailing lists or the forums.?
  2. How should I start approching the project.?
  3. Is there a minimal task that i should complete specific to my project for the proposal to be fruitful.?

I would appreciate any suggestions or guidance from the maintainers and community members on this.

Thank you.

7 Likes

Hi Dhrulian,

To your first question: both avenues of communication are fine. The mailing list has less traffic but more developers active. Choose what works best for you.

As for specific advice on how to aproach It, I don’t have much. Though, do you have a decice you could test a driver against?
I for example got some “Dell Wyse 3040”, they are quite small machines and i got them for about 20eur. So not that expensive. But perhaps you already have another machine with eMMC storage.

Haiku currently does not support arm or arm64 well however, so attempting the drvier on those would be quite a bit more challenging, as you would have to complete the arm64 or arm port first. (Although this is also an option for GSOC)

1 Like

That would indeed be the first thing to set up. Can qemu emulate an eMMC device? If it can, that’s probably the easiest way to debug the driver. So you can start by setting up a Haiku virtual machine booting from another type of disk and try to attach an eMMC device to it through an SDHCI PCI device.

Then you can see in the syslog the sdhci driver should detect the bus, but then the mmc_disk driver will fail to initialize eMMC, because currently it only knows commands suitable for SD cards and these are a bit different. Part of the work will be establishing an initialization sequence that works for both SD and eMMC devices.

You can also have a look at the existing code in src/add-ons/kernel (in busses/sdhci bus_managers/mmc and disk/mmc). The driver is split in these 3 parts so we can extend it later: to implement other low level controllers that are not compatible with sdhci, and higher level drivers for other type of cards (such as SDIO cards).

I think studying all this should give you the needed info to write an application proposal for this project. Let me know if you need more details about one or more of these things!

2 Likes

Yes it can.

2 Likes

I have x86 tablet with eMMC SSD to test. I heard other Haiku users reports about laptops with eMMC SSD.

3 Likes

Thank you everybody,

I will first try setting up QEMU with eMMC emulation and explore how Haiku detects the SDHCI controller and MMC bus., with that i will try getting a chromebook (thought of starting it on x86 first.) for this project. I share my reasonings , findings on the same thread.

4 Likes

Ahoy @Dhrulian !

Welcome to Haiku Globe !

Have a joyful journey with coding kernel parts to Haiku’s storage driver support !..

May the Force be with you, kép

2 Likes

Thank you @KitsunePrefecture !!

You can test on real hardware as well as qemu. Especially if it makes it more exciting for you to see your work make Haiku run on a new machine!

But qemu may be a friendlier place to start if you never worked on drivers before. It allows to do it on a platform where everything is software, and can be analyzed and debugged with tools you already know.

Anyway, itws possible to setup so you can test on both, or start with one and move to the other later on.

For chromebooks, I have one with eMMC (and x86 cpu) but I had to reflash it with an UEFI firmware, replacing the default chromebook one. Otherwise there was no way to start Haiku on it. I don’t know if all models are the same, but maybe that’s something to keep in mind (depending on if you’re already familiar with that type of reflashing and changing firmwares)

1 Like

Sure @PulkoMandy , I will first start with QEMU and share the results later after some development , I will find hardware to test on it and with your suggestion Chromebook wouldnt be my first choice :smile:

1 Like

There are also many devices that come with Windows preinstalled where you can easily boot another OS,that have eMMC as internal storage.
I own 4 devices of that sort,but can’t really recommend one of them as they also have other missing drivers (sometimes it’s input,sometimes it’s wifi,one device has the screen rotated 90 degree,…)
But I’m sure you’ll find something that works if you don’t buy as exotic hardware as I did.

1 Like

A good one to start trying on, & quite cheap to buy pre used - One moment, please...

1 Like

Yippe! I was able to setup Haiku on QEMU and attach eMMC device .Here are the outputs.

First I tried attaching SD card and checked the logs.

Second, I attached eMMC storage and checked the logs.

Next I will be going through the repository and do the analysis and come out with possible reasoning and solutions for the issue and share it along.

Sorry for taking this long i was stuck in Qemu; apparently, the older versions didnot recognise the device, So I had to build the QEMU 10.2.0V.
I also read in the GSOC contributions guidelines that we need to tackle beginner friendly issues or project specific issues and submit patches on it. How to find them.?

5 Likes

Checked here?

2 Likes

I will go through them , Thank you

1 Like

You can pick any issue that is in your reach. So if you prefer to dive straight into the MMC drivers, that works too!

2 Likes

I went through MMC related issues , and most of them are very hardware specific and some of them are related to the eMMC storage support (which could come under my project) and you mentioned in one of the comments that you are working on the driver.

So could help me with issues that i can take up which will be helpful to my project.?

Hello,

The project is about eMMC devices which would correspond to this ticket:

I think all the other ones are about supporting different hardware controllers. You may hit hardware issues depending on what hardware (or emulated hardware) you test on.

In your logs you can see that the driver is doing the initialization sequence for an SD card. It starts with CMD0 (reset the card) then CMD8 (voltage check) and CMD5 (detection of SDIO cards) and ACMD41.

You can find the documentation for this command sequence in SD Host Controller Simplified Specification (Simplified Specifications - SD Association, part A2) as figure 3-9.

At this point the log says “Card did not enter ACMD mode”, which is expected since ACMD41 is a SD card specific command and does not exist for eMMC. If you compare this with the flowchart in the SDHC specification linked above, you see that we should end in the “Not SD card” block (numbered 17 in the diagram).

We should continue by checking if the device is compatible with MMC. Maybe a little backstory is helpful to understand the situation here. Initially the standard for memory cards was going to be MMC. Several companies were working together on that and they defined the electrical specifications, the physical card format and connector, and the basic command structure. However. at some point, some of the companies decided to “fork” that standardization effort, mainly to add DRM to the cards (hence the name “Secure Digital”). They preserved the same physical layer, but defined different commands for various things. The two camps don’t talk to each other anymore. So, the SD card specs never mention MMC, and the MMC spec doesn’t mention SD. It is up to us to merge the two together and identify the proper command sequence that allows us to find out what type of device we are dealing with.

Anyway, once we reach the “Not an SD card” step, the SD specification just stops telling us what to do. But we can look at the initialization sequence for MMC instead. You can find that in the MMC specification: https://vems.hu/files/mmc/mmcsys-version_3-1.pdf as figure 17 (this is an older specification for MMC, not eMMC, that means devices packaged as cards like SD and not as chips soldered directly to a motherboard. But I checked eMMC specifications I could find, and the command sequence for these steps did not change). We already did the CMD0 to reset the card, so we should likely continue with CMD1, CMD2 and CMD3. If you look at the diagram for SD cards, you can see that the two may converge again at this point, since the initialization for SD cards does not use CMD1, but it also ends with CMD2 and CMD3. That makes sense, since CMD2 and CMD3 are what allows to identify the card (read its unique ID) and then assign it a short address used to later send it commands. Initially MMC and SD supported multiple devices on the same bus. For eMMC, this option was removed, as it was getting in the way of allowing higher communication speeds.

It looks like the current driver takes a wrong turn after failing to send ACMD41. A little bit more detail about what ACMD means: this is for “Application commands” which allows to define extra command number specific to one type of cards (here, specific to SD cards). The implementation consists of sending CMD55, and then the next command will be handled as an application command instead of a normal command.

Looking closely at the diagram in the SD spec, ACMD41 can end up in 3 different ways. Looking at the corresponding text for step 13, these are:

  • The command is succesful (OCR OK)
  • The command returns an error (OCR fail)
  • The card does not enter application mode (no response to CMD55 to enter ACMD mode)

According to your logs with eMMC connected, we should be in that last case. But this is not detected correctly and the driver continues on with the next steps for SD cards (steps 14-16 in the SDHC specification diagram) instead of going to MMC mode where it should send CMD1.

So that’s the first thing to change: fix the detection of failed CMD55, and make the mmc_bus manager switch to MMC initialization commands in that case.

Once we have that working and the eMMC is detected and initialized, there will be more work to do on:

  • The commands for reading and writing to the card may be different. Study of the respective specifications will be needed
  • With the current driver, data transfers will tend to be slow. Both SD and eMMC support a variety of ways to increase the speed. At the hardware bus level: switching to 4 bit or even 8 bit data bus to send more bits at a time, using higher clock rates, using bulk commands to read multiple sectors at a time. These will require negociation with the card because oldest cards may not support all of it. And at the SDHC controller level: “Advanced DMA”, “Auto CMD12”, and various other features allow the controller to perform more work on its own without so much control from the CPU, and make sure the SD or eMMC device is not spending much time idle, waiting for the CPU to handle interrupts and prepare the next command to send.

That was a lot of info :sweat_smile:
I hope I did not make too much mistakes here. Obviously I have not really tested and confirmed all of this yet (otherwise the driver would already be working). I am not actively working on that driver at the moment, but I will happily provide help if you have more questions, and review patches when they are ready.

5 Likes

Thanks a lot :heart:!! for this , I will be going through the SD card and the MMC specification for further and update on this soon.

Even though it was it was lot of info, it gave me directions to look into!!.
Once I get a good hold of intialisation steps , I can look into the CMD55 detection

Hey everybody !!, during this time I have made a detailed analysis of the existing code and associated issues related to my project.

Overview -

The project requires eMMC (Embedded Multi Media Card) storage support. Firstly, to understand there are multiple storages devices such as SD cards (SDSC, SDHC, SDXC) , eMMC (embedded MMC, soldered on board) these are already soldered onto the board. All of these devices work on MMC bus protocol and are controlled via SDHCI controller

However, currently Haiku does not properly recognize or initialize eMMC devices. The existing MMC bus implementation assumes SD card initialization flow (CMD8 + ACMD41), while eMMC devices require a different initialization sequence (CMD1-based).

Analysis -

Now I sharing the exploration I have done within the code structure related to the project.

The complete initiliasation , controlling of the devices happens at three layers and they are present at:

Main path src/add-ons/kernel:

1. (busses/mmc)

The files present in this directory are mainly related to the discovery and functioning of SDHCI controller.

  • sdhci_pci.cpp and sdhci_acpi.cpp are related to the discovery of the SDHCI controller.

  • Now to main part sdhci.cpp-
    -I will be listing out the important functions and their purpose.

*Constructor -

  • First we check if any interrupt are active present.
  • Install the interrupt handler
  • We reset all the registers of sdhci controller
  • Print all the registers capabilities.
  • Power on the card if inserted
  • For initialisation we set the clock frequency to 400khz.
  • Enable the interrupts.
  • Start a polling thread through “Workthread” ( more on this in a bit).

*ExecuteCommand()-

  • The response type R1, R2, R3 is determined
  • The argument register
  • The command register
  • It wait for “command complete” interrupt
  • It handles timeout
  • It handles CRC errors.
  • Read response

*DOIO()-

  • It sets up DMA address
  • It sets up block size (512 bytes)
  • It sets up block count
  • It calls ExecuteCommand()
  • Waits for transfer complete interrupt

*SetScanSemaphore()-

  • When the card is inserted it releases semaphore and interrupt in enabled.

*HandleInterrupts():

  • It check if the card is removed , inserted , transfer complete ,power errors
  • After the above it then clears the interrupt bits.

*WorkThread();

  • According to code some ACPI setups dont support IRQ thus, polling is done.

*Register_device()-Used for registering the SD Controller on the , supports_device()- Determines if a device is PCI SDHCI or ACPI SDHCI

2. (Busmanager/mmc):

MMC_bus.cpp- It mainly contains the protocol layer of MMC.

*Constructor-

  • It is called via MMC_module.cpp
  • It stores device node
  • Gets parent driver (SDHCI):
  • It connects MMCBus to SdhciBus. Creates semaphores
  • It spawns a ‘WorkerThread’ (More about this )

*Deconstructor-
when driver is removed.

  • It stops worker thread
  • It deletes semaphores
  • It cleans up state

*ExecuteCommand()-

  • It calls _ActivateDevice(rca)
  • It forwards command to SDHCI:
  • It is called by disk driver and forwarded to SDHCI

*DOIO()-

  • It is called by mmc_disk driver during read/write.
  • Calls _ActivateDevice(rca)
  • Forwards to SDHCI:

*_ActivateDevice(rca)-

  • It activates the device , through ExecuteCommand() and works for SD as well eMMC cards.

*_WorkerThread()-

  • Card insertion triggers an interrupt

  • We reset all the cards and wait until card is inserted and scanned again.

  • To initialise we reduce the clock speed ,

  • We check for card compatability here it only works for SD providing, CMD8 , but MMC cards follow a different sequence.

  • We continue with ACM41 (SD Card initialisation) further jump for OCR(operational condition registers) waiting for the card to be ready.

  • The type of SD card is identified.

  • We are using CMD2 and CMD3 to assign new RCA (unique address) to the cards but we need to assign new RCA because they can create collision

  • After this we complete tRCA assignment we can enter the data phase, completing the initialisation phase.

  • Create a device node allowing mmc_diisk driver attachment.

3 . (drivers/disk/mmc)

mmc_disk.cpp- It is block driver layer , which provides an interface between blocks and the file system.

*mmc_disk_supports_device()-

  • It filters out MMC devices.
  • Here it checks for device type , here eMMC is supported.

*mmc_disk_execute_iorequest()-

  • Here read and write request is converted to Input Output request.
  • This functions then traces to DOIO() of MMC_bus then to DOIO() of SDHCI

*mmc_disk_init_driver()-

  • It allocates mmc_disk_driver_info
  • It gets parent node (mmc_bus)
  • It gets mmc_bus interface:
  • Retrieves RCA:

*Geometry()-

  • We parse the CSD register which gives information related to manufacturing information, including block size and total block count.
  • It allows us to compute sector size ,total sectors .

Understanding the entire flow of the system.

  • The loading of all the three layers of drivers are handled by the device Manager-

  • FIrst it loads the SDHCI controller throught the modules array which contains information about the controller.

  • SDCHI object is created.

  • The device Manager calls mmc_bus_init() which creates an object of MMC_BUS.

  • The MMC_BUS get attached to the SDCHI whith it being refernced as the parent node.

  • Workerthread starts and the initialisation sequence of the card takes place CMD0 , ACMD41 , OCR checks , RCA is assigned .

  • The device gets published.

  • Next the device manager loads up the mmc_disk , thus creating a block device.

  • The read and write operations are then carried out by the IO requests which are forwarded to DOIO of mmc_bus and then sdhci.

  • This above operation happens through hardware DMA , which genrates interrupts and is handled.

I have tried to cover important things as much as possible with respect to current structure of my project , I might have excuse few things
The todos and fixes were present in the code , I didnt explicity mention them here.

@PulkoMandy I found the 4.1 v and the 5.1v documentation , both have same state diagram for card identification.

JESD84-B51 - PDFCOFFEE.COM eMMC 5.1v Documentation

I believe I have a good understanding of the code and flow .
I plan on starting with eMMC identification can i go ahead with it.

I have tried to cover important things as much as possible with respect to current structure of my project , I might have missed few things. So if anything is wrong or should be understood do correct me on this.
The todos and fixes were present in the code , I didnt explicity mention them here.

2 Likes