These are chat archives for esp8266/Arduino

26th
May 2016
liangzelang
@liangzelang
May 26 2016 05:21

The broadcast address for an IPv4 host can be obtained by performing a bitwise OR operation between the bit complement of the subnet mask and the host's IP address. In other words, take the host's IP address, and set to '1' any bit positions which hold a '0' in the subnet mask.

Example: For broadcasting a packet to an entire IPv4 subnet using the private IP address space 172.16.0.0/12, which has the subnet mask 255.240.0.0, the broadcast address is 172.16.0.0 | 0.15.255.255 = 172.31.255.255.

A special definition exists for the IP broadcast address 255.255.255.255. It is the broadcast address of the zero network or 0.0.0.0, which in Internet Protocol standards stands for this network, i.e. the local network. Transmission to this address is limited by definition, in that it is never forwarded by the routers connecting the local network to other networks.

while my subnet MASK is 0.0.0.0
aneek231
@aneek231
May 26 2016 09:05
Hi! I am using <GDBStub.h> library for ESP8266. When I call gdbstub_do_break(); for generating an interrupt to go into gdbstub, the wdt stats resetting but When I call gdbstub_init_debug_entry(); before gdbstub_do_break(); , then it works fine although in the readme file for this library , I have not seen that we should call this function.
aneek231
@aneek231
May 26 2016 09:21
Secondly after successfully inserting breakpoints at some line, I get cannot insert breakpoint error accessing memory.
But on some other lines , it works perfect.
Ivan Grokhotkov
@igrr
May 26 2016 09:41
are you using br command in gdb? or hbr?
aneek231
@aneek231
May 26 2016 09:41
br
Ivan Grokhotkov
@igrr
May 26 2016 09:42
well when you tell gdb stub to br, it literally tries to insert a break instruction at given address
if the address is in flash, this will fail
hbr uses hardware breakpoint register of the CPU so it may be used for flash code as well
Mario Mikočević
@mozgy
May 26 2016 09:43
@igrr github web page still says 2.2-rc, is this on purpose ?
Ivan Grokhotkov
@igrr
May 26 2016 09:43
no i guess i forgot to update that. doesn't happen automatically unfortunately.
aneek231
@aneek231
May 26 2016 09:44
if there is only 1 hbr supported ?
Ivan Grokhotkov
@igrr
May 26 2016 09:45
Correct, the CPU only has 1 hardware breakpoint.
but you can remove it with del command and set a new one
aneek231
@aneek231
May 26 2016 09:46
can you please tell me the other question as well
Ivan Grokhotkov
@igrr
May 26 2016 09:46
which is?
aneek231
@aneek231
May 26 2016 09:47
why I need to call gdbstub_init_debug_entry(); with gdbstub_do_break(); ?
otherwise wdi starts resetting
but when I call gdbstub_init_debug_entry(); before that it goes into gdb stub
successfully :)
Ivan Grokhotkov
@igrr
May 26 2016 09:48
gdbstub_init_debug_entry should be called from gdbstub_init, which is called from user_init (i.e. program entry point)
i.e. this should happen automatically
something's not working right i guess
can you add some printf into gdbstub_init to see if it gets called?
that is in libraries/GDBStub/src/internal/gdbstub.c:776
aneek231
@aneek231
May 26 2016 09:50
I have not called gdbstub_init myself
and also didnt include any user_init
Ivan Grokhotkov
@igrr
May 26 2016 09:50
you shouldn't, gdbstub_init gets called from main
aneek231
@aneek231
May 26 2016 09:50
okay
i have just included <GDBStub.h>
That's basically the call chain. And it should work with just #include <GDBStub.h> in the sketch
so, try adding a printf into gdbstub_init function at libraries/GDBStub/src/internal/gdbstub.c:776 to see if it gets called
aneek231
@aneek231
May 26 2016 09:53
Okay thanks let me figure out
aneek231
@aneek231
May 26 2016 11:56
gdbstub_init is not being called
so I have to call gdbstub_init(); in my setup(). I am worried that instead of gdbstub_init(); if I call gdb_init() it doesnt work
although gdb_init calls gdbstub_init() :worried:
What is the difference in both functions
Ivan Grokhotkov
@igrr
May 26 2016 12:33
Are you using Arduino IDE or something else to build the code (Platfrom.IO, Eclipse)?
aneek231
@aneek231
May 26 2016 12:33
Platformio
Ivan Grokhotkov
@igrr
May 26 2016 12:34
Ah, well, that would explain it I guess. Could you please try to build the same sketch with Arduino IDE? Without calling gdbstub_init in setup, just include GDBStub.h
I want to make sure it works in Arduino for you
because it does for me ;)
aneek231
@aneek231
May 26 2016 12:36
Ohh I don't have it. You think this might be a problem ?
Ivan Grokhotkov
@igrr
May 26 2016 12:38
Well i don't have platform.io to tell exactly...
aneek231
@aneek231
May 26 2016 12:39
Okay :)
thanks btw :)
aneek231
@aneek231
May 26 2016 12:47
Now I am writing this to my actual sketch
gdbstub_init();
gdbstub_do_break();
I am getting this error
/home/aneek231/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pioenvs/esp12e/firmware.elf section .text' will not fit in regioniram1_0_seg'
collect2: error: ld returned 1 exit status
What does it mean ?
aneek231
@aneek231
May 26 2016 12:54
I get this error during compilation
Ivan Grokhotkov
@igrr
May 26 2016 12:55
This means that you have run out of code space in IRAM.
What other libraries do you use in your sketch?
aneek231
@aneek231
May 26 2016 12:57
A lot of :worried:
Ivan Grokhotkov
@igrr
May 26 2016 12:59
There's little that you can do in that case... You may try to move GDBStub from IRAM into flash, reverting this change: https://github.com/esp8266/Arduino/commit/4b3c36b4304420a343e0c030df8389e1c9443784#diff-1d7867bbf97ef2a55b63ab5333de3737
but, depending on when you hit a breakpoint, it may no longer work.
i.e. if you happen to hit a breakpoint or an exception when flash cache is disabled, it's not going to work.
but you may at least try.
aneek231
@aneek231
May 26 2016 13:11
How much code space it requires
because I already have it around 150K
Ivan Grokhotkov
@igrr
May 26 2016 13:12
code space in IRAM
not in flash
you can tell how much space is used in each memory region by running xtensa-esp108-elf-size -A <your_sketch_name>.elf
aneek231
@aneek231
May 26 2016 13:13
Oh okay ;)
Ivan Grokhotkov
@igrr
May 26 2016 13:13
oops
xtensa-lx106-elf-size
too much ESP32 today
Martin Ayotte
@martinayotte
May 26 2016 13:14
:-)
aneek231
@aneek231
May 26 2016 13:14
:D
Clemens Kirchgatterer
@everslick
May 26 2016 14:02

