STM32F4xx Kompillieren von LwIP Demo

OP (Firma: EleLa - www.elela.de) #2472377
Lesenswert?
• ▲
▼
Hallo,

Ich bin grad dabei das Demo-Projekt von ST mit Eclipse / GCC zu 
kompillieren.

Das Kompilieren klappt soweit, aber mit dem Linken hat der jetzt noch 
ein Problem:
1
arm-none-eabi-gcc ./out/src/LwIP/fs.o ./out/src/LwIP/fsdata.o ./out/src/LwIP/httpserver-netconn.o ./out/src/LwIP/main.o ./out/src/LwIP/netconf.o ./out/src/LwIP/serial_debug.o ./out/src/LwIP/stm32f4x7_eth_bsp.o ./out/src/LwIP/stm32f4xx_it.o ./out/src/LwIP/system_stm32f4xx.o ./out/lib/src/misc.o ./out/lib/system_stm32f4xx.o ./out/lib/src/stm32f4xx_exti.o ./out/lib/src/stm32f4xx_flash.o ./out/lib/src/stm32f4xx_gpio.o ./out/lib/src/stm32f4xx_rcc.o ./out/lib/src/stm32f4xx_syscfg.o ./out/lib/FreeRTOS/croutine.o ./out/lib/FreeRTOS/list.o ./out/lib/FreeRTOS/queue.o ./out/lib/FreeRTOS/tasks.o ./out/lib/FreeRTOS/portable/heap_2.o ./out/lib/FreeRTOS/portable/port.o ./out/lib/LwIP/api/api_lib.o ./out/lib/LwIP/api/api_msg.o ./out/lib/LwIP/api/err.o ./out/lib/LwIP/api/netbuf.o ./out/lib/LwIP/api/netdb.o ./out/lib/LwIP/api/netifapi.o ./out/lib/LwIP/api/sockets.o ./out/lib/LwIP/api/tcpip.o ./out/lib/LwIP/core/dhcp.o ./out/lib/LwIP/core/dns.o ./out/lib/LwIP/core/init.o ./out/lib/LwIP/core/mem.o ./out/lib/LwIP/core/memp.o ./out/lib/LwIP/core/netif.o ./out/lib/LwIP/core/pbuf.o ./out/lib/LwIP/core/raw.o ./out/lib/LwIP/core/stats.o ./out/lib/LwIP/core/sys.o ./out/lib/LwIP/core/tcp.o ./out/lib/LwIP/core/tcp_in.o ./out/lib/LwIP/core/tcp_out.o ./out/lib/LwIP/core/udp.o ./out/lib/LwIP/core/ipv4/autoip.o ./out/lib/LwIP/core/ipv4/icmp.o ./out/lib/LwIP/core/ipv4/igmp.o ./out/lib/LwIP/core/ipv4/inet.o ./out/lib/LwIP/core/ipv4/inet_chksum.o ./out/lib/LwIP/core/ipv4/ip.o ./out/lib/LwIP/core/ipv4/ip_addr.o ./out/lib/LwIP/core/ipv4/ip_frag.o ./out/lib/LwIP/netif/etharp.o ./out/lib/LwIP/netif/ethernetif.o ./out/lib/LwIP/netif/sys_arch.o ./out/lib/LwIP/eth/stm32f4x7_eth.o -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -nostartfiles -T./prj/STM32F4xxxG-ROM_ST-LINK.ld -Wl,-Map=MainApp_rom.map,--cref,--no-warn-mismatch -L/WinARM/CodeSourcery/arm-none-eabi/lib -lc  -o MainApp_rom.elf
2
./out/src/LwIP/fsdata.o:(.rodata+0xa928): multiple definition of `file__STM32F4x7_files_logo_jpg'
3
./out/src/LwIP/fs.o:(.rodata+0xa928): first defined here
4
./out/src/LwIP/fsdata.o:(.rodata+0xa93c): multiple definition of `file__STM32F4x7_files_ST_gif'
5
./out/src/LwIP/fs.o:(.rodata+0xa93c): first defined here
6
./out/src/LwIP/fsdata.o:(.rodata+0xa950): multiple definition of `file__STM32F4x7_files_stm32_jpg'
7
./out/src/LwIP/fs.o:(.rodata+0xa950): first defined here
8
./out/src/LwIP/fsdata.o:(.rodata+0xa964): multiple definition of `file__404_html'
9
./out/src/LwIP/fs.o:(.rodata+0xa964): first defined here
10
./out/src/LwIP/fsdata.o:(.rodata+0xa978): multiple definition of `file__STM32F4x7_html'
11
./out/src/LwIP/fs.o:(.rodata+0xa978): first defined here
12
./out/lib/system_stm32f4xx.o:(.data+0x0): multiple definition of `SystemCoreClock'
13
./out/src/LwIP/system_stm32f4xx.o:(.data+0x0): first defined here
14
./out/lib/system_stm32f4xx.o:(.data+0x4): multiple definition of `AHBPrescTable'
15
./out/src/LwIP/system_stm32f4xx.o:(.data+0x4): first defined here
16
./out/lib/system_stm32f4xx.o: In function `SystemInit':
17
D:\WinARM\Projekt\Proj_USBDspyII\MainApp/lib/system_stm32f4xx.c:209: multiple definition of `SystemInit'
18
./out/src/LwIP/system_stm32f4xx.o:D:\WinARM\Projekt\Proj_USBDspyII\MainApp/src/LwIP/system_stm32f4xx.c:209: first defined here
19
./out/lib/system_stm32f4xx.o: In function `SystemCoreClockUpdate':
20
D:\WinARM\Projekt\Proj_USBDspyII\MainApp/lib/system_stm32f4xx.c:287: multiple definition of `SystemCoreClockUpdate'
21
./out/src/LwIP/system_stm32f4xx.o:D:\WinARM\Projekt\Proj_USBDspyII\MainApp/src/LwIP/system_stm32f4xx.c:287: first defined here
22
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
23
sbrkr.c:(.text+0x18): undefined reference to `_sbrk'
24
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-writer.o): In function `_write_r':
25
writer.c:(.text+0x20): undefined reference to `_write'
26
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-closer.o): In function `_close_r':
27
closer.c:(.text+0x18): undefined reference to `_close'
28
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-fstatr.o): In function `_fstat_r':
29
fstatr.c:(.text+0x1c): undefined reference to `_fstat'
30
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-isattyr.o): In function `_isatty_r':
31
isattyr.c:(.text+0x18): undefined reference to `_isatty'
32
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-lseekr.o): In function `_lseek_r':
33
lseekr.c:(.text+0x20): undefined reference to `_lseek'
34
/WinARM/CodeSourcery/arm-none-eabi/lib\libc.a(lib_a-readr.o): In function `_read_r':
35
readr.c:(.text+0x20): undefined reference to `_read'
36
collect2: ld returned 1 exit status
37
gmake: *** [MainApp_rom.elf] Error 1

