Index: firmware/App/Common.h =================================================================== diff -u -rf2652e85c8676d0356fea2690cfd9cac716ca795 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/App/Common.h (.../Common.h) (revision f2652e85c8676d0356fea2690cfd9cac716ca795) +++ firmware/App/Common.h (.../Common.h) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -23,10 +23,24 @@ typedef unsigned int BOOL; ///< 32-bit boolean type typedef unsigned char BYTE; ///< 8-bit byte type +typedef enum SW_Mode_POST_States +{ + MODE_POST_CHECK_FOR_UPDATE = 0, + MODE_POST_VERIFY_IMAGE, + NUM_OF_MODE_POST_STATES +} MODE_POST_STATE_T; +typedef enum SW_Mode_Update_States +{ + MODE_SW_UPDATE_START = 0, + MODE_SW_UPDATE_UPDATE, + MODE_SW_UPDATE_RESYNC, + MODE_SW_UPDATE_VERIFY, + NUM_OF_MODE_SW_UPDATE_STATES +} MODE_SW_UPDATE_STATE_T; + typedef enum SW_Update_Destinations { - //UPDATE_NONE = 0, UPDATE_FIRMWARE = 0, UPDATE_FPGA, NUM_OF_UPDAT_DESTS Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rabb9687e52d9db5df1abe7626ba04a6d431ba823 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision abb9687e52d9db5df1abe7626ba04a6d431ba823) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -1,8 +1,8 @@ /* * ModeStandby.c * - * Created on: Jul 31, 2024 + * Created on: Aug 7, 2024 * Author: fw */ -#include "ModeStandby.h" + Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -rabb9687e52d9db5df1abe7626ba04a6d431ba823 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision abb9687e52d9db5df1abe7626ba04a6d431ba823) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -1,7 +1,7 @@ /* * ModeStandby.h * - * Created on: Jul 31, 2024 + * Created on: Aug 7, 2024 * Author: fw */ Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -rf2652e85c8676d0356fea2690cfd9cac716ca795 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision f2652e85c8676d0356fea2690cfd9cac716ca795) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -54,8 +54,6 @@ static SW_UPDATE_RCV_STATUS_T SWUpdateRcvStatus; static SW_UPDATE_BUFFER_STATUS_T SWUpdateBufferStatus; -static U32 FORTESTREMOVE = 0; - static void consumeReceivedUpdateCANFrame( U08* data ); static void processReceivedUpdateCANFrame( void ); static void processRecievedCmdCANFrame( U08* data ); @@ -170,25 +168,10 @@ SWUpdateRcvStatus.SWUpdateFrameCount++; - //if ( NUM_OF_CAN_FRAMES_TO_UPDATE == SWUpdateRcvStatus.SWUpdateFrameCount ) if ( SWUpdateRcvStatus.SWUpdateFrameCount % NUM_OF_CAN_FRAMES_TO_UPDATE == 0 ) { processReceivedUpdateCANFrame(); - - // TODO REmove - if ( FORTESTREMOVE == 1 ) - { - BOOL test = FALSE; - } - FORTESTREMOVE++; - //sendAckNackStatusFromFirmware( ACK, FALSE ); - //clearSWUpdateBuffer( FALSE ); - // TODO Remove } - else - { - //SWUpdateRcvStatus.SWUpdateFrameCount++; - } } } Index: firmware/App/Services/NVDataMgmt.c =================================================================== diff -u --- firmware/App/Services/NVDataMgmt.c (revision 0) +++ firmware/App/Services/NVDataMgmt.c (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -0,0 +1,25 @@ +/* + * NVDataMgmt.c + * + * Created on: Aug 7, 2024 + * Author: fw + */ + +#include "F021.h" +#include "system.h" // For fapi operations + + +#include "NVDataMgmt.h" + +#define ROUNDED_HCLK_FREQ FLOAT_TO_INT_WITH_ROUND(HCLK_FREQ) ///< Rounded HCLK for EERPOM clock. + + + +void initNVDataMgmt( void ) +{ + Fapi_initializeFlashBanks(208); + + Fapi_setActiveFlashBank( Fapi_FlashBank0 ); + + +} Index: firmware/App/Services/NVDataMgmt.h =================================================================== diff -u --- firmware/App/Services/NVDataMgmt.h (revision 0) +++ firmware/App/Services/NVDataMgmt.h (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -0,0 +1,15 @@ +/* + * NVDataMgmt.h + * + * Created on: Aug 7, 2024 + * Author: fw + */ + +#ifndef __NVDATAMGMT_H__ +#define __NVDATAMGMT_H__ + +#include "BLCommon.h" + +void initNVDataMgmt( void ); + +#endif Index: firmware/App/Services/Utilities.c =================================================================== diff -u -rf2652e85c8676d0356fea2690cfd9cac716ca795 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/App/Services/Utilities.c (.../Utilities.c) (revision f2652e85c8676d0356fea2690cfd9cac716ca795) +++ firmware/App/Services/Utilities.c (.../Utilities.c) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -62,9 +62,4 @@ return crc; } -BOOL isCRCValid( U32 msgCRC, U32 calcCRC ) -{ - return ( msgCRC == calcCRC ? TRUE : FALSE ); -} - Index: firmware/App/Services/Utilities.h =================================================================== diff -u -rf2652e85c8676d0356fea2690cfd9cac716ca795 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/App/Services/Utilities.h (.../Utilities.h) (revision f2652e85c8676d0356fea2690cfd9cac716ca795) +++ firmware/App/Services/Utilities.h (.../Utilities.h) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -15,6 +15,4 @@ U32 crc32( U32 initialValue, U08 *address, U32 len ); -BOOL isCRCValid( U32 msgCRC, U32 calcCRC ); // TODO remove - #endif Index: firmware/include/sys_core.h =================================================================== diff -u -rabb9687e52d9db5df1abe7626ba04a6d431ba823 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/include/sys_core.h (.../sys_core.h) (revision abb9687e52d9db5df1abe7626ba04a6d431ba823) +++ firmware/include/sys_core.h (.../sys_core.h) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -54,6 +54,7 @@ #endif /* USER CODE BEGIN (0) */ +void _copyAPI2RAM_(void); /* USER CODE END */ /** @def USER_STACK_LENGTH Index: firmware/source/sys_core.asm =================================================================== diff -u -rabb9687e52d9db5df1abe7626ba04a6d431ba823 -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/source/sys_core.asm (.../sys_core.asm) (revision abb9687e52d9db5df1abe7626ba04a6d431ba823) +++ firmware/source/sys_core.asm (.../sys_core.asm) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -134,7 +134,36 @@ .endasmfunc +;------------------------------------------------------------------------------- +; +; Copy the Flash API from flash to SRAM. +; + .def _copyAPI2RAM_ + .asmfunc + +_copyAPI2RAM_ + + .ref apiLoadStart +flash_load .word apiLoadStart + .ref apiRunStart +flash_run .word apiRunStart + .ref apiLoadSize +flash_size .word apiLoadSize + + ldr r0, flash_load + ldr r1, flash_run + ldr r2, flash_size + add r2, r1, r2 +copy_loop1: + ldr r3, [r0], #4 + str r3, [r1], #4 + cmp r1, r2 + blt copy_loop1 + bx lr + + .endasmfunc + ;------------------------------------------------------------------------------- ; Initialize Stack Pointers ; SourceId : CORE_SourceId_002 Index: firmware/source/sys_link.cmd =================================================================== diff -u -r850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/source/sys_link.cmd (.../sys_link.cmd) (revision 850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f) +++ firmware/source/sys_link.cmd (.../sys_link.cmd) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -1,36 +1,36 @@ /*----------------------------------------------------------------------------*/ /* sys_link.cmd */ /* */ -/* -* Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions +/* +* Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com +* +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions * are met: * -* Redistributions of source code must retain the above copyright +* Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -60,6 +60,8 @@ RAM (RW) : origin=0x08005800 length=0x0002a800 /* USER CODE BEGIN (2) */ + + /* USER CODE END */ } @@ -80,16 +82,23 @@ SECTIONS { .intvecs : {} > VECTORS - .text : {} > FLASH0 - .const : {} > FLASH0 - .cinit : {} > FLASH0 - .pinit : {} > FLASH0 + .text : {} > FLASH0 + .const : {} > FLASH0 + .cinit : {} > FLASH0 + .pinit : {} > FLASH0 .bss : {} > RAM .data : {} > RAM .sysmem : {} > RAM - + /* USER CODE BEGIN (4) */ + flashAPI: + { + //../Debug/App/Services/NVDataMgmt.obj (.text) + NVDataMgmt.obj (.text) + //--library= "/home/fw/workspace_bl/bootloader/firmware/App/Services/FlashAPI/F021_API_CortexR4_LE_L2FMC_V3D16_NDS.lib" (.text) + --library= F021_API_CortexR4_LE_L2FMC_V3D16_NDS.lib (.text) + } palign=8 load = FLASH0, run = RAM, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize) /* USER CODE END */ } Index: firmware/source/sys_main.c =================================================================== diff -u -r850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/source/sys_main.c (.../sys_main.c) (revision 850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f) +++ firmware/source/sys_main.c (.../sys_main.c) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -63,6 +63,7 @@ #include "BLCommon.h" #include "CommBuffers.h" #include "Interrupts.h" +#include "NVDataMgmt.h" #include "TaskBG.h" #include "Timers.h" /* USER CODE END */ @@ -76,11 +77,23 @@ */ /* USER CODE BEGIN (2) */ +/*extern unsigned int apiLoadStart; +extern unsigned int apiLoadSize; +extern unsigned int apiRunStart; + +extern unsigned int constLoadStart; +extern unsigned int constLoadSize; +extern unsigned int constRunStart; +*/ /* USER CODE END */ int main(void) { /* USER CODE BEGIN (3) */ + + //memcpy(&apiRunStart, &apiLoadStart, (uint32)&apiLoadSize); + //memcpy(&constRunStart, &constLoadStart, (uint32)&constLoadSize); + initProcessor(); initSoftware(); initTasks(); @@ -104,6 +117,7 @@ { initCommBuffers(); initInterrupts(); + initNVDataMgmt(); initTimers(); } Index: firmware/source/sys_startup.c =================================================================== diff -u -r850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f -rdeef095c63fe86de42a7e052e1b9985b0118b02e --- firmware/source/sys_startup.c (.../sys_startup.c) (revision 850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f) +++ firmware/source/sys_startup.c (.../sys_startup.c) (revision deef095c63fe86de42a7e052e1b9985b0118b02e) @@ -629,6 +629,7 @@ /* initialize copy table */ __TI_auto_init(); /* USER CODE BEGIN (75) */ + _copyAPI2RAM_(); /* USER CODE END */ /* call the application */