mirror of
https://github.com/drasko/open-ameba.git
synced 2024-11-24 23:14:17 +00:00
update
This commit is contained in:
parent
5e40d9d461
commit
6278f73e47
20 changed files with 2557 additions and 2579 deletions
|
@ -1288,20 +1288,15 @@ void fATFO(void *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mem info
|
||||||
void fATST(void *arg) {
|
void fATST(void *arg) {
|
||||||
extern void dump_mem_block_list(void); // heap_5.c
|
extern void dump_mem_block_list(void); // heap_5.c
|
||||||
//DBG_INFO_MSG_ON(_DBG_TCM_HEAP_); // On Debug TCM MEM
|
|
||||||
#if DEBUG_AT_USER_LEVEL > 1
|
|
||||||
printf("ATST: Mem info:\n");
|
|
||||||
#endif
|
|
||||||
// vPortFree(pvPortMalloc(4)); // Init RAM heap
|
|
||||||
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
|
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
|
||||||
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||||
|
#if CONFIG_DEBUG_LOG > 1
|
||||||
dump_mem_block_list();
|
dump_mem_block_list();
|
||||||
u32 saved = ConfigDebugInfo;
|
|
||||||
DBG_INFO_MSG_ON(_DBG_TCM_HEAP_); // On Debug TCM MEM
|
|
||||||
tcm_heap_dump();
|
tcm_heap_dump();
|
||||||
ConfigDebugInfo = saved;
|
#endif;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||||
char *cBuffer = pvPortMalloc(512);
|
char *cBuffer = pvPortMalloc(512);
|
||||||
|
|
|
@ -459,7 +459,8 @@ void fATWx(void *arg){
|
||||||
ip = LwIP_GetIP(&xnetif[i]);
|
ip = LwIP_GetIP(&xnetif[i]);
|
||||||
gw = LwIP_GetGW(&xnetif[i]);
|
gw = LwIP_GetGW(&xnetif[i]);
|
||||||
#endif
|
#endif
|
||||||
printf("\nWIFI %s Status: Running\n==============================\n", ifname[i]);
|
printf("\nWIFI %s Status: Running\n", ifname[i]);
|
||||||
|
printf("==============================\n");
|
||||||
|
|
||||||
rltk_wlan_statistic(i);
|
rltk_wlan_statistic(i);
|
||||||
|
|
||||||
|
@ -478,7 +479,8 @@ void fATWx(void *arg){
|
||||||
at_printf("%d.%d.%d.%d,", ip[0], ip[1], ip[2], ip[3]);
|
at_printf("%d.%d.%d.%d,", ip[0], ip[1], ip[2], ip[3]);
|
||||||
at_printf("%d.%d.%d.%d", gw[0], gw[1], gw[2], gw[3]);
|
at_printf("%d.%d.%d.%d", gw[0], gw[1], gw[2], gw[3]);
|
||||||
#endif
|
#endif
|
||||||
printf("Interface (%s)\n==============================\n", ifname[i]);
|
printf("\nInterface (%s)\n", ifname[i]);
|
||||||
|
printf("==============================\n");
|
||||||
printf("\tMAC => %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]) ;
|
printf("\tMAC => %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]) ;
|
||||||
printf("\tIP => %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
printf("\tIP => %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||||
printf("\tGW => %d.%d.%d.%d\n", gw[0], gw[1], gw[2], gw[3]);
|
printf("\tGW => %d.%d.%d.%d\n", gw[0], gw[1], gw[2], gw[3]);
|
||||||
|
@ -494,7 +496,8 @@ void fATWx(void *arg){
|
||||||
client_info.count = AP_STA_NUM;
|
client_info.count = AP_STA_NUM;
|
||||||
wifi_get_associated_client_list(&client_info, sizeof(client_info));
|
wifi_get_associated_client_list(&client_info, sizeof(client_info));
|
||||||
|
|
||||||
printf("Associated Client List:\n==============================\n");
|
printf("Associated Client List:\n");
|
||||||
|
printf("==============================\n");
|
||||||
|
|
||||||
if(client_info.count == 0)
|
if(client_info.count == 0)
|
||||||
printf("Client Num: 0\n", client_info.count);
|
printf("Client Num: 0\n", client_info.count);
|
||||||
|
@ -530,7 +533,8 @@ void fATWx(void *arg){
|
||||||
mac = LwIP_GetMAC(&xnetif[i]);
|
mac = LwIP_GetMAC(&xnetif[i]);
|
||||||
ip = LwIP_GetIP(&xnetif[i]);
|
ip = LwIP_GetIP(&xnetif[i]);
|
||||||
gw = LwIP_GetGW(&xnetif[i]);
|
gw = LwIP_GetGW(&xnetif[i]);
|
||||||
printf("Interface ethernet\n==============================\n");
|
printf("\nInterface ethernet\n");
|
||||||
|
printf("==============================\n");
|
||||||
printf("\tMAC => %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]) ;
|
printf("\tMAC => %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]) ;
|
||||||
printf("\tIP => %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
printf("\tIP => %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
|
||||||
printf("\tGW => %d.%d.%d.%d\n", gw[0], gw[1], gw[2], gw[3]);
|
printf("\tGW => %d.%d.%d.%d\n", gw[0], gw[1], gw[2], gw[3]);
|
||||||
|
@ -542,9 +546,14 @@ void fATWx(void *arg){
|
||||||
|
|
||||||
#if defined(configUSE_TRACE_FACILITY) && (configUSE_TRACE_FACILITY == 1) && (configUSE_STATS_FORMATTING_FUNCTIONS == 1)
|
#if defined(configUSE_TRACE_FACILITY) && (configUSE_TRACE_FACILITY == 1) && (configUSE_STATS_FORMATTING_FUNCTIONS == 1)
|
||||||
{
|
{
|
||||||
signed char pcWriteBuffer[1024];
|
char * pcWriteBuffer = malloc(1024);
|
||||||
|
if(pcWriteBuffer) {
|
||||||
vTaskList((char*)pcWriteBuffer);
|
vTaskList((char*)pcWriteBuffer);
|
||||||
printf("Task List:\n%s\n", pcWriteBuffer);
|
printf("\nTask List:\n");
|
||||||
|
printf("==============================\n");
|
||||||
|
printf("Name\t Status Priority HighWaterMark TaskNumber\n%s\n", pcWriteBuffer);
|
||||||
|
free(pcWriteBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,8 @@
|
||||||
#ifndef WPS_DEFS_H
|
#ifndef WPS_DEFS_H
|
||||||
#define WPS_DEFS_H
|
#define WPS_DEFS_H
|
||||||
|
|
||||||
|
|
||||||
/* Diffie-Hellman 1536-bit MODP Group; RFC 3526, Group 5 */
|
/* Diffie-Hellman 1536-bit MODP Group; RFC 3526, Group 5 */
|
||||||
#define WPS_DH_GROUP (5)
|
#define WPS_DH_GROUP (5)
|
||||||
|
|
||||||
#define WPS_UUID_LEN (16)
|
#define WPS_UUID_LEN (16)
|
||||||
#define WPS_NONCE_LEN (16)
|
#define WPS_NONCE_LEN (16)
|
||||||
#define WPS_AUTHENTICATOR_LEN (8)
|
#define WPS_AUTHENTICATOR_LEN (8)
|
||||||
|
@ -246,7 +244,6 @@ enum wps_assoc_state {
|
||||||
WPS_ASSOC_IP_FAILURE = 4
|
WPS_ASSOC_IP_FAILURE = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define WPS_DEV_OUI_WFA (0x0050f204)
|
#define WPS_DEV_OUI_WFA (0x0050f204)
|
||||||
|
|
||||||
enum wps_dev_categ {
|
enum wps_dev_categ {
|
||||||
|
|
|
@ -152,51 +152,6 @@ extern unsigned char dhcp_mode_sta;
|
||||||
#include "freertos/wrapper.h"
|
#include "freertos/wrapper.h"
|
||||||
#include "skbuff.h"
|
#include "skbuff.h"
|
||||||
|
|
||||||
//extern Rltk_wlan_t rltk_wlan_info[2];
|
|
||||||
void patch_rltk_wlan_deinit(void) {
|
|
||||||
uint8_t chk;
|
|
||||||
if (rltk_wlan_info[0].enable || rltk_wlan_info[0].enable) {
|
|
||||||
_adapter *ad = rltk_wlan_info[0].dev->priv;
|
|
||||||
ad->bSurpriseRemoved = 1;
|
|
||||||
rtw_wakeup_task(&ad->isrThread.task);
|
|
||||||
while (1) {
|
|
||||||
save_and_cli(); // = taskENTER_CRITICAL(); // = vPortEnterCritical()
|
|
||||||
rltk_wlan_info[0].enable = 0;
|
|
||||||
rltk_wlan_info[1].enable = 0;
|
|
||||||
chk = rltk_wlan_info[0].tx_busy + rltk_wlan_info[0].rx_busy
|
|
||||||
+ rltk_wlan_info[1].tx_busy + rltk_wlan_info[0].rx_busy;
|
|
||||||
restore_flags();
|
|
||||||
if (!chk)
|
|
||||||
break;
|
|
||||||
rtl_printf("[%s] Wait for TX/RX Busy (%d)\n", __func__, chk);
|
|
||||||
vTaskDelay(10);
|
|
||||||
}
|
|
||||||
while (1) {
|
|
||||||
if (!*(u32 *) (ad->isrThread.wakeup_sema) || ad->RxStop == 2)
|
|
||||||
break;
|
|
||||||
rtl_printf("[%s] Wait for RxStop\n", __func__);
|
|
||||||
vTaskDelay(10);
|
|
||||||
}
|
|
||||||
rtw_dev_remove(rltk_wlan_info);
|
|
||||||
rtw_drv_halt();
|
|
||||||
deinit_timer_wrapper();
|
|
||||||
|
|
||||||
rltk_wlan_info[0].enable = 0;
|
|
||||||
rltk_wlan_info[1].enable = 0;
|
|
||||||
|
|
||||||
rltk_wlan_info[0].dev = 0;
|
|
||||||
rltk_wlan_info[0].skb = 0;
|
|
||||||
rltk_wlan_info[0].tx_busy = 0;
|
|
||||||
rltk_wlan_info[0].rx_busy = 0;
|
|
||||||
rltk_wlan_info[0].enable = 0;
|
|
||||||
rltk_wlan_info[1].dev = 0;
|
|
||||||
rltk_wlan_info[1].skb = 0;
|
|
||||||
rltk_wlan_info[1].tx_busy = 0;
|
|
||||||
rltk_wlan_info[1].rx_busy = 0;
|
|
||||||
rltk_wlan_info[1].enable = 0;
|
|
||||||
//deinit_mem_monitor(NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------end-patch//
|
//------------------------------------------------------------------------end-patch//
|
||||||
static int wifi_connect_local(rtw_network_info_t *pWifi) {
|
static int wifi_connect_local(rtw_network_info_t *pWifi) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1056,8 +1011,7 @@ int wifi_off(void) {
|
||||||
wpas_wps_deinit();
|
wpas_wps_deinit();
|
||||||
#endif
|
#endif
|
||||||
info_printf("Deinitializing WIFI ...\n");
|
info_printf("Deinitializing WIFI ...\n");
|
||||||
// extern void patch_rltk_wlan_deinit();
|
rltk_wlan_deinit();
|
||||||
patch_rltk_wlan_deinit();
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((rltk_wlan_running(WLAN0_IDX) == 0)
|
if ((rltk_wlan_running(WLAN0_IDX) == 0)
|
||||||
|
|
|
@ -774,7 +774,7 @@ int wext_add_custom_ie(const char *ifname, void *cus_ie, int ie_num) {
|
||||||
int cmd_len = sizeof("SetCusIE");
|
int cmd_len = sizeof("SetCusIE");
|
||||||
if (ie_num <= 0 || !cus_ie) {
|
if (ie_num <= 0 || !cus_ie) {
|
||||||
#if CONFIG_DEBUG_LOG > 3
|
#if CONFIG_DEBUG_LOG > 3
|
||||||
wext_printf("%s: wrong parameter!\n", __func__);
|
error_printf("%s: wrong parameter!\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
memset(&iwr, 0, sizeof(iwr));
|
||||||
|
@ -807,7 +807,7 @@ int wext_update_custom_ie(const char *ifname, void * cus_ie, int ie_index) {
|
||||||
int cmd_len = sizeof("UpdateIE");
|
int cmd_len = sizeof("UpdateIE");
|
||||||
if (ie_index <= 0 || !cus_ie) {
|
if (ie_index <= 0 || !cus_ie) {
|
||||||
#if CONFIG_DEBUG_LOG > 3
|
#if CONFIG_DEBUG_LOG > 3
|
||||||
wext_printf("%s: wrong parameter!\n", __func__);
|
error_printf("%s: wrong parameter!\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
memset(&iwr, 0, sizeof(iwr));
|
memset(&iwr, 0, sizeof(iwr));
|
||||||
|
|
|
@ -381,8 +381,7 @@ typedef struct HeapRegion
|
||||||
* terminated by a HeapRegions_t structure that has a size of 0. The region
|
* terminated by a HeapRegions_t structure that has a size of 0. The region
|
||||||
* with the lowest start address must appear first in the array.
|
* with the lowest start address must appear first in the array.
|
||||||
*/
|
*/
|
||||||
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions );
|
static void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions );
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map to the memory management routines required for the port.
|
* Map to the memory management routines required for the port.
|
||||||
|
|
|
@ -202,24 +202,22 @@ HeapRegion_t xHeapRegions[] =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
#if 1
|
|
||||||
/*
|
/*
|
||||||
Dump xBlock list
|
Dump xBlock list
|
||||||
*/
|
*/
|
||||||
void dump_mem_block_list()
|
void dump_mem_block_list(void)
|
||||||
{
|
{
|
||||||
|
if(pxEnd == NULL) vPortDefineHeapRegions( xHeapRegions );
|
||||||
|
#if CONFIG_DEBUG_LOG > 1
|
||||||
// if(pxEnd == NULL) vPortDefineHeapRegions( xHeapRegions ); // test code start
|
// if(pxEnd == NULL) vPortDefineHeapRegions( xHeapRegions ); // test code start
|
||||||
BlockLink_t *pxBlock = &xStart;
|
BlockLink_t *pxBlock = &xStart;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
DBG_8195A("RAM Free Heap Memory List:\n");
|
||||||
DBG_8195A("RAM Heap Memory List:\n");
|
for(pxBlock = pxBlock->pxNextFreeBlock; pxBlock->pxNextFreeBlock != NULL; pxBlock = pxBlock->pxNextFreeBlock) {
|
||||||
while(pxBlock->pxNextFreeBlock != NULL)
|
DBG_8195A(" [%d]=%p, %d\n", ++count, pxBlock, pxBlock->xBlockSize);
|
||||||
{
|
|
||||||
DBG_8195A(" [%d]=%p, %d\n", count++, pxBlock, pxBlock->xBlockSize);
|
|
||||||
pxBlock = pxBlock->pxNextFreeBlock;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void *pvPortMalloc( size_t xWantedSize )
|
void *pvPortMalloc( size_t xWantedSize )
|
||||||
{
|
{
|
||||||
|
@ -228,7 +226,6 @@ void *pvReturn = NULL;
|
||||||
|
|
||||||
/* Realtek test code start */
|
/* Realtek test code start */
|
||||||
if(pxEnd == NULL) vPortDefineHeapRegions( xHeapRegions );
|
if(pxEnd == NULL) vPortDefineHeapRegions( xHeapRegions );
|
||||||
|
|
||||||
/* Realtek test code end */
|
/* Realtek test code end */
|
||||||
|
|
||||||
/* The heap must be initialised before the first call to
|
/* The heap must be initialised before the first call to
|
||||||
|
@ -343,11 +340,14 @@ void *pvReturn = NULL;
|
||||||
{
|
{
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
|
||||||
traceMALLOC( pvReturn, xWantedSize );
|
traceMALLOC( pvReturn, xWantedSize );
|
||||||
}
|
}
|
||||||
( void ) xTaskResumeAll();
|
( void ) xTaskResumeAll();
|
||||||
|
if(pvReturn == NULL) {
|
||||||
|
DBG_RAM_HEAP_WARN("ram_alloc(%d): freeSpace(%d)!\n", xWantedSize, xFreeBytesRemaining);
|
||||||
|
} else {
|
||||||
|
// DBG_RAM_HEAP_INFO("ram_alloc:%p[%d]\n", pvReturn , xWantedSize);
|
||||||
|
}
|
||||||
#if( configUSE_MALLOC_FAILED_HOOK == 1 )
|
#if( configUSE_MALLOC_FAILED_HOOK == 1 )
|
||||||
{
|
{
|
||||||
if( pvReturn == NULL )
|
if( pvReturn == NULL )
|
||||||
|
@ -410,6 +410,7 @@ BlockLink_t *pxLink;
|
||||||
{
|
{
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
// DBG_RAM_HEAP_INFO("ram_free:%p[%d]\n", pv , pxLink->xBlockSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +512,7 @@ uint8_t *puc;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions )
|
static void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions )
|
||||||
{
|
{
|
||||||
BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock;
|
BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock;
|
||||||
uint8_t *pucAlignedHeap;
|
uint8_t *pucAlignedHeap;
|
||||||
|
|
|
@ -3488,6 +3488,14 @@ TCB_t *pxTCB;
|
||||||
|
|
||||||
#endif /* portCRITICAL_NESTING_IN_TCB */
|
#endif /* portCRITICAL_NESTING_IN_TCB */
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
char * sprintf_pcTaskName(char * buf, char * name)
|
||||||
|
{
|
||||||
|
int len = sprintf(buf, name);
|
||||||
|
if(len < configMAX_TASK_NAME_LEN) {
|
||||||
|
memset(buf + len, ' ', configMAX_TASK_NAME_LEN - len);
|
||||||
|
}
|
||||||
|
return buf + configMAX_TASK_NAME_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) )
|
#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) )
|
||||||
|
|
||||||
|
@ -3559,8 +3567,9 @@ TCB_t *pxTCB;
|
||||||
cStatus = 0x00;
|
cStatus = 0x00;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pcWriteBuffer = sprintf_pcTaskName( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName);
|
||||||
|
|
||||||
sprintf( pcWriteBuffer, "%s\t\t%c\t%u\t%u\t%u\r\n", pxTaskStatusArray[ x ].pcTaskName, cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );
|
sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );
|
||||||
pcWriteBuffer += strlen( pcWriteBuffer );
|
pcWriteBuffer += strlen( pcWriteBuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3654,12 +3663,7 @@ TCB_t *pxTCB;
|
||||||
else
|
else
|
||||||
ulDeltaRunTimeCounter = portCONFIGURE_STATS_PEROID_VALUE*ulStatsAsPercentage/100;
|
ulDeltaRunTimeCounter = portCONFIGURE_STATS_PEROID_VALUE*ulStatsAsPercentage/100;
|
||||||
#endif
|
#endif
|
||||||
int cnt = sprintf( pcWriteBuffer, "%s", pxTaskStatusArray[ x ].pcTaskName);
|
pcWriteBuffer = sprintf_pcTaskName( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName);
|
||||||
pcWriteBuffer += cnt;
|
|
||||||
while(cnt < configMAX_TASK_NAME_LEN) {
|
|
||||||
cnt++;
|
|
||||||
*pcWriteBuffer++ = ' ';
|
|
||||||
}
|
|
||||||
if( ulStatsAsPercentage > 0UL )
|
if( ulStatsAsPercentage > 0UL )
|
||||||
{
|
{
|
||||||
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
|
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
|
||||||
|
|
|
@ -40,10 +40,10 @@ typedef struct Heap
|
||||||
void tcm_heap_init(void);
|
void tcm_heap_init(void);
|
||||||
|
|
||||||
/// Allocate a chunk of memory of \a size bytes from the heap
|
/// Allocate a chunk of memory of \a size bytes from the heap
|
||||||
void *tcm_heap_allocmem(int size);
|
// void *tcm_heap_allocmem(int size);
|
||||||
|
|
||||||
/// Free a chunk of memory of \a size bytes from the heap
|
/// Free a chunk of memory of \a size bytes from the heap
|
||||||
void tcm_heap_freemem(void *mem, int size);
|
// void tcm_heap_freemem(void *mem, int size);
|
||||||
|
|
||||||
int tcm_heap_freeSpace(void);
|
int tcm_heap_freeSpace(void);
|
||||||
|
|
||||||
|
|
|
@ -55,25 +55,35 @@ void tcm_heap_init(void)
|
||||||
|
|
||||||
void tcm_heap_dump(void)
|
void tcm_heap_dump(void)
|
||||||
{
|
{
|
||||||
|
if(!g_heap_inited) tcm_heap_init();
|
||||||
|
#if CONFIG_DEBUG_LOG > 1
|
||||||
MemChunk *chunk, *prev;
|
MemChunk *chunk, *prev;
|
||||||
struct Heap* h = &g_tcm_heap;
|
struct Heap* h = &g_tcm_heap;
|
||||||
|
int count = 0;
|
||||||
|
int free_mem;
|
||||||
|
|
||||||
DBG_8195A("TCM Free List:\n");
|
DBG_8195A("TCM Free Heap Memory List:\n");
|
||||||
|
for (chunk = h->FreeList; chunk; chunk = chunk->next) {
|
||||||
|
DBG_8195A(" [%d]=%p, %d\n", ++count, chunk, chunk->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (prev = (MemChunk *)&h->FreeList, chunk = h->FreeList;
|
for (prev = (MemChunk *)&h->FreeList, chunk = h->FreeList;
|
||||||
chunk;
|
chunk;
|
||||||
prev = chunk, chunk = chunk->next)
|
prev = chunk, chunk = chunk->next)
|
||||||
{
|
{
|
||||||
DBG_8195A(" prev %x, chunk %x, size %d\n", prev, chunk, chunk->size);
|
DBG_8195A(" [%d]=%p, %d\n", ++count, chunk, chunk->size);
|
||||||
}
|
}
|
||||||
// DBG_8195A(" end %x\n", tcm_heap);
|
*/
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tcm_heap_allocmem(int size)
|
static void *tcm_heap_allocmem(int size)
|
||||||
{
|
{
|
||||||
MemChunk *chunk, *prev;
|
MemChunk *chunk, *prev;
|
||||||
struct Heap* h = &g_tcm_heap;
|
struct Heap* h = &g_tcm_heap;
|
||||||
_irqL irqL;
|
_irqL irqL;
|
||||||
DBG_TCM_INFO("allocmem(%d)\n", size);
|
|
||||||
rtw_enter_critical(&tcm_lock, &irqL);
|
rtw_enter_critical(&tcm_lock, &irqL);
|
||||||
|
|
||||||
if(!g_heap_inited) tcm_heap_init();
|
if(!g_heap_inited) tcm_heap_init();
|
||||||
|
@ -98,46 +108,28 @@ void *tcm_heap_allocmem(int size)
|
||||||
{
|
{
|
||||||
/* Just remove this chunk from the free list */
|
/* Just remove this chunk from the free list */
|
||||||
prev->next = chunk->next;
|
prev->next = chunk->next;
|
||||||
#ifdef _DEBUG
|
|
||||||
memset(chunk, ALLOC_FILL_CODE, size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rtw_exit_critical(&tcm_lock, &irqL);
|
|
||||||
//printf("----ALLOC1-----\n\r");
|
|
||||||
// tcm_heap_dump();
|
|
||||||
//printf("--------------\n\r");
|
|
||||||
return (void *)chunk;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Allocate from the END of an existing chunk */
|
/* Allocate from the END of an existing chunk */
|
||||||
chunk->size -= size;
|
chunk->size -= size;
|
||||||
|
chunk = (MemChunk *)((uint8_t *)chunk + chunk->size);
|
||||||
|
}
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
memset((uint8_t *)chunk + chunk->size, ALLOC_FILL_CODE, size);
|
memset(chunk, ALLOC_FILL_CODE, size);
|
||||||
#endif
|
#endif
|
||||||
rtw_exit_critical(&tcm_lock, &irqL);
|
|
||||||
//printf("----ALLOC2-----\n\r");
|
|
||||||
// tcm_heap_dump();
|
|
||||||
//printf("--------------\n\r");
|
|
||||||
|
|
||||||
return (void *)((uint8_t *)chunk + chunk->size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rtw_exit_critical(&tcm_lock, &irqL);
|
rtw_exit_critical(&tcm_lock, &irqL);
|
||||||
//printf("----ALLOC3-----\n\r");
|
DBG_TCM_HEAP_INFO("tcm_alloc:%p[%d]\n", chunk, size);
|
||||||
DBG_TCM_WARN(ANSI_COLOR_MAGENTA "allocmem(%d): freeSpace(%d)!\n" ANSI_COLOR_RESET, size, tcm_heap_freeSpace());
|
return (void *)chunk;
|
||||||
// if (likely(ConfigDebugErr & _DBG_TCM_HEAP_)) {
|
}
|
||||||
// tcm_heap_dump();
|
}
|
||||||
// }
|
rtw_exit_critical(&tcm_lock, &irqL);
|
||||||
// tcm_heap_dump();
|
DBG_TCM_HEAP_WARN("tcm_alloc(%d) - freeSpace(%d)!\n", size, tcm_heap_freeSpace());
|
||||||
//printf("--------------\n\r");
|
|
||||||
return NULL; /* fail */
|
return NULL; /* fail */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tcm_heap_freemem(void *mem, int size)
|
||||||
void tcm_heap_freemem(void *mem, int size)
|
|
||||||
{
|
{
|
||||||
MemChunk *prev;
|
MemChunk *prev;
|
||||||
//ASSERT(mem);
|
//ASSERT(mem);
|
||||||
|
@ -146,7 +138,7 @@ void tcm_heap_freemem(void *mem, int size)
|
||||||
|
|
||||||
rtw_enter_critical(&tcm_lock, &irqL);
|
rtw_enter_critical(&tcm_lock, &irqL);
|
||||||
|
|
||||||
if(!g_heap_inited) tcm_heap_init();
|
// if(!g_heap_inited) tcm_heap_init();
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
memset(mem, FREE_FILL_CODE, size);
|
memset(mem, FREE_FILL_CODE, size);
|
||||||
|
@ -216,10 +208,7 @@ void tcm_heap_freemem(void *mem, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
rtw_exit_critical(&tcm_lock, &irqL);
|
rtw_exit_critical(&tcm_lock, &irqL);
|
||||||
//printf("---FREE %x--\n\r", mem);
|
DBG_TCM_HEAP_INFO("tcm_free:%p[%d]\n", mem, size);
|
||||||
//tcm_heap_dump();
|
|
||||||
//printf("--------------\n\r");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tcm_heap_freeSpace(void)
|
int tcm_heap_freeSpace(void)
|
||||||
|
@ -293,7 +282,8 @@ void tcm_heap_free(void *mem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
//----------- Tests -------------
|
||||||
static void alloc_test(int size, int test_len)
|
static void alloc_test(int size, int test_len)
|
||||||
{
|
{
|
||||||
//Simple test
|
//Simple test
|
||||||
|
@ -352,5 +342,6 @@ int tcm_heap_testRun(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif // tests
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -209,9 +209,9 @@ prvDiagSPrintf(
|
||||||
#define OTG_WARN_PREFIX "[OTG Wrn]"
|
#define OTG_WARN_PREFIX "[OTG Wrn]"
|
||||||
#define OTG_INFO_PREFIX "[OTG Inf]"
|
#define OTG_INFO_PREFIX "[OTG Inf]"
|
||||||
|
|
||||||
#define TCM_ERR_PREFIX "[TCM Err]"
|
#define HEAP_ERR_PREFIX "[HEAP Err]"
|
||||||
#define TCM_WARN_PREFIX "[TCM Wrn]"
|
#define HEAP_WARN_PREFIX "[HEAP Wrn]"
|
||||||
#define TCM_INFO_PREFIX "[TCM Inf]"
|
#define HEAP_INFO_PREFIX "[HEAP Inf]"
|
||||||
|
|
||||||
#define FEEP_ERR_PREFIX "[FEEP Err]"
|
#define FEEP_ERR_PREFIX "[FEEP Err]"
|
||||||
#define FEEP_WARN_PREFIX "[FEEP Wrn]"
|
#define FEEP_WARN_PREFIX "[FEEP Wrn]"
|
||||||
|
@ -378,9 +378,18 @@ prvDiagSPrintf(
|
||||||
}\
|
}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define DBG_TCM_ERR(...) do {\
|
#define DBG_TCM_HEAP_ERR(...) do {\
|
||||||
if (likely(ConfigDebugErr & _DBG_TCM_HEAP_)) \
|
if (likely(ConfigDebugErr & _DBG_TCM_HEAP_)){ \
|
||||||
_DbgDump(TCM_ERR_PREFIX __VA_ARGS__);\
|
_DbgDump(HEAP_ERR_PREFIX ANSI_COLOR_RED);\
|
||||||
|
_DbgDump(__VA_ARGS__ );\
|
||||||
|
_DbgDump(ANSI_COLOR_RESET);}\
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define DBG_RAM_HEAP_ERR(...) do {\
|
||||||
|
if (likely(ConfigDebugErr & _DBG_RAM_HEAP_)){ \
|
||||||
|
_DbgDump(HEAP_ERR_PREFIX ANSI_COLOR_RED);\
|
||||||
|
_DbgDump(__VA_ARGS__ );\
|
||||||
|
_DbgDump(ANSI_COLOR_RESET);}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define DBG_MISC_ERR(...) do {\
|
#define DBG_MISC_ERR(...) do {\
|
||||||
|
@ -425,7 +434,8 @@ prvDiagSPrintf(
|
||||||
#define DBG_8195A_OTG_WARN(...)
|
#define DBG_8195A_OTG_WARN(...)
|
||||||
#define DBG_8195A_OTG_ERR(...)
|
#define DBG_8195A_OTG_ERR(...)
|
||||||
|
|
||||||
#define DBG_TCM_ERR(...)
|
#define DBG_TCM_HEAP_ERR(...)
|
||||||
|
#define DBG_RAM_HEAP_ERR(...)
|
||||||
#define DBG_FEEP_ERR(...)
|
#define DBG_FEEP_ERR(...)
|
||||||
|
|
||||||
#endif // end of else of "#if CONFIG_DEBUG_ERROR"
|
#endif // end of else of "#if CONFIG_DEBUG_ERROR"
|
||||||
|
@ -544,9 +554,18 @@ prvDiagSPrintf(
|
||||||
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define DBG_TCM_WARN(...) do {\
|
#define DBG_TCM_HEAP_WARN(...) do {\
|
||||||
if (likely(ConfigDebugWarn & _DBG_TCM_HEAP_)) \
|
if (likely(ConfigDebugWarn & _DBG_TCM_HEAP_)){ \
|
||||||
_DbgDump(TCM_WARN_PREFIX __VA_ARGS__);\
|
_DbgDump(HEAP_WARN_PREFIX ANSI_COLOR_MAGENTA);\
|
||||||
|
_DbgDump(__VA_ARGS__ );\
|
||||||
|
_DbgDump(ANSI_COLOR_RESET);}\
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define DBG_RAM_HEAP_WARN(...) do {\
|
||||||
|
if (likely(ConfigDebugWarn & _DBG_RAM_HEAP_)){ \
|
||||||
|
_DbgDump(HEAP_WARN_PREFIX ANSI_COLOR_MAGENTA);\
|
||||||
|
_DbgDump(__VA_ARGS__ );\
|
||||||
|
_DbgDump(ANSI_COLOR_RESET);}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define DBG_FEEP_WARN(...) do {\
|
#define DBG_FEEP_WARN(...) do {\
|
||||||
|
@ -581,7 +600,8 @@ prvDiagSPrintf(
|
||||||
#define DBG_CRYPTO_WARN(...)
|
#define DBG_CRYPTO_WARN(...)
|
||||||
#define DBG_ADC_WARN(...)
|
#define DBG_ADC_WARN(...)
|
||||||
#define DBG_DAC_WARN(...)
|
#define DBG_DAC_WARN(...)
|
||||||
#define DBG_TCM_WARN(...)
|
#define DBG_TCM_HEAP_WARN(...)
|
||||||
|
#define DBG_RAM_HEAP_WARN(...)
|
||||||
#define DBG_FEEP_WARN(...)
|
#define DBG_FEEP_WARN(...)
|
||||||
#define DBG_MISC_WARN(...)
|
#define DBG_MISC_WARN(...)
|
||||||
|
|
||||||
|
@ -704,9 +724,18 @@ prvDiagSPrintf(
|
||||||
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
_DbgDump(TIMER_PREFIX __VA_ARGS__);\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define DBG_TCM_INFO(...) do {\
|
#define DBG_TCM_HEAP_INFO(...) do {\
|
||||||
if (likely(ConfigDebugInfo & _DBG_TCM_HEAP_)) \
|
if (likely(ConfigDebugInfo & _DBG_TCM_HEAP_)){\
|
||||||
_DbgDump(TCM_INFO_PREFIX __VA_ARGS__);\
|
_DbgDump(HEAP_INFO_PREFIX ANSI_COLOR_BLUE);\
|
||||||
|
_DbgDump(__VA_ARGS__ );\
|
||||||
|
_DbgDump(ANSI_COLOR_RESET);}\
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
#define DBG_RAM_HEAP_INFO(...) do {\
|
||||||
|
if (likely(ConfigDebugInfo & _DBG_RAM_HEAP_)){ \
|
||||||
|
_DbgDump(HEAP_INFO_PREFIX ANSI_COLOR_BLUE);\
|
||||||
|
_DbgDump(__VA_ARGS__ );\
|
||||||
|
_DbgDump(ANSI_COLOR_RESET);}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define DBG_FEEP_INFO(...) do {\
|
#define DBG_FEEP_INFO(...) do {\
|
||||||
|
@ -741,7 +770,8 @@ prvDiagSPrintf(
|
||||||
#define DBG_CRYPTO_INFO(...)
|
#define DBG_CRYPTO_INFO(...)
|
||||||
#define DBG_ADC_INFO(...)
|
#define DBG_ADC_INFO(...)
|
||||||
#define DBG_DAC_INFO(...)
|
#define DBG_DAC_INFO(...)
|
||||||
#define DBG_TCM_INFO(...)
|
#define DBG_RAM_HEAP_INFO(...)
|
||||||
|
#define DBG_TCM_HEAP_INFO(...)
|
||||||
#define DBG_FEEP_INFO(...)
|
#define DBG_FEEP_INFO(...)
|
||||||
#define DBG_MISC_INFO(...)
|
#define DBG_MISC_INFO(...)
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4646
build/obj/build.nmap
4646
build/obj/build.nmap
File diff suppressed because it is too large
Load diff
|
@ -121,17 +121,15 @@ void fATWS(int argc, char *argv[]){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mem info
|
||||||
// Mem info
|
// Mem info
|
||||||
void fATST(void){
|
void fATST(void){
|
||||||
extern u8 __HeapLimit, __StackTop;
|
|
||||||
extern struct Heap g_tcm_heap;
|
|
||||||
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
|
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
|
||||||
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
|
||||||
|
#if CONFIG_DEBUG_LOG > 1
|
||||||
dump_mem_block_list();
|
dump_mem_block_list();
|
||||||
u32 saved = ConfigDebugInfo;
|
|
||||||
DBG_INFO_MSG_ON(_DBG_TCM_HEAP_); // On Debug TCM MEM
|
|
||||||
tcm_heap_dump();
|
tcm_heap_dump();
|
||||||
ConfigDebugInfo = saved;
|
#endif;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||||
char *cBuffer = pvPortMalloc(512);
|
char *cBuffer = pvPortMalloc(512);
|
||||||
|
|
Loading…
Reference in a new issue