[chbot] Most puzzling arm compilation problem
Robin Gilks
robin at gilks.org
Thu Oct 1 23:42:13 BST 2015
The code I use to drive the Nordic NRF24L01+ module includes a function to
print out useful information. It takes a callback function as a parameter
that does the actual printing.
All this works fine when compiled for the AVR but on the ARM I get the
following problem. No idea what the overlap means but the '_sbrk' error
implies that malloc is being invoked somewhere - I'm using newlib which
expects you to define system calls. If I turn off the callback then it
compiles cleanly.
/usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/bin/ld: section
.ARM.exidx loaded at [000000000000a358,000000000000a35f] overlaps section
.data loaded at [000000000000a358,000000000000ada3]
/usr/lib/gcc/arm-none-eabi/4.8/../../../arm-none-eabi/lib/armv7-m/libc.a(lib_a-sbrkr.o):
In function `_sbrk_r':
/home/tin/projects/debian/arm-toolchain/collab-maint/newlib/build/arm-none-eabi/armv7-m/newlib/libc/reent/../../../../../../newlib/libc/reent/sbrkr.c:58:
undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status
Here are the functions, all wrapped up in conditionals!!
* declare the callback
#if NRF24L01_PRINTENABLE == 1
static void
debug_prints (const char *s)
{
kfile_printf (&serial.fd, "%s", s);
}
#endif
* invoke the callback in mainline code
#if NRF24L01_PRINTENABLE == 1
nrf24l01_printinfo (debug_prints);
#endif
* use the callback from the driver
#if NRF24L01_PRINTENABLE == 1
/*
* print info - print output function supplied!!
*/
void nrf24l01_printinfo(void(*prints)(const char *)) {
char buff[100];
prints("info\r\n");
sprintf(buff,"STATUS: %02X\r\n", nrf24l01_getstatus()); prints(buff);
sprintf(buff,"CONFIG: %02X\r\n",
nrf24l01_readregister(NRF24L01_REG_CONFIG)); prints(buff);
sprintf(buff,"RF_CH: %02X\r\n",
nrf24l01_readregister(NRF24L01_REG_RF_CH)); prints(buff);
sprintf(buff,"RF_SETUP: %02X\r\n",
nrf24l01_readregister(NRF24L01_REG_RF_SETUP)); prints(buff);
sprintf(buff,"EN_AA: %02X\r\n",
nrf24l01_readregister(NRF24L01_REG_EN_AA)); prints(buff);
sprintf(buff,"EN_RXADDR: %02X\r\n",
nrf24l01_readregister(NRF24L01_REG_EN_RXADDR)); prints(buff);
sprintf(buff,"OBSERVE_TX: %02X\r\n",
nrf24l01_readregister(NRF24L01_REG_OBSERVE_TX)); prints(buff);
prints("\r\n");
}
#endif
* prototype the callback
#if NRF24L01_PRINTENABLE == 1
extern void nrf24l01_printinfo(void(*prints)(const char *));
#endif
All the code (apart from the very top level which is pretty trivial) is at
https://github.com/g8ecj/bertos/tree/g8ecj/all
So I'm obviously missing something here but I'm at a loss as to what!!
--
Robin Gilks
More information about the Chchrobotics
mailing list