From 22ce51b0192863fd8e27e79915371ea653927dae Mon Sep 17 00:00:00 2001 From: john-1 Date: Tue, 21 Apr 2026 21:31:22 +0300 Subject: [PATCH 1/2] Fix ubi write failing after TFTP on hi3516av200 (heap too small) `ubi write` failed with -ENOMEM after any TFTP transfer because `vmalloc(126976)` (malloc for one LEB) could not find 124KB of free heap. The root cause was that hi-common.h unconditionally redefined CONFIG_SYS_MALLOC_LEN to (CONFIG_ENV_SIZE + 512KB), silently overriding the board-specific value set in hi3516av200.h. This left only ~576KB of heap, of which ~548KB was consumed by UBI structures and network stack allocations after TFTP. Guard CONFIG_SYS_MALLOC_LEN in hi-common.h with #ifndef so board-specific values are preserved, and increase the hi3516av200 malloc pool from 128KB to 2MB. Closes #5 Co-Authored-By: Claude Opus 4.6 (1M context) --- include/configs/hi-common.h | 2 ++ include/configs/hi3516av200.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/configs/hi-common.h b/include/configs/hi-common.h index c46a9506..784ba0c3 100644 --- a/include/configs/hi-common.h +++ b/include/configs/hi-common.h @@ -52,7 +52,9 @@ #define CONFIG_SYS_HUSH_PARSER 1 #define CONFIG_SYS_PROMPT_HUSH_PS2 " > " +#ifndef CONFIG_SYS_MALLOC_LEN #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 512*1024) +#endif #define CONFIG_CMD_MTDPARTS 1 #define CONFIG_RBTREE 1 #define CONFIG_MTD_DEVICE 1 diff --git a/include/configs/hi3516av200.h b/include/configs/hi3516av200.h index 87d96804..fac5730e 100644 --- a/include/configs/hi3516av200.h +++ b/include/configs/hi3516av200.h @@ -101,7 +101,7 @@ #define FMC_TEXT_ADRS (FMC_MEM_BASE) #define MEM_BASE_DDR (DDR_MEM_BASE) -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2*1024*1024) /* size in bytes reserved for initial data */ #define CONFIG_SYS_GBL_DATA_SIZE 128 From ec2db820c08b19660c5ae6022a369bee8879426f Mon Sep 17 00:00:00 2001 From: john-1 Date: Tue, 21 Apr 2026 21:45:18 +0300 Subject: [PATCH 2/2] Fix hi3519v101 build: increase malloc pool to match hi3516av200 The #ifndef guard in hi-common.h now lets board-specific CONFIG_SYS_MALLOC_LEN values through. The hi3519v101 default of 128KB was below the 512KB minimum required by UBI, causing a build error. Increase to 2MB to match hi3516av200. Co-Authored-By: Claude Opus 4.6 (1M context) --- include/configs/hi3519v101.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/hi3519v101.h b/include/configs/hi3519v101.h index 978a72da..0b3074b1 100644 --- a/include/configs/hi3519v101.h +++ b/include/configs/hi3519v101.h @@ -102,7 +102,7 @@ #define FMC_TEXT_ADRS (FMC_MEM_BASE) #define MEM_BASE_DDR (DDR_MEM_BASE) -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2*1024*1024) /* size in bytes reserved for initial data */ #define CONFIG_SYS_GBL_DATA_SIZE 128