diff --git a/sysutils/mmc-utils/Makefile b/sysutils/mmc-utils/Makefile index bfb7a0290b5e..031e7befa88d 100644 --- a/sysutils/mmc-utils/Makefile +++ b/sysutils/mmc-utils/Makefile @@ -1,31 +1,31 @@ PORTNAME= mmc-utils -DISTVERSION= 20211202 +DISTVERSION= 20230209 DISTVERSIONSUFFIX= -${MMC_GITSHASH} CATEGORIES= sysutils MASTER_SITES= https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/snapshot/${MMC_GITHASH}${EXTRACT_SUFX}?dummy=/ -MAINTAINER= ports@FreeBSD.org +MAINTAINER= marius@FreeBSD.org COMMENT= Userspace tools for MMC/SD devices -WWW= https://www.kernel.org/doc/Documentation/mmc/mmc-tools.txt +WWW= https://www.kernel.org/doc/html/latest/driver-api/mmc/mmc-tools.html LICENSE= BSD3CLAUSE GPLv2 LICENSE_COMB= multi IGNORE_DragonFly= only supported on FreeBSD -MMC_GITHASH= a1b233c2a31baa5b77cb67c0c3be4767be86f727 +MMC_GITHASH= d4c2910981ff99b983734426dfa99632fb81ac6b MMC_GITSHASH= ${MMC_GITHASH:C/^(........).*/\1/} PLIST_FILES= man/man1/mmc.1.gz sbin/mmc USES= gmake WRKSRC= ${WRKDIR}/${MMC_GITHASH} 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 .include diff --git a/sysutils/mmc-utils/distinfo b/sysutils/mmc-utils/distinfo index 7278400b05f9..f98908a6048e 100644 --- a/sysutils/mmc-utils/distinfo +++ b/sysutils/mmc-utils/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1639924509 -SHA256 (mmc-utils-20211202-a1b233c2.tar.gz) = fb275b57353bb53ff97d9ba4716928ed159341a1e1539f6face40bc63b39e674 -SIZE (mmc-utils-20211202-a1b233c2.tar.gz) = 47220 +TIMESTAMP = 1676241599 +SHA256 (mmc-utils-20230209-d4c29109.tar.gz) = ba1414aaa31d87f0c37b6a8ddf6da67af4776a2e6b05c165d4d6d53294c7a628 +SIZE (mmc-utils-20230209-d4c29109.tar.gz) = 50506 diff --git a/sysutils/mmc-utils/files/patch-man_mmc.1 b/sysutils/mmc-utils/files/patch-man_mmc.1 deleted file mode 100644 index 284d221c1326..000000000000 --- a/sysutils/mmc-utils/files/patch-man_mmc.1 +++ /dev/null @@ -1,33 +0,0 @@ ---- 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 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 index cf88845d082c..0255a194a82d 100644 --- a/sysutils/mmc-utils/files/patch-mmc.c +++ b/sysutils/mmc-utils/files/patch-mmc.c @@ -1,18 +1,34 @@ ---- mmc.c.orig 2021-12-18 19:59:21 UTC +--- mmc.c.orig 2023-02-09 14:16:51 UTC +++ mmc.c -@@ -229,6 +229,7 @@ static struct Command commands[] = { +@@ -234,6 +234,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[] = { +@@ -242,6 +243,7 @@ static struct Command commands[] = { "secure-trim1 | secure-trim2 | trim \n", NULL }, ++#endif + { do_general_cmd_read, -1, + "gen_cmd read", " [arg]\n" + "Send GEN_CMD (CMD56) to read vendor-specific format/meaning data from \n\n" +@@ -260,6 +262,7 @@ static struct Command commands[] = { + "Issues a CMD0 GO_PRE_IDLE", + NULL + }, ++#if defined(__linux__) + { do_alt_boot_op, -1, + "boot_operation", " \n" + "Does the alternative boot operation and writes the specified starting blocks of boot data into the requested file.\n\n" +@@ -272,6 +275,7 @@ static struct Command commands[] = { + "4. The MMC will perform a soft reset, if your system cannot handle that do not use the boot operation from mmc-utils.\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 b1b5eab3cb51..9db6d8ec4374 100644 --- a/sysutils/mmc-utils/files/patch-mmc.h +++ b/sysutils/mmc-utils/files/patch-mmc.h @@ -1,29 +1,25 @@ ---- mmc.h.orig 2021-12-18 19:59:21 UTC +--- mmc.h.orig 2023-02-09 14:16:51 UTC +++ mmc.h -@@ -17,10 +17,26 @@ +@@ -17,8 +17,22 @@ * those modifications are Copyright (c) 2016 SanDisk Corp. */ +#if defined(__linux__) + #include #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 */ + #define MMC_GO_IDLE_STATE 0 /* bc */ diff --git a/sysutils/mmc-utils/files/patch-mmc__cmds.c b/sysutils/mmc-utils/files/patch-mmc__cmds.c index fdac6beabd56..305e2ec7461f 100644 --- a/sysutils/mmc-utils/files/patch-mmc__cmds.c +++ b/sysutils/mmc-utils/files/patch-mmc__cmds.c @@ -1,82 +1,91 @@ ---- mmc_cmds.c.orig 2021-12-18 19:59:21 UTC +--- mmc_cmds.c.orig 2023-02-09 14:16:51 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) +@@ -88,8 +93,15 @@ int write_extcsd_value(int fd, __u8 index, __u8 value, + (value << 8) | + EXT_CSD_CMD_SET_NORMAL; + idata.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; ++#if defined(__FreeBSD__) ++ if (timeout_ms != 0) { ++ fprintf(stderr, "Command timeout not supported\n"); ++ return -EOPNOTSUPP; ++ } ++#else + /* Kernel will set cmd_timeout_ms if 0 is set */ + idata.cmd_timeout_ms = timeout_ms; ++#endif + + ret = ioctl(fd, MMC_IOC_CMD, &idata); + if (ret) +@@ -121,8 +133,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); -@@ -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"); -@@ -1881,8 +1902,10 @@ int do_read_extcsd(int nargs, char **argv) +@@ -1974,8 +1997,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) +@@ -2646,6 +2671,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: +@@ -2800,6 +2826,7 @@ out: close(dev_fd); return ret; } +#endif int do_ffu(int nargs, char **argv) +@@ -3145,6 +3172,7 @@ int do_preidle(int nargs, char **argv) + return 0; + } + ++#if defined(__linux__) + int do_alt_boot_op(int nargs, char **argv) + { + int fd, ret, boot_data_fd; +@@ -3247,3 +3275,4 @@ dev_fd_close: + exit(1); + return 0; + } ++#endif diff --git a/sysutils/mmc-utils/pkg-descr b/sysutils/mmc-utils/pkg-descr index 78c85514c224..d55ec10587e9 100644 --- a/sysutils/mmc-utils/pkg-descr +++ b/sysutils/mmc-utils/pkg-descr @@ -1,34 +1,34 @@ 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: +Ulf Hansson, you can find it at the below public git repository: https://git.kernel.org/pub/scm/utils/mmc/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.