40#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
41#define ALIGN(x,a) __ALIGN_MASK(x, a - 1)
43#define FREAD_BLOCK (8 * 1024)
47#if defined(MSVC_PLATFORM) || defined(BT8XXEMU_PLATFORM)
48#define EVE_FLASH_DIR __FILE__ "\\..\\..\\..\\common\\eve_flash"
50#define EVE_FLASH_DIR "/Test/common/eve_flash"
53#if defined(BT815_ENABLE)
54#define FILE_BLOB (EVE_FLASH_DIR "\\BT815-unified.blob")
55#elif defined(BT817_ENABLE)
56#define FILE_BLOB (EVE_FLASH_DIR "\\BT817-unified.blob")
59#define FILE_BLOB (EVE_FLASH_DIR "\\BT815-unified.blob")
62#if defined(EVE_FLASH_AVAILABLE)
74 Ftf_Write_Blob_Default(phost);
122 printf(
"Updating blob\n");
133 printf(
"Blob updated successful\n");
137 printf(
"Failed to update Blob\n");
153 printf(
"Writing blob from file %s\n", blobfile);
157 printf(
"Unable to open file: %s\n", blobfile);
160 ret = Ftf_Update_Blob(phost, pBuff);
164 return Ftf_Write_Blob_Default(phost);
178 printf(
"Writing blob default\n");
182 printf(
"Unable to open file: %s\n",
FILE_BLOB);
185 return Ftf_Update_Blob(phost, pBuff);
192void Ftf_Progress_Close() {
215#pragma warning(disable : 4996)
216 strcpy(progress.
file, filePath);
217 strcpy(progress.
fileName, fileName);
223 printf(
"Unable to open file: %s\n", filePath);
231 Ftf_Write_BlobFile(phost, filePath);
234 Ftf_Write_Blob_Default(phost);
240 printf(
"Unable to open file: %s\n", filePath);
280 while (progress->
sent < progress->
fileSize && sent < progress->bytesPerPercent) {
284 while (ramGSent < RAM_G_SIZE && progress->sent < progress->fileSize && sent < progress->bytesPerPercent) {
288 printf(
"Error on reading file: %s\n", progress->
file);
295 progress->
sent += bytes;
299 ramGSent = (ramGSent + 4095) & (~4095);
301 progress->
addr += ramGSent;
322 while (progress->
sent < progress->
fileSize && sent < progress->bytesPerPercent) {
325 if ((progress->
fileSize - progress->
sent) < fileWriteBlock) {
330 blockSize =
ALIGN(fileWriteBlock, 64);
335 printf(
"Error when reading flash\n");
340 progress->
sent += blockSize;
341 progress->
addr += blockSize;
343 printf(
"Unable to write file: %s\n", progress->
file);
388 snprintf(s, 100,
"%u %%", val * 100 / range);
416 uint32_t pc = Ftf_Progress_Write_Next(phost, progress);
417 Ftf_Progress_Ui(phost, progress);
423 Ftf_Progress_Close();
443 uint32_t pc = Ftf_Progress_Read_Next(phost, progress);
444 Ftf_Progress_Ui(phost, progress);
450 Ftf_Progress_Close();
469 if (isErase && !Ftf_Flash_Erase(phost)) {
482 printf(
"Unable to open file: %s\n", fileName);
492 while (blocklen > 0) {
519 if (!Ftf_Flash_Erase(phost)) {
530 while (file[i] != NULL) {
541 while (file[i] != NULL) {
545 printf(
"Unable to open file: %s\n", file[i]);
554 }
while (blocklen > 0);
563 memset(pBuff, 0,
sizeof(pBuff));
587 Ftf_Write_BlobFile(phost, fileName);
593 Ftf_Write_Blob_Default(phost);
597 printf(
"Cannot switch flash to fullmode\n");
606 printf(
"Unable to open file: %s\n", fileName);
617 while (sent < fileSize) {
619 while (ramGSent <
RAM_G_SIZE && sent < fileSize) {
622 printf(
"Error on reading file: %s\n", fileName);
632 ramGSent = (ramGSent + 4095) & (~4095);
653 while (file[i] != NULL) {
654 bytes = Ftf_Write_File_To_Flash_By_RAM_G(phost, file[i],
addr);
656 printf(
"Error when write file %s to RAM_G", file[i]);
678 const uint32_t blockSize = 4 * 1024;
679 uint8_t* buff = (
char*)malloc(4 * 1024);
680 address =
ALIGN(address, 64);
681 size =
ALIGN(size, 4);
683 printf(
"Unable to malloc\n");
688 printf(
"Unable to open file: %s\n", output);
695 memset(buff, 0, 4 * 1024);
696 uint32_t bytes = blockSize > size ? size : blockSize;
703 printf(
"Unable to write file: %s\n", output);
755 printf(
"Unable to open file: %s\n", file);
758 while (fileSize > 0 && sent < nbytes) {
761 printf(
"Error on f_read\n");
764 if ((sent + bytes) > nbytes) {
765 bytes = nbytes - sent;
802 while (file[i] != NULL) {
805 printf(
"Error when write file: %s\n", file[i]);
827 printf(
"Unable to open file: %s\n", output);
842 printf(
"Unable to write file: %s\n", output);
EVE_HAL_EXPORT bool EVE_Cmd_wrMem(EVE_HalContext *phost, const uint8_t *buffer, uint32_t size)
Write buffer to Coprocessor's comand fifo.
EVE_HAL_EXPORT bool EVE_Cmd_wr32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor's command fifo.
EVE's co-processor commmands.
static void EVE_CoCmd_clearCache(EVE_HalContext *phost)
Send CMD_CLEARCACHE.
static void EVE_CoCmd_flashErase(EVE_HalContext *phost)
Send CMD_FLASHERASE.
static void EVE_CoCmd_swap(EVE_HalContext *phost)
Send CMD_SWAP.
EVE_HAL_EXPORT void EVE_CoCmd_text(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, const char *s,...)
Send CMD_TEXT.
static void EVE_CoCmd_dlStart(EVE_HalContext *phost)
Send CMD_DLSTART.
static void EVE_CoCmd_progress(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t h, uint16_t options, uint16_t val, uint16_t range)
Send CMD_PROGRESS.
#define EVE_CMD_FIFO_SIZE
#define COLOR_RGB(red, green, blue)
#define FLASH_STATUS_BASIC
#define FLASH_STATUS_FULL
#define CLEAR_COLOR_RGB(red, green, blue)
EVE_HAL_EXPORT uint32_t EVE_Hal_rd32(EVE_HalContext *phost, uint32_t addr)
Read 4 bytes from Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_rdMem(EVE_HalContext *phost, uint8_t *result, uint32_t addr, uint32_t size)
Read a block data from Coprocessor's memory.
EVE_HAL_EXPORT void EVE_Hal_wrMem(EVE_HalContext *phost, uint32_t addr, const uint8_t *buffer, uint32_t size)
Write a buffer to Coprocessor's memory.
EVE_HAL_EXPORT uint8_t EVE_Hal_rd8(EVE_HalContext *phost, uint32_t addr)
Read 8 bits from Coprocessor's memory.
unsigned long long uint64_t
int FileIO_File_Read(char *buffer, long bytes)
int FileIO_File_Seek(unsigned long offset)
int FileIO_File_Write(const char *buffer, long buffersize)
int FileIO_File_Open(const char *filePath, enum _FILEIO_E_FOPEN e)
int FileIO_File_To_Buffer(const char *file, char *buff, long offset, int size, int *byteCount)
Read a whole file to a buffer.
File read-write library for Eve application, support a unique interface for every platform.
uint32_t Ftf_Write_File_nBytes_To_RAM_G(EVE_HalContext *phost, const char *file, uint32_t addr, int nbytes, int offset)
Transfer a file to RAM_G.
uint32_t Ftf_Write_File_To_RAM_G(EVE_HalContext *phost, const char *file, uint32_t addr)
Transfer a file to RAM_G.
#define FILE_BLOB
Use BT815 blob as default.
uint32_t Ftf_Write_FileArr_To_RAM_G(EVE_HalContext *phost, char *file[], uint32_t addr)
Transfer a file list into RAM_G.
uint32_t Ftf_Read_File_From_RAM_G(EVE_HalContext *phost, const uint8_t *output, uint32_t startAddress, uint32_t size)
Read data on RAM_G into a file.
File transfer interface from host to flash.
#define FTF_PROGESS_WRITE
uint32_t FlashHelper_SwitchFullMode(EVE_HalContext *phost)
Flash_Cmd_Status_t FlashHelper_Read(EVE_HalContext *phost, uint32_t dest_ram, uint32_t src_flash, uint32_t num, uint8_t *read_data)
uint32_t FlashHelper_SwitchState(EVE_HalContext *phost, uint8_t nextState)
Flash_Cmd_Status_t FlashHelper_Update(EVE_HalContext *phost, uint32_t dest_flash, uint32_t src_ram, uint32_t num)
void EVE_Cmd_waitFlush(EVE_HalContext *host)
#define FLASH_WRITE_ALIGN_BYTE