解决cvg申请内存导致不足的的问题

This commit is contained in:
2025-04-24 11:39:31 +08:00
parent fc6412adf0
commit 73ea1d6f5f
8 changed files with 38 additions and 17 deletions

View File

@@ -18,7 +18,7 @@ if __name__ == "__main__":
os.remove("../python_script_log.log") os.remove("../python_script_log.log")
except Exception as e: except Exception as e:
print(e) print(e)
# os.system("python3 ../praper_vscode.py clear >> ../python_script_log.log") os.system("python3 ../praper_vscode.py clear >> ../python_script_log.log")
path="../tools/gen_img/customer" path="../tools/gen_img/customer"
if os.path.exists(path): if os.path.exists(path):
shutil.rmtree(path) shutil.rmtree(path)

View File

@@ -51,9 +51,12 @@ void *os_mem_malloc(module_id_t module_id, size_t size)
#endif #endif
{ {
(void)module_id; // avoid warning. to be fixed. (void)module_id; // avoid warning. to be fixed.
void *buf = pvPortMalloc(size);
#if IOT_OS_MALLOC_DEBUG #if IOT_OS_MALLOC_DEBUG
iot_printf("%s:%d malloc.\n", file, line); iot_printf("os_mem_malloc: size=%d\n", size);
#endif
void* buf = pvPortMalloc(size);
#if IOT_OS_MALLOC_DEBUG
iot_printf("%s:%d malloc. p=%p\n", file, line, buf);
#endif #endif
if (buf) { if (buf) {
os_mem_set(buf, 0, size); os_mem_set(buf, 0, size);

View File

@@ -24,6 +24,7 @@ extern unsigned int _heap_start;
#define MEM_MAP_PART_0_ADDR ((int)&_heap_start) #define MEM_MAP_PART_0_ADDR ((int)&_heap_start)
#define MEM_MAP_PART_0_LENTH ((size_t)((unsigned char *)&_heap_end - \ #define MEM_MAP_PART_0_LENTH ((size_t)((unsigned char *)&_heap_end - \
(unsigned char*)&_heap_start)) (unsigned char*)&_heap_start))
#define OS_DUMP_START ((int)&_heap_end)
#if (IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA) #if (IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA)
@@ -31,8 +32,24 @@ extern unsigned int _heap_start;
#else /* (IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA) */ #else /* (IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA) */
#if (IOT_MP_SUPPORT == 0)
#if RUN_IN_PSRAM
#define MEM_MAP_RESERVED_BUF_SZ (300 * 1024)
#else /* RUN_IN_PSRAM */
#define MEM_MAP_RESERVED_BUF_SZ (128 * 1024)
#endif /* RUN_IN_PSRAM */
#else /* IOT_MP_SUPPORT == 0 */
#define MEM_MAP_RESERVED_BUF_SZ (64 * 1024) #define MEM_MAP_RESERVED_BUF_SZ (64 * 1024)
#endif /* IOT_MP_SUPPORT == 0 */
#endif /* (IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA) */ #endif /* (IOT_STA_CONTROL_MODE == IOT_STA_CONTROL_TYPE_STA) */
#if (RUN_IN_PSRAM) #if (RUN_IN_PSRAM)
@@ -108,7 +125,6 @@ extern unsigned int _heap_start;
MEM_MAP_PART_1_ADDR, MEM_MAP_PART_1_LENTH, \ MEM_MAP_PART_1_ADDR, MEM_MAP_PART_1_LENTH, \
MEM_MAP_PART_2_ADDR, MEM_MAP_PART_2_LENTH, \ MEM_MAP_PART_2_ADDR, MEM_MAP_PART_2_LENTH, \
MEM_MAP_PART_3_ADDR, MEM_MAP_PART_3_LENTH} MEM_MAP_PART_3_ADDR, MEM_MAP_PART_3_LENTH}
#else /* (BUILD_AMP_TYPE == IOT_BUILD_AMP_NONE) */ #else /* (BUILD_AMP_TYPE == IOT_BUILD_AMP_NONE) */
#define MEM_MAP_PART_1_ADDR (0x70000000) #define MEM_MAP_PART_1_ADDR (0x70000000)

View File

