build.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. export VERSION=1
  3. export REV=07-05-2016
  4. set -e
  5. set +x
  6. ESC=$(echo -en \\0033)
  7. BOLD="$ESC[1m"
  8. OFF="$ESC[0m"
  9. bold() {
  10. echo "$BOLD$1$OFF"
  11. }
  12. fail() {
  13. bold "$@"
  14. exit 1
  15. }
  16. clean() { # Clean environement
  17. make clean
  18. #rm SimpleBGC_2_40b8+bootloader.zip
  19. }
  20. bootloader() { # Build bootloader only
  21. make MCU=atmega328p LED_START_FLASHES=3 BAUD_RATE=115200L LED_DATA_FLASH=1 atmega328
  22. }
  23. fusion() { # Build bootloader and fusion with SimpleBGC_2.40
  24. unzip SimpleBGC_2_40b8.zip
  25. srec_cat SimpleBGC_2_40b8.hex -intel optiboot_atmega328.hex -intel -o SimpleBGC_2_40b8+bootloader.hex -intel
  26. zip SimpleBGC_2_40b8+bootloader.zip SimpleBGC_2_40b8+bootloader.hex
  27. }
  28. flashboot() { # Build and flash bootloader only
  29. avrdude -c usbasp -p atmega328p -b19200 -e -u -U lock:w:0x3f:m -U efuse:w:0x05:m -U hfuse:w:0xDC:m -U lfuse:w:0xFF:m -U flash:w:optiboot_atmega328.hex -U lock:w:0x3f:m
  30. }
  31. flashall() { # Build fusion SimpleBGC and flash
  32. avrdude -c usbasp -p atmega328p -b19200 -e -u -U lock:w:0x3f:m -U efuse:w:0x05:m -U hfuse:w:0xDC:m -U lfuse:w:0xFF:m -U flash:w:SimpleBGC_2_40b8+bootloader.hex -U lock:w:0x3f:m
  33. }
  34. cd "$SRC_DIR"
  35. case "$1" in
  36. clean) clean;;
  37. bootloader) clean ; bootloader ;;
  38. fusion) clean ; bootloader ; fusion ;;
  39. flashboot) clean ; bootloader ; flashboot ;;
  40. flashfusion) clean; bootloader ; fusion ; flashall ;;
  41. *)
  42. echo >&2 "${BOLD}Mosbootloader v:$VERSION rev:$REV"
  43. echo >&2 "${BOLD}Usage: $0 (clean | bootloader | fusion | flashboot | flashfusion)$OFF"
  44. echo >&2
  45. echo >&2 "Build actions:"
  46. grep "() { #" $0 | grep -v grep | sort | sed -e "s:^: :" -e "s:() { #: @:" | while read i; do
  47. echo " " $(eval "echo $i") | tr @ \\t
  48. done
  49. exit 1
  50. ;;
  51. esac