Den Linb Path und -lc habe ich angegeben, aber irgendwie klappt das 
nicht.
Kann mir bitte jemand auf die Sprünge helfen was da noch fehlt damit ich 
das
undefined reference to `_sbrk'
: : :
weg bekomme?

Gruß Markus
Persönliche Seite #2472568
Lesenswert?
• ▲
▼
Moin Markus,

das sieht danach aus als wenn du die newlib verwendest.

lies dir das mal durch.

Modify this linkerscript a little bit:

[...]
.bss :
{
  _bss = .;
  *(.bss*)
  *(COMMON)
  _ebss = .;
  . = ALIGN (8);
  _end = .;
} > SRAM

PROVIDE(__HEAP_START = _end );
[...]

(2) create a file syscalls.c and add the following code:

/* based on a example-code from Keil for CS G++ */

/* for caddr_t (typedef char * caddr_t;) */
#include <sys/types.h>

extern int  __HEAP_START;

caddr_t _sbrk ( int incr )
{
  static unsigned char *heap = NULL;
  unsigned char *prev_heap;

  if (heap == NULL) {
    heap = (unsigned char *)&__HEAP_START;
  }
  prev_heap = heap;
  /* check removed to show basic approach */

  heap += incr;

  return (caddr_t) prev_heap;
}

(3) make sure the file is compiled and the object-code from it gets
linked

This should get you started (not tested here). You can add additional
"out of heap-space" checks later if needed.


Ich hab das Problem schon mal um schifft durch ne neu implementation von 
printf. Musst mal checken was für dich besser ist newlib funktionen raus 
schmeißen oder diesen Workaround probieren.

MfG

Tec
#2472574
Lesenswert?
• ▲
▼
> undefined reference to `_sbrk'
Du verwendest die Newlib, die bei CodeSourcery G++ dabei liegt? Dann 
fehlt noch:
1
 -lcs3unhosted -lgcc

Aber da sind noch mehr Fehler: IIRC included "fs.c" die "fsdata.c", 
letztere darf man also nicht mit kompilieren/linken. Außerdem hast Du 
die Datei "system_stm32f4xx.o" in zwei Verzeichnissen.
OP (Firma: EleLa - www.elela.de) #2476613
Lesenswert?
• ▲
▼
Vielen Dank für die Tipps, ich habe es nun hin bekommen, zumindest 
klappt jetzt das kompilieren.

Zusätzlich waren noch die Änderungen nötig:
LD Datei:
1
    /* heap section */
2
    .co_heap (NOLOAD):
3
    {
4
      __cs3_heap_start = . ;
5
        . = ALIGN(8);
6
        *(.co_heap .co_heap.*)
7
     __cs3_heap_end = . ;
8
    } > ram

und irgendwo in der main.c:
1
#define HEAPSIZE 0x100
2
unsigned char __cs3_heap_start[HEAPSIZE] __attribute__ ((section (".bss.extsram"), aligned(8)));
3
unsigned char *__cs3_heap_limit = __cs3_heap_start + HEAPSIZE;

Laufen (LED Blinken) tut noch nicht. Da muss ich noch etwas mehr suchen.

Antwort schreiben

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.