aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Common/SWUpdate
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-02-10 18:28:41 +0200
committerShlomo Hecht <shlomo@twine-s.com>2019-02-10 18:28:41 +0200
commita65868d1d77b1929b855abd0c19bdc08bc9cee9d (patch)
tree09486bed718fb096914780f33313fb82a0207c87 /Software/Embedded_SW/Embedded/Common/SWUpdate
parent82179e1b69b62b971a04af571979e7d10c60fd7a (diff)
parentac9678197fc6142595089155d98442239a64e6d7 (diff)
downloadTango-a65868d1d77b1929b855abd0c19bdc08bc9cee9d.tar.gz
Tango-a65868d1d77b1929b855abd0c19bdc08bc9cee9d.zip
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate')
-rw-r--r--Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c52
-rw-r--r--Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c21
2 files changed, 16 insertions, 57 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
index 11fbf86c4..60873243c 100644
--- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
+++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c
@@ -48,7 +48,7 @@ FIL *UploadFileHandle = 0; //the system supports a single active file
FIL *DownloadFileHandle = 0; //the system supports a single active file
char FileHandleChar[5];
char ErrorMsg[100];
-#define MAX_CHUNK_LENGTH 2000
+#define MAX_CHUNK_LENGTH 4000
int32_t FileLength = 0;
int32_t FileReceivedLength = 0;
int32_t FileSentLength = 0;
@@ -422,51 +422,10 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer)
DeleteResponse response = DELETE_RESPONSE__INIT;
- DIR dir;
FILINFO* fno = 0;
//int NumOfFiles = 0;
FRESULT Fresult = FR_OK;
- /*Fresult |= f_opendir(&dir, g_cCwdBuf);
- if(Fresult != FR_OK)
- {
- LOG_ERROR (Fresult,"f_write error");
- }
- else
- {
-
- fno = my_malloc(sizeof(FILINFO));
- memset (fno,0,sizeof(FILINFO));
- Fresult = f_stat(request->path,fno);
- if (Fresult == FR_OK)
- {
- if (isDirectory(fno->fattrib))
- {
- //============================
- Fresult = f_opendir(&dir, request->path);
- if (Fresult == FR_OK)
- {
- Fresult = f_readdir(&dir, &fno);
- if (Fresult == FR_OK)
- {
- if(fno->fname[0] ==0)
- {
- //no files
- Fresult = f_unlink(request->path);
- }
- else
- {
- LOG_ERROR (fno,"Directory not empty");
- }
- }
- }
- }
- else
- {
- Fresult = f_unlink(request->path);
- }
- }
- }*/
Fresult = f_unlink(request->path);
responseContainer = createContainer(MESSAGE_TYPE__DeleteResponse, requestContainer->token, false, &response, &delete_response__pack, &delete_response__get_packed_size);
@@ -509,9 +468,9 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer)
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
response.has_capacity = true;
- response.capacity = tot_sect/2;
+ response.capacity = tot_sect/2*1024;
response.has_freespace = true;
- response.freespace = fre_sect/2;
+ response.freespace = fre_sect/2*1024;
response.root = "/";
}
@@ -588,16 +547,11 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer)
FilesInfo[i] = &Data[i];
Data[i].has_attribute = true;
Data[i].attribute = fno[i]->fattrib;
- Data[i].has_length = true;
Data[i].name = fno[i]->fname;
Data[i].has_length = true;
Data[i].length = fno[i]->fsize;
Data[i].lastmodifieddate = fno[i]->fdate;
Data[i].lastmodifiedtime = fno[i]->ftime;
- //strcpy(FullPath[i],request->path);
- //strcat(FullPath[i],'\\');
- //strcat(FullPath[i],&fno[i]->fname);
- //sprintf (FullPath[i], "%s/%s", request->path, &fno[i]->fname);
if (i==0)
usnprintf(&FullPath[i], 50, "%s", request->path);
else
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c
index 35bde3636..e029bf2ce 100644
--- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c
+++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c
@@ -24,16 +24,15 @@
#include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h"
#include "Common/SWUpdate/FileSystem.h"
-
uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer)
{
- uint32_t status = OK;
void* buffer = NULL;
uint32_t Bytes = 0;
char SWINFOPath[100];
+ char FullPath[50];
FRESULT Fresult = FR_OK;
int File_i;
-
+ bool Reboot = false;
MessageContainer responseContainer;
ActivateVersionRequest* request = activate_version_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
@@ -41,12 +40,13 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer)
ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT;
VersionPackageDescriptor* VersionPackage;// = VERSION_PACKAGE_DESCRIPTOR__INIT;
+ FPGA_ID FileDestinationToFPGAId[VERSION_FILE_DESTINATION__FPGA3+1] = {MAX_FPGA,FPGA1,FPGA2,FPGA3};
+
strcpy (SWINFOPath,request->path);
- strcat(SWINFOPath,"//SWINFO.DAT");
+ strcat(SWINFOPath,"/file1.pck");
Fresult = FileRead(SWINFOPath, &Bytes, &buffer);
-
if (Fresult == FR_OK)
{
VersionPackage = version_package_descriptor__unpack(NULL,Bytes,buffer);
@@ -61,17 +61,22 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer)
case VERSION_FILE_DESTINATION__FPGA3:
//validate
//update
- Fresult = FPGA_Programming_Up( VersionPackage->filedescriptors[File_i]->destination, VersionPackage->filedescriptors[File_i]->filename, false);
+ usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename);
+ if (VersionPackage->filedescriptors[File_i]->destination == VERSION_FILE_DESTINATION__FPGA3)
+ Reboot = true;
+ else
+ Reboot = false;
+ Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, Reboot);
break;
default:
- LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong fule update Destination");
+ LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong file update Destination");
Fresult = FR_INVALID_NAME;
break;
}
}
}
responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, requestContainer->token, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size);
- if (status!= OK)
+ if (Fresult!= OK)
{
responseContainer.error = FileError_to_ErrorCode[Fresult];
responseContainer.errormessage = "Activate Version Request error";