diff --git a/sysutils/mmc-utils/Makefile b/sysutils/mmc-utils/Makefile index c12815178a01..c593023d166c 100644 --- a/sysutils/mmc-utils/Makefile +++ b/sysutils/mmc-utils/Makefile @@ -1,43 +1,43 @@ # Created by: Marius Strobl PORTNAME= mmc-utils -PORTVERSION= 20191004 -DISTVERSIONSUFFIX= -73d6c59a +PORTVERSION= 20211130 +DISTVERSIONSUFFIX= -a1b233c2 CATEGORIES= sysutils MASTER_SITES= LOCAL/marius MAINTAINER= marius@FreeBSD.org COMMENT= Userspace tools for MMC/SD devices LICENSE= BSD3CLAUSE GPLv2 LICENSE_COMB= multi IGNORE_DragonFly= only supported on FreeBSD USES= gmake tar:bzip2 PLIST_FILES= man/man1/mmc.1.gz sbin/mmc MMC_GITURL= git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc-utils.git 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 diff --git a/sysutils/mmc-utils/distinfo b/sysutils/mmc-utils/distinfo index 9321537d587e..f978889f5446 100644 --- a/sysutils/mmc-utils/distinfo +++ b/sysutils/mmc-utils/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1571606199 -SHA256 (mmc-utils-20191004-73d6c59a.tar.bz2) = ec15feab72548412cdbf6112b75ade526d6bfd39e237cef4253594d07346a4db -SIZE (mmc-utils-20191004-73d6c59a.tar.bz2) = 40584 +TIMESTAMP = 1639857562 +SHA256 (mmc-utils-20211130-a1b233c2.tar.bz2) = 08580126453b7ca20988236030d98d5e59c82ebbd990a4b9bbf9a8b6dfaa59aa +SIZE (mmc-utils-20211130-a1b233c2.tar.bz2) = 42512 diff --git a/sysutils/mmc-utils/files/patch-man_mmc.1 b/sysutils/mmc-utils/files/patch-man_mmc.1 index 421843e900a1..284d221c1326 100644 --- a/sysutils/mmc-utils/files/patch-man_mmc.1 +++ b/sysutils/mmc-utils/files/patch-man_mmc.1 @@ -1,33 +1,33 @@ ---- man/mmc.1.orig 2018-02-26 22:10:51 UTC +--- man/mmc.1.orig 2021-12-18 19:59:21 UTC +++ man/mmc.1 -@@ -30,21 +30,24 @@ This sets the eMMC to be write-protected +@@ -30,21 +30,24 @@ This sets the eMMC to be write-protected until next bo Set the eMMC data sector size to 4KB by disabling emulation on . .TP -.BR "gp create <-y|-n> " +.BR "gp create <-y|-n|-c> " create general purpose partition for the . -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 to 1 else set it to 0. To set extended attribute to general partition set to 1,2 else set it to 0. NOTE! This is a one-time programmable (unreversible) change. .TP -.BR "enh_area set <-y|-n> " +.BR "enh_area set <-y|-n|-c> " Enable the enhanced user area for the . -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> " +.BR "write_reliability set <-y|-n|-c> " Enable write reliability per partition for the . -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 " diff --git a/sysutils/mmc-utils/files/patch-mmc.c b/sysutils/mmc-utils/files/patch-mmc.c new file mode 100644 index 000000000000..cf88845d082c --- /dev/null +++ b/sysutils/mmc-utils/files/patch-mmc.c @@ -0,0 +1,18 @@ +--- mmc.c.orig 2021-12-18 19:59:21 UTC ++++ mmc.c +@@ -229,6 +229,7 @@ static struct Command commands[] = { + "Run Field Firmware Update with on .\n", + NULL + }, ++#if defined(__linux__) + { do_erase, -4, + "erase", " " " " " " "\n" + "Send Erase CMD38 with specific argument to the \n\n" +@@ -237,6 +238,7 @@ static struct Command commands[] = { + "secure-trim1 | secure-trim2 | trim \n", + NULL + }, ++#endif + { 0, 0, 0, 0 } + }; + diff --git a/sysutils/mmc-utils/files/patch-mmc.h b/sysutils/mmc-utils/files/patch-mmc.h index 06e2590edf25..b1b5eab3cb51 100644 --- a/sysutils/mmc-utils/files/patch-mmc.h +++ b/sysutils/mmc-utils/files/patch-mmc.h @@ -1,29 +1,29 @@ ---- mmc.h.orig 2018-02-26 22:10:51 UTC +--- mmc.h.orig 2021-12-18 19:59:21 UTC +++ mmc.h @@ -17,10 +17,26 @@ * those modifications are Copyright (c) 2016 SanDisk Corp. */ +#if defined(__linux__) #include +#elif defined(__FreeBSD__) +#include +#include +#include +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 +#if 0 /* From kernel linux/major.h */ #define MMC_BLOCK_MAJOR 179 +#endif /* From kernel linux/mmc/mmc.h */ #define MMC_SWITCH 6 /* ac [31:0] See below R1b */ diff --git a/sysutils/mmc-utils/files/patch-mmc__cmds.c b/sysutils/mmc-utils/files/patch-mmc__cmds.c index e58640a03985..fdac6beabd56 100644 --- a/sysutils/mmc-utils/files/patch-mmc__cmds.c +++ b/sysutils/mmc-utils/files/patch-mmc__cmds.c @@ -1,64 +1,82 @@ ---- mmc_cmds.c.orig 2018-12-26 19:54:04 UTC +--- mmc_cmds.c.orig 2021-12-18 19:59:21 UTC +++ mmc_cmds.c @@ -28,7 +28,12 @@ #include #include #include +#if defined(__linux__) #include /* for BLKGETSIZE */ +#elif defined(__FreeBSD__) +#include /* for offsetof() */ +#include /* for DIOCG{MEDIA,SECTOR}SIZE */ +#endif #include "mmc.h" #include "mmc_cmds.h" @@ -120,8 +125,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); -@@ -1530,13 +1546,18 @@ int do_read_extcsd(int nargs, char **arg +@@ -1605,13 +1621,18 @@ int do_read_extcsd(int nargs, char **argv) /* A441/A43: reserved [197] [195] [193] [190] [188] * [186] [184] [182] [180] [176] */ - if (ext_csd_rev >= 6) + if (ext_csd_rev >= 6) { printf("I/O Driver Strength [DRIVER_STRENGTH: 0x%02x]\n", ext_csd[197]); + printf("Enhanced Strobe mode [STROBE_SUPPORT: 0x%02x]\n", + ext_csd[184]); + } /* DEVICE_TYPE in A45, CARD_TYPE in A441 */ reg = ext_csd[196]; printf("Card Type [CARD_TYPE: 0x%02x]\n", reg); + if (reg & 0x80) printf(" HS400 Dual Data Rate eMMC @200MHz 1.2VI/O\n"); + if (reg & 0x40) printf(" HS400 Dual Data Rate eMMC @200MHz 1.8VI/O\n"); if (reg & 0x20) printf(" HS200 Single Data Rate eMMC @200MHz 1.2VI/O\n"); if (reg & 0x10) printf(" HS200 Single Data Rate eMMC @200MHz 1.8VI/O\n"); if (reg & 0x08) printf(" HS Dual Data Rate eMMC @52MHz 1.2VI/O\n"); -@@ -1883,7 +1904,7 @@ static int do_rpmb_op(int fd, - u_int16_t rpmb_type; - struct mmc_ioc_multi_cmd *mioc; - struct mmc_ioc_cmd *ioc; -- struct rpmb_frame frame_status = {0}; -+ struct rpmb_frame frame_status = {{0}}; +@@ -1881,8 +1902,10 @@ int do_read_extcsd(int nargs, char **argv) + (ext_csd[EXT_CSD_CMDQ_DEPTH] & 0x1f) + 1); + printf("Command Enabled [CMDQ_MODE_EN]: 0x%02x\n", + ext_csd[EXT_CSD_CMDQ_MODE_EN]); ++#if defined(__linux__) + printf("Note: CMDQ_MODE_EN may not indicate the runtime CMDQ ON or OFF.\n" + "Please check sysfs node '/sys/devices/.../mmc_host/mmcX/mmcX:XXXX/cmdq_en'\n"); ++#endif + } + out_free: + return ret; +@@ -2515,6 +2538,7 @@ int do_cache_dis(int nargs, char **argv) + return do_cache_ctrl(0, nargs, argv); + } + ++#if defined(__linux__) + static int erase(int dev_fd, __u32 argin, __u32 start, __u32 end) + { + int ret = 0; +@@ -2657,6 +2681,7 @@ out: + close(dev_fd); + return ret; + } ++#endif + - if (!frame_in || !frame_out || !out_cnt) - return -EINVAL; + int do_ffu(int nargs, char **argv)