I want to use printf but most of the time I get this build error:
printf("%x", atoi(&f[0]));
__
Link error: undefined reference to `_fstat' conv line 0 C/C++ Problem
Link error: undefined reference to `_isatty' conv line 0 C/C++ Problem
I have included wm_stdio.h, also tried just stdio.h but keeps giving the error.
I am using ARM_EABI_GCC_DEBUG as compiler, it seems to have to do something with the compiler. Does anyone else have this error. Or does anyone know a fix to it?
Using:
Developer Studio 2.1.1
Open AT Embedded Software Suite package 2.36
Open AT OS Package 6.36
Firmware Package 7.46
WIP Plug-in Package 5.42
Are you including “adl_global.h”?
yes
#include "adl_global.h"
#include "wm_stdio.h"
#include "wm_uart.h"
#include "wip.h"
#include "main.h"
#include "HTTP.h"
#include "RS485.h"
#include "TCP.h"
looks familiar, see github.com/jhofstee/siwi2way/bl … wi_stubs.c.
I think the issue is that Siwi only partially implemented the stubs for newlib. If you want printf to work
you likely need to implement the stubs for it. I only added the stubs to make the linker happy.
That indeed solves the error, but if I upload it to the FXT009 it keeps resetting trough the watchdog timer. I Stripped my code but the watchdog keeps coming in.
#include "adl_global.h"
#include <wm_stdio.h>
const u16 wm_apmCustomStackSize = 1024*4;
static void main_task(void);
const adl_InitTasks_t adl_InitTasks [] =
{
{ main_task, 4096, "task0", 1 },
{ 0, 0, 0, 0 }
};
int cnt = 0;
adl_tmr_t *timer;
void TimerHandler ( u8 ID, void *Context)
{
TRACE (( 1, "Timer" ));
cnt++;
if(cnt==1){
u8 gh = printf("%x", 99);
DUMP(1,&gh,2);
}
if(cnt>=2){
adl_tmrUnSubscribe(timer, TimerHandler, ADL_TMR_TYPE_100MS);
}
}
void main_task (void)
{
TRACE (( 1, "Embedded : Main application" ));
timer = adl_tmrSubscribe ( TRUE, 100, ADL_TMR_TYPE_100MS, TimerHandler );
}
Right, I should probably have been a bit clearer, I was refering to “Does anyone else have this error”, not to the usage of printf. You will get the same errors when using the c99 strtoul and friends. The linker will look for some libc functions but won’t find them. I used the glue for some calls, to satisfy the linker. The glue isn’t supposed to be used though! Just dummies so the linker is happy and functions like strtoul will work.
printf DOES use the libc internals and hence it will crash, or at best you endup in _abort, triggering a watchdog reset. A simple solution is not to use printf The more complicated version is to fix the libc calls…
aha yes I understand thanks. So it is just another bug in the sierra wireless firmware -_-
Well it is not really a bug I guess, just buggy. I don’t think SiWi promises a full libc / c99 / posix / c++ support / libm and all the other things they ship along. They would presumably argue that only the documented functions are supported.