Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Programming Interface to eMMC in QNX: (8 Items)
   
Programming Interface to eMMC in QNX  
Hello QNX Expert,

I am very new to the QNX and NXP S32G board.
I am trying to access eMMC Card through C Code on NXP S32G board. Earlier, we managed to access eMMC Card on Linux using
 the following sample code. But in QNX, it faced an issue using ioctl() calls.

Do you have any information and/or documents discussing accessing eMMC in QNX through programming?

I want to know how to read (ex. a device's physical sector size), write, and erase (number of blocks) in eMMC.
This API's like open() close(), lssek(), write() works.

Sample code for Linux
	int fd = open("/dev/mmcblk0", O_RDWR);

	struct stat sb;
	fstat(fd, &sb)

	int secsize = 0;
	ret = ioctl(fd, BLKSSZGET, &secsize); //a device's physical sector size
	if (ret < 0) 
	{
		// set the erase block size
		uint64_t range[2];
		range[0] = offset; // input address
		range[1] = len;    // input block size
		if (ioctl(fd, BLKDISCARD, &range)
		{

		}
	}

	close(fd)
	

Best Regards,
Manoj
Re: Programming Interface to eMMC in QNX  
The QNX sdmmc driver has a devctl() api. You can find a list of supported commands in the online documentation.

E.g. if you are using QNX 7.1:
http://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.devctl/topic/sdmmc.html
Re: Programming Interface to eMMC in QNX  
The physical sector size will be in the card register data, that you get with DCMD_SDMMC_CARD_REGISTER.
You can erase sectors with DCMD_SDMMC_ERASE.

Directly writing a block, bypassing the block device layer, is not supported, but you can write raw data to the block 
device or partition.
Re: Programming Interface to eMMC in QNX  
Hi Gerd,

Thanks for your quick reply and help by sharing this useful information. 

Best regards,
Manoj
Re: Programming Interface to eMMC in QNX  
Hi Gerd,

Thanks for sharing the information about devctl()
Do you have any example code to refer about DCMD_SDMMC_CARD_REGISTER & DCMD_SDMMC_ERASE

Thanks
Manoj
Re: Programming Interface to eMMC in QNX  
Hi Manoj,

Only what you can find in our online documentation. Anything else would typically require a support contract.
If you are working on a project with an existing support contract, please contact you QNX PM.

Best Regards,
Gerd
Re: Programming Interface to eMMC in QNX  
Hi Gred,

I guess DCMD_SDMMC_CARD_REGISTER which you mentioned is the wrong one to use for sector size. Instead, I tried 
DCMD_SDMMC_DEVICE_INFO, and it is working as SDMMC_DEVICE_INFO is having required members (sectors, sector_size & 
erase_size).

To erase sectors with DCMD_SDMMC_ERASE is working.

Thanks
Manoj
Re: Programming Interface to eMMC in QNX  
Hi Manoj,

You are right, I forgot to tell about the DCMD_SDMMC_DEVICE_INFO command.
Anyhow, the information you get with that is basically a mapping and some calculation based on data from the device 
registers.

Good to hear that DCMD_SDMMC_ERASE is working for you.
Just keep in mind to not use it on partitions with mounted file systems ;-)

Regards,
Gerd