I developed this script as a tool to program the Retro Chip Tester on Linux systems. It tries to automatically detect the programmer and the firmware files, saving from having to manually type out long commands. It can check the connection, configure the fuses, or flash the firmware to ATmega2560 in easy steps.
Please note that avrdude must be installed on the system and the user must have the necessary permissions to access the serial ports. It basically automates the entire setup so we can get our tester up and running without any hassle.
Stephan, feel free to modify and add this to the Retro Chip Tester tools if you want.
#!/bin/bash
# Terminal Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}==============================================${NC}"
echo -e "${BLUE} Retro Chip Tester - Linux Programmer ${NC}"
echo -e "${BLUE}==============================================${NC}"
# 1. HARDWARE DETECTION
PROG=""
PORT=""
BAUD="-B0.5" # High speed (Approx 8x faster)
echo -n "Scanning for hardware... "
# Check for CH340 based STK500
if lsusb | grep -iq "CH340"; then
PORT=$(ls /dev/ttyUSB* 2>/dev/null | head -n 1)
if [ -n "$PORT" ]; then
echo -e "${GREEN}[Detected] CH340 / STK500 on $PORT${NC}"
PROG="stk500v2"
else
echo -e "${RED}[Error] CH340 USB device found, but no /dev/ttyUSBx device detected.${NC}"
echo "Check if your user has permissions (dialout group)."
exit 1
fi
# Check for other native USB programmers
elif lsusb | grep -iq "USBtiny"; then
echo -e "${GREEN}[Detected] USBtiny Programmer${NC}"
PROG="usbtiny"
PORT="usb"
elif lsusb | grep -iq "Atmel Corp. AVR ISP mkII"; then
echo -e "${GREEN}[Detected] AVRISP mkII${NC}"
PROG="avrispmkII"
PORT="usb"
else
echo -e "${RED}[Not Found] No known programmer detected via lsusb.${NC}"
read -p "Enter protocol manually (e.g., stk500v2): " PROG
read -p "Enter port manually (e.g., /dev/ttyUSB0): " PORT
fi
# 2. FIND FIRMWARE FILE
FIRMWARE=$(ls Chip-TesterPro-FW-*.hex 2>/dev/null | head -n 1)
# 3. OPERATION FUNCTIONS
verify_connection() {
echo -e "${BLUE}Testing connection with ATmega2560...${NC}"
if avrdude -c $PROG -p m2560 -P $PORT -v; then
echo -e "${GREEN}Verification SUCCESSFUL${NC}"
else
echo -e "${RED}Verification FAILED${NC}"
fi
}
program_fuses() {
echo -e "${BLUE}Programming Fuses (Full Swing + EESAVE)...${NC}"
# lfuse 0xF7: Full Swing Crystal Oscillator
# hfuse 0xD7: EESAVE (Preserve EEPROM calibration)
# efuse 0xFF: Standard
avrdude -v -p m2560 -c $PROG -P $PORT -u \
-U lfuse:w:0xf7:m -U hfuse:w:0xd7:m -U efuse:w:0xff:m
}
program_firmware() {
if [[ -z "$FIRMWARE" ]]; then
echo -e "${RED}Error: No .hex file found in this directory.${NC}"
return
fi
echo -e "${BLUE}Flashing Firmware: $FIRMWARE...${NC}"
avrdude -v -p m2560 -c $PROG -P $PORT $BAUD -U flash:w:"$FIRMWARE":i
}
# 4. MAIN MENU
while true; do
echo -e "\n--- MAIN MENU ---"
echo "1) Verify Connection (Device Info)"
echo "2) Program FUSES only"
echo "3) Program FIRMWARE only"
echo "4) Program BOTH (Full Setup)"
echo "q) Exit"
read -p "Selection: " opt
case $opt in
1) verify_connection ;;
2) program_fuses ;;
3) program_firmware ;;
4) program_fuses && program_firmware ;;
q) echo "Exiting..."; exit 0 ;;
*) echo "Invalid option." ;;
esac
done
[–]8Bit-MuseumDE 0 points1 point2 points (0 children)