diff options
Diffstat (limited to 'LUFA')
-rw-r--r-- | LUFA/Common/Attributes.h (renamed from LUFA/Common/FunctionAttributes.h) | 21 | ||||
-rw-r--r-- | LUFA/Common/Common.h | 4 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.c | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.h | 4 | ||||
-rw-r--r-- | LUFA/ManPages/ChangeLog.txt | 1 | ||||
-rw-r--r-- | LUFA/ManPages/DevelopingWithLUFA.txt | 1 | ||||
-rw-r--r-- | LUFA/ManPages/SoftwareBootloaderJump.txt | 63 |
7 files changed, 87 insertions, 13 deletions
diff --git a/LUFA/Common/FunctionAttributes.h b/LUFA/Common/Attributes.h index a3c9a8a3a..62d40734a 100644 --- a/LUFA/Common/FunctionAttributes.h +++ b/LUFA/Common/Attributes.h @@ -29,11 +29,12 @@ */
/** \file
- * \brief AVR-GCC special function attribute macros.
+ * \brief AVR-GCC special function/variable attribute macros.
*
- * This file contains macros for applying GCC specific attributes to functions to control various optimizer
- * and code generation features of the compiler. Attributes may be placed in the function prototype in any
- * order, and multiple attributes can be specified for a single function via a space separated list.
+ * This file contains macros for applying GCC specific attributes to functions and variables to control various
+ * optimizer and code generation features of the compiler. Attributes may be placed in the function prototype
+ * or variable declaration in any order, and multiple attributes can be specified for a single item via a space
+ * separated list.
*
* On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are
* critical to the code's function and thus must throw a compiler error when used.
@@ -43,9 +44,10 @@ */
/** \ingroup Group_Common
- * @defgroup Group_FuncAttr Function Attributes
+ * @defgroup Group_GCCAttr Function/Variable Attributes
*
- * Macros for easy access GCC function attributes, which can be applied to function prototypes.
+ * Macros for easy access GCC function and variable attributes, which can be applied to function prototypes or
+ * variable attributes.
*
* @{
*/
@@ -110,6 +112,13 @@ * identical name (in which case the weak reference is discarded at link time).
*/
#define ATTR_WEAK __attribute__ ((weak))
+
+ /** Forces the compiler to not automatically zero the given global variable on startup, so that the
+ * current RAM contents is retained. Under most conditions this value will be random due to the
+ * behaviour of volatile memory once power is removed, but may be used in some specific circumstances,
+ * like the passing of values back after a system watchdog reset.
+ */
+ #define ATTR_NO_INIT __attribute__ ((section (".noinit")))
#endif
/** Places the function in one of the initialization sections, which execute before the main function
diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h index f64de8ff8..5f1b2eae5 100644 --- a/LUFA/Common/Common.h +++ b/LUFA/Common/Common.h @@ -32,7 +32,7 @@ * \brief Common library convenience macros and functions.
*
* This file contains macros which are common to all library elements, and which may be useful in user code. It
- * also includes other common headers, such as Atomic.h, FunctionAttributes.h and BoardTypes.h.
+ * also includes other common headers, such as Atomic.h, Attributes.h and BoardTypes.h.
*/
/** @defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h
@@ -59,7 +59,7 @@ /* Includes: */
#include <avr/io.h>
- #include "FunctionAttributes.h"
+ #include "Attributes.h"
#include "BoardTypes.h"
/* Public Interface - May be used in end-application: */
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c index 1b67ba2c3..4ec0b244f 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -130,7 +130,7 @@ static uint8_t DComp_NextMSInterfaceEndpoint(void* const CurrentDescriptor) }
static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, MS_CommandBlockWrapper_t* const SCSICommandBlock,
- void* BufferPtr)
+ const void* const BufferPtr)
{
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
@@ -152,7 +152,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf Pipe_Freeze();
if ((BufferPtr != NULL) &&
- ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, SCSICommandBlock, BufferPtr)) != PIPE_RWSTREAM_NoError))
+ ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, SCSICommandBlock, (void*)BufferPtr)) != PIPE_RWSTREAM_NoError))
{
Pipe_Freeze();
return ErrorCode;
@@ -557,7 +557,7 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, }
uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, const uint32_t BlockAddress,
- const uint8_t Blocks, const uint16_t BlockSize, void* BlockBuffer)
+ const uint8_t Blocks, const uint16_t BlockSize, const void* BlockBuffer)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnected;
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h index 3dbf64940..d2ab97009 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -277,7 +277,7 @@ */
uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex,
const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize,
- void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);
+ const void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);
/* Inline Functions: */
/** General management task for a given Mass Storage host class interface, required for the correct operation of
@@ -320,7 +320,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t* const SCSICommandBlock,
- void* BufferPtr);
+ const void* const BufferPtr);
static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo);
static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t* const SCSICommandBlock, void* BufferPtr);
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 57093aeb6..f4c995f17 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -12,6 +12,7 @@ * - Added incomplete MIDIToneGenerator project
* - Added new Relay Controller Board project (thanks to OBinou)
* - Added board hardware driver support for the Teensy, USBTINY MKII, Benito and JM-DB-U2 lines of third party USB AVR boards
+ * - Added new ATTR_NO_INIT variable attribute
*
* <b>Changed:</b>
* - AVRISP programmer project now has a more robust timeout system, allowing for an increase of the software USART speed
diff --git a/LUFA/ManPages/DevelopingWithLUFA.txt b/LUFA/ManPages/DevelopingWithLUFA.txt index 66c1ed4c6..eb079baab 100644 --- a/LUFA/ManPages/DevelopingWithLUFA.txt +++ b/LUFA/ManPages/DevelopingWithLUFA.txt @@ -16,6 +16,7 @@ * - \subpage Page_VIDPID Allocated USB VID and PID Values
* - \subpage Page_BuildLibrary Building as a Linkable Library
* - \subpage Page_WritingBoardDrivers How to Write Custom Board Drivers
+ * - \subpage Page_SoftwareBootloaderStart How to jump to the bootloader in software
* - \subpage Page_SchedulerOverview Overview of the Simple LUFA Scheduler (DEPRECATED)
*/
\ No newline at end of file diff --git a/LUFA/ManPages/SoftwareBootloaderJump.txt b/LUFA/ManPages/SoftwareBootloaderJump.txt new file mode 100644 index 000000000..afdc0b32a --- /dev/null +++ b/LUFA/ManPages/SoftwareBootloaderJump.txt @@ -0,0 +1,63 @@ +/** \file
+ *
+ * This file contains special DoxyGen information for the generation of the main page and other special
+ * documentation pages. It is not a project source file.
+ */
+
+/**
+ * \page Page_SoftwareBootloaderStart Entering the Bootloader via Software
+ *
+ * A common requirement of many applications is the ability to jump to the programmed bootloader of a chip
+ * on demand, via the code's firmware (i.e. not as a result of any physical user interaction with the
+ * hardware). This might be required because the device does not have any physical user input, or simply
+ * just to streamline the device upgrade process on the host PC.
+ *
+ * The following C code snippet may be used to enter the bootloader upon request by the user application.
+ * By using the watchdog to physically reset the controller, it is ensured that all system hardware is
+ * completely reset to their defaults before the bootloader is run. This is important; since bootloaders
+ * are written to occupy a very limited space, they usually make assumptions about the register states based
+ * on the default values after a hard-reset of the chip.
+ *
+ * \code
+ * #include <avr/wdt.h>
+ * #include <avr/io.h>
+ * #include <util/delay.h>
+ *
+ * #include <LUFA/Common/Common.h>
+ * #include <LUFA/Drivers/USB/USB.h>
+ *
+ * uint32_t Boot_Key ATTR_NO_INIT;
+ *
+ * #define MAGIC_BOOT_KEY 0xDC42ACCA
+ * #define BOOTLOADER_START_ADDRESS ({FLASH_SIZE_BYTES} - {BOOTLOADER_SEC_SIZE_BYTES})
+ *
+ * int Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3);
+ * int Bootloader_Jump_Check(void)
+ * {
+ * // If the bootloader key is correct, clear it and jump to the bootloader
+ * if (Boot_Key == MAGIC_BOOT_KEY)
+ * {
+ * Boot_Key = 0;
+ * ((void (*)(void))BOOTLOADER_START_ADDRESS)();
+ * }
+ * }
+ *
+ * void Jump_To_Bootloader(void)
+ * {
+ * // If USB is used, detatch from the bus and wait 2 seconds for the host to register it
+ * USB_ShutDown();
+ * for (uint8_t i = 0; i < 128; i++)
+ * _delay_ms(16);
+ *
+ * // Set the bootloader key to the magic value and force a reset
+ * Boot_Key = MAGIC_BOOT_KEY;
+ * wdt_enable(WDTO_250MS);
+ * for (;;);
+ * }
+ * \endcode
+ *
+ * Note that the bootloader magic key can be any arbitrary value. The {FLASH_SIZE_BYTES} and
+ * {BOOTLOADER_SEC_SIZE_BYTES} tokens should be replaced with the total flash size of the AVR
+ * in bytes, and the allocated size of the bootloader section for the target AVR.
+ *
+ */
\ No newline at end of file |