Merge tag 'LUFA-170418' into ProMicro
authorPeter Henn <Peter.Henn@web.de>
Wed, 29 Dec 2021 12:10:53 +0000 (12:10 +0000)
committerPeter Henn <Peter.Henn@web.de>
Wed, 29 Dec 2021 13:42:06 +0000 (13:42 +0000)
- use merge strategy "theirs", means in principle rebase ProMicro branch
  to LUFA-170418
- remove the wrong FUSE_BOOTRST check in Application_Jump_Check
  which was added in the meantime

1  2 
Bootloaders/DFU/BootloaderDFU.c
Bootloaders/DFU/BootloaderDFU.h
Bootloaders/DFU/makefile
LUFA/StudioIntegration/lufa_toolchain.xml
LUFA/StudioIntegration/makefile

@@@ -121,18 -131,38 +131,27 @@@ void Application_Jump_Check(void
  
                /* Re-enable JTAG debugging */
                JTAG_ENABLE();
 -              /* Check if the device's BOOTRST fuse is set */
 -              if (boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS) & FUSE_BOOTRST)
 -              {
 -                      /* If the reset source was not an external reset or the key is correct, clear it and jump to the application */
 -                      if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
 -                        JumpToApplication = true;
 -
 -                      /* Clear reset source */
 -                      MCUSR &= ~(1 << EXTRF);
 -              }
 -              else
+       #else
+               {
+                       /* If the reset source was the bootloader and the key is correct, clear it and jump to the application;
+                        * this can happen in the HWBE fuse is set, and the HBE pin is low during the watchdog reset */
+                       if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
+                               JumpToApplication = true;
+                       /* Clear reset source */
+                       MCUSR &= ~(1 << WDRF);
+               }
        #endif
  
-       /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
-       if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
-         JumpToApplication |= true;
+       /* Don't run the user application if the reset vector is blank (no app loaded) */
+       bool ApplicationValid = (pgm_read_word_near(0) != 0xFFFF);
  
        /* If a request has been made to jump to the user application, honor it */
-       if (JumpToApplication)
+       if (JumpToApplication && ApplicationValid)
        {
                /* Turn off the watchdog */
-               MCUSR &= ~(1<<WDRF);
-               wdt_disable(); 
+               MCUSR &= ~(1 << WDRF);
+               wdt_disable();
  
                /* Clear the boot key and jump to the user application */
                MagicBootKey = 0;
@@@ -231,12 -226,8 +250,12 @@@ static void ResetHardware(void
  {
        /* Shut down the USB and other board hardware drivers */
        USB_Disable();
 -      LEDs_Disable();
 +      //LEDs_Disable();
 +      DDRB = 0;
 +      PORTB = 0;
 +      DDRD = 0;
 +      PORTD = 0;
-       
        /* Disable Bootloader active LED toggle timer */
        TIMSK1 = 0;
        TCCR1B = 0;
                #include "Config/AppConfig.h"
  
                #include <LUFA/Drivers/USB/USB.h>
 -              #include <LUFA/Drivers/Board/LEDs.h>
 +              //#include <LUFA/Drivers/Board/LEDs.h>
+               #include <LUFA/Platform/Platform.h>
+       /* Preprocessor Checks: */
+               #if !defined(__OPTIMIZE_SIZE__)
+                       #error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
+               #endif
  
        /* Macros: */
                /** Major bootloader version number. */
Simple merge
                                <toolchain-config name="avrgcc.compiler.optimization.OtherFlags" value="-fdata-sections" toolchain="avrgcc"/>\r
                                <toolchain-config name="avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection" value="True" toolchain="avrgcc"/>\r
                                <toolchain-config name="avrgcc.compiler.warnings.AllWarnings" value="True" toolchain="avrgcc"/>\r
-                               <toolchain-config name="avrgcc.compiler.miscellaneous.OtherFlags" value="-std=gnu99 -fno-strict-aliasing" toolchain="avrgcc"/>\r
+                               <toolchain-config name="avrgcc.compiler.miscellaneous.OtherFlags" value="-mrelax -std=gnu99 -fno-strict-aliasing -fno-jump-tables" toolchain="avrgcc"/>\r
                                <toolchain-config name="avrgcc.linker.optimization.GarbageCollectUnusedSections" value="True" toolchain="avrgcc"/>\r
                                <toolchain-config name="avrgcc.linker.optimization.RelaxBranches" value="True" toolchain="avrgcc"/>\r
 -                              <toolchain-config name="avrgcc.linker.miscellaneous.LinkerFlags" value="-Wl,--relax" toolchain="avrgcc"/>\r
                        </module>\r
                </select-by-device>\r
  \r
@@@ -81,6 -135,8 +135,9 @@@ check_filenames: $(MODULE_OUTPUT_XML
                        fi; \
                done || exit 1; \
        done;
 +      @echo Verified referenced filenames of ASF.xml modules.
  
- .PHONY: all clean generate_xml generate_vsix check_filenames
+ check_database:
+       python ProjectGenerator/project_generator.py -b $(LUFA_ROOT)/../ --main-ext-uuid=0e160d5c-e331-48d9-850b-e0387912171b CHECK
+ .PHONY: all clean generate_help generate_xml generate_vsix check_filenames check_database