From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61196 invoked by alias); 24 Mar 2017 11:46:10 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 60612 invoked by uid 89); 24 Mar 2017 11:46:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.3 required=5.0 tests=AWL,BAYES_40,FREEMAIL_FORGED_REPLYTO,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=faults, demo, mpu, MPU X-HELO: ms-10.1blu.de Received: from ms-10.1blu.de (HELO ms-10.1blu.de) (178.254.4.101) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Mar 2017 11:46:05 +0000 Received: from p54803099.dip0.t-ipconnect.de ([84.128.48.153] helo=[127.0.0.1]) by ms-10.1blu.de with esmtpa (Exim 4.86_2) (envelope-from ) id 1crNfQ-0000EJ-8i for newlib@sourceware.org; Fri, 24 Mar 2017 12:46:04 +0100 From: Jochen Strohbeck Subject: Re: Hard faults using sprintf() and float References: <46f40c33-b4c9-5c80-3b68-dd5e23bab8c0@strohbeck.net> <58D4E921.80504@embedded-brains.de> Reply-To: strohbeck@gmx.net To: newlib@sourceware.org Message-ID: Date: Fri, 24 Mar 2017 11:46:00 -0000 MIME-Version: 1.0 In-Reply-To: <58D4E921.80504@embedded-brains.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Con-Id: 127816 X-Con-U: 0-jochen X-SW-Source: 2017/txt/msg00222.txt.bz2 Not sure what must be aligned and how. Could you please be more precise ? Here is a part of my linker script taken from Atmel's FreeRTOS demo: /* .bss section which is used for uninitialized data */ .bss (NOLOAD) : { . = ALIGN(4); _sbss = . ; _szero = .; *(.bss .bss.*) *(COMMON) . = ALIGN(4); _ebss = . ; _ezero = .; } > ram /* stack section */ .stack (NOLOAD): { . = ALIGN(8); _sstack = .; . = . + STACK_SIZE; . = ALIGN(8); _estack = .; } > ram /* heap section */ .heap (NOLOAD): { . = ALIGN(8); _sheap = .; . = . + HEAP_SIZE; . = ALIGN(8); _eheap = .; } > ram . = ALIGN(4); _end = . ; _ram_end_ = ORIGIN(ram) + LENGTH(ram) -1 ; } I guess that printf/sprintf allocates dynamic memory. I provided calloc_r(), alloc_r() etc in order to use the FreeRTOS memory allocation but this doesn't seem to help out here. Therefore I would like to know (a little) more about what must be provided in order to work newlib smoothly with (Free)RTOS. Probably the info I found in the net is outdated. BTW: Sometimes I get some weird formatted output as shown in the second line of these three examples: {"input":{"U":-1.955017e+01,"I":-4.877560e-04,"R":0.000000e+00}, {"input":{"U":-1.955017e+01,"I":-4.00 e-04,"R":0.000000e+00}, {"input":{"U":-1.956951e+01,"I":-4.856550e-04,"R":0.000000e+00}, {"input":{"U":-1.956951e+01,"I":-4.8 672e-04,"R":0.000000e+00}, {"input":{"U":-1.955017e+01,"I":-4.908266e-04,"R":0.000000e+00}, {"input":{"U":-3.00 e+01,"I":-4.959982e-04,"R":0.000000e+00}, Found this issue because the spaces between mantissa and exponent seem to break the json parser in the python lib. Could this be related to a probably memory misalignment or is this caused by something else ? Regards, Jochen > Looks like you have a problem with misaligned loads. Check your MPU > configuration.