From d723bb19742e1522c5859fba5ea5a75b5e902ac1 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 5 Feb 2019 14:50:38 +0200 Subject: IDS bug fix (microstepping) #217 solved --- Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index a12c02867..ceb341c38 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -49,9 +49,9 @@ FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; #define MAX_CHUNK_LENGTH 2000 -int FileLength = 0; -int FileReceivedLength = 0; -int FileSentLength = 0; +uint32_t FileLength = 0; +uint32_t FileReceivedLength = 0; +uint32_t FileSentLength = 0; static char g_cCwdBuf[50] = "/"; uint32_t WrittenBytes = 0; uint32_t ReadBytes = 0; -- cgit v1.3.1 From a73a6f639445640123705f3e68e6a7ecd654ef41 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 6 Feb 2019 11:30:20 +0200 Subject: flash programming improved, working --- Software/Embedded_SW/Embedded/.cproject | 2 +- .../Embedded/Common/SWUpdate/FileSystem.c | 5 +- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 16 ++--- .../Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c | 72 ++++++++++++++++++---- .../Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h | 4 +- .../Drivers/I2C_Communication/DAC/Blower.c | 2 +- .../Embedded/Drivers/USB_Communication/USBCDCD.c | 7 +++ Software/Embedded_SW/Embedded/Embedded.cfg | 6 ++ Software/Embedded_SW/Embedded/Main.c | 6 +- Software/Embedded_SW/Embedded/tm4c129xnczad.cmd | 2 +- 10 files changed, 91 insertions(+), 31 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c') diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 38422568f..89dc72b30 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -169,7 +169,7 @@ - + diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 11fbf86c4..d39c335ef 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -509,9 +509,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,7 +588,6 @@ 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; diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 35bde3636..dcb8cf8f2 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -24,13 +24,12 @@ #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; @@ -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,19 @@ 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); + + Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, false); 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"; diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c index ab0775af3..248c9e66d 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c @@ -14,8 +14,8 @@ #include "FPGA_Programming_Up.h" #include - - +#include "Modules/Control/Control.h" +#include "Modules/Control/MillisecTask.h" extern short int main_vme(); @@ -69,8 +69,8 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot FPGA_JTAG.GPI_TDO.Pin = GPIO_PIN_7; break; default: - //return error - break; + return FR_INVALID_OBJECT; + //break; } FileHandlevme = malloc(sizeof(FIL)); @@ -79,7 +79,7 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot { return(fresult); } - main_vme(); + fresult = main_vme(); @@ -91,14 +91,62 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot return fresult; } +/****************************************************************************** + * ======== messageTsk ======== + * Task for this function is created statically. See the project's .cfg file. + * this message task is created statically in system initialization, + ******************************************************************************/ +Mailbox_Handle FPGALoadMsgQ = NULL; +typedef enum +{ + OneFPGALoad, +}FPGALoadMessages; -void Test_Programing_Up() +typedef struct FPGALoadMessage{ + uint16_t messageId; + FPGA_ID FPGA_Id; + char * FullPath; + bool IncludeReboot; +}FPGALoadMessageStruc; + +FRESULT FPGA_Programming_Request(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot) { - char FullPath1[] = "0://FPGAJTAG//F1TangoF.vme"; - char FullPath2[] = "0://FPGAJTAG//F2TangoF.vme"; - char FullPath3[] = "0://FPGAJTAG//F3_Tango.vme"; - FPGA_Programming_Up(FPGA1, FullPath1, FALSE); - FPGA_Programming_Up(FPGA2, FullPath2, FALSE); - FPGA_Programming_Up(FPGA3, FullPath3, FALSE); + FPGALoadMessageStruc FPGALoadMessage; + + FPGALoadMessage.messageId = OneFPGALoad; + FPGALoadMessage.FPGA_Id = FPGA_Id; + FPGALoadMessage.FullPath = FullPath; + FPGALoadMessage.IncludeReboot = IncludeReboot; + if (FPGALoadMsgQ != NULL) + Mailbox_post(FPGALoadMsgQ , &FPGALoadMessage, BIOS_NO_WAIT); + return FR_OK; +} + + +void FPGALoadTask(UArg arg0, UArg arg1) +{ + FPGALoadMessageStruc FPGALoadMessage; + Error_Block eb; + Error_init(&eb); + + FPGALoadMsgQ = Mailbox_create(sizeof(FPGALoadMessageStruc), 4, NULL,&eb); + + while(1) + { + Mailbox_pend(FPGALoadMsgQ , &FPGALoadMessage, BIOS_WAIT_FOREVER); + switch (FPGALoadMessage.messageId) + { + case OneFPGALoad: + ControlStop(); + MillisecStop(); + FPGA_Programming_Up(FPGALoadMessage.FPGA_Id,FPGALoadMessage.FullPath,FPGALoadMessage.IncludeReboot); + ControlStart(); + MillisecStart(); + //printf( "Finished Load FPGA %d File %s\n", FPGALoadMessage.FPGA_Id,FPGALoadMessage.FullPath ); + break; + default: + break; + } + } } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h index 91ad2a61a..b752f24b3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h @@ -32,8 +32,10 @@ typedef struct GPIO GPI_TDO; //GPI FPGA->MCU }FPGA_JTAG_GPIO; +//Independent task non blocking call +FRESULT FPGA_Programming_Request(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); +//direct blocking call FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); - #endif /* DRIVERS_FPGA_FULL_VME_FPGA_PROGRAMMING_UP_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c index 37789abb1..940cd136c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -217,7 +217,7 @@ uint32_t Gradual_Increase_Blower(uint32_t Initial_mV,uint32_t Target_mV) uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV) { Control_Voltage_To_Blower(Initial_mV); - Report("Finished Increasing blower",__FILE__,__LINE__,(int)Initial_mV,RpWarning,(int)millisecondCounter,0); + Report("Cancelled Increasing blower",__FILE__,__LINE__,(int)Initial_mV,RpWarning,(int)millisecondCounter,0); if (RemoveControlCallback(BlowerControlId, Gradual_Increase_Blower_Callback )==OK) { Report("Remove control callback",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 4c6b18030..b3ab21f0a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -810,6 +810,13 @@ void USBCDCD_init(void) /* State specific variables */ state = USBCDCD_STATE_UNCONFIGURED; + /*added lines for drivers version 4.178*/ + uint32_t g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000); + USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock); + //uint32_t ui32PLLRate; + //SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate); + //USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate); + /* Set the USB stack mode to Device mode with VBUS monitoring */ USBStackModeSet(0, eUSBModeForceDevice, 0); diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 97c95a452..45ed20a54 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -116,6 +116,12 @@ MillisecTaskParams.stackSize = 2048; MillisecTaskParams.priority = 12; Program.global.millisec = Task.create("&MillisecTask", MillisecTaskParams); +var FPGALoad = new Task.Params(); +FPGALoad.instance.name = "FPGALoad"; +FPGALoad.stackSize = 4096; +FPGALoad.priority = 5; +Program.global.FPGALoad = Task.create("&FPGALoadTask", FPGALoad); + var ControlTaskParams = new Task.Params(); ControlTaskParams.instance.name = "control"; ControlTaskParams.stackSize = 2048; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 5e96abaf6..b13bab1d5 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -30,8 +30,6 @@ #include #include "Sys_PinOut_Config/MCU_MAIN_pinout.h" -#include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" - /* #include "Drivers/SPI_SDCARD/SDSPI.h" #include "Drivers/SPI_SDCARD/SDCardSPI.h" @@ -203,9 +201,7 @@ int main(void) } //Control_File_System();// test file system //IDS_ModuleInit(); -/* - Test_Programing_Up() -*/ + //GetFiles(); - to start jtag //GetVmeByte(); diff --git a/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd b/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd index d63d890cd..25916dae2 100644 --- a/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd +++ b/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd @@ -42,7 +42,7 @@ MEMORY { /* Application stored in and executes from internal flash */ - FLASH (RX) : origin = APP_BASE, length = 0x000B0000 + FLASH (RX) : origin = APP_BASE, length = 0x000D0000 /* Application stored in and executes from internal flash */ FLASH_RAM (RWX) : origin = FLASH_RAM_BASE, length = 0x00030000 /* Application uses internal RAM for data */ -- cgit v1.3.1