Application/include/cali.h | ●●●●● patch | view | raw | blame | history | |
Application/source/main.c | ●●●●● patch | view | raw | blame | history | |
Application/source/nvm.c | ●●●●● patch | view | raw | blame | history | |
Application/source/uds_modules/did.c | ●●●●● patch | view | raw | blame | history | |
Application/source/uds_modules/did.h | ●●●●● patch | view | raw | blame | history | |
Application/source/uds_modules/uds.c | ●●●●● patch | view | raw | blame | history | |
Cmsis/Startup/startup_XL6600.S | ●●●●● patch | view | raw | blame | history | |
xl6600_flash.ld | ●●●●● patch | view | raw | blame | history |
Application/include/cali.h
File was deleted Application/source/main.c
@@ -37,9 +37,10 @@ Hal_CANConfig(); Hal_CrcInit(); // CRC FOR FLASH UDS_Init(); did_init(); NVM_Init(); light_init(); did_init(); } /** Application/source/nvm.c
@@ -55,8 +55,8 @@ extern int8_t Fbl_CheckPresent() { int8_t rtn = 0; uint8_t i = 0; int8_t rtn = 1; uint8_t i = 1; uint8_t prensnttemp[8] = {0}; uint8_t prensntmasktemp[8] = {0}; FblReadPattern(prensnttemp, APP_PRESENT_ADDR); @@ -65,7 +65,7 @@ { if ((prensnttemp[i] + prensntmasktemp[i]) != 0xff) { rtn = 1; rtn = 0; break; } } @@ -88,7 +88,7 @@ if ((retValue1 == EE_OK) && (retValue2 == EE_OK)) { // rtn = OP_STATUS_OK; rtn = FblWriteProgramBlock(); rtn = DID_SaveProgamDataToNvm(); } return rtn; } Application/source/uds_modules/did.c
@@ -44,16 +44,51 @@ uint16_t DIDTable_Entry_Count_u16 = 0; UDS_DIDtableEntry DIDtable[UDS_DID_TABLE_SIZE]; static uint8_t DID_LoaderWaitTimer = 0; // static uint8_t DID_LoaderWaitTimer = 0; static uint8_t DID_NeedtoSaveFlag = 0; void did_init(void) { DID_NeedtoSaveFlag = 0; UDS_InitDIDMapRW(DID_NS_ProgrammingCounter, VA_PROGRAM_DATA, &NVM_ProgramBLOCK.ProgrammingCounter, 1); UDS_InitDIDMapRW(DID_NS_ProAtpCounter, VA_PROGRAM_DATA, &NVM_ProgramBLOCK.ProgrammingAttempCounter, 1); UDS_InitDIDMapRW(DID_NS_ReadFingerPrint, VA_PROGRAM_DATA, &NVM_ProgramBLOCK.FingerPrint_W, 9); UDS_InitDIDMapRW(DID_NS_RepairShopCodeOrTester, VA_PROGRAM_DATA, &NVM_ProgramBLOCK.RepairShopCodeOrTesterSerialNumber, 16); UDS_InitDIDMapRW(DID_NS_ECUProgtammingDate, VA_PROGRAM_DATA, &NVM_ProgramBLOCK.UDS_NS_ProgrammingDate.ProgrammingDate_YY_H, 4); UDS_InitDIDMapRW(DID_NS_WriteFingerPrint, VA_PROGRAM_DATA, &NVM_ProgramBLOCK.FingerPrint_W, 10); FblReadProgramBlock(); // load program data.must after ee_init() } extern void DID_SetWriteSaveFlag(void) { DID_NeedtoSaveFlag = 1; } extern int8_t DID_SaveProgamDataToNvm(void) { int8_t rtn = OP_STATUS_FAIL; if (DID_NeedtoSaveFlag == 1) { rtn = FblWriteProgramBlock(); } else { rtn = OP_STATUS_OK; } } extern void DID_UpdateProgramCnt(void) { NVM_ProgramBLOCK.ProgrammingCounter += 1; DID_NeedtoSaveFlag = 1; } extern void DID_UpdateAtpProgramCnt(void) { NVM_ProgramBLOCK.ProgrammingAttempCounter += 1; DID_NeedtoSaveFlag = 1; } extern int8_t FblReadProgramBlock(void) @@ -61,13 +96,14 @@ uint32_t *p_dest = (uint32_t *)(&NVM_ProgramBLOCK); uint8_t i = 0; int8_t rtn = OP_STATUS_FAIL; int8_t rtn = OP_STATUS_OK; EE_Status retValue1 = EE_WRITE_ERROR; for (i = 0; i < (ProgramBlockLenth >> 2); i++) { if (EE_OK != EE_ReadVariable32bits(VA_PROGRAM_DATA + i * 4, (p_dest + i))) { rtn = OP_STATUS_FAIL; break; } } @@ -78,13 +114,14 @@ { uint32_t *p_dest = (uint32_t *)(&NVM_ProgramBLOCK); uint8_t i = 0; int8_t rtn = OP_STATUS_FAIL; int8_t rtn = OP_STATUS_OK; EE_Status retValue1 = EE_WRITE_ERROR; for (i = 0; i < (ProgramBlockLenth >> 2); i++) { if (EE_OK != EE_WriteVariable32bits(VA_PROGRAM_DATA + i * 4, *(p_dest + i))) { rtn = OP_STATUS_FAIL; break; } } Application/source/uds_modules/did.h
@@ -76,4 +76,8 @@ void did_init(void); extern int8_t FblReadProgramBlock(void); extern int8_t FblWriteProgramBlock(void); extern void DID_UpdateProgramCnt(void); extern void DID_UpdateAtpProgramCnt(void); extern int8_t DID_SaveProgamDataToNvm(void); extern void DID_SetWriteSaveFlag(void); #endif /* DID_H */ Application/source/uds_modules/uds.c
@@ -9,6 +9,7 @@ #include "cantp_user.h" #include "xl_mcan.h" #include "uds.h" #include "did.h" #include "fbl_ap.h" #include "fbl_def.h" #include "nvm.h" @@ -308,7 +309,7 @@ /* Build DID data set */ static bool UDS_BuildDidSet(uint8_t *payload); /* Switch to default session */ static void UDS_SwitchtoDefaultSession(void); static void UDS_SwitchtoDefaultSession(uint8_t resetcmd); /*Security access*/ static void UDS_ControlDTCSetting(uint8_t *payload); @@ -376,7 +377,7 @@ {ECU_RESET, UDS_ECURest, false, true, false, true, SECURITY_ACCESS_LOCKED}, {READ_DATA_BY_IDENTIFIER, UDS_ReadData, true, true, false, false, SECURITY_ACCESS_LOCKED}, {SECURITY_ACCESS, UDS_SecurityAccess, false, true, false, false, SECURITY_ACCESS_LOCKED}, {COMMUNICATION_CONTROL, UDS_CommunicationControl, false, true, true, true, SECURITY_ACCESS_LOCKED}, // {COMMUNICATION_CONTROL, UDS_CommunicationControl, false, true, true, true, SECURITY_ACCESS_LOCKED}, {WRITE_DATA_BY_IDENTIFIER, UDS_WriteDataByIdentifier, false, true, false, false, SECURITY_ACCESS_UNLOCK_LEVEL_1}, {ROUTINE_CONTROL, UDS_RoutineControl, false, true, false, false, SECURITY_ACCESS_UNLOCK_LEVEL_2}, {TESTER_PRESENT, UDS_TesterPresent, true, true, true, true, SECURITY_ACCESS_LOCKED}, @@ -1030,23 +1031,17 @@ if (CDT_HASEXPIRED(TesterPresentTimer_u16) != false) { UDS_SwitchtoDefaultSession(); UDS_SwitchtoDefaultSession(true); } } else { UDS_SwitchtoDefaultSession(); UDS_SwitchtoDefaultSession(true); } } else { CDT_RESET(TesterPresentTimer_u16, 0); #if 0 if(CDT_EXPIRED(EntrySleepModeTimer_u16)==true) { //SBC_shutdown(); } #endif } } @@ -1204,29 +1199,14 @@ } else { if ((DID_u16 & 0xff00u) == 0xF100u) { /* UDS_WriteF1DIDdata(&payload[3], Index_to_be_written); */ memcpy(DIDtable[Index_to_be_written].address, &payload[3], DIDtable[Index_to_be_written].size); } else { /* Flip the data contents in rx buffer */ UDS_FlipEndian(&payload[3], DIDtable[Index_to_be_written].size); /* not sure this should be done... */ /* memory copy the data into DID data location */ memcpy(DIDtable[Index_to_be_written].address, &payload[3], DIDtable[Index_to_be_written].size); } /* UDS_WriteF1DIDdata(&payload[3], Index_to_be_written); */ memcpy(DIDtable[Index_to_be_written].address, &payload[3], DIDtable[Index_to_be_written].size); /* Write the change to NVM */ if (DIDtable[Index_to_be_written].nvBlockID != 0xFF) { // todo // CAL_Save_Calibration_Block( // DIDtable[Index_to_be_written].nvBlockID); DID_SetWriteSaveFlag(); } UDS_L_tx_msg_buffer[0] = GET_RESPONSE_SERVICE_ID(WRITE_DATA_BY_IDENTIFIER); @@ -1446,6 +1426,7 @@ /*****************************************************************************/ static void UDS_SessionControl(uint8_t *payload) { uint16_t cnt = 5000u; /* Change session based on CAN message request */ bool UDS_SessionSetOk_b = false; uint8_t sub_func = UDS_GET_SUB_FUNCTION(payload[UDS_RQ_BYTE1]); @@ -1473,6 +1454,7 @@ { /**/ UDS_L_Diag_session_e = PROGRAMMING; UDS_SessionSetOk_b = true; FblSetFblProgramRequestFlag(); } else if ((UDS_L_Diag_session_e == DEFAULT) || (UDS_L_ProgrammingPreconditionCheckOK_b == false)) /*DEFAULT session can not trans to PROGRAMMING*/ @@ -1484,7 +1466,35 @@ } break; case DEFAULT: UDS_SwitchtoDefaultSession(); if (UDS_L_Diag_session_e == PROGRAMMING) { UDS_L_tx_msg_buffer[0] = GET_RESPONSE_SERVICE_ID(SESSION_CONTROL); UDS_L_tx_msg_buffer[1] = UDS_L_Diag_session_e; UDS_L_tx_msg_buffer[2] = 0; UDS_L_tx_msg_buffer[3] = 0; UDS_L_tx_msg_buffer[4] = 0; UDS_L_tx_msg_buffer[5] = 0; /* Specify the send payload size */ UDS_L_tx_msg_size = 0x06; /* Compose a response message and send a positive */ /* response with the request data */ UDS_RespTxMessage(); while (cnt--) { ; /// wait send command send out and then reset } UDS_SwitchtoDefaultSession(true); while (1) ; } else { UDS_SwitchtoDefaultSession(false); } TesterPresentTimer_u16 = 0; break; default: @@ -1508,12 +1518,6 @@ /* response with the request data */ UDS_RespTxMessage(); } #ifdef ENABLE_BOOTLOADER if (UDS_L_Diag_session_e == PROGRAMMING) { /*reset es*/ CPU_HardReset(); } #endif } /*****************************************************************************/ @@ -2076,6 +2080,7 @@ { } } DID_UpdateAtpProgramCnt(); /*always from buff 0*/ currentbuffId = 0; UDS_L_TransferDataState_e = TRANFER_START; @@ -2245,6 +2250,7 @@ /* Compose a response message and send a positive */ /* response with the request data */ UDS_RespTxMessage(); DID_UpdateProgramCnt(); } /*****************************************************************************/ @@ -2404,10 +2410,14 @@ /* (1) Date: 10/30/2014 Fogbugz: case#: 2283 */ /* Initial release by Tom Tao */ /*****************************************************************************/ static void UDS_SwitchtoDefaultSession(void) static void UDS_SwitchtoDefaultSession(uint8_t restcmd) { UDS_L_Diag_session_e = DEFAULT; UDS_L_ProgrammingPreconditionCheckOK_b = false; if (restcmd == true) { CPU_HardReset(); } } static void UDS_StringCopy(char *p_src, char *p_dest, uint8_t max_size) Cmsis/Startup/startup_XL6600.S
@@ -258,88 +258,6 @@ .word Reserved21_IRQHandler .word BootRAM /* @0x1E0. This is for boot in RAM mode for xl6600d High Density devices. */ /****************************************************************************** * * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * ******************************************************************************/ .section .isr_vector_dup,"a",%progbits .align 4 .type g_pfnVectors_dup, %object .size g_pfnVectors_dup, .-g_pfnVectors_dup g_pfnVectors_dup: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word 0 .word 0 .word 0 .word SVC_Handler .word DebugMon_Handler .word 0 .word PendSV_Handler .word SysTick_Handler .word Reserved16_IRQHandler .word Reserved17_IRQHandler .word Reserved18_IRQHandler .word Reserved19_IRQHandler .word Reserved20_IRQHandler .word FMC_IRQHandler .word PMC_IRQHandler .word DMA_IRQHandler .word I2C0_IRQHandler .word I2C1_IRQHandler .word SPI0_IRQHandler .word SPI1_IRQHandler .word UART0_IRQHandler .word UART1_IRQHandler .word UART2_IRQHandler .word ADC0_IRQHandler .word ACMP0_IRQHandler .word FTM0_IRQHandler .word FTM1_IRQHandler .word FTM2_IRQHandler .word RTC_IRQHandler .word ACMP1_IRQHandler .word PIT_CH0_IRQHandler .word PIT_CH1_IRQHandler .word KBI0_IRQHandler .word KBI1_IRQHandler .word Reserved42_IRQHandler .word ICS_IRQHandler .word WDOG_IRQHandler .word PWT_IRQHandler .word MCAN_IRQHandler .word EXTI0_IRQHandler .word EXTI1_IRQHandler .word EXTI2_IRQHandler .word EXTI3_IRQHandler .word EXTI4_IRQHandler .word EXTI5_IRQHandler .word EXTI6_IRQHandler .word EXTI7_IRQHandler .word EXTI8_IRQHandler .word EXTI9_IRQHandler .word EXTI10_IRQHandler .word EXTI11_IRQHandler .word EXTI12_IRQHandler .word EXTI13_IRQHandler .word EXTI14_IRQHandler .word EXTI15_IRQHandler .word EWM_IRQHandler .word Reserved21_IRQHandler .word BootRAM /* @0x1E0. This is for boot in RAM mode for xl6600d High Density devices. */ GPIOA: .word 0x40100000 GPIOB: xl6600_flash.ld
@@ -45,7 +45,7 @@ DRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 18K RAM_VECT_TBL (xrw) : ORIGIN = 0x20000000, LENGTH = 0x200 FALSH_DRIVER_RAM (xrw):ORIGIN = 0x20000200, LENGTH = 0x100 BOOTFLAG (xrw) : ORIGIN = 0x20004700, LENGTH = 0x100 BOOTFLAG (xrw) : ORIGIN = 0x20000300, LENGTH = 0x100 FLASH_BOOT (rx) : ORIGIN = 0x0000000, LENGTH = 48K FLASH_APP (rx) : ORIGIN = 0x000C100, LENGTH = 256K -48K -8K-0x100