Ejemplo n.º 1
0
void pp_soft_wdt_feed_local()
{
	struct rst_info rst_info;
	rst_info.exccause = RSR(EXCCAUSE);
	rst_info.epc1 = RSR(EPC1);
	rst_info.epc2 = RSR(EPC2);
	rst_info.epc3 = RSR(EPC3);
	rst_info.excvaddr = RSR(EXCVADDR);
	rst_info.depc = RSR(DEPC);
	if(wdt_flg == true) {
		rst_info.reason = REASON_SOFT_WDT_RST; // =3
		system_rtc_mem_write(0, &rst_info, sizeof(rst_info));
		ets_intr_lock();
		Wait_SPI_Idle(flashchip);
		Cache_Read_Enable_New();
		system_restart_local();
	}
	else {
		rst_info.reason = REASON_WDT_RST; // =1
		system_rtc_mem_write(0, &rst_info, sizeof(rst_info));
#if DEF_SDK_VERSION >= 1119
		wDev_MacTim1Arm(soft_wdt_interval);
#else
		ets_timer_disarm(SoftWdtTimer);
		ets_timer_arm_new(SoftWdtTimer, soft_wdt_interval, 0, 1);
#endif
		wdt_flg = true;
		pp_post(12);
	}
}
Ejemplo n.º 2
0
void pvShowMalloc()
{
	BlockLink_t *pxIterator;
//ets_printf("sh0:%d,%d,",uxHeapStructSize,sizeof( BlockLink_t ));
	if(uxHeapStructSize < sizeof( BlockLink_t ))
		return;
	ETS_INTR_LOCK();
	Wait_SPI_Idle(&flashchip);
	Cache_Read_Enable_New();
//ets_printf("sh1,");
	os_printf("--------Show Malloc--------\n");
	for( pxIterator = &yStart; pxIterator->pxNextFreeBlock != NULL;pxIterator = pxIterator->pxNextFreeBlock) {
		char file_name[33];
		const char *file_name_printf;
//ets_printf("sh2,");
		file_name_printf = vGetFileName(file_name, pxIterator->pxNextFreeBlock->file);
		os_printf("F:%s\tL:%u\tmalloc %d\t@ %x\n", file_name_printf, pxIterator->pxNextFreeBlock->line, pxIterator->pxNextFreeBlock->xBlockSize - 0x80000000, ( void * ) ( ( ( unsigned char * ) pxIterator->pxNextFreeBlock ) + uxHeapStructSize));
//ets_printf("sh3,");
//		ets_delay_us(2000);
        system_soft_wdt_feed();
	}
	os_printf("--------Free %d--------\n\n", xFreeBytesRemaining);

#if 0
	uint32 last_link = (uint32)yStart.pxNextFreeBlock;
	uint32 index = 0;
	os_printf("'*':used, '-'free, each %d bytes\n", portBYTE_ALIGNMENT_v);
	os_printf("%x:", last_link);
	for( pxIterator = &yStart; pxIterator->pxNextFreeBlock != NULL;pxIterator = pxIterator->pxNextFreeBlock) {
	    uint16 i;
	    for (i = 0; i < ((uint32)pxIterator->pxNextFreeBlock - last_link) / portBYTE_ALIGNMENT_v; i++) {
	        index++;
	        os_printf("-");
	        if (index % 64 == 0) {
	            os_printf("\n%x:", (uint32)yStart.pxNextFreeBlock + index * portBYTE_ALIGNMENT_v);
	        }
	    }
	    for (i = 0; i < pxIterator->pxNextFreeBlock->xBlockSize / portBYTE_ALIGNMENT_v; i++) {
	        index++;
	        os_printf("*");
	        if (index % 64 == 0) {
	            os_printf("\n%x:", (uint32)yStart.pxNextFreeBlock + index * portBYTE_ALIGNMENT_v);
            }
	    }
	    last_link = ((uint32)pxIterator->pxNextFreeBlock + pxIterator->pxNextFreeBlock->xBlockSize);
        system_soft_wdt_feed();
    }
	os_printf("\n\n");
#endif

//ets_printf("sh4\n");
	ETS_INTR_UNLOCK();
}
Ejemplo n.º 3
0
/******************************************************************************
 * FunctionName : spi_flash_read
 * Description  : чтение массива байт из flash
 *  			  читает из flash по QSPI блоками по SPI_FBLK байт
 *  			  в ROM-BIOS SPI_FBLK = 32 байта, 64 - предел SPI буфера
 * Parameters   : flash Addr, pointer, кол-во
 * Returns      : SpiFlashOpResult 0 - ok
 * Опции gcc: -mno-serialize-volatile !
 *******************************************************************************/
