Add bootloader

This commit is contained in:
2022-12-06 08:55:42 +01:00
parent 9830c36543
commit 4e3b086afd
7 changed files with 43 additions and 9 deletions

View File

@ -70,7 +70,9 @@
#define COMMAND_ALARM 4
#define COMMAND_CLEAR_ERROR 5
#define WATCHDOG 33000
#define COMMAND_REBOOT 255
#define WATCHDOG 3000
//=================================================================================================
// Section: MACROS
@ -276,6 +278,10 @@ PRIVATE VOID vTask( PVOID arg )
case COMMAND_CLEAR_ERROR:
VARH_vSetVariableDataFromSystemU32( VARH_eError, 0x00000000 );
break;
case COMMAND_REBOOT:
PECO_Enable( FALSE );
HAL_NVIC_SystemReset();
break;
default:
break;
}

View File

@ -189,12 +189,12 @@ PRIVATE BOOL boReadReg( U8 u8Register, PU16 pu16Data, BOOL boIs16bit );
//-------------------------------------------------------------------------------------------------
BOOL ADCD_boInitializeModule( VOID )
{
BOOL boOK = TRUE;
BOOL boOK = TRUE;
boOK &= ( ( m_pstMutexID = osMutexNew( &m_stMutexAttr ) ) == NULL ) ? FALSE : TRUE;
boOK &= ( ( m_pstMutexID = osMutexNew( &m_stMutexAttr ) ) == NULL ) ? FALSE : TRUE;
osMutexAcquire( m_pstMutexID, osWaitForever );
// Conifg ADC Cold
DIPO_vSetOutput( DIPO_eCS_Module );
boOK &= boWriteReg( REG_CONFIG, (U16) CONFIG | CONFIG_FAULTSTATCLEAR, FALSE );
@ -204,10 +204,13 @@ BOOL ADCD_boInitializeModule( VOID )
DIPO_vSetOutput( DIPO_eCS_Water );
boOK &= boWriteReg( REG_CONFIG, (U16) CONFIG | CONFIG_FAULTSTATCLEAR, FALSE );
DIPO_vResetOutput( DIPO_eCS_Water );
/** @todo read back configuration */
osMutexRelease( m_pstMutexID );
return( boOK );
return( boOK );
}
//-------------------------------------------------------------------------------------------------

View File

@ -91,7 +91,24 @@ void vDefaultTask(void *argument);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/**
* @brief Vector base address configuration. It should no longer be at the start of
* flash memory but moved forward because the first part of flash is
* reserved for the bootloader. Note that this is already done by the
* bootloader before starting this program. Unfortunately, function
* SystemInit() overwrites this change again.
* @return none.
*/
static void VectorBase_Config(void)
{
/* The constant array with vectors of the vector table is declared externally in the
* c-startup code.
*/
extern const unsigned long g_pfnVectors[];
/* Remap the vector table to where the vector table is located for this program. */
SCB->VTOR = (unsigned long)&g_pfnVectors[0];
}
/* USER CODE END 0 */
/**
@ -101,7 +118,7 @@ void vDefaultTask(void *argument);
int main(void)
{
/* USER CODE BEGIN 1 */
VectorBase_Config();
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/

View File

@ -201,6 +201,13 @@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BUILD_DIR):
mkdir $@
#######################################
# size
#######################################
size:
"C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.2 mpacbti-bet1\bin\arm-none-eabi-size.exe" $(BUILD_DIR)/$(TARGET).elf
#######################################
# clean up
#######################################

View File

@ -63,7 +63,7 @@ MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
FLASH (rx) : ORIGIN = 0x8002800, LENGTH = 128K-10K
}
/* Define output sections */

View File

@ -63,7 +63,7 @@ MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
FLASH (rx) : ORIGIN = 0x8002800, LENGTH = 128K-10K
}
/* Define output sections */

View File

@ -230,6 +230,7 @@ g_pfnVectors:
.word RNG_IRQHandler
.word FPU_IRQHandler
.word CRS_IRQHandler
.word 0x55AA11EE
/*******************************************************************************