<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-07-30 1:35 GMT+02:00 Denis Obrezkov <span dir="ltr"><<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="gmail-h5">2017-07-29 19:14 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 29, 2017 4:04 AM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382elided-text"><div class="gmail_quote">2017-07-29 3:45 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 28, 2017 7:11 PM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397elided-text"><div class="gmail_quote">2017-07-29 1:41 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 28, 2017 6:39 PM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266elided-text"><div class="gmail_quote">2017-07-29 1:28 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 28, 2017 6:14 PM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241elided-text"><div class="gmail_quote">2017-07-29 0:57 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 28, 2017 5:55 PM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887elided-text"><div class="gmail_quote">2017-07-28 22:36 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Can you check the memory immediately after a download'?<div><br></div><div>Then after the loop that copies initialized data into place?</div><div><br></div><div>I suspect something off there. Could be a linker script issue or the</div><div>copy gone crazy.</div><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-HOEnZb"><font color="#888888"><div><br></div><div>--joel</div></font></span></div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-HOEnZb"><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 28, 2017 at 3:20 PM, Denis Obrezkov <span dir="ltr"><<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482h5"><div class="gmail_quote">2017-07-28 22:16 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-h5">On Fri, Jul 28, 2017 at 2:50 PM, Denis Obrezkov <span dir="ltr"><<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138m_1910985692606246180gmail-h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br>I can see that during task initialization I have a call:</div><div class="gmail_extra"><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138m_1910985692606246180gmail-m_4666396122888093712gmail-"><div class="gmail_extra"> _Thread_Initialize_informatio<wbr>n (information=information@entry<wbr>=0x80000ad4 <_RTEMS_tasks_Information>, the_api=the_api@entry=OBJECTS_<wbr>CLASSIC_API, the_class=the_class@entry=1, maximum=124, </div><div class="gmail_extra"> is_string=is_string@entry=fals<wbr>e, maximum_name_length=maximum_na<wbr>me_length@entry=4)</div><div><br></div></span><div>And maximum is 124, but I have a configuration parameter:</div><div><div>#define CONFIGURE_MAXIMUM_TASKS 4</div></div></div></div></blockquote><div><br></div></div></div><div>I can't imagine any standard RTEMS test configuring that many tasks. </div><div>Is there a data corruption issue?</div><div><br></div><div>124 = 0x7c which doesn't ring any bells for me on odd memory issues.</div><div><br></div><div>What is the contents of "Configuration_RTEMS_API"?<br></div></div></div></div></blockquote></span><div>Oh, I change my configuration options a bit, they are: </div><div><div> #define CONFIGURE_APPLICATION_NEEDS_CL<wbr>OCK_DRIVER</div><div> #define CONFIGURE_APPLICATION_DISABLE_<wbr>FILESYSTEM</div><div> #define CONFIGURE_DISABLE_NEWLIB_REENT<wbr>RANCY</div><div> #define CONFIGURE_TERMIOS_DISABLED</div><div> #define CONFIGURE_LIBIO_MAXIMUM_FILE_D<wbr>ESCRIPTORS 0</div><div> #define CONFIGURE_MINIMUM_TASK_STACK_S<wbr>IZE 512</div><div> #define CONFIGURE_MAXIMUM_PRIORITY 3</div><div> #define CONFIGURE_DISABLE_CLASSIC_API_<wbr>NOTEPADS</div><div> #define CONFIGURE_IDLE_TASK_BODY Init</div><div> #define CONFIGURE_IDLE_TASK_INITIALIZE<wbr>S_APPLICATION</div><div> #define CONFIGURE_TASKS 4</div><div><br></div><div> #define CONFIGURE_MAXIMUM_TASKS 4</div><div> </div><div> #define CONFIGURE_UNIFIED_WORK_AREAS</div></div><div><br></div><div>Also it is the test from a lower ticker example. </div><div>Configuration_RTEMS_API with -O0 option: </div><div><div class="gmail_extra"><div class="gmail_extra">{maximum_tasks = 5, maximum_timers = 0, maximum_semaphores = 7, maximum_message_queues = 0, maximum_partitions = 0, maximum_regions = 0, maximum_ports = 0, maximum_periods = 0, </div><div class="gmail_extra"> maximum_barriers = 0, number_of_initialization_tasks = 0, User_initialization_tasks_tabl<wbr>e = 0x0}<br></div><div class="gmail_extra"><br></div>with -Os option:</div><div class="gmail_extra"><div class="gmail_extra">{maximum_tasks = 124, maximum_timers = 0, maximum_semaphores = 7, maximum_message_queues = 0, maximum_partitions = 0, maximum_regions = 0, maximum_ports = 0, maximum_periods = 0, </div><div class="gmail_extra"> maximum_barriers = 0, number_of_initialization_tasks = 0, User_initialization_tasks_tabl<wbr>e = 0x0}</div></div></div></div></div></div></blockquote><div><br></div></div></div><div>Hmmm.. If you look at this structure in gdb without attaching to the target, what</div><div>is maximum_tasks?</div><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-HOEnZb"><font color="#888888"><div><br></div><div>--joel </div></font></span><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="gmail_extra"><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div></div><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138m_1910985692606246180gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><br></div><div>It seems that other tasks are LIBBLOCK tasks.</div><div><br></div><div>Also, this is my Configuration during run:</div><div><div>(gdb) p Configuration.stack_space_size<wbr> </div><div>$1 = 2648</div><div>(gdb) p Configuration.work_space_size </div><div>$2 = 4216</div><div>(gdb) p Configuration.interrupt_stack_<wbr>size </div><div>$3 = 512</div><div>(gdb) p Configuration.idle_task_stack_<wbr>size </div><div>$4 = 512</div></div></div></div></blockquote><div><br></div></span><div>That looks reasonable. Add CONFIGURE_MAXIMUM_PRIORITY and set it to 4. That should</div><div>reduce the workspace.</div><div><br></div><div> long term, we might want to consider lowering it permanently like one of the Coldfires </div><div>had to. Or change the default scheduler to the Simple one to save memory.</div><div><br></div></div></div></div></blockquote><br class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138m_1910985692606246180gmail-Apple-interchange-newline"></span><div>I haven't dealt with the Scheduler option yet. </div><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138HOEnZb"><font color="#888888"><div><br></div></font></span></div></div><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138HOEnZb"><font color="#888888"><div class="gmail_extra"><div><br></div><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138m_1910985692606246180gmail_signature">Regards, Denis Obrezkov</div>
</div></font></span></div>
</blockquote></span></div><br></div></div>
</blockquote></div></div></div>maximum_tasks = 4</div><div class="gmail_extra">So, is it a linker file issue?<br><br>This is it:<br><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/c/src/lib/libbsp/riscv32/hifive1/startup/linkcmds" target="_blank">https://github.com/embeddedden<wbr>/rtems-riscv/blob/hifive1/c/sr<wbr>c/lib/libbsp/riscv32/hifive1/s<wbr>tartup/linkcmds</a><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail_signature">Regards, Denis Obrezkov</div>
</font></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div>After download:</div><div class="gmail_extra"><div class="gmail_extra">{maximum_tasks = 938162044, maximum_timers = 1270834941, maximum_semaphores = <a href="tel:(253)%20480-1264" value="+12534801264" target="_blank">2534801264</a>, maximum_message_queues = 425684620, maximum_partitions = 1496738036, </div><div class="gmail_extra"> maximum_regions = <a href="tel:(308)%20556-0870" value="+13085560870" target="_blank">3085560870</a>, maximum_ports = 4269782132, maximum_periods = <a href="tel:(236)%20201-2542" value="+12362012542" target="_blank">2362012542</a>, maximum_barriers = 1138223297, number_of_initialization_tasks = 4224313421, </div><div class="gmail_extra"> User_initialization_tasks_tabl<wbr>e = 0x43bd1bd3}</div><div><br></div><div>right after data copying:</div><div><div>{maximum_tasks = 124, maximum_timers = 0, maximum_semaphores = 1, maximum_message_queues = 0, maximum_partitions = 0, maximum_regions = 0, maximum_ports = 0, maximum_periods = 0, </div><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887quoted-text"><div> maximum_barriers = 0, number_of_initialization_tasks = 0, User_initialization_tasks_tabl<wbr>e = 0x0}</div></div></div><div><br></div><div>But I found the mistake - I made it in .data initialization code </div><div>(<a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/c/src/lib/libbsp/riscv32/hifive1/start/start.S#L116" target="_blank">https://github.com/embeddedde<wbr>n/rtems-riscv/blob/hifive1/c/s<wbr>rc/lib/libbsp/riscv32/hifive1/<wbr>start/start.S#L116</a> - first byte in the loop was uninitialized)</div></div></div></blockquote></div></div></div><div dir="auto"><br></div></div></div><div dir="auto">Awesome! Does that mean it is running?</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><font color="#888888"><br clear="all"><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail_signature">Regards, Denis Obrezkov</div>
</font></span></font></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div></div>Yes, it is running now. Not far, but running. </div><div class="gmail_extra">Now I am having an exception during atexit( Clock_exit )</div></div></blockquote></div></div></div><div dir="auto"><br></div></div></div><div dir="auto">Does it get to bsp_cleanup and bsp_reset? Are you seeing the Terminate?</div><div dir="auto"><br></div><div dir="auto">I think those are the names. Basically some BSPs deliberately throw an exception as the way to end. </div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><font color="#888888"><br><br clear="all"><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255gmail_signature">Regards, Denis Obrezkov</div>
</font></span></font></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div></div>Unfortunately, I have an exception in the beginning during clock driver initialization around this line:</div><div class="gmail_extra"><div class="gmail_extra">0x204053a0 80 in ../../../../../gcc-7.1.0/newli<wbr>b/libc/stdlib/__atexit.c</div></div></div></blockquote></div></div></div><div dir="auto"><br></div></div></div><div dir="auto">No obvious suggestions from me right now except to debug.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><font color="#888888"><div class="gmail_extra"><br></div><div><br></div><br clear="all"><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200m_4664819504922746266m_-4120003778743072957gmail_signature">Regards, Denis Obrezkov</div>
</font></span></font></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div></div>Is it possible that newlib has a wrong linker file? That a variable placed out of the rtems-linkcmd-defined bounds?</div></div></blockquote></div></div></div><div dir="auto"><br></div></div></div><div dir="auto">I don't think so. Look at the atexit source and see what it assume is initialized</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><font color="#888888"><br><br clear="all"><span class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail-m_-6082462341514230397m_909783186968089200gmail_signature">Regards, Denis Obrezkov</div>
</font></span></font></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div></div>I found out that the error occurs in gcc-7.1.0/newlib/libc/stdlib/_<wbr>_atexit.c:80:</div><div>p = _GLOBAL_ATEXIT;<br><br></div><div>p defined like:</div><div><div>register struct _atexit *p;</div><div><br></div></div><div>on the one hand the value of p is:</div><div><div>(gdb) print p</div><div>$56 = <optimized out></div></div><div><br></div><div>on the other hand:</div><div>_GLOBAL_ATEXIT:</div><div><br></div><div><div>#ifdef _REENT_GLOBAL_ATEXIT</div><div>extern struct _atexit *_global_atexit; /* points to head of LIFO stack */</div><div># define _GLOBAL_ATEXIT _global_atexit</div><div>#else</div><div># define _GLOBAL_ATEXIT (_GLOBAL_REENT->_atexit)</div><div>#endif</div><div><br></div><div>and _REENT_GLOBAL_ATEXIT should be defined due to (newlib/libc/include/sys):</div><div><div>#if defined(__rtems__)</div><div>#define __FILENAME_MAX__ 255</div><div>#define _READ_WRITE_RETURN_TYPE _ssize_t</div><div>#define __DYNAMIC_REENT__</div><div>#define _REENT_GLOBAL_ATEXIT</div><div>#endif</div></div><div><br></div><div>but _global_atexit located at random locations outside of my memory regions.</div></div></div></blockquote></div></div></div><div dir="auto"><br></div></div></div><div dir="auto">Does it show up at a valid address when you look at the nm output?</div><div dir="auto"><br></div><div dir="auto">Does it behave differently when you drop optimization?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font color="#888888"><br clear="all"><span class="gmail-m_-8875067193912882799m_-4881307802067692566HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566m_4826166642645949382m_8688459743873834255gmail_signature">Regards, Denis Obrezkov</div>
</font></span></font></div></div>
</blockquote></div></div></div></div></blockquote><div> </div></div></div><div>Oh, the pointer itself is located in a proper location, but the value it stores is out of memory.</div><div>Anyway, it fails before it is able to utilize the wrong value.</div></div></div><div class="gmail_extra">It behaves the same way without optimization.<span class="gmail-HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="gmail-m_-8875067193912882799m_-4881307802067692566gmail_signature">Regards, Denis Obrezkov</div>
</font></span></div></div>
</blockquote></div><br><div>I've also found that my bad address (caught in mbadaddr register) is 0x1a913cb0:</div><div>(gdb) x /3i 0x1a913cb0-4</div><div> 0x1a913cac: unimp</div><div> 0x1a913cae: unimp</div><div> 0x1a913cb0: unimp</div><div><br></div><div><br></div><div>At the same time:</div><div><div>(gdb) p _global_atexit </div><div>$5 = (struct _atexit *) 0x1a913cac</div></div><div><br></div><div>Located very close to the wrong address. </div>-- <br><div class="gmail_signature">Regards, Denis Obrezkov</div>
</div></div>