123456789101112131415161718 |
- #!/bin/bash
- EEPROMHex='eeprom-content.hex' # File used for manufacturer brand
- Product='Block Erupter Sapphire'
- SerialPrefix='Foo-' # Prepended before 8-digit serial number
- SerialNoFile='last-serialno' # File holds the last allocated serial number
- if ! [ -e "${SerialNoFile}" ]; then
- echo "WARNING: Initializing ${SerialNoFile} file (this should only happen ONCE EVER)" >&2
- echo '10000000' > "${SerialNoFile}"
- fi
- i="$(<"${SerialNoFile}")"
- for dev in $(lsusb | perl -nle 'm/(\d{3}).*?(\d{3}).*CP210x/ && print "$1/$2"'); do
- let ++i
- echo "$i" >"${SerialNoFile}"
- ./cp210x-program -m $dev -w -F "$EEPROMHex" \
- --set-product-string="$Product" \
- --set-serial-number "${SerialPrefix}$i"
- done
|