generate makefile

shenhome
Posts: 2
Joined: Thu Apr 06, 2017 9:14 pm

generate makefile

Postby shenhome » Thu Apr 06, 2017 9:42 pm

hello,

Is there any instructions for how to generate makefile?

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: generate makefile

Postby Her Mary » Fri Apr 07, 2017 2:29 pm

google it ?

mforcen
Posts: 1
Joined: Fri Apr 07, 2017 6:25 pm

Re: generate makefile

Postby mforcen » Fri Apr 07, 2017 6:37 pm

There are several examples of makefile within the net.
Found mine attached here:

Code: Select all

AR = xtensa-lx106-elf-ar
CC = xtensa-lx106-elf-gcc
NM = xtensa-lx106-elf-nm
CPP = xtensa-lx106-elf-g++
LD = xtensa-lx106-elf-gcc
OBJCOPY = xtensa-lx106-elf-objcopy
OBJDUMP = xtensa-lx106-elf-objdump

CFLAGS +=            \
   -Os            \
   -g            \
   -Wpointer-arith         \
   -Wundef            \
   -Werror            \
   -Wl,-EL            \
   -fno-inline-functions      \
   -nostdlib         \
   -mlongcalls         \
   -mtext-section-literals      \
   -D__ets__         \
   -DICACHE_FLASH         

CCFLAGS +=            \
   -Os            \
   -g            \
   -Wpointer-arith         \
   -Wundef            \
   -Werror            \
   -Wl,-EL            \
   -fno-inline-functions      \
   -nostdlib         \
   -mlongcalls         \
   -mtext-section-literals      \
   -D__ets__         \
   -DICACHE_FLASH         \
   -fno-rtti         \
   -fno-exceptions
   
INCLUDES +=                  \
    -I/opt/Espressif/ESP8266_NONOS_SDK/include   \
    -Iinclude               \
    -I.

LDDIR = -L/opt/Espressif/ESP8266_NONOS_SDK/lib/

LDFILE = -Teagle.app.v6.ld

LIBS = -lc -lmain -lgcc -lssl -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lwpa2 -lupgrade -lpwm -lsmartconfig -lwps -lcrypto -luart -lssl
   
   

SRC = $(wildcard *.cpp)
SRCC = $(wildcard *.c)
GDBSRC = $(wildcard gdb/*.c)
GDBASM = $(wildcard gdb/*.S)
OBJ = $(SRC:.cpp=.cpp.o)
OBJC =$(SRCC:.c=.o)
GDBASMOBJ = $(GDBASM:.S=.o)
GDBOBJ = $(GDBSRC:.c=.o)

LDFLAGS +=         \
   -nostdlib      \
   -Wl,--no-check-sections   \
   -u call_user_start   \
   -Wl,-static      \
   $(LDDIR)      \
   $(LDFILE)      \
   -Wl,--start-group   \
   $(LIBS)         \
   app.a         \
   -Wl,--end-group   

all: fichero.app.out
   xtensa-lx106-elf-objdump --headers --section=.data --section=.rodata --section=.bss --section=.text --section=.irom0.text fichero.app.out

   xtensa-lx106-elf-objcopy --only-section .text --output-target binary fichero.app.out eagle.app.v6.text.bin

   xtensa-lx106-elf-objcopy --only-section .data --output-target binary fichero.app.out eagle.app.v6.data.bin

   xtensa-lx106-elf-objcopy --only-section .rodata --output-target binary fichero.app.out eagle.app.v6.rodata.bin

   xtensa-lx106-elf-objcopy --only-section .irom0.text --output-target binary fichero.app.out eagle.app.v6.irom0text.bin
   
   python /opt/Espressif/ESP8266_NONOS_SDK/tools/gen_appbin.py fichero.app.out 0 0 0 0 6
   
fichero.app.out: compile
   $(LD) $(LDFLAGS) -o $@
   
compile: app.a

app.a: $(OBJ) $(OBJC) $(GDBOBJ) $(GDBASMOBJ)
   xtensa-lx106-elf-ar -cru app.a $^
   
$(OBJ): $(SRC)
   $(CPP) $(CCFLAGS) $(INCLUDES) -c $(@:.o=) -o $@
   
$(OBJC): $(SRCC)
   $(CC) $(CFLAGS) $(INCLUDES) -c $(@:.o=.c) -o $@
   
$(GDBOBJ): $(GDBSRC)
   $(CC) $(CFLAGS) $(INCLUDES) -c $(@:.o=.c) -o $@

$(GDBASMOBJ): $(GDBASM)
   $(CC) $(INCLUDES) -c $(@:.o=.S) -o $@
   
clean:
   rm app.a *.o
   rm eagle.app.v6.data.bin eagle.app.v6.irom0text.bin
   rm eagle.app.v6.rodata.bin eagle.app.v6.text.bin fichero.app.out
   rm eagle.app.flash.bin
   rm gdb/*.o
   
flash:
   esptool.py -p /dev/ttyUSB0 -b 115200 write_flash --flash_freq 40m --flash_mode qio --flash_size 32m 0x00000 eagle.app.flash.bin 0x10000 eagle.app.v6.irom0text.bin 0x3FC000 esp_init_data_default.bin  0x3FE000 blank.bin


It is intended to work with C and C++ sources (xtensa ports from jcmvbkbc at Github) using SDK.

Who is online

Users browsing this forum: No registered users and 60 guests