branding.GekkoScience-Compac.bash 818 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. #EEPROMHex='eeprom-content.GekkoScience-Compac.hex' # File used for manufacturer brand
  3. EEPROMHex='backup/eeprom-content.GekkoScience-Compac-bitshopperde.hex'
  4. SerialPrefix='GS-' # Prepended before 8-digit serial number
  5. SerialNoFile='last-serialno' # File holds the last allocated serial number
  6. if ! [ -e "${SerialNoFile}" ]; then
  7. echo "WARNING: Initializing ${SerialNoFile} file (this should only happen ONCE EVER)" >&2
  8. echo '10000000' > "${SerialNoFile}"
  9. fi
  10. i="$(<"${SerialNoFile}")"
  11. for dev in $(lsusb | perl -nle 'm/(\d{3}).*?(\d{3}).*CP210x/ && print "$1/$2"'); do
  12. let ++i
  13. echo "$i" >"${SerialNoFile}"
  14. FullSerial="${SerialPrefix}$i"
  15. echo "Programming serial number ${FullSerial} onto device $dev ..."
  16. ./cp210x-program -m $dev -w -F "$EEPROMHex" \
  17. --set-serial-number "${FullSerial}"
  18. done