define ATTR_GDBFN ICACHE_FLASH_ATTR

but this did not make gdbstub fit into my firmware either :-(
even though i already optimized the hell out of it
Ivan Grokhotkov
@igrr
May 26 2016 14:04
can you run xtensa-lx106-elf-size -A sketch_name.elf on the elf file generated without GDBStub so i could get an idea how much hell is left there?
the path to xtensa-lx106-elf-size should be the same as xtensa-lx106-elf-gcc — see compilation log in IDE window
Clemens Kirchgatterer
@everslick
May 26 2016 14:21
.data 904 1073643520
.rodata 6620 1073644432
.bss 30288 1073651056
.irom0.text 272931 1075843088
.text 30446 1074790400
.comment 4985 0
LIBS = $(ESP_LIBS)/ESP8266WiFi \
$(ESP_LIBS)/ESP8266mDNS \
$(ESP_LIBS)/ESP8266WebServer \
$(ESP_LIBS)/EEPROM \
$(ESP_LIBS)/Hash \
$(ESP_LIBS)/arduinoWebSockets
Ivan Grokhotkov
@igrr
May 26 2016 14:23
.text 30446
approx. 2.3k left
Clemens Kirchgatterer
@everslick
May 26 2016 14:25
yeah, and it is already compiled with -Os
Ivan Grokhotkov
@igrr
May 26 2016 14:25
You aren't using Arduino IDE, are you?
Clemens Kirchgatterer
@everslick
May 26 2016 14:25
no, make
Ivan Grokhotkov
@igrr
May 26 2016 14:25
to compile the code, that is
Clemens Kirchgatterer
@everslick
May 26 2016 14:26
i use a modified version of makeESPArduino
Ivan Grokhotkov
@igrr
May 26 2016 14:29
Usually when i need to figure out why something doesn't fit into somewhere, i do it like this:
  • do objdump -j .text -t <elf output file> before adding problematic code (in this case, GDBStub)
  • increase segment size in linker script, in this case iram1_0_seg. this obviously will not run on the device, but you will be able to analyze .elf output
  • do objdump once again and compare the output
Clemens Kirchgatterer
@everslick
May 26 2016 14:30
ahh, ic. nice trick
Ivan Grokhotkov
@igrr
May 26 2016 14:31
piping objdump output through something like | awk '{print $3}' | sort can help doing diff afterwards
i.e. get rid of column with addresses which will obviously be different
and leave just the column with symbol names
Clemens Kirchgatterer
@everslick
May 26 2016 14:37
hmm, but here i have different number of columns i.e.:
40100050 g .text 00000000 _UserExceptionVector
40100000 g .text 00000000 _stext
4010109c g F .text 00000000 .hidden __gedf2
last line has F while other two have them not
Clemens Kirchgatterer
@everslick
May 26 2016 14:48
anyway, i see that gdbstub functions are now in the .text segment even though i set ATTR_GDBFN to ICACHE_FLASH_ATTR
BUT: i did it in my own c file before including gdbstub.h and i now realized that there is no #ifndef guard for exactly THAT define in gdbstub-cfg.h
shouldn't it be like that:
#ifndef GDBSTUB_GDBFN
#define GDBSTUB_GDBFN ICACHE_RAM_ATTR
#endif
Ivan Grokhotkov
@igrr
May 26 2016 14:53
You added the define to your .c file? How would that have any effect on GDBStub's code?
Clemens Kirchgatterer
@everslick
May 26 2016 14:54
before #include <gdbstub.h>
no?
ah, it does not include gdbstub-cfg.h anyway
ok, then of course it does nothing
but still i could define them in the Makefile but GDBSTUB_GDBFN would be redefined in gdbstub-cfg.h because there is no guard
Ivan Grokhotkov
@igrr
May 26 2016 15:03
Why not just change gdbstub-cfg.h?
Clemens Kirchgatterer
@everslick
May 26 2016 15:04
i try to avoid changing files from other git repositories. to not have to worry about conflicts and merging
and then all the #ifndef guards are useless anyway (for the other defines)
Ivan Grokhotkov
@igrr
May 26 2016 15:06
i guess the rest can be overriden from a makefile
Clemens Kirchgatterer
@everslick
May 26 2016 15:07
yes exactly, all can but GDBSTUB_GDBFN can't
Clemens Kirchgatterer
@everslick
May 26 2016 15:40
gdbstub.c
/home/clemens/Devel/ESP8266/Arduino/libraries/GDBStub/src/internal/gdbstub.c: In function 'install_uart_hdlr':
/home/clemens/Devel/ESP8266/Arduino/libraries/GDBStub/src/internal/gdbstub.c:719:2: warning: passing argument 2 of 'ets_isr_attach' from incompatible pointer type [enabled by default]
/home/clemens/Devel/ESP8266/Arduino/tools/sdk/include/ets_sys.h:182:6: note: expected 'int_handler_t' but argument is of type 'void ()(void , void )'
void ets_isr_attach(int intr, int_handler_t handler, void
arg);
Clemens Kirchgatterer
@everslick
May 26 2016 16:08
ok this is wrong typedef in ets_sys.h
it should be typedef void (*int_handler_t)(void *, void *);
again i tried to compile with GDBStub now i get:
/tmp/espade/obj/gdbstub-entry.S.o: In function `noIcountReset':
/home/clemens/Devel/ESP8266/Arduino/libraries/GDBStub/src/internal/gdbstub-entry.S:117:(.text+0x6d): dangerous relocation: call0: call target out of range: gdbstub_handle_debug_exception
Clemens Kirchgatterer
@everslick
May 26 2016 16:17
hmpf, one has to pass -mlongcalls to the assembler flags to get rid of the call target out of range error
but now it links