From: David K. <da...@em...> - 2014-04-18 20:41:07
|
If printf("Hello\n") does not work then stdout is not directed to the right port. rs232_print and printf should be calling the exact same same character output routine. If printf works then printf_P(PSTR("Hello\n")) should also work, the PSTR macro just forces an address in program flash memory, which printf_P uses to fetch the string. However printf_P("Hello") or printf(PSTR("Hello")) won't work, the _P routines expect an address in program flash. There are a lot of those, memcpy_P, strcmp_P, etc. The PRINTF macro is just a convenient way to avoid typing PSTR all the time. -----Original Message----- From: P Gupta Sent: Friday, April 18, 2014 4:19 PM To: Contiki developer mailing list Subject: Re: [Contiki-developers]Fwd:Fwd:Fwd:RegardingRS232supportforAtmega2560... Dear David Sir, Thanks for those gems of inputs, by those I am very easily now able to get the memory usage in decreasing order and am at work in optimizing those which are memory monsters :) Also, I am still not able to get rid of rs232_print() for getting prints; PRINTF and printf_P(STR, ...) are really not working for me, and this is getting really clumsy for me, cos whereever I want to see print (as in uip, etc.) PRINTF is used and those aren't giving out print even if I define DEBUG=1; what am I missing? Also, Arduino by default configures port 0 for debug, so have now dedicated RS232 port 1 for XBee. With regards, P Gupta On Sat, Apr 19, 2014 at 1:02 AM, David Kopf <da...@em...> wrote: The UART needs to be within 5% of nominal, see http://electronics.stackexchange.com/questions/27763/using-the-atmega328-with-the-internal-oscillator The internal oscillator depends greatly on temperature and to a lesser extent on Vcc and could vary by 10% over the allowed operating range. The factory value for OSCCAL is typically specified as 3% at 25°C and 5 volts. If there is an accurate crystal reference it does not take long to calibrate to within 1% under the current operating conditions. Timing accuracy is useful for some applications, for example turning the radio on at precise times to detect a transmission. A 1% error is not so great, 10 milliseconds per second, but parts per million can be had by comparing the phase of the cpu clock to an external watch crystal and wobbling OSCCAL around the average value, see https://github.com/contiki-os/contiki/wiki/RDC-Phase-optimization I have no experience with external RAM, don't know how easy it is to use but surely adds some complication. If at all possible I'd get it going with reduced memory by decreasing table and buffer sizes. To see what is using RAM look at the map file or run avr-objdump on the elf file. For example a webserver build that overflows RAM: $ avr-size -C --mcu=atmega128rfa1 webserver6.avr-atmega128rfa1 AVR Memory Usage ---------------- Device: atmega128rfa1 Program: 66834 bytes (51.0% Full) (.text + .data + .bootloader) Data: 19840 bytes (121.1% Full) (.data + .bss + .noinit) EEPROM: 41 bytes (1.0% Full) (.eeprom) The css_style sheet is taking 2571 bytes of RAM because I forget to compile it using the flash attribute: dak@Ginger ~/contiki/examples/webserver-ipv6 $ avr-objdump -t --section=.data webserver6.avr-atmega128rfa1 | sort -r --key=3 webserver6.avr-atmega128rfa1: file format elf32-avr 00800200 l d .data 00000000 .data 00801032 l O .data 00000a0b data_style_css 00800c56 l O .data 000003dc data_index_html 0080062f l O .data 0000030e data_files_shtml 0080095b l O .data 000002fb data_header_html ... Some RAM could be freed by reducing the length of the packet queue, or neighbor or route table sizes. rxframe is 389 bytes showing it allows three buffered 802.15.4 packets, going to single buffering would save 256 bytes: $ avr-objdump -t --section=.bss webserver6.avr-atmega128rfa1 | sort -r --key=3 webserver6.avr-atmega128rfa1: file format elf32-avr 00801dda l d .bss 00000000 .bss 0080295a l O .bss 00000a2c packets_memb_memb_mem 00802281 l O .bss 00000690 buframmem_memb_mem 008042a2 g O .bss 00000500 uip_aligned_buf 00803391 l O .bss 00000500 sicslowpan_aligned_buf 00804b0a g O .bss 000003c0 uip_ds6_nbr_cache 00803955 l O .bss 000003ac routememb_memb_mem 00801de0 l O .bss 00000208 conns_memb_mem 00803d11 l O .bss 00000200 parent_memb_memb_mem 00804010 g O .bss 00000186 rxframe 00804975 g O .bss 0000011b uip_ds6_if 00804869 g O .bss 000000fa uip_udp_conns 00802143 l O .bss 000000b2 packetbuf_aligned ... -----Original Message----- From: P Gupta Sent: Friday, April 18, 2014 10:38 AM To: Contiki developer mailing list Subject: Re: [Contiki-developers]Fwd:Fwd:Fwd:RegardingRS232supportforAtmega2560... Dear David Sir, Thanks for the inputs, I am testing the things. I haven't really done anything with the OSCCAL for arduino mega (like in avr-raven calibrate_rc_osc_32k() is called in initialize). Why is it actually required to be done, give me some insight. One more important thing I would like to discuss. It is regarding adding more memory to my Arduino Mega 2560. Off late, I have realized, that 8KB RAM is a bit less when using memb memory allocations. Need few KBs more I guess. There's a way to it, and that is by using 23K256 or 23LC1024 SRAM chip by Microchip which is SPI-compatible bus interface and adds 256Kbit/1 Mbit of memory. Now coming to Contiki, if I mount this chip on Arduino on SPI bus, for all the static memory related things, the internal memory is used by the OS and it's processes, while all the dynamic memory management done by memb (allocation, free) gets done from the external RAM on SPI ? With regards, P Gupta On Thu, Apr 17, 2014 at 11:51 PM, David Kopf <da...@em...> wrote: The RPL mote should send a couple of DIS packets at startup and the jackdaw in sniffer mode will report those as long as the radio channel is correct. That lets you debug the tx routine without even implementing the rx. In network mode the jackdaw will ignore packets with mismatching PANid, destination address, or checksum but raw packet mode 'r' will report the rest to wireshark. Junk characters are usually a baud rate mismatch. Verify the CPU frequency is what you think it is (e.g. turn on an LED, loop F_CPU times, turn off LED). If that frequency is right then the UART should output with the baud rate you set but it won't be exact unless using a crystal having a multiple of the baud rate. Try 9600 and increase from there. 57600 using the internal oscillator may require a change in OSCCAL. The UART output is shifted to RS232 levels, yes? -----Original Message----- From: P Gupta Sent: Wednesday, April 16, 2014 6:02 PM To: Contiki developer mailing list Subject: Re: [Contiki-developers]Fwd:Fwd:Fwd:RegardingRS232supportforAtmega2560... Dear David Sir, I was also thinking on the same grounds, thanks for confirming. The program uses mmem_* functions, hence, removing those would be difficult (and I have already reduced the mmem by MMEM_CONF_SIZE=512). Keeping it aside, I tried out simple-udp-rpl unicast sender with mmem commented from arduino-main and the board didn't hang (thus it's indeed stack overflow problem). I will see the way in which I can reduce the memory usage of the actual program. Meanwhile, the simple-udp-rpl unicast sender is now running on the board and as expected nothing over air (the rzusb I am having doesn't show any packets on wireshark. Possibly cos of xbee driver (which is still untested) ?. How to go about debugging that ? The prints coming on minicom for unicast-sender are also unreadable, junk characters. With regards, P Gupta ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ Contiki-developers mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/contiki-developers ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ Contiki-developers mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/contiki-developers ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ Contiki-developers mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/contiki-developers ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ Contiki-developers mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/contiki-developers |