SpiFlashOpResult __attribute__((optimize("O2"))) spi_flash_read(uint32 faddr, void *des, uint32 size)
{
#if DEBUGSOO > 5
	ets_printf("fread:%p<-%p[%u]\n", des, faddr, size);
#endif
	if(des == NULL) return SPI_FLASH_RESULT_ERR;
	if(size != 0) {
		faddr <<= 8; faddr >>= 8;
		Cache_Read_Disable();
		Wait_SPI_Idle(flashchip);
		uint32 blksize = (uint32)des & 3;
		if(blksize) {
			blksize = 4 - blksize;
			if(size < blksize) blksize = size;
			SPI0_ADDR = faddr | (blksize << 24);
			SPI0_CMD = SPI_READ;
			size -= blksize;
			faddr += blksize;
			while(SPI0_CMD);
			register uint32 data_buf = SPI0_W0;
			do {
				*(uint8 *)des = data_buf;
				des = (uint8 *)des + 1;
				data_buf >>= 8;
			} while(--blksize);
		}
		while(size) {
			if(size < SPI_FBLK) blksize = size;
			else blksize = SPI_FBLK;
			SPI0_ADDR = faddr | (blksize << 24);
			SPI0_CMD = SPI_READ;
			size -= blksize;
			faddr += blksize;
			while(SPI0_CMD);
			uint32 *srcdw = (uint32 *)(&SPI0_W0);
			while(blksize >> 2) {
				*((uint32 *)des) = *srcdw++;
				des = ((uint32 *)des) + 1;
				blksize -= 4;
			}
			if(blksize) {
				uint32 data_buf = *srcdw;
				do {
					*(uint8 *)des = data_buf;
					des = (uint8 *)des + 1;
					data_buf >>= 8;
				} while(--blksize);
				break;
			}
		}
		Cache_Read_Enable_def();
	}
Ejemplo n.º 4
0
SpiFlashOpResult __attribute__((optimize("O3"))) spi_flash_read(uint32 faddr, void *des, uint32 size)
{
#if DEBUGSOO > 5
	ets_printf("fread:%p<-%p[%u]\n", des, faddr, size);
#endif
	if(des == NULL) return SPI_FLASH_RESULT_ERR;
	if(size != 0) {
		faddr <<= 8; faddr >>= 8; //	faddr &= (1 << 24) - 1; //	if((faddr >> 24) || ((faddr + size) >> 24)) return SPI_FLASH_RESULT_ERR;
		Cache_Read_Disable();
		Wait_SPI_Idle(flashchip);
		uint32 blksize = (uint32)des & 3;
		if(blksize) {
			blksize = 4 - blksize;
#if DEBUGSOO > 4
			ets_printf("fr1:%p<-%p[%u]\n", des, faddr, blksize);
#endif
			if(size < blksize) blksize = size;
			SPI0_ADDR = faddr | (blksize << 24);
			SPI0_CMD = SPI_READ;
			size -= blksize;
			faddr += blksize;
			while(SPI0_CMD);
			register uint32 data_buf = SPI0_W0;
			do {
				*(uint8 *)des = data_buf;
				des = (uint8 *)des + 1;
				data_buf >>= 8;
			} while(--blksize);
		}
		while(size) {
			if(size < SPI_FBLK) blksize = size;
			else blksize = SPI_FBLK;
#if DEBUGSOO > 5
			ets_printf("fr2:%p<-%p[%u]\n", des, faddr, blksize);
#endif
			SPI0_ADDR = faddr | (blksize << 24);
			SPI0_CMD = SPI_READ;
			size -= blksize;
			faddr += blksize;
			while(SPI0_CMD);
			//__asm__ __volatile__("memw" : : : "memory");
			// volatile uint32 *srcdw = (volatile uint32 *)(SPI0_BASE+0x40);
			uint32 *srcdw = (uint32 *)(&SPI0_W0);
//			uint32 *srcdw = (uint32 *)(SPI0_BASE+0x40);
			while(blksize >> 2) {
				*((uint32 *)des) = *srcdw++;
				des = ((uint32 *)des) + 1;
				blksize -= 4;
			}
			if(blksize) {
#if DEBUGSOO > 4
				ets_printf("fr3:%p<-%p[%u]\n", des, faddr, blksize);
#endif
				uint32 data_buf = *srcdw;
				do {
					*(uint8 *)des = data_buf;
					des = (uint8 *)des + 1;
					data_buf >>= 8;
				} while(--blksize);
				break;
			}
		}
		Cache_Read_Enable_def();
	}