OneOfTheInfiniteMonkeys / sdinfo

A BASH script decoding Micro SD Card Information in PiOS BASH displaying SD Card manufacturer and age from the Micro SD CID.
MIT License
7 stars 0 forks source link
card debian micro microsd pi pios raspberry sd sdcard

sdinfo

Micro SD Card Information in PiOS BASH
With many devices and cards this utility eases microSD card identification and maintenance, as the microSD card may be difficult to access. The utility also provides an estimate of the cards age from the manufacturing date to facilitate management based on age if desired.

GitHub release (latest SemVer including pre-releases) Build Status Maintenance GitHub GitHub repo size made-with-bash Raspberry Pi

sdinfo identifies 35 microSD card manufacturers and 24 re-brand labels. The key advantage of 'sdinfo' being a BASH script, is Internet acess, Python, other languages or libraries are not required. If preferred, the script can be copy / pasted avoiding install of GIT (though GIT possibly a better option for version management). Developed on PiOS, the script may operate on other systems. However, has not been verified.

Raspberry Pi Micro SD card selections. Image copyright (c) 21 Aug 2022 OneOfTheInfiniteMonkeys All Rights Reserved

NOTE

Target platform

Debian - Raspberry PI PiOS

Installation

If you don't have GIT installed, install with:
   sudo apt install git

Clone the repository into a newly created directory on a Raspberry Pi (Debian)
e.g.
   cd ~
   sudo git clone https://github.com/OneOfTheInfiniteMonkeys/sdinfo.git

Note - Installation of GIT is not a requirement. The files can be copy/pasted if preferred, though it's probable version control might be more challenging.

Running

Following installation using the steps detailed in the Installation section, a folder will have been created in your home directory which contains the sdinfo BASH script.

To run sdinfo script enter the following commands:
   cd ~/sdinfo
Run the script :
   bash sdinfo.sh
The script may take some time to run as it searches, using find, for the microSD CID file.

To test the script with an SD Card CID (e.g. from another system, list etc.)
   cd ~/sdinfo
   bash sdinfo.sh -c 1b534d454332515430615763c7013633

Update (using GIT)

The Git Pull command will download the latest version of the repository, immediately updating the local repository.
   cd ~/sdinfo
run git
   sudo git pull

Version check against GIT

Using the -cv option and an available internet connection allows the running version variant to be checked against the release version on GitHub (Git is not required for this operation).
Example usage:
   cd ~/sdinfo
   bash sdinfo.sh -cv

Output example
SDInfo version : 00.60
Latest Release : 00.6

Options

sdinfo supports the following command line parameters :

-a, --additional Output additional information
-m, --minimal Only minimal output from the script
-t, --table Switch off table output (typically use with -m)

Commands

-c, --cid Provide a CID string to be decoded
-cv, --checkversion Display local code version and GitHub version
-s, --sourcepath Provide a path to the CID (faster if you know the location or have alternate locations)
-h, --help, -? Displays this help and exits
-v, --version Displays version information for sdinfo and exits
< Application Name > < Command > < Revision > ( < Date {yyyy-mm-dd} {hh:mm} > )

Output Explanation

A typical output from sdinfo is shown below for a Raspberry Pi SD card:

   ___________________  
  |                   |  
  | |               ==|  
  | |               ==|  
  | |   SDInfo      ==|  
  | |   2021-12-24  ==|  
  | |               ==|  
  | |       __    ____|  
  |________/  |__/  

MID : Samsung
OID : SM
PNM : EC2QT
PRV : 30
PSN : 1633117127
MDT : 2019/1/1
AID : 1092

A concise output can be obtained using the -m and -t options together:

   cd ~/sdinfo
Run the script :
   bash sdinfo.sh -m -t

MID : Samsung OID : SM PNM : EC2QT PRV : 30 PSN : 1633117127 MDT : 2019/1/1 AID : 1092

Consisting of the following information :

MID Manufacturer Identifier
OID OEM Identifier
PNM Part number
PRV Part version
PSN Part serial number
MDT Manufactured date yyyy/mm/01
AID Age in days

Age in days is calculated from the manufactured date and the systems current date. It assumes first of the month as the CID has no day number, assuming a start of year 2000 (2 characters), and a month number (1 character).

To see card re-branding use the -a option:
   cd ~/sdinfo
Run the script :
   bash sdinfo.sh -a

This code decodes the presented microSD card CID data and does not rely on your OS to determine the information presented. Thus you may see differences between information presented by the OS and by this script (Caveat emptor).

Trademarks, Affiliations, Information Provenance

Trademarks are owned by their respective holders.
No affiliation or association is implied or should be inferred with any organisation.
Information is provided for Indication Only.