@@ -52,7 +52,7 @@ ADD_LIB += os driver common rf_mac
.PHONY: TARGET .PHONY: TARGET
TARGET: .output/plc/lib/kl3_core1.out TARGET: .output/plc/lib/kl3_core1.out
@echo "const char plc_core1[] = {" > plc_core1.h @echo "const char plc_core1[] = {" > plc_core1.h
@./bin2hex_frame ../kl3_core1/.output/plc/lib/kl3_core1.bin tmp.txt @./bin2hex_frame ../kl3_core1/.output/plc/lib/kl3_core1.bin tmp.txt > /dev/null
@cat tmp.txt >> plc_core1.h @cat tmp.txt >> plc_core1.h
@echo "};" >> plc_core1.h @echo "};" >> plc_core1.h
@mv plc_core1.h ../kl3_core0 @mv plc_core1.h ../kl3_core0

View File

@@ -41,7 +41,7 @@ extern "C" {
#define GPIO_RS485_TXE 7 #define GPIO_RS485_TXE 7
#define GPIO_IR_TXD 8 #define GPIO_IR_TXD 8
#define GPIO_IR_RXD 9 #define GPIO_IR_RXD 9
#define GPIO_GEODE_OVT 10 #define GPIO_GEODE_OVT 10 // 外部pa的gpio中断
#define GPIO_SMART_BOOT_SEL 11 #define GPIO_SMART_BOOT_SEL 11
#define GPIO_PM_CHARGE_EN 12 #define GPIO_PM_CHARGE_EN 12
#define GPIO_RST_CTRL 13 #define GPIO_RST_CTRL 13

View File

@@ -85,7 +85,7 @@ extern "C" {
#if ((TARGET_VERSION == TARGET_KUNLUN3) && !SUPPORT_SOUTHERN_POWER_GRID) #if ((TARGET_VERSION == TARGET_KUNLUN3) && !SUPPORT_SOUTHERN_POWER_GRID)
/* #define number of nodes supported in the PLC network must be (n * 8 - 1) */ /* #define number of nodes supported in the PLC network must be (n * 8 - 1) */
#define PLC_NETWORK_SCALE 2039 #define PLC_NETWORK_SCALE 1535
#else /* (TARGET_VERSION == TARGET_KUNLUN3) */ #else /* (TARGET_VERSION == TARGET_KUNLUN3) */

View File

@@ -40,7 +40,8 @@ extern "C" {
#define TARGET_KUNLUN3 3 #define TARGET_KUNLUN3 3
#ifndef TARGET_VERSION #ifndef TARGET_VERSION
#define TARGET_VERSION TARGET_KUNLUN #define TARGET_VERSION 5
#error "please define TARGET_VERSION in Makefile"
#endif #endif
/* production line defination, plc by default */ /* production line defination, plc by default */

View File

@@ -233,13 +233,13 @@ void heap_alloc_caps_init(unsigned int reserved_sz);
void *pvPortMallocTagged( size_t xWantedSize, BaseType_t tag ) void *pvPortMallocTagged( size_t xWantedSize, BaseType_t tag )
{ {
BlockLink_tag_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; BlockLink_tag_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
void *pvReturn = NULL; void *pvReturn = NULL;
/* The heap must be initialised before the first call to /* The heap must be initialised before the first call to
prvPortMalloc(). */ prvPortMalloc(). */
//configASSERT( tagpxEnd ); //configASSERT( tagpxEnd );
// 这里实际分配内存
vTaskSuspendAll(); vTaskSuspendAll();
{ {
if (NULL == tagpxEnd) { if (NULL == tagpxEnd) {
@@ -274,7 +274,8 @@ void *pvReturn = NULL;
one of adequate size is found. */ one of adequate size is found. */
pxPreviousBlock = &tagxStart; pxPreviousBlock = &tagxStart;
pxBlock = tagxStart.pxNextFreeBlock; pxBlock = tagxStart.pxNextFreeBlock;
while( ( ( pxBlock->xTag != tag ) || ( pxBlock->xBlockSize < xWantedSize ) ) && ( pxBlock->pxNextFreeBlock != NULL ) ) // 从第一个内存池开始 找到一个能够分配指定内存大小的内存池
while (((pxBlock->xTag != tag) || (pxBlock->xBlockSize < xWantedSize)) && (pxBlock->pxNextFreeBlock != NULL))
{ {
pxPreviousBlock = pxBlock; pxPreviousBlock = pxBlock;
pxBlock = pxBlock->pxNextFreeBlock; pxBlock = pxBlock->pxNextFreeBlock;