mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Stefan Kerkmann <s.kerkmann@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Cc: Stefan Kerkmann <s.kerkmann@pengutronix.de>
Subject: [PATCH 0/9] mci: core: add CID as parameters and fix parsing
Date: Tue, 28 May 2024 17:39:19 +0200	[thread overview]
Message-ID: <20240528-feature-mmc-cid-as-parameters-v1-0-e5dc0c1d3eaa@pengutronix.de> (raw)

This series adds the fields of the CID register found in MMC and SD
cards as parameters to the device. The intention is to use these
parameters in scripting e.g. for safety checks before applying
potentially destructive changes.

During the implementation I found several bugs in the implementation of
the CID parsing that usually stem from not discerning between MMC and
SD cards.

For a proof of work I have attached these outputs of both an internal
eMMC and SD card on an Phyboard Polis imx8mm device. The first output is
mmc-utils and the second barebox at the state of this patch series:

eMMC:

root@phyboard-polis-imx8mm-4:~ mmc cid read /sys/class/block/mmcblk2/device -v
======MMC/CID======
        MID: 0x13 (Micron)
        CBX: 0x1 (BGA)
        OID: 0x4e
        PNM: Q2J55L
        PRV: 0x10 (1.0)
        PSN: 0x13723b3f
        MDT: 0x93 2000 oct <-- This is likely a bug in mmc-utils
        CRC: 0x00

barebox@PHYTEC phyBOARD-Polis-i.MX8MM RDK: devinfo mmc2
Card information:
<snip>
  Manufacturer ID: 0x13
  OEM/Application ID: 0x4E
  CBX: 1
  Product name: 'Q2J55L'
  Product revision: 1.0
  Serial no: 326253375
  Manufacturing date: 2022.3
</snip>
Parameters:
<snip>
  cid_cbx: 1 (type: uint32)
  cid_mdt: 2022.3 (type: string)
  cid_mid: 0x13 (type: uint32)
  cid_oid: 0x4E (type: string)
  cid_pnm: Q2J55L (type: string)
  cid_prv: 1.0 (type: string)
  cid_psn: 326253375 (type: uint32)
</snip>

SD card:

root@phyboard-polis-imx8mm-4:~ mmc cid read /sys/class/block/mmcblk1/device -v
======SD/CID======
        MID: 0x63 (Unlisted)
        OID: C`
        PNM: CACTU
        PRV: 0x02 (0.2)
        PSN: 0x583010d2
        MDT: 0x158 2021 sep
        CRC: 0x00

barebox@PHYTEC phyBOARD-Polis-i.MX8MM RDK:/ devinfo mmc1
Card information:
<snip>
  Manufacturer ID: 0x63
  OEM/Application ID: C`
  Product name: 'CACTU'
  Product revision: 0.2
  Serial no: 2139062282
  Manufacturing date: 2021.8
</snip>
Parameters:
<snip>
  cid_mdt: 2021.8 (type: string)
  cid_mid: 0x63 (type: uint32)
  cid_oid: C` (type: string)
  cid_pnm: CACTU (type: string)
  cid_prv: 0.2 (type: string)
  cid_psn: 2139062282 (type: uint32)
</snip>

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
Stefan Kerkmann (9):
      mci: core: rename mtd to mdt
      mci: core: add cbx extraction function
      mci: core: add product name extraction function
      mci: core: add manufacturing date extraction function
      mci: core: parse cid into parameters
      mci: core: fix extract_prv and write to string buffer
      mci: core: add CBX field as parameter and print it
      mci: core: fix extract_oid and write to string buffer
      mci: core: add missing slice range for extract_psn function

 drivers/mci/mci-core.c | 119 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 98 insertions(+), 21 deletions(-)
---
base-commit: 80d7c9d3d80e75e2335a123d414fd7fe83508291
change-id: 20240528-feature-mmc-cid-as-parameters-685158ffc027

Best regards,
-- 
Stefan Kerkmann <s.kerkmann@pengutronix.de>




             reply	other threads:[~2024-05-28 15:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 15:39 Stefan Kerkmann [this message]
2024-05-28 15:39 ` [PATCH 1/9] mci: core: rename mtd to mdt Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 2/9] mci: core: add cbx extraction function Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 3/9] mci: core: add product name " Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 4/9] mci: core: add manufacturing date " Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 5/9] mci: core: parse cid into parameters Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 6/9] mci: core: fix extract_prv and write to string buffer Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 7/9] mci: core: add CBX field as parameter and print it Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 8/9] mci: core: fix extract_oid and write to string buffer Stefan Kerkmann
2024-05-28 15:39 ` [PATCH 9/9] mci: core: add missing slice range for extract_psn function Stefan Kerkmann
2024-05-29  6:17 ` [PATCH 0/9] mci: core: add CID as parameters and fix parsing Sascha Hauer
2024-05-29  7:24 ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240528-feature-mmc-cid-as-parameters-v1-0-e5dc0c1d3eaa@pengutronix.de \
    --to=s.kerkmann@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox