1 Hex data for various sg3_utils utilities 2 ======================================== 3 4The files in this folder contain hexadecimal data (in ASCII) and associated 5comments (prefixed with the hash mark symbol: '#' ). Files containing 6hexadecimal data have the extension ".hex". There is at least one file 7containing binary data and it has the extension ".raw". 8 9The utility that each hex file is associated with can be determined in most 10case by prepending "sg_" to these filenames. Then go to the 'src' folder (a 11sibling folder to this one) and look for a match or partial match on 12the name. 13 14For example: 15 vpd_dev_id.hex 16after prepending 'sg_' becomes: 17 sg_vpd_dev_id.hex 18which is a partial match on the sg_vpd utility. 19The remaining 'dev_id.hex' is meant to suggest the 'device identifier' 20VPD page which is a mandatory VPD page for SCSI devices.. 21 22Assuming sg3_utils is installed, it can be tested like this: 23 sg_vpd --inhex=<folder_holding_sg3_utils>/inhex/vpd_dev_id.hex 24 25And should output this: 26 27Device Identification VPD page: 28 Addressed logical unit: 29 designator type: NAA, code set: Binary 30 0x5000c5003011cb2b 31 Target port: 32 designator type: NAA, code set: Binary 33 transport: Serial Attached SCSI Protocol (SPL-4) 34 0x5000c5003011cb29 35 designator type: Relative target port, code set: Binary 36 transport: Serial Attached SCSI Protocol (SPL-4) 37 Relative target port: 0x1 38 Target device that contains addressed lu: 39 designator type: NAA, code set: Binary 40 transport: Serial Attached SCSI Protocol (SPL-4) 41 0x5000c5003011cb28 42 designator type: SCSI name string, code set: UTF-8 43 SCSI name string: 44 naa.5000C5003011CB28 45 46Not all the hex files follow the "prepend sg_" pattern. Those hex files 47starting with 'nvme_' are examples of invoking NVMe commands with the 48sg_raw utility. 49 50Binary <--> Hexadecimal 51----------------------- 52The vpd_zbdc.raw file is binary and was created by: 53 sg_decode_sense --inhex=vpd_zbdc.hex --nodecode --write=vpd_zbdc.raw 54as an example of converting a file in ASCII hexadecimal byte oriented 55format to binary. 56 57Turning binary output into hexadecimal can be done several ways. For 58viewing in byte oriented ASCII hex these Unix commands can be used: 59 od -t x1 vpd_zbdc.raw 60 hexdump -C vpd_zbdc.raw 61 62Each line starting with a "input offset" which is a running count of 63bytes, starting at zero. The hexdump examples shows an ASCII rendering 64of those 16 bytes to the right of each line. The sg_decode_sense utility 65may also be used: 66 sg_decode_sense --binary=vpd_zbdc.raw -H 67 sg_decode_sense --binary=vpd_zbdc.raw -HH 68 69The second form of sg_decode_sense appends an ASCII rendering of the 16 70bytes to the right of each line. 71 72When ASCII hexadecimal is being used as input to a utility in this 73package, the "input offset" at the start of each line (and the optional 74ASCII rendering to the right of each line) must not be given. 75That can be done with hexdump: 76 hexdump -An -C -v vpd_zbdc.raw 77 ^^^ 78That is a syntax error, there is no 'A' option <<<<<<<< check 79 80And the sg_decode_sense utility can do it with (with the --nodecode option): 81 sg_decode_sense -N --binary=vpd_zbdc.raw -HHH 82That will print suitable lines of hexadecimal (16 bytes per line) to the 83console (stdout) To go the other way (i.e. hexadecimal to binary): 84 sg_decode_sense -N --inhex=vpd_zbdc.hex --write=vpd_zbdc.bin 85 86 87Conclusion 88---------- 89Users are encouraged to send the author any ASCII hex files for utilities 90that support --inhex and don't have hex data already. Special cases are 91also welcome. They help the author test this code. 92 93Douglas Gilbert 9418th July 2022 95