diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-02-20 11:39:04 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-02-20 11:39:04 +0200 |
| commit | 57a828b4d11ab8274053ee035c8de8014ddd4ca1 (patch) | |
| tree | c88e63b5e9019fe67cc3be451e46fbe57efc4a35 /Software/Embedded_SW/Embedded/Common/SWUpdate | |
| parent | 2d55102532afaccc447c8a28ded8ccb93437683b (diff) | |
| parent | d6e2772dd98e6880de14ea12be0ef53bae24f763 (diff) | |
| download | Tango-57a828b4d11ab8274053ee035c8de8014ddd4ca1.tar.gz Tango-57a828b4d11ab8274053ee035c8de8014ddd4ca1.zip | |
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | 35 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c | 38 |
2 files changed, 43 insertions, 30 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 8aabafd2e..1ba656657 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -100,7 +100,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) if (Semaphore_pend(FFS_Sem, BIOS_NO_WAIT)) { CommRxTaskHandle = Task_self(); - Task_setPri(CommRxTaskHandle, 3); + Task_setPri(CommRxTaskHandle, 2); // Report("Task_setPri", __FILE__, __LINE__, 4, RpWarning, (int)CommRxTaskHandle, 0); //Report("FileUploadRequestFunc 2", __FILE__, __LINE__, msec_millisecondCounter, RpWarning, (int)0, 0); Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS); @@ -280,16 +280,22 @@ uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) Fresult = FR_DENIED; else { - Semaphore_pend(FFS_Sem, BIOS_WAIT_FOREVER); - Fresult = f_open(DownloadFileHandle,request->filename,FA_READ ); - if (Fresult == FR_OK) + if (Semaphore_pend(FFS_Sem, BIOS_NO_WAIT)) { - response.has_maxchunklength = true; - response.maxchunklength = MAX_CHUNK_LENGTH; - strcpy(FileHandleChar, "1234"); - response.downloadid = FileHandleChar; //supporting only single file at each time. + Fresult = f_open(DownloadFileHandle,request->filename,FA_READ ); + if (Fresult == FR_OK) + { + response.has_maxchunklength = true; + response.maxchunklength = MAX_CHUNK_LENGTH; + strcpy(FileHandleChar, "1234"); + response.downloadid = FileHandleChar; //supporting only single file at each time. + Report("data request", __FILE__, 1234, MAX_CHUNK_LENGTH, RpWarning, (int)fno->fsize, 0); + } + else + { + Semaphore_post(FFS_Sem); + } } - } } @@ -323,10 +329,11 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) Buffer = my_malloc (MAX_CHUNK_LENGTH); if (Buffer != NULL) { - Fresult = f_read(SentFileHandle,Buffer,2000,&ReadBytes ); + Fresult = f_read(SentFileHandle,Buffer,MAX_CHUNK_LENGTH,&ReadBytes ); if(Fresult != FR_OK) { - LOG_ERROR (Fresult,"f_write error"); + LOG_ERROR (Fresult,"f_read error"); + Semaphore_post(FFS_Sem); } else { @@ -334,6 +341,7 @@ uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) response.buffer.len = ReadBytes; response.buffer.data = Buffer; FileSentLength += ReadBytes; + Report("sending data to MS", __FILE__, ReadBytes, FileSentLength, RpWarning, (int)FileLength, 0); if (FileSentLength == FileLength) { REPORT_MSG (FileSentLength,"file download ended successfully"); @@ -715,8 +723,10 @@ FRESULT FileWrite(void * buffer, uint16_t size,char *path, uint32_t timeout) Fresult = f_write(FileHandle,buffer,size,&Bytes ); if(Fresult != FR_OK) { - LOG_ERROR (Fresult,"fread error"); + LOG_ERROR (Fresult,"fwrite error"); } + //LOG_ERROR (Bytes,"f_write ok no of bytes"); + Report("f_write ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)size, 0); f_close(FileHandle); } else @@ -762,6 +772,7 @@ FRESULT FileRead(char *path, uint32_t *Size, void **Buffer) { *Buffer = buffer; *Size = (uint32_t)fno->fsize; + Report("f_read ok no of bytes", __FILE__, __LINE__, Bytes, RpWarning, (int)fno->fsize, 0); } else { diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index c42dc6695..4bbe44aea 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -24,6 +24,7 @@ #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" #include "drivers/FPGA/Full_Vme/ispvme/vmopcode.h" +#include "drivers/Flash_ram/FlashProgram.h" #include "Common/Utilities/Utils.h" #include "Common/SWUpdate/FileSystem.h" @@ -53,6 +54,7 @@ uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; MessageContainer responseContainer; + bool last = true; usnprintf(activateString, 1000, "file %d of %d bytes %d of %d",CurrentRunningFile,NumberOfFiles,vme_index,CurrentFileSize); @@ -60,31 +62,29 @@ uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) if (CurrentRunningFile<NumberOfFiles) { - responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, ActivateToken, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); - responseContainer.continuous = true; - uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - size_t container_size = message_container__pack(&responseContainer, container_buffer); - my_free(responseContainer.data.data); - SendChars(container_buffer, container_size); - return OK; + last = false; } - responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, ActivateToken, true, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); + responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, ActivateToken, last, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); + responseContainer.has_continuous = true; responseContainer.continuous = true; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars(container_buffer, container_size); - if (SafeRemoveControlCallback(ActivateVersionControlId, ActivateVersionCallBackFunction )==OK) - ActivateVersionControlId = 0xFF; - else - LOG_ERROR(255,"ActivateVersionCallBackFunction"); - - if (Reboot == true) + if (last == true) { - LOG_ERROR(255,"Update successful, Rebooting in 5 seconds"); - Task_sleep (eOneSecond*5); - Power_Reset(); + if (SafeRemoveControlCallback(ActivateVersionControlId, ActivateVersionCallBackFunction )==OK) + ActivateVersionControlId = 0xFF; + else + LOG_ERROR(255,"ActivateVersionCallBackFunction"); + + if (Reboot == true) + { + LOG_ERROR(255,"Update successful, Rebooting in 5 seconds"); + Task_sleep (eOneSecond*5); + Power_Reset(); + } } return OK; @@ -165,6 +165,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); Fresult = f_unlink("//SYSINFO//PROCESSP.CFG"); Fresult |= f_rename (FullPath, "//SYSINFO//PROCESSP.CFG"); + LoadProcessParamsFromFile(); CurrentRunningFile++; break; case VERSION_FILE_DESTINATION__AlarmParams: @@ -180,6 +181,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); Fresult = f_unlink("//SYSINFO//GENHWCFG.CFG"); Fresult |= f_rename (FullPath, "//SYSINFO//GENHWCFG.CFG"); + HWConfigurationLoadFile(); CurrentRunningFile++; break; default: @@ -190,6 +192,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) } } responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, requestContainer->token, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); + responseContainer.has_continuous = true; responseContainer.continuous = true; if (Fresult!= OK) { @@ -197,7 +200,6 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) responseContainer.errormessage = "Activate Version Request error"; responseContainer.continuous = false; } - responseContainer.continuous = true; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); |
