Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Mar 2017 22:36:05 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r436309 - in head/sysutils: . mmc-utils mmc-utils/files
Message-ID:  <201703162236.v2GMa5pH079678@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Thu Mar 16 22:36:04 2017
New Revision: 436309
URL: https://svnweb.freebsd.org/changeset/ports/436309

Log:
  Add a port of mmc-utils, a collection of tools for MMC/SD devices.
  Among others, this allows to partition eMMC devices via /dev/mmcsdN.
  Currently, FreeBSD version 1200025 or later is required for mmc-utils.
  
  CAVEAT EMPTOR: Partitioning eMMC devices is a one-time operation.

Added:
  head/sysutils/mmc-utils/
  head/sysutils/mmc-utils/Makefile   (contents, props changed)
  head/sysutils/mmc-utils/distinfo   (contents, props changed)
  head/sysutils/mmc-utils/files/
  head/sysutils/mmc-utils/files/patch-man_mmc.1   (contents, props changed)
  head/sysutils/mmc-utils/files/patch-mmc.h   (contents, props changed)
  head/sysutils/mmc-utils/files/patch-mmc_cmds.c   (contents, props changed)
  head/sysutils/mmc-utils/pkg-descr   (contents, props changed)
Modified:
  head/sysutils/Makefile

Modified: head/sysutils/Makefile
==============================================================================
--- head/sysutils/Makefile	Thu Mar 16 20:56:18 2017	(r436308)
+++ head/sysutils/Makefile	Thu Mar 16 22:36:04 2017	(r436309)
@@ -612,6 +612,7 @@
     SUBDIR += mkfwimage
     SUBDIR += mkntpwd
     SUBDIR += mksunbootcd
+    SUBDIR += mmc-utils
     SUBDIR += mnrpes
     SUBDIR += modules
     SUBDIR += mog

Added: head/sysutils/mmc-utils/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/mmc-utils/Makefile	Thu Mar 16 22:36:04 2017	(r436309)
@@ -0,0 +1,48 @@
+# Created by: Marius Strobl <marius@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME=	mmc-utils
+PORTVERSION=	20160901
+DISTVERSIONSUFFIX=	-2cb6695e
+CATEGORIES=	sysutils
+MASTER_SITES=	LOCAL/marius
+
+MAINTAINER=	marius@FreeBSD.org
+COMMENT=	Userspace tools for MMC/SD devices
+
+LICENSE=	BSD3CLAUSE GPLv2
+LICENSE_COMB=	multi
+
+USES=		gmake tar:bzip2
+
+PLIST_FILES=	man/man1/mmc.1.gz sbin/mmc
+
+.include <bsd.port.pre.mk>
+
+.if (${OPSYS} == FreeBSD && \
+	${OSVERSION} < 1200025)) || \
+	${OPSYS} == DragonFly
+IGNORE=		only supported on recent OS versions
+.endif
+
+post-patch:
+.for i in Makefile mmc_cmds.c mmc.c man/mmc.1
+	@${REINPLACE_CMD} -e 's|^AM_CFLAGS|#^|; s|path/to|dev|g;\
+		s|mmcblk|mmcsd|g' ${WRKSRC}/${i}
+.endfor
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/mmc ${STAGEDIR}${PREFIX}/sbin
+	${INSTALL_MAN} ${WRKSRC}/man/mmc.1 ${STAGEDIR}${PREFIX}/man/man1
+
+maintainer-fetch:
+	@${MAKE} clean
+	@${MKDIR} ${WRKSRC}
+	@git clone ${MMC_GITURL} ${WRKSRC}
+	@cd ${WRKSRC} && git reset --hard ${DISTVERSIONSUFFIX:S|^-||}
+	@${TAR} -cyf ${_DISTDIR:S|/$||}/${DISTFILES:M${PORTNAME}-*} \
+		-C ${WRKSRC}/.. --exclude .git .
+	@${MAKE} makesum
+	@${MAKE} clean
+
+.include <bsd.port.post.mk>

Added: head/sysutils/mmc-utils/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/mmc-utils/distinfo	Thu Mar 16 22:36:04 2017	(r436309)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1489527894
+SHA256 (mmc-utils-20160901-2cb6695e.tar.bz2) = 8373b45e04bb0aef27a3127ba6654560f6599cfba61b21b14ab7cf0d25150359
+SIZE (mmc-utils-20160901-2cb6695e.tar.bz2) = 40056

