aboutsummaryrefslogtreecommitdiff
path: root/sysutils/mmc-utils
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2017-03-16 22:36:04 +0000
committerMarius Strobl <marius@FreeBSD.org>2017-03-16 22:36:04 +0000
commit1c2892dd9173c1cd0b1cc81ee054a678feb1f386 (patch)
tree10fcc1119018cc3771a42a9a4e37600b3f8c9251 /sysutils/mmc-utils
parentb0b289db08582c19fd7c939f29f98287d1ecea4c (diff)
downloadports-1c2892dd9173c1cd0b1cc81ee054a678feb1f386.tar.gz
ports-1c2892dd9173c1cd0b1cc81ee054a678feb1f386.zip
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.
Notes
Notes: svn path=/head/; revision=436309
Diffstat (limited to 'sysutils/mmc-utils')
-rw-r--r--sysutils/mmc-utils/Makefile48
-rw-r--r--sysutils/mmc-utils/distinfo3
-rw-r--r--sysutils/mmc-utils/files/patch-man_mmc.133
-rw-r--r--sysutils/mmc-utils/files/patch-mmc.h25
-rw-r--r--sysutils/mmc-utils/files/patch-mmc_cmds.c34
-rw-r--r--sysutils/mmc-utils/pkg-descr36
6 files changed, 179 insertions, 0 deletions
diff --git a/sysutils/mmc-utils/Makefile b/sysutils/mmc-utils/Makefile
new file mode 100644
index 000000000000..7110f43efd12
--- /dev/null
+++ b/sysutils/mmc-utils/Makefile
@@ -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>
diff --git a/sysutils/mmc-utils/distinfo b/sysutils/mmc-utils/distinfo
new file mode 100644
index 000000000000..1f134c0a3a3c
--- /dev/null
+++ b/sysutils/mmc-utils/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1489527894
+SHA256 (mmc-utils-20160901-2cb6695e.tar.bz2) = 8373b45e04bb0aef27a3127ba6654560f6599cfba61b21b14ab7cf0d25150359
+SIZE (mmc-utils-20160901-2cb6695e.tar.bz2) = 40056
diff --git a/sysutils/mmc-utils/files/patch-man_mmc.1 b/sysutils/mmc-utils/files/patch-man_mmc.1
new file mode 100644
index 000000000000..9e859a8c724d
--- /dev/null
+++ b/sysutils/mmc-utils/files/patch-man_mmc.1
@@ -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>"
diff --git a/sysutils/mmc-utils/files/patch-mmc.h b/sysutils/mmc-utils/files/patch-mmc.h
new file mode 100644
index 000000000000..1017e7cc82c0
--- /dev/null
+++ b/sysutils/mmc-utils/files/patch-mmc.h
@@ -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; } }
diff --git a/sysutils/mmc-utils/files/patch-mmc_cmds.c b/sysutils/mmc-utils/files/patch-mmc_cmds.c
new file mode 100644
index 000000000000..4bb8e20c0d15
--- /dev/null
+++ b/sysutils/mmc-utils/files/patch-mmc_cmds.c
@@ -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);
diff --git a/sysutils/mmc-utils/pkg-descr b/sysutils/mmc-utils/pkg-descr
new file mode 100644
index 000000000000..405e23583145
--- /dev/null
+++ b/sysutils/mmc-utils/pkg-descr
@@ -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