newLib integration

View: New views
7 Messages — Rating Filter:   Alert me  

newLib integration

by athomi@bluewin.ch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I'm quite new to the "world of Ethernut" and doing my first steps with the examples provided on the ethernut
homepage.
The troubles started with the "Output Format Specifiers" Example (as described in the NutWiki: http://www.ethernut.de/nutwiki/Output_Format_Specifiers
, where the following compiler errors occured:

... mallocr.c:3326: undefined reference to `_sbrk_r` (serveral times)

I'm using the following setup:
- Windows XP
- Latests YAGARTO GNU Toolchain (29.03.2009)
- Ethernut 4.8.2 (with Nut/OS Configurator 2.0.8)

After some Googling i have found, that the newlib (1.17.0) used by
YAGARTO has been build to support reentrant stubs.

Some more googling later, i think that newlib (resp. its build options) are the key problems. Newlib seems to expect
some functions provided by the OS (like a "glue-layer" between the newlib and the OS).

Also called as "syscalls.c", which a haven't found within the Nut/OS sources.



Now my Questions:

- Does anybody have managed to compile the example Output Format Specifiers with the latest YAGARTO GNU Toolchain?

- Does Nut/OS provide such an newlib "integration" (like syscalls.c)?

- Has anybody already written such an newlib "integration" for Nut/OS?

  (i'm too new to the Nut/OS so i haven't got the necessary knowledge for such an "integration")

- Generally spoken, how can i compile this example with that YAGARTO version?



And an additional question related to a compiler warning in front of the compiler errros:

- " implicit declaration of function '_ioctl' ", i know its only a warning but i think this warning should not occur.



Thanks for any hint



Regards,

Aurel Thomi
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

config flashspace usage on SAM7X256

by Bernd Walter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

After playing a bit with Lua the ROM size is getting a bit too small.
The ld script says:
/* Last 16k flash is used to save config. */
MEMORY
{
  rom(rx) : org = 0x00000000, len = 240k
  ram(rw) : org = 0x00200000, len = 64k
}

I don't need Ethernut to save anything, because I do it myself in an
AT45DB chip.
But I'm unable to find the code using it so that I can disable.
Or is it just reserved for future use?

I also have the option to use X512, which are already working fine
with their additional RAM.
But I wonder what Ethernut is doing about this config page, because
flashing the upper half on the X512 is slightly different.

--
B.Walter <bernd@...> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: config flashspace usage on SAM7X256

by Ethernut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bernd Walter wrote:

> I don't need Ethernut to save anything, because I do it myself in an
> AT45DB chip.
> But I'm unable to find the code using it so that I can disable.
> Or is it just reserved for future use?

Hi Bernd,

at least saving the configuration had been removed from the system
libraries in 4.9. Still, the system libraries read CONFOS and CONFNET.

In general this is done by calling NutNvMemLoad(), provided in
dev/nvmem.c. Depending on the configuration in include/cfg/eeprom.h,
this routine may access the X12x6 EEPROM, an AT45DB or AT49BV flash
memory, the internal EEPROM on AVR CPUs or the internal flash on AT91
devices.

If no valid configuration for NVMEM is available, NutLoadConfig will
return an error, but still set an default hostname. NutNetLoadConfig
will also return with error, but still set the MAC address to all bits
set and all other items cleared to zero.

The problem is, that the returned error will let higher level routines
fail (e.g. DHCP).

In your special case I'd suggest to configure NUT_CONFIG_AT45D (new SPI
bus interface) or NUT_CONFIG_AT45DB (old with integrated SPI routines.
For the latter you may then even implement your own At45dbParamRead() to
override default linking to dev/at45db.c.

Harald


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: config flashspace usage on SAM7X256

by Bernd Walter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Jun 20, 2009 at 01:35:50PM +0200, Harald Kipp wrote:

> Bernd Walter wrote:
>
> > I don't need Ethernut to save anything, because I do it myself in an
> > AT45DB chip.
> > But I'm unable to find the code using it so that I can disable.
> > Or is it just reserved for future use?
>
> Hi Bernd,
>
> at least saving the configuration had been removed from the system
> libraries in 4.9. Still, the system libraries read CONFOS and CONFNET.
>
> In general this is done by calling NutNvMemLoad(), provided in
> dev/nvmem.c. Depending on the configuration in include/cfg/eeprom.h,
> this routine may access the X12x6 EEPROM, an AT45DB or AT49BV flash
> memory, the internal EEPROM on AVR CPUs or the internal flash on AT91
> devices.

Ah - must have been blind.
I don't define NUT_CONFIG_AT91EFC and DHCP is working for me.
And At91EfcSectorRead isn't defined in the linked file.
DHCP of course isn't remembering it's former config, but this is ok
for me.
Guess I'm save to asume that nothing is changing Flash pages.

My network startup code is:
        NutRegisterDevice(&DEV_ETHER, 0, 0);
        NutNetLoadConfig(DEV_ETHER_NAME);
        if (getenv("ip") != NULL && getenv("netmask") != NULL && strcmp(getenv("ip"), "dhcp") != 0) {
                l_ip = inet_addr(getenv("ip"));
                l_mask = inet_addr(getenv("netmask"));
                NutNetIfConfig("eth0", my_mac, l_ip, l_mask);
                if (getenv("gateway") != NULL) {
                        l_gw = inet_addr(getenv("gateway"));
                        NutIpRouteAdd(0, 0, l_gw, &DEV_ETHER);
                }
        } else {
                while (NutDhcpIfConfig("eth0", my_mac, 60000) != 0);
        }
        if (getenv("dns") != NULL) {
                l_dns = inet_addr(getenv("dns"));
                NutDnsConfig(0, 0, l_dns);
        }

getenv is using AT45DB and is derived from AVR code, which was on this
list some time ago.
I'm quite happy with the code as is together with my own AT45DB code.
It was tricky enough, because I'm also running Micro-SD cards with
Nut/OS code on the same SPI.
my_mac is also filled via getenv at a different place, which is doing
the hex parsing.

> If no valid configuration for NVMEM is available, NutLoadConfig will
> return an error, but still set an default hostname. NutNetLoadConfig
> will also return with error, but still set the MAC address to all bits
> set and all other items cleared to zero.
>
> The problem is, that the returned error will let higher level routines
> fail (e.g. DHCP).

No problems with DHCP so far and it seems that I really don't have any
kind of NV configured.

> In your special case I'd suggest to configure NUT_CONFIG_AT45D (new SPI
> bus interface) or NUT_CONFIG_AT45DB (old with integrated SPI routines.
> For the latter you may then even implement your own At45dbParamRead() to
> override default linking to dev/at45db.c.
>
> Harald
>
>

--
B.Walter <bernd@...> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: config flashspace usage on SAM7X256

by Bernd Walter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Jun 20, 2009 at 01:35:50PM +0200, Harald Kipp wrote:
> Bernd Walter wrote:
>
> > I don't need Ethernut to save anything, because I do it myself in an
> > AT45DB chip.
> > But I'm unable to find the code using it so that I can disable.
> > Or is it just reserved for future use?
>
> Hi Bernd,

Hi Harald,
 maybe this is of interest for you and others.
I've reduced the code size about 50k by switching several Ethernut
files to thumb.
Thumb running from flash should be faster on SAM7X anyway.
My own code was thumb already.

os failed because of ISR or assembly code.
dev and arch were not tried because of possible ISR code.
Maybe I missed something.
Others probably want it in a more configureable fashion.

[1491]devel> svn diff contrib/ethernut-4.8.2/
Index: contrib/ethernut-4.8.2/pro/Makefile
===================================================================
--- contrib/ethernut-4.8.2/pro/Makefile (revision 4191)
+++ contrib/ethernut-4.8.2/pro/Makefile (working copy)
@@ -116,6 +116,7 @@
 LIBDIR = $(top_blddir)/lib
 include $(top_srcdir)/UserConf.mk
 include $(top_srcdir)/Makedefs
+CPFLAGS+= -mthumb
 
 SRCS =  dhcpc.c resolv.c httpd.c httpd_p.c rfctime.c httpopt.c ssi.c asp.c auth.c cgi.c dencode.c sntp.c syslog.c ftpd.c \
        wins.c discover.c snmp.c snmp_agent.c snmp_api.c snmp_auth.c snmp_config.c snmp_mib.c asn1.c \
Index: contrib/ethernut-4.8.2/fs/Makefile
===================================================================
--- contrib/ethernut-4.8.2/fs/Makefile  (revision 4191)
+++ contrib/ethernut-4.8.2/fs/Makefile  (working copy)
@@ -90,6 +90,7 @@
 LIBDIR = $(top_blddir)/lib
 include $(top_srcdir)/UserConf.mk
 include $(top_srcdir)/Makedefs
+CPFLAGS+= -mthumb
 
 SRCS = pathops.c dirent.c fat.c uromfs.c pnutfs.c \
        phatfs.c phatvol.c phatdir.c phatio.c \
Index: contrib/ethernut-4.8.2/crt/Makefile
===================================================================
--- contrib/ethernut-4.8.2/crt/Makefile (revision 4196)
+++ contrib/ethernut-4.8.2/crt/Makefile (working copy)
@@ -85,6 +85,7 @@
 LIBDIR = $(top_blddir)/lib
 include $(top_srcdir)/UserConf.mk
 include $(top_srcdir)/Makedefs
+CPFLAGS+= -mthumb
 
 SRCC =  close.c clrerr.c ioctl.c open.c getf.c read.c putf.c write.c fclose.c \
         fcloseall.c fdopen.c feof.c ferror.c fflush.c filelength.c fileno.c flushall.c \
Index: contrib/ethernut-4.8.2/gorp/Makefile
===================================================================
--- contrib/ethernut-4.8.2/gorp/Makefile        (revision 4191)
+++ contrib/ethernut-4.8.2/gorp/Makefile        (working copy)
@@ -45,6 +45,7 @@
 LIBDIR = $(top_blddir)/lib
 include $(top_srcdir)/UserConf.mk
 include $(top_srcdir)/Makedefs
+CPFLAGS+= -mthumb
 
 SRCS =  base64/base64_decode.c \
         base64/base64_encode.c \
Index: contrib/ethernut-4.8.2/lua/Makefile
===================================================================
--- contrib/ethernut-4.8.2/lua/Makefile (revision 4192)
+++ contrib/ethernut-4.8.2/lua/Makefile (working copy)
@@ -10,6 +10,7 @@
 
 include $(top_srcdir)/UserConf.mk
 include $(top_srcdir)/Makedefs
+CPFLAGS+= -mthumb
 
 SRCS = lapi.c ldo.c ldump.c ldebug.c lfunc.c lgc.c \
        lmem.c lobject.c lopcodes.c lstate.c lstring.c ltable.c \
Index: contrib/ethernut-4.8.2/net/Makefile
===================================================================
--- contrib/ethernut-4.8.2/net/Makefile (revision 4191)
+++ contrib/ethernut-4.8.2/net/Makefile (working copy)
@@ -86,6 +86,7 @@
 LIBDIR = $(top_blddir)/lib
 include $(top_srcdir)/UserConf.mk
 include $(top_srcdir)/Makedefs
+CPFLAGS+= -mthumb
 
 SRC1 =  tcpsock.c tcpsm.c tcpin.c tcpout.c tcputil.c \
        udpsock.c udpin.c udpout.c \

--
B.Walter <bernd@...> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: config flashspace usage on SAM7X256

by Tim DeBaillie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bernd Walter wrote:

> Hi Harald,
>  maybe this is of interest for you and others.
> I've reduced the code size about 50k by switching several Ethernut
> files to thumb.
> Thumb running from flash should be faster on SAM7X anyway.
> My own code was thumb already.
>
> os failed because of ISR or assembly code.
> dev and arch were not tried because of possible ISR code.
> Maybe I missed something.
> Others probably want it in a more configureable fashion.
>
> [1491]devel> svn diff contrib/ethernut-4.8.2/
> Index: contrib/ethernut-4.8.2/pro/Makefile
> ===================================================================
> --- contrib/ethernut-4.8.2/pro/Makefile (revision 4191)
> +++ contrib/ethernut-4.8.2/pro/Makefile (working copy)
> @@ -116,6 +116,7 @@
>  LIBDIR = $(top_blddir)/lib
>  include $(top_srcdir)/UserConf.mk
>  include $(top_srcdir)/Makedefs
> +CPFLAGS+= -mthumb
>  
>  SRCS =  dhcpc.c resolv.c httpd.c httpd_p.c rfctime.c httpopt.c ssi.c asp.c auth.c cgi.c dencode.c sntp.c syslog.c ftpd.c \
>         wins.c discover.c snmp.c snmp_agent.c snmp_api.c snmp_auth.c snmp_config.c snmp_mib.c asn1.c \
> Index: contrib/ethernut-4.8.2/fs/Makefile
> ===================================================================
> --- contrib/ethernut-4.8.2/fs/Makefile  (revision 4191)
> +++ contrib/ethernut-4.8.2/fs/Makefile  (working copy)
> @@ -90,6 +90,7 @@
>  LIBDIR = $(top_blddir)/lib
>  include $(top_srcdir)/UserConf.mk
>  include $(top_srcdir)/Makedefs
> +CPFLAGS+= -mthumb
>  
>  SRCS = pathops.c dirent.c fat.c uromfs.c pnutfs.c \
>         phatfs.c phatvol.c phatdir.c phatio.c \
> Index: contrib/ethernut-4.8.2/crt/Makefile
> ===================================================================
> --- contrib/ethernut-4.8.2/crt/Makefile (revision 4196)
> +++ contrib/ethernut-4.8.2/crt/Makefile (working copy)
> @@ -85,6 +85,7 @@
>  LIBDIR = $(top_blddir)/lib
>  include $(top_srcdir)/UserConf.mk
>  include $(top_srcdir)/Makedefs
> +CPFLAGS+= -mthumb
>  
>  SRCC =  close.c clrerr.c ioctl.c open.c getf.c read.c putf.c write.c fclose.c \
>          fcloseall.c fdopen.c feof.c ferror.c fflush.c filelength.c fileno.c flushall.c \
> Index: contrib/ethernut-4.8.2/gorp/Makefile
> ===================================================================
> --- contrib/ethernut-4.8.2/gorp/Makefile        (revision 4191)
> +++ contrib/ethernut-4.8.2/gorp/Makefile        (working copy)
> @@ -45,6 +45,7 @@
>  LIBDIR = $(top_blddir)/lib
>  include $(top_srcdir)/UserConf.mk
>  include $(top_srcdir)/Makedefs
> +CPFLAGS+= -mthumb
>  
>  SRCS =  base64/base64_decode.c \
>          base64/base64_encode.c \
> Index: contrib/ethernut-4.8.2/lua/Makefile
> ===================================================================
> --- contrib/ethernut-4.8.2/lua/Makefile (revision 4192)
> +++ contrib/ethernut-4.8.2/lua/Makefile (working copy)
> @@ -10,6 +10,7 @@
>  
>  include $(top_srcdir)/UserConf.mk
>  include $(top_srcdir)/Makedefs
> +CPFLAGS+= -mthumb
>  
>  SRCS = lapi.c ldo.c ldump.c ldebug.c lfunc.c lgc.c \
>         lmem.c lobject.c lopcodes.c lstate.c lstring.c ltable.c \
> Index: contrib/ethernut-4.8.2/net/Makefile
> ===================================================================
> --- contrib/ethernut-4.8.2/net/Makefile (revision 4191)
> +++ contrib/ethernut-4.8.2/net/Makefile (working copy)
> @@ -86,6 +86,7 @@
>  LIBDIR = $(top_blddir)/lib
>  include $(top_srcdir)/UserConf.mk
>  include $(top_srcdir)/Makedefs
> +CPFLAGS+= -mthumb
>  
>  SRC1 =  tcpsock.c tcpsm.c tcpin.c tcpout.c tcputil.c \
>         udpsock.c udpin.c udpout.c \
>
>  

Bernd,

I attempted to change the CRT to -mthumb. This is the error I received:

collect2: ld terminated with signal 11 [Segmentation fault]
arm-elf/bin/ld:
/usr/local/gnuarm/lib/gcc/arm-elf/4.2.3/libgcc.a(_udivsi3.o)(__udivsi3):
warning: interworking not enabled.
first occurrence: nutos/hubblt/libnutcrt.a(fread.o): thumb call to arm
arm-elf/bin/ld: BFD (GNU Binutils) 2.18 assertion fail elf32-arm.c:6532
nutos/hubblt/libnutcrt.a(fread.o): In function `fread':
fread.c:(.text+0x54): dangerous relocation: make: *** [hub.elf] Error 1


Do I have to install a thumb cross compiler or something? If so, where
do I find such a beast.

I'm running Ubuntu 9.04.


Thanks,
Tim

--
Tim DeBaillie

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: config flashspace usage on SAM7X256

by Bernd Walter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 22, 2009 at 09:30:49AM -0500, Timothy M. De Baillie wrote:
> Bernd,
>
> I attempted to change the CRT to -mthumb. This is the error I received:
>
> collect2: ld terminated with signal 11 [Segmentation fault]

Bad thing - ld shouldn't segfault, but anyway - this is just a ugly
symptom of another problem.

> arm-elf/bin/ld:
> /usr/local/gnuarm/lib/gcc/arm-elf/4.2.3/libgcc.a(_udivsi3.o)(__udivsi3):
> warning: interworking not enabled.
> first occurrence: nutos/hubblt/libnutcrt.a(fread.o): thumb call to arm
> arm-elf/bin/ld: BFD (GNU Binutils) 2.18 assertion fail elf32-arm.c:6532
> nutos/hubblt/libnutcrt.a(fread.o): In function `fread':
> fread.c:(.text+0x54): dangerous relocation: make: *** [hub.elf] Error 1
>
>
> Do I have to install a thumb cross compiler or something? If so, where
> do I find such a beast.

You also need to enable thumb interwork support, because not everything
can be thumb.
I have:
[1597]devel> grep interwork contrib/ethernut-4.8.2/Makedefs
# Generating code that works with mixed arm and thumb mode (interwork).
CPFLAGS = $(MCFLAGS) -Os -mthumb-interwork -fomit-frame-pointer -Wall -Werror -Wstrict-prototypes -Wa,-ahlms=$(@:.o=.lst) $(DEFS) $(UCPFLAGS)

Not sure if I added it myself or was default.
-mthumb-interwork is the importent point.
newlib needs this support as well, but usually the linker automatically
selects the right one if you add the parametrs to the linker process
as well.
But the error message clearly says that libnutcrt was missing interwork
support.

--
B.Walter <bernd@...> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion