Sfoglia il codice sorgente

更新CPU工程:
1. 优化CPU工程board.h部分代码异常问题。
2. 优化CPU工程sdmmc控制器出现数据错误时卡死问题。
3. 优化CPU工程ff_sddisk.c驱动中SD与emmc兼容性问题。
4. 修改CPU工程ff_sfdisk.c驱动中部分代码实现逻辑。
5. 优化CPU工程usb/sd卡demo中差分升级部分写入按OTA_RW_SIZE单位操作(部分flash需256K对其擦除)。
6. 优化CPU工程VG库代码编译警告问题。
7. 优化CPU工程spi nor flash infineon芯片一线速率最高支持50M问题。

helen 2 giorni fa
parent
commit
746636630c

+ 11 - 7
amt630hv160-freertos-beta/ArkmicroFiles/libboard-amt630hv160/include/board.h

@@ -402,13 +402,17 @@
 #define DEVICE_TYPE_SELECT			EMMC_FLASH					//需要与MCU工程amt630hv160_conf.h中CPU_DEVICE_TYPE_SELECT对应
 #define MCU_DEVICE_TYPE_SELECT		SPI_NOR_FLASH				//需要与MCU工程amt630hv160_conf.h中DEVICE_TYPE_SELECT对应
 
-#if DEVICE_TYPE_SELECT == SPI_NOR_FLASH
-//#define SPI0_QSPI_MODE
-//#define NORFLASH_ERASE_METHOD_INFINEON						//使用英飞凌擦除方法.前128KB使用4KB擦除粒度.后面使用256KB擦除粒度.
-#elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
+#if DEVICE_TYPE_SELECT == SPI_NAND_FLASH
 #define SPI2_QSPI_MODE
 #define SPI_NOR_FLASH_SUPPORT
-#else
+#endif
+
+#if DEVICE_TYPE_SELECT == SPI_NOR_FLASH || defined(SPI_NOR_FLASH_SUPPORT)
+//#define SPI0_QSPI_MODE
+//#define NORFLASH_ERASE_METHOD_INFINEON						//使用英飞凌擦除方法.前128KB使用4KB擦除粒度.后面使用256KB擦除粒度.
+#endif
+
+#if DEVICE_TYPE_SELECT == EMMC_FLASH
 #if DEVICE_TYPE_SELECT != MCU_DEVICE_TYPE_SELECT
 #undef DW_SPI0_SUPPORT
 #endif
@@ -668,7 +672,6 @@ emmc DDR address space
 #define ULOG_ASYNC_OUTPUT_THREAD_STACK	2048
 #define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY	10
 /*********************************************/
-#endif
 
 /********** carlink ec flash storage configuration ************/
 /* Note: The address and size should be redefined by the user */
@@ -683,4 +686,5 @@ emmc DDR address space
 #else
 /* re-define CARLINK_EC_FLASH_OFFSET and CARLINK_EC_FLASH_SIZE for spi nand or emmc */
 #endif
-/*********************************************/
+/*********************************************/
+#endif  /* _BOARD_H */

+ 6 - 0
amt630hv160-freertos-beta/ArkmicroFiles/libcpu-amt630hv160/source/sdmmc.c

@@ -877,6 +877,9 @@ static int ark_mmc_write_pio(struct mmc_driver *mmc_drv)
 
 		status = readl(mmc_obj->base + SDMMC_MINTSTS);
 		writel(SDMMC_INT_TXDR, mmc_obj->base + SDMMC_MINTSTS);
+
+		if (status & SDMMC_INT_DATA_ERROR)
+			return -1;
 	} while (status & SDMMC_INT_TXDR); /* if TXDR write again */
 
 	return 0;
@@ -927,6 +930,9 @@ static int ark_mmc_read_pio(struct mmc_driver *mmc_drv, bool dto)
 		} while (remain);
 		status = readl(mmc_obj->base + SDMMC_MINTSTS);
 		writel(SDMMC_INT_RXDR, mmc_obj->base + SDMMC_RINTSTS);
+
+		if (status & SDMMC_INT_DATA_ERROR)
+			return -1;
 	/* if the RXDR is ready read again */
 	} while ((status & SDMMC_INT_RXDR) ||
 		 (dto && MMC_GetWaterlevel(mmc_obj)));