Added: head/sysutils/mmc-utils/files/patch-man_mmc.1
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/mmc-utils/files/patch-man_mmc.1	Thu Mar 16 22:36:04 2017	(r436309)
@@ -0,0 +1,33 @@
+--- man/mmc.1.orig	2017-01-25 19:03:34 UTC
++++ man/mmc.1
+@@ -30,21 +30,24 @@ This sets the eMMC to be write-protected
+ Set the eMMC data sector size to 4KB by disabling emulation on
+ <device>.
+ .TP
+-.BR "gp create <-y|-n> <length KiB> <partition> <enh_attr> <ext_attr> <device>"
++.BR "gp create <-y|-n|-c> <length KiB> <partition> <enh_attr> <ext_attr> <device>"
+ create general purpose partition for the <device>.
+-Dry-run only unless -y is passed.
++Dry-run only unless -y or -c is passed.
++Use -c if more partitioning settings are still to come.
+ To set enhanced attribute to general partition being created set <enh_attr> to 1 else set it to 0.
+ To set extended attribute to general partition set <ext_attr> to 1,2 else set it to 0.
+ NOTE!  This is a one-time programmable (unreversible) change.
+ .TP
+-.BR "enh_area set <-y|-n> <start KiB> <length KiB> <device>"
++.BR "enh_area set <-y|-n|-c> <start KiB> <length KiB> <device>"
+ Enable the enhanced user area for the <device>.
+-Dry-run only unless -y is passed.
++Dry-run only unless -y or -c is passed.
++Use -c if more partitioning settings are still to come.
+ NOTE!  This is a one-time programmable (unreversible) change.
+ .TP
+-.BR "write_reliability set <-y|-n> <partition> <device>"
++.BR "write_reliability set <-y|-n|-c> <partition> <device>"
+ Enable write reliability per partition for the <device>.
+-Dry-run only unless -y is passed.
++Dry-run only unless -y or -c is passed.
++Use -c if more partitioning settings are still to come.
+ NOTE!  This is a one-time programmable (unreversible) change.
+ .TP
+ .BR "status get <device>"

Added: head/sysutils/mmc-utils/files/patch-mmc.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/mmc-utils/files/patch-mmc.h	Thu Mar 16 22:36:04 2017	(r436309)
@@ -0,0 +1,25 @@
+--- mmc.h.orig	2017-01-25 19:03:34 UTC
++++ mmc.h
+@@ -17,8 +17,22 @@
+  * those modifications are Copyright (c) 2016 SanDisk Corp.
+  */
+ 
++#if defined(__linux__)
+ #include <asm-generic/int-ll64.h>
+ #include <linux/mmc/ioctl.h>
++#elif defined(__FreeBSD__)
++#include <dev/mmc/mmc_ioctl.h>
++#include <sys/endian.h>
++#include <sys/types.h>
++typedef int8_t   __s8;
++typedef uint8_t  __u8;
++typedef int16_t  __s16;
++typedef uint16_t __u16;
++typedef int32_t  __s32;
++typedef uint32_t __u32;
++typedef int64_t  __s64;
++typedef uint64_t __u64;
++#endif
+ #include <stdio.h>
+ 
+ #define CHECK(expr, msg, err_stmt) { if (expr) { fprintf(stderr, msg); err_stmt; } }

Added: head/sysutils/mmc-utils/files/patch-mmc_cmds.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/mmc-utils/files/patch-mmc_cmds.c	Thu Mar 16 22:36:04 2017	(r436309)
@@ -0,0 +1,34 @@
+--- mmc_cmds.c.orig	2017-01-25 19:03:34 UTC
++++ mmc_cmds.c
+@@ -32,7 +32,11 @@
+ #include <errno.h>
+ #include <stdint.h>
+ #include <assert.h>
++#if defined(__linux__)
+ #include <linux/fs.h>
++#elif defined(__FreeBSD__)
++#include <sys/disk.h>
++#endif
+ 
+ #include "mmc.h"
+ #include "mmc_cmds.h"
+@@ -120,8 +124,19 @@ static __u32 get_size_in_blks(int fd)
+ {
+ 	int res;
+ 	int size;
++#if defined(__FreeBSD__)
++	off_t mediasize;
++#endif
+ 
++#if defined(__linux__)
+ 	res = ioctl(fd, BLKGETSIZE, &size);
++#elif defined(__FreeBSD__)
++	res = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
++	if (!res) {
++		res = ioctl(fd, DIOCGSECTORSIZE, &size);
++		size = mediasize / size;
++	}
++#endif
+ 	if (res) {
+ 		fprintf(stderr, "Error getting device size, errno: %d\n",
+ 			errno);

Added: head/sysutils/mmc-utils/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/mmc-utils/pkg-descr	Thu Mar 16 22:36:04 2017	(r436309)
@@ -0,0 +1,36 @@
+MMC tools introduction
+======================
+
+There is one MMC test tools called mmc-utils, which is maintained by
+Chris Ball, you can find it at the below public git repository:
+http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc-utils.git/
+
+Functions
+=========
+
+The mmc-utils tools can do the following:
+ - Print and parse extcsd data.
+ - Determine the eMMC writeprotect status.
+ - Set the eMMC writeprotect status.
+ - Set the eMMC data sector size to 4KB by disabling emulation.
+ - Create general purpose partition.
+ - Enable the enhanced user area.
+ - Enable write reliability per partition.
+ - Print the response to STATUS_SEND (CMD13).
+ - Enable the boot partition.
+ - Set Boot Bus Conditions.
+ - Enable the eMMC BKOPS feature.
+ - Permanently enable the eMMC H/W Reset feature.
+ - Permanently disable the eMMC H/W Reset feature.
+ - Send Sanitize command.
+ - Program authentication key for the device.
+ - Counter value for the rpmb device will be read to stdout.
+ - Read from rpmb device to output.
+ - Write to rpmb device from data file.
+ - Enable the eMMC cache feature.
+ - Disable the eMMC cache feature.
+ - Print and parse CID data.
+ - Print and parse CSD data.
+ - Print and parse SCR data.
+
+WWW: https://github.com/torvalds/linux/blob/master/Documentation/mmc/mmc-tools.txt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703162236.v2GMa5pH079678>