From a536a01ebfe5f8d34c9d0abc7364d260962b4aab Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 31 Aug 2022 18:15:35 +0100 Subject: [PATCH 1/2] Create a bespoke bootloader programmer for gammaBoot trinkets --- src/avrdude.conf.in | 17 +++++++++++++++++ src/usbtiny.c | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 1152af77..f2d0c009 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1458,6 +1458,23 @@ programmer usbpid = 0x0c9f; ; +#------------------------------------------------------------ +# gemmaBoot +#------------------------------------------------------------ + +# Serving the Gemma bootloader +# https://github.com/adafruit/Adafruit-Trinket-Gemma-Bootloader + +programmer + id = "gemmaBoot"; + desc = "Gemma bootloader disguised as USBtiny"; + type = "usbtiny"; + prog_modes = PM_SPM; + connection_type = usb; + usbvid = 0x2341; + usbpid = 0x0105; +; + #------------------------------------------------------------ # arduinoisp #------------------------------------------------------------ diff --git a/src/usbtiny.c b/src/usbtiny.c index 2e319318..7153ede9 100644 --- a/src/usbtiny.c +++ b/src/usbtiny.c @@ -618,7 +618,13 @@ static int usbtiny_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) { if (! usbtiny_avr_op( pgm, p, AVR_OP_CHIP_ERASE, res )) { return -1; } - usleep( p->chip_erase_delay ); + + if(pgm->prog_modes & PM_SPM) { // Talking to bootloader directly + AVRMEM *fl = avr_locate_mem(p, "flash"); + // Estimated time it takes to erase all pages in bootloader + usleep(p->chip_erase_delay * (fl? fl->num_pages: 999)); + } else + usleep(p->chip_erase_delay); // prepare for further instruction pgm->initialize(pgm, p); From a5f3885b50c34799927037c2a4bb263f27c787bc Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Wed, 7 Sep 2022 09:56:28 +0100 Subject: [PATCH 2/2] Add and modify programmers for gemmaBoot in avrdude.conf.in --- src/avrdude.conf.in | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index f2d0c009..6e9df324 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1459,20 +1459,35 @@ programmer ; #------------------------------------------------------------ -# gemmaBoot +# arduino_gemma #------------------------------------------------------------ -# Serving the Gemma bootloader -# https://github.com/adafruit/Adafruit-Trinket-Gemma-Bootloader +# https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders/gemma programmer - id = "gemmaBoot"; - desc = "Gemma bootloader disguised as USBtiny"; + id = "arduino_gemma"; + desc = "Arduino Gemma bootloader disguised as USBtiny"; type = "usbtiny"; prog_modes = PM_SPM; connection_type = usb; usbvid = 0x2341; - usbpid = 0x0105; + usbpid = 0x0c9f; +; + +#------------------------------------------------------------ +# adafruit_gemma +#------------------------------------------------------------ + +# https://github.com/adafruit/Adafruit-Trinket-Gemma-Bootloader + +programmer + id = "adafruit_gemma"; + desc = "Adafruit Trinket Gemma bootloader disguised as USBtiny"; + type = "usbtiny"; + prog_modes = PM_SPM; + connection_type = usb; + usbvid = 0x1781; + usbpid = 0x0c9f; ; #------------------------------------------------------------