{"action":"created","issue":{"url":"https://api.github.com/repos/contiki-os/contiki/issues/2089","repository_url":"https://api.github.com/repos/contiki-os/contiki","labels_url":"https://api.github.com/repos/contiki-os/contiki/issues/2089/labels{/name}","comments_url":"https://api.github.com/repos/contiki-os/contiki/issues/2089/comments","events_url":"https://api.github.com/repos/contiki-os/contiki/issues/2089/events","html_url":"https://github.com/contiki-os/contiki/pull/2089","id":202935296,"number":2089,"title":"Add stack usage checker feature on CC26xx, Z1, Sky, Exp5438 and Wismote platforms","user":{"login":"atiselsts","id":3797089,"avatar_url":"https://avatars.githubusercontent.com/u/3797089?v=3","gravatar_id":"","url":"https://api.github.com/users/atiselsts","html_url":"https://github.com/atiselsts","followers_url":"https://api.github.com/users/atiselsts/followers","following_url":"https://api.github.com/users/atiselsts/following{/other_user}","gists_url":"https://api.github.com/users/atiselsts/gists{/gist_id}","starred_url":"https://api.github.com/users/atiselsts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atiselsts/subscriptions","organizations_url":"https://api.github.com/users/atiselsts/orgs","repos_url":"https://api.github.com/users/atiselsts/repos","events_url":"https://api.github.com/users/atiselsts/events{/privacy}","received_events_url":"https://api.github.com/users/atiselsts/received_events","type":"User","site_admin":false},"labels":[{"id":17330602,"url":"https://api.github.com/repos/contiki-os/contiki/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-01-24T20:46:24Z","updated_at":"2017-01-26T13:57:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/contiki-os/contiki/pulls/2089","html_url":"https://github.com/contiki-os/contiki/pull/2089","diff_url":"https://github.com/contiki-os/contiki/pull/2089.diff","patch_url":"https://github.com/contiki-os/contiki/pull/2089.patch"},"body":"This patch adds library code for estimation on run-time stack usage with the aim to make software development for Contiki more robust.\r\n\r\nUsing the estimator is as simple as:\r\n```\r\n  printf(\"stack usage: %u permitted: %u\\n\",\r\n         stack_checker_get_usage(), stack_checker_get_reserved_size());\r\n```\r\nFor more, see `examples/stack/main.c`.\r\n\r\nThe idea behind the implementation is to pre-fill the stack region at the system's initialization with a known patter and then check the boundaries of that pattern during run-time.\r\n\r\nWhen evaluating the checker on some of the example applications in Contiki I was not able to find any that overflows the stack region immediately after starting up. However, `cc26xx-web-demo` on TI SensorTag likely does that as soon it has to do any serious job such as handling some requests. Immediately after startup there's less than 100 bytes free, as stack usage is 560 bytes from the maximal 658 bytes. Meanwhile, functions such as `coap_notify_observers_sub()` in the CoAP implementation use literally hundreds of bytes of stack space on their own.\r\n\r\nThe amount of stack \"reserved\" on CC26xx by default by the linker script (`cpu/cc26xx-cc13xx/cc26xx.ld`) is just 0x200 or 512 bytes, which is woefully inadequate in my opinion. (This \"reservation\" does not ensure the stack does not overflow during runtime, it just creates a compile-time error if there are less-than-this bytes free after the end of the `.data` segment). For our projects in University of Bristol we have changed that to 0x500 or 0x700 depending on the project. In particular, in a real deployment that uses the CoAP / 6LoWPAN / TSCH  / IEEE 802.15.4 network stack I've observed stack usage up to 1750 bytes using this checker library.\r\n"},"comment":{"url":"https://api.github.com/repos/contiki-os/contiki/issues/comments/275393769","html_url":"https://github.com/contiki-os/contiki/pull/2089#issuecomment-275393769","issue_url":"https://api.github.com/repos/contiki-os/contiki/issues/2089","id":275393769,"user":{"login":"atiselsts","id":3797089,"avatar_url":"https://avatars.githubusercontent.com/u/3797089?v=3","gravatar_id":"","url":"https://api.github.com/users/atiselsts","html_url":"https://github.com/atiselsts","followers_url":"https://api.github.com/users/atiselsts/followers","following_url":"https://api.github.com/users/atiselsts/following{/other_user}","gists_url":"https://api.github.com/users/atiselsts/gists{/gist_id}","starred_url":"https://api.github.com/users/atiselsts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atiselsts/subscriptions","organizations_url":"https://api.github.com/users/atiselsts/orgs","repos_url":"https://api.github.com/users/atiselsts/repos","events_url":"https://api.github.com/users/atiselsts/events{/privacy}","received_events_url":"https://api.github.com/users/atiselsts/received_events","type":"User","site_admin":false},"created_at":"2017-01-26T13:57:28Z","updated_at":"2017-01-26T13:57:28Z","body":"Hi Antonio,\r\n\r\ndeciding the RAM size and address on cc2538 looks tricky, as they are dependent on many defines in  `dev/cc2538-dev.h` and the linker script `cc2538.lds`.\r\n\r\nWhen I now think about this, maybe it's better to make this less accurate but also less platform dependent and just assume that the stack bottom is an address of a local variable in the `main()` function, rather than requiring a platform-specific `#define`."}}
{"actor":{"display_login":"atiselsts"}}