[PATCH][MSP430] MSP430: Define __BUFSIZ__ as 256 to prevent default of 1024 being used

Jozef Lawrynowicz jozef.l@somniumtech.com
Wed Jul 19 18:01:00 GMT 2017


Many MSP430 devices have a very small amount of RAM (the MSP430FR5969
has 2kB). A simple "Hello World" printf program built for one of these
devices will not execute properly as stack and heap collide before
output is printed.
About 1.5kB of heap is allocated to do the printf, but reducing
__BUFSIZ__ to 256 brings this to around 750 bytes, and the hello world
program comfortably executes on hardware.

Patch is attached.
-------------- next part --------------
From 7ba27bcfe2fbbc66d07c7f85062d7050b6381fcb Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Mon, 10 Jul 2017 17:19:00 +0000
Subject: [PATCH] MSP430: Define __BUFSIZ__ as 256 to prevent default of 1024
 being used

---
 newlib/libc/include/sys/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index c536698..39f8384 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -155,6 +155,7 @@
 #define _REENT_SMALL
 #endif
 
+#define __BUFSIZ__ 256
 #define __SMALL_BITFIELDS
 
 #ifdef __MSP430X_LARGE__
-- 
1.8.3.1



More information about the Newlib mailing list