wareck 2 years ago
parent
commit
f427b64f95
4 changed files with 19 additions and 13 deletions
  1. 10 9
      build.sh
  2. 5 1
      make_backup.sh
  3. 1 0
      tools/.gitignore
  4. 3 3
      tools/dummy_calculator.sh

+ 10 - 9
build.sh

@@ -9,8 +9,8 @@ flash_arduino="u2" # u2 or ftdi
 arduino_device="ttyACM0" # ls /dev/tty* and find your arduino
 arduino_device="ttyACM0" # ls /dev/tty* and find your arduino
 mega=2560 #2560 or 1280
 mega=2560 #2560 or 1280
 
 
-script_version="2.2.0"
-rdate="13/01/2022"
+script_version="2.2.1"
+rdate="24/12/2022"
 
 
 ################
 ################
 ##  SOFTWARE  ##
 ##  SOFTWARE  ##
@@ -31,7 +31,7 @@ echo
 
 
 function arduino_ {
 function arduino_ {
 echo -e ""
 echo -e ""
-echo -e "\e[97mBuild Arduino SPI_Flash tools:\e[0m\e[24m"
+echo -e "\e[97mBuild Arduino SPI_Flash tools...\e[0m\e[24m"
 if [ -a /dev/ttyACM0 ]
 if [ -a /dev/ttyACM0 ]
 then
 then
 arduino_device="ttyACM0"
 arduino_device="ttyACM0"
@@ -127,7 +127,7 @@ sudo sed -i -e "s/\#dtparam=spi=on/dtparam=spi=on/g" /boot/config.txt
 fi
 fi
 }
 }
 
 
-function ch341_ {
+function ch341a_ {
 cat <<'EOF'>> .lastbuild
 cat <<'EOF'>> .lastbuild
 Mode=ch341
 Mode=ch341
 Device=ch341
 Device=ch341
@@ -137,7 +137,8 @@ echo -e "\n\e[93mBuild CH341 SPIFlash tools:\e[0m\e[24m"
 echo -e "\n\e[93mPerforming Update :\e[0m"
 echo -e "\n\e[93mPerforming Update :\e[0m"
 sudo apt-get update
 sudo apt-get update
 sudo apt-get upgrade -y
 sudo apt-get upgrade -y
-sudo apt-get install build-essential pciutils usbutils libpci-dev libusb-dev libusb-1.0-0 libusb-1.0-0-dev libftdi1 libftdi-dev zlib1g-dev subversion git ghex libusb-1.0-0-dev libftdi-dev libftdi1-dev libjaylink-dev -y
+sudo apt-get install build-essential pciutils usbutils libpci-dev libusb-dev libusb-1.0-0 libusb-1.0-0-dev libftdi1 libftdi-dev zlib1g-dev subversion git \
+ghex libusb-1.0-0-dev libftdi-dev libftdi1-dev libjaylink-dev -y
 cat <<'EOF'>>02-ch341a.rules
 cat <<'EOF'>>02-ch341a.rules
 # Ch341A
 # Ch341A
 # Ch341A
 # Ch341A
@@ -210,7 +211,7 @@ echo -e "\n\e[93mCheck flashrom :\e[0m"
 flashrom -p serprog:dev=/dev/$arduino_device:115200 || :
 flashrom -p serprog:dev=/dev/$arduino_device:115200 || :
 }
 }
 
 
-function flashrom_ch341_check_ {
+function flashrom_ch341a_check_ {
 echo -e "\n\e[93mCheck flashrom :\e[0m"
 echo -e "\n\e[93mCheck flashrom :\e[0m"
 sudo flashrom -p ch341a_spi || :
 sudo flashrom -p ch341a_spi || :
 }
 }
@@ -248,7 +249,7 @@ Usage: $0 [--arduino] [--mega] [--raspberry] [--clean] [--help]
      --arduino          Build Serial SPI flashrom tools for arduino328
      --arduino          Build Serial SPI flashrom tools for arduino328
      --mega             Build Serial SPI flashrom tools for arduinoMega
      --mega             Build Serial SPI flashrom tools for arduinoMega
      --raspberry        Build Serial SPI flashrom tools for raspberryPI
      --raspberry        Build Serial SPI flashrom tools for raspberryPI
-     --ch341		 Build Serial SPI flashrom tools for CH341 USB
+     --ch341a		Build Serial SPI flashrom tools for CH341 USB
      --clean       	Clean all build files
      --clean       	Clean all build files
 
 
 Install script Written by: wareck <wareck@gmail.com>
 Install script Written by: wareck <wareck@gmail.com>
@@ -276,8 +277,8 @@ do
         --raspberry)
         --raspberry)
             raspberry_ && flashrom_ && flashrom_raspberry_check_ && footer_
             raspberry_ && flashrom_ && flashrom_raspberry_check_ && footer_
             ;;
             ;;
-        --ch341)
-            ch341_ && flashrom_ && flashrom_ch341_check_ && footer_
+        --ch341a)
+            ch341a_ && flashrom_ && flashrom_ch341a_check_ && footer_
             ;;
             ;;
         --clean)
         --clean)
             clean_
             clean_

+ 5 - 1
make_backup.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
 #!/bin/bash
-device=arduino #arduino or raspberry
+device=ch341a #arduino or raspberry
 port=ttyACM0
 port=ttyACM0
 baud=115200
 baud=115200
 rpi_speed=20000 # between 512 to 30000, 20000 seems to be the best
 rpi_speed=20000 # between 512 to 30000, 20000 seems to be the best
@@ -14,6 +14,10 @@ modprobe spi_bcm2835
 modprobe spidev
 modprobe spidev
 flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=$rpi_speed -r backup.hex
 flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=$rpi_speed -r backup.hex
 fi
 fi
+if [ $device = "ch341a" ]
+then
+flashrom -p ch341a_spi -r backup.hex
+fi
 
 
 echo "n'oubliez pas de renomer le fichier !!!!"
 echo "n'oubliez pas de renomer le fichier !!!!"
 echo "d'ont forget to rename your file !!!!"
 echo "d'ont forget to rename your file !!!!"

+ 1 - 0
tools/.gitignore

@@ -0,0 +1 @@
+dummy.bin

+ 3 - 3
tools/dummy_cal.sh → tools/dummy_calculator.sh

@@ -1,8 +1,8 @@
 #!/bin/bash
 #!/bin/bash
-echo -e "\e[97mDummy file builder / calculator :\e[0m\e[24m"
+echo -e "\e[97mDummy file builder / calculator v2.0:\e[0m\e[24m"
 
 
 function help_ {
 function help_ {
-echo -e "\nUsage $0 image_size bios_size\n"
+echo -e "\nUsage $0 bios_size chip_size\n"
 }
 }
 
 
 if [ -x $1 ] |[ -x $2 ]
 if [ -x $1 ] |[ -x $2 ]
@@ -11,7 +11,7 @@ help_
 exit 0
 exit 0
 fi
 fi
 
 
-result=$[$1-$2]
+result=$[$2-$1]
 echo -e "Dummy image size : $result B"
 echo -e "Dummy image size : $result B"
 
 
 dd if=/dev/zero of=dummy.bin bs=$result count=1 status=none
 dd if=/dev/zero of=dummy.bin bs=$result count=1 status=none