+ 39 - 34
amt630hv160-freertos-beta/FreeRTOS-Plus/FreeRTOS-FAT/portable/ff_sddisk.c

@@ -218,7 +218,6 @@ struct mmcsd_card *xCardInfo;
 			/* Initialise the created disk structure. */
 			memset( pxDisk, '\0', sizeof( *pxDisk ) );
 
-
 			if( xPlusFATMutex == NULL)
 			{
 				xPlusFATMutex = xSemaphoreCreateRecursiveMutex();
@@ -259,27 +258,29 @@ struct mmcsd_card *xCardInfo;
 					pxDisk->xStatus.bPartitionNumber = xPartitionNumber;
 					if( FF_SDDiskMount( pxDisk ) == 0 )
 					{
+						if (xCardInfo->card_type == CARD_TYPE_MMC) {
 #if DEVICE_TYPE_SELECT == EMMC_FLASH
-						if ( PartitionAndFormatEmmcDisk(pxDisk) != FF_ERR_NONE )
-						{
+							if ( PartitionAndFormatEmmcDisk(pxDisk) != FF_ERR_NONE )
+							{
+								FF_PRINTF( "FF_SDDiskInit: Mounted SD-card/emmc fail.\n");
+								FF_SDDiskDelete( pxDisk );
+								pxDisk = NULL;
+							}
+							else
+							{
+								if( pcName == NULL )
+								{
+									pcName = "/";
+								}
+								FF_FS_Add( pcName, pxDisk );
+								FF_PRINTF( "FF_SDDiskInit: Mount SD-card/emmc as root \"%s\"\n", pcName );
+							}
+#endif
+						} else {
 							FF_PRINTF( "FF_SDDiskInit: Mounted SD-card/emmc fail.\n");
 							FF_SDDiskDelete( pxDisk );
 							pxDisk = NULL;
 						}
-						else
-						{
-							if( pcName == NULL )
-							{
-								pcName = "/";
-							}
-							FF_FS_Add( pcName, pxDisk );
-							FF_PRINTF( "FF_SDDiskInit: Mount SD-card/emmc as root \"%s\"\n", pcName );
-						}
-#else
-						FF_PRINTF( "FF_SDDiskInit: Mounted SD-card/emmc fail.\n");
-						FF_SDDiskDelete( pxDisk );
-						pxDisk = NULL;
-#endif
 					}
 					else
 					{
@@ -350,6 +351,7 @@ BaseType_t FF_SDDiskFormatRemount( FF_Disk_t *pxDisk, const char *pcName )
 {
 FF_Error_t xError;
 BaseType_t xReturn = pdFAIL;
+struct mmcsd_card *xCardInfo = (struct mmcsd_card *)pxDisk->pvTag;
 
 	xError = FF_Unmount( pxDisk );
 
@@ -359,27 +361,30 @@ BaseType_t xReturn = pdFAIL;
 	}
 	else
 	{
+		if (xCardInfo->card_type == CARD_TYPE_MMC) {
 #if DEVICE_TYPE_SELECT == EMMC_FLASH
-		if ( PartitionAndFormatEmmcDisk(pxDisk) != FF_ERR_NONE )
-		{
-			FF_PRINTF( "FF_SDDiskFormatRemount: PartitionAndFormatEmmcDisk fail.\n");
-			FF_SDDiskDelete( pxDisk );
-			pxDisk = NULL;
-		}
-		else
-		{
-			if( pcName == NULL )
+			if ( PartitionAndFormatEmmcDisk(pxDisk) != FF_ERR_NONE )
 			{
-				pcName = "/";
+				FF_PRINTF( "FF_SDDiskFormatRemount: PartitionAndFormatEmmcDisk fail.\n");
+				FF_SDDiskDelete( pxDisk );
+				pxDisk = NULL;
+			}
+			else
+			{
+				if( pcName == NULL )
+				{
+					pcName = "/";
+				}
+				FF_FS_Add( pcName, pxDisk );
+				FF_PRINTF( "FF_SDDiskFormatRemount: Mount SD-card/emmc as root \"%s\"\n", pcName );
+				xReturn = pdPASS;
 			}
-			FF_FS_Add( pcName, pxDisk );
-			FF_PRINTF( "FF_SDDiskFormatRemount: Mount SD-card/emmc as root \"%s\"\n", pcName );
-		}
-#else
-		FF_PRINTF( "FF_SDDiskInit: Mounted SD-card/emmc fail.\n");
-		FF_SDDiskDelete( pxDisk );
-		pxDisk = NULL;
 #endif
+		} else {
+			FF_PRINTF( "FF_SDDiskInit: Mounted SD-card/emmc fail.\n");
+			FF_SDDiskDelete( pxDisk );
+			pxDisk = NULL;
+		}
 	}
 
 	return xReturn;

+ 23 - 22
amt630hv160-freertos-beta/FreeRTOS-Plus/FreeRTOS-FAT/portable/ff_sfdisk.c

@@ -47,6 +47,8 @@
 #include "sfud.h"
 #include "snfud.h"
 
+
+#if (DEVICE_TYPE_SELECT == SPI_NOR_FLASH) || (DEVICE_TYPE_SELECT == SPI_NAND_FLASH)
 /* Misc definitions. */
 #define sfSIGNATURE 			0x41404342UL
 #define sfHUNDRED_64_BIT		( 100ull )
@@ -67,7 +69,6 @@ static int32_t prvFFWrite( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t
 /*-----------------------------------------------------------*/
 
 /*_RB_ Variables require a comment block where appropriate. */
-static sfud_flash *sflash;
 static SemaphoreHandle_t xPlusFATMutex;
 
 /*-----------------------------------------------------------*/
@@ -78,17 +79,17 @@ static int32_t prvFFRead( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t
 	/*_RB_ Many of the comments in this file apply to other functions in the file. */
 
 	if( ( pxDisk != NULL ) &&
-		( sflash != NULL ) &&
+		( pxDisk->pvTag != NULL ) &&
 		( pxDisk->ulSignature == sfSIGNATURE ) &&
 		( pxDisk->xStatus.bIsInitialised != pdFALSE ) &&
 		( ulSectorNumber < pxDisk->ulNumberOfSectors ) &&
 		( ( pxDisk->ulNumberOfSectors - ulSectorNumber ) >= ulSectorCount ) )
 	{
 #if DEVICE_TYPE_SELECT == SPI_NOR_FLASH
-		iReturn = sfud_read(sflash, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
+		iReturn = sfud_read((sfud_flash *)pxDisk->pvTag, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
 			ulSectorCount * sfSECTOR_SIZE, pucBuffer);
-#else	//elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
-		iReturn = snfud_read(sflash, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
+#elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
+		iReturn = snfud_read((sfud_flash *)pxDisk->pvTag, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
 			ulSectorCount * sfSECTOR_SIZE, pucBuffer);
 #endif
 		/*_RB_ I'm guessing 4096 is a sector size, but that needs to be clear.
@@ -125,17 +126,17 @@ static int32_t prvFFWrite( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t
 	int32_t iReturn;
 
 	if( ( pxDisk != NULL ) &&
-		( sflash != NULL ) &&
+		( pxDisk->pvTag != NULL ) &&
 		( pxDisk->ulSignature == sfSIGNATURE ) &&
 		( pxDisk->xStatus.bIsInitialised != pdFALSE ) &&
 		( ulSectorNumber < pxDisk->ulNumberOfSectors ) &&
 		( ( pxDisk->ulNumberOfSectors - ulSectorNumber ) >= ulSectorCount ) )
 	{
 #if DEVICE_TYPE_SELECT == SPI_NOR_FLASH
-		iReturn = sfud_erase_write(sflash, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
+		iReturn = sfud_erase_write((sfud_flash *)pxDisk->pvTag, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
 			ulSectorCount * sfSECTOR_SIZE, pucBuffer);
-#else	//elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
-		iReturn = snfud_erase_write(sflash, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
+#elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
+		iReturn = snfud_erase_write((sfud_flash *)pxDisk->pvTag, sfDISK_MEDIA_OFFSET + ulSectorNumber * sfSECTOR_SIZE,
 			ulSectorCount * sfSECTOR_SIZE, pucBuffer);
 #endif
 		if( iReturn == 0 ) /*_RB_ Signed/unsigned mismatch (twice!) */
@@ -164,17 +165,15 @@ static int32_t prvFFWrite( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t
 #if DEVICE_TYPE_SELECT == SPI_NAND_FLASH
 static void prvFFFlushCache( struct xFFDisk * pxDisk )
 {
-	if( sflash != NULL )
-	{
-		snfud_flush(sflash);
+	if(( pxDisk != NULL ) && ( pxDisk->pvTag != NULL )) {
+		snfud_flush((sfud_flash *)pxDisk->pvTag);
 	}
 }
 
 static void prvFFFormat( struct xFFDisk * pxDisk )
 {
-	if( sflash != NULL )
-	{
-		snfud_fs_format(sflash);
+	if(( pxDisk != NULL ) && ( pxDisk->pvTag != NULL )) {
+		snfud_fs_format((sfud_flash *)pxDisk->pvTag);
 	}
 }
 #endif
@@ -232,14 +231,15 @@ static FF_Error_t PartitionAndFormatSFDisk( FF_Disk_t * pxDisk )
 /* mount an spi-flash partition */
 FF_Disk_t *FF_SFDiskInit( const char *pcName )
 {
-FF_Error_t xFFError;
-BaseType_t xPartitionNumber = 0;
-FF_CreationParameters_t xParameters;
-FF_Disk_t * pxDisk;
+	FF_Error_t xFFError;
+	BaseType_t xPartitionNumber = 0;
+	FF_CreationParameters_t xParameters;
+	FF_Disk_t * pxDisk;
+	sfud_flash * sflash;
 
 #if DEVICE_TYPE_SELECT == SPI_NOR_FLASH
 	sflash = sfud_get_device(0);
-#else	//elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
+#elif DEVICE_TYPE_SELECT == SPI_NAND_FLASH
 	sflash = snfud_get_device(0);
 #endif
 
@@ -253,14 +253,13 @@ FF_Disk_t * pxDisk;
 			/* Initialise the created disk structure. */
 			memset( pxDisk, '\0', sizeof( *pxDisk ) );
 
-
 			if( xPlusFATMutex == NULL)
 			{
 				xPlusFATMutex = xSemaphoreCreateRecursiveMutex();
 			}
-			//pxDisk->ulNumberOfSectors = sflash->chip.capacity / sfSECTOR_SIZE;
 			pxDisk->ulNumberOfSectors = OTA_MEDIA_SIZE / sfSECTOR_SIZE;
 			pxDisk->ulSignature = sfSIGNATURE;
+			pxDisk->pvTag = sflash;
 #if DEVICE_TYPE_SELECT == SPI_NAND_FLASH
 			pxDisk->fnFlushApplicationHook = prvFFFlushCache;
 #endif
@@ -406,6 +405,7 @@ BaseType_t xReturn = pdFAIL;
 			}
 			FF_FS_Add( pcName, pxDisk );
 			FF_PRINTF( "FF_SDDiskFormatRemount: Mount SPI nor/nand Flash as root \"%s\"\n", pcName );
+			xReturn = pdPASS;
 		}
 	}
 
@@ -523,4 +523,5 @@ BaseType_t xReturn = pdPASS;
 
 	return xReturn;
 }
+#endif
 /*-----------------------------------------------------------*/

+ 2 - 2
amt630hv160-freertos-beta/demo/sdmmc_test_demo.c

@@ -26,7 +26,7 @@ static int sdcard_read_test(void)
 	size_t wrsize;
 	uint32_t offset;
 
-	filebuf = pvPortMalloc(0x10000);
+	filebuf = pvPortMalloc(OTA_RW_SIZE);
 	if (!filebuf) {
 		printf("%s filebuf malloc fail.\n", __func__);
 		return -1;
@@ -48,7 +48,7 @@ static int sdcard_read_test(void)
 		flash_erase(OTA_MEDIA_OFFSET, filesize);
 
 		while (leftsize) {
-			wrsize = leftsize > 0x10000 ? 0x10000 : leftsize;
+			wrsize = leftsize > OTA_RW_SIZE ? OTA_RW_SIZE : leftsize;
 			ff_fread(filebuf, 1, wrsize, fp);
 			flash_write(offset, wrsize, filebuf);
 			offset += wrsize;

+ 2 - 2
amt630hv160-freertos-beta/demo/usb_test_demo.c

@@ -38,7 +38,7 @@ static void usb_read_thread(void *para)
 			size_t wrsize;
 			uint32_t offset;
 
-			filebuf = pvPortMalloc(0x10000);
+			filebuf = pvPortMalloc(OTA_RW_SIZE);
 			if (!filebuf) {
 				printf("%s filebuf malloc fail.\n", __func__);
 				continue;
@@ -59,7 +59,7 @@ static void usb_read_thread(void *para)
 				flash_erase(OTA_MEDIA_OFFSET, filesize);
 
 				while (leftsize) {
-					wrsize = leftsize > 0x10000 ? 0x10000 : leftsize;
+					wrsize = leftsize > OTA_RW_SIZE ? OTA_RW_SIZE : leftsize;
 					ff_fread(filebuf, 1, wrsize, fp);
 					flash_write(offset, wrsize, filebuf);
 					offset += wrsize;

+ 6 - 2
amt630hv160-freertos-beta/lib/awtk/awtk/3rd/vglite/vgcanvas_nanovg_vglite.c

@@ -98,7 +98,9 @@ typedef struct _vgcanvas_nanovg_t {
 
 extern void ark_g2d_invalidate_cache(uint32_t address, uint32_t width, uint32_t height, uint32_t stride, uint32_t pxSize);
 extern void ark_g2d_clean_cache(uint32_t address, uint32_t width, uint32_t height, uint32_t stride, uint32_t pxSize);
+#ifdef VGLITE_FONT_CACHE
 static void font_cache_init();
+#endif
 //static void font_cache_deinit();
 
 void vg_lite_bus_error_handler(void) {
@@ -1541,7 +1543,9 @@ void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* d
 	uint32_t bounds[4] = {dst->x, dst->y - dst->h, dst->w, dst->y};
 	int32_t x0, x1, y0, y1;
 	uint32_t start_address, rt_pixsize, dataSize = 0, vertFlag = 0;
+#ifdef VGLITE_FONT_CACHE
 	void* tempData;
+#endif
 	vg_lite_enable_scissor();
 
 	x0 = (dst->x < r->x) ? r->x : dst->x;
@@ -1571,7 +1575,7 @@ void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* d
 		vertFlag = 1;
 		dataSize = get_vglite_vertor_font(vertices, num_vertices);
 		if (dataSize <= 0) {
-			printf("dataSize %d,glyphIndex:%d,chr:%lc\r\n", (uint32_t)tempData, glyphIndex, chr);
+			printf("dataSize %d,glyphIndex:%d,chr:%d\r\n", dataSize, glyphIndex, (int)chr);
 		}
 #ifdef VGLITE_FONT_CACHE
 #ifndef FONT_CACHE_CH
@@ -1608,6 +1612,7 @@ void vglite_draw_glyph_truetype(stbtt_fontinfo* sf, wchar_t chr, const rect_t* d
 	}
 	CHECK_ERROR(vg_lite_draw(rt, &pathx, VG_LITE_FILL_NON_ZERO, &matrix, VG_LITE_BLEND_SRC_OVER, color));
 	CHECK_ERROR(vg_lite_flush());
+
 	vg_lite_clear_path(&pathx);
 	vg_lite_disable_scissor();
 	if (vertFlag) {
@@ -1673,7 +1678,6 @@ void vg_lite_clear_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t col
 	vg_lite_rectangle_t dstRect = {x, y, w, h};
 	vg_lite_color_t vg_color = color;
 	vg_lite_buffer_t* rt;
-	ret_t ret;
 	rt = (vg_lite_buffer_t*)vglite_get_render_target();
 	if (!rt) {
 		printf("rt not found, %d\r\n", __LINE__);

+ 5 - 0
amt630hv160-freertos-beta/lib/sfud/port/sfud_port.c

@@ -37,8 +37,13 @@
 #include "FreeRTOS.h"
 #include "errno.h"
 #include "os_adapt.h"
+#include "board.h"
 
+#ifdef NORFLASH_ERASE_METHOD_INFINEON
+#define SFUD_SPI_MAX_HZ		50625000			//CPU (<=50.625MHz)	MCU (<=50.625MHz)
+#else
 #define SFUD_SPI_MAX_HZ		81000000			//CPU (<=81MHz)	MCU (<=50.625MHz)
+#endif
 #define SFUD_QSPI_MAX_HZ	50625000			//CPU (<=50.625MHz)	MCU (<=50.625MHz)