ESP8266 Developer Zone The Official ESP8266 Forum 2017-10-12T19:02:43+08:00 https://bbs.espressif.com:443/feed.php?f=16&t=5843 2017-10-12T19:02:43+08:00 2017-10-12T19:02:43+08:00 https://bbs.espressif.com:443/viewtopic.php?t=5843&p=16398#p16398 <![CDATA[How to enable AT interface in your programs]]> Statistics: Posted by Andrewgvks — Thu Oct 12, 2017 7:02 pm


]]>
2017-08-18T23:38:51+08:00 2017-08-18T23:38:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=5843&p=15220#p15220 <![CDATA[Re: How to enable AT interface in your programs ?]]>
finally I successfully build this code using makefile attached at the end of this post.
Maybe someone will find it useful.

The difference is that there is one additional step between compilation and linking.
It is making archive (library) from the object file.
It somehow makes code not to overflow iram.

Example from my post compiles and runs, and as You said I can run all "standard" AT commands.

What I am struggling with now, is having both: AT commands and GPIO interrupt handler.

Finally I get down to two examples presented below.
This is what I do in void ICACHE_FLASH_ATTR sdk_init_done_cb(void).

I would appreciate if someone could point out what I do wrong.

a) in this setup I have interrupt handler working, but I cannot issue any AT command

Code:

at_init();
gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
ETS_GPIO_INTR_DISABLE();
ETS_GPIO_INTR_ATTACH(gpio_interrupt,NULL);
gpio_pin_intr_state_set(GPIO_ID_PIN(GPIO2), GPIO_PIN_INTR_NEGEDGE);
ETS_GPIO_INTR_ENABLE();


b) in this setup I can issue AT comands but interrupt handler is not working (I get wtd reset)

Code:

gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
ETS_GPIO_INTR_DISABLE();
ETS_GPIO_INTR_ATTACH(gpio_interrupt,NULL);
gpio_pin_intr_state_set(GPIO_ID_PIN(GPIO2), GPIO_PIN_INTR_NEGEDGE);
ETS_GPIO_INTR_ENABLE();
at_init();


Dominik

PS.

Code:

CFLAGS = -I. -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -D__ets__ -DICACHE_FLASH
LDLIBS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa -lmain -lat -lssl -lairkiss -lwps -lsmartconfig user_main.a -Wl,--end-group
LDFLAGS = -L/opt/esp-open-sdk/sdk/lib -T/opt/esp-open-sdk/sdk/ld/eagle.app.v6.ld

default: user_main-0x00000.bin

user_main.o: user_main.c
        xtensa-lx106-elf-gcc $(CFLAGS) -c user_main.c -o user_main.o

user_main.a: user_main.o
        xtensa-lx106-elf-ar cru user_main.a user_main.o

user_main: user_main.a
        xtensa-lx106-elf-gcc $(LDFLAGS) $(LDLIBS) -o user_main

user_main-0x00000.bin: user_main
        esptool.py elf2image $^

flash: user_main-0x00000.bin
        esptool.py --port /dev/ttyAMA0 --baud 115200 write_flash 0x00000 user_main-0x00000.bin 0x10000 user_main-0x10000.bin

clean:
        rm -f *.o
        rm -f *.bin
        rm -f user_main

Statistics: Posted by dniekowal — Fri Aug 18, 2017 11:38 pm


]]>
2017-08-07T12:37:55+08:00 2017-08-07T12:37:55+08:00 https://bbs.espressif.com:443/viewtopic.php?t=5843&p=15016#p15016 <![CDATA[Re: How to enable AT interface in your programs ?]]> https://github.com/espressif/ESP8266_NONOS_SDK/tree/master/examples/at
You should compile this example first, then remove all the custom command registrations. Then you can use AT commands and also have your own custom program.
Calling at_init enables all default AT commands. You can use the commands even if you don't add any new ones.

Statistics: Posted by Guest — Mon Aug 07, 2017 12:37 pm


]]>
2017-08-03T21:15:53+08:00 2017-08-03T21:15:53+08:00 https://bbs.espressif.com:443/viewtopic.php?t=5843&p=14977#p14977 <![CDATA[How to enable AT interface in your programs ?]]>
I am using esp-open-sdk.

AT commands work for default esp software (or after flashing esp with Espressif bin files).
Each time I overwrite default software with my own programs, the esp does not react to AT commands.

Do You know how to enable AT module in Your own programs ?
Is it possible ?

The Espressif SDK NONOS SDK API documentation says about at_custom.h and at_init(), but it looks like this is for developing custom AT commands.

I do not want to implement any custom AT commands, I just want expose standard functionality via AT commands (connecting to access point etc) in my own programs.

Is calling at_init() the right way to go ?

I tried to verify it on my own, but I am facing following problem.

This is my sketch:

Code:

#include <osapi.h>
#include <eagle_soc.h>
#include <at_custom.h>

void ICACHE_FLASH_ATTR user_init(void)
{
   uart_div_modify(0, UART_CLK_FREQ / 115200);
   os_delay_us(1000);

   at_init();
   at_port_print("\r\nAT module initialized\r\n");
}


And this is error I get while building:

Code:

xtensa-lx106-elf-gcc -I. -DICACHE_FLASH -mlongcalls   -c -o user_main.o user_main.c
xtensa-lx106-elf-gcc -Teagle.app.v6.ld  user_main.o  -nostdlib -Wl,--gc-sections -Wl,--start-group -lgcc -lmain -lnet80211 -lwpa -llwip -lpp -lphy -lc -lat -lairkiss -lwps -lsmartconfig -lespnow -lssl -Wl,--end-group -o user_main
/opt/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: user_main section `.text' will not fit in region `iram1_0_seg'
/opt/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: region `iram1_0_seg' overflowed by 3641 bytes
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'user_main' failed
make: *** [user_main] Error 1


I am using the same makefile for all my "projects", and it looks for me like I get this problem only when libat.a is used.

Thanks in advance.

Statistics: Posted by dniekowal — Thu Aug 03, 2017 9:15 pm


]]>