<div dir="auto"><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">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="elided-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="m_-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="m_-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="m_-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="m_-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="m_-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="m_-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="m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-HOEnZb"><font color="#888888"><div><br></div><div>--joel</div></font></span></div><div class="m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-HOEnZb"><div class="m_-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="m_-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="m_-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="m_-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="m_-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="m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-HOEnZb"><font color="#888888"><div><br></div><div>--joel </div></font></span><span class="m_-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="m_-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="m_-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="m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482m_-8004567108446954901gmail-m_-5041057659938603138HOEnZb"><font color="#888888"><div><br></div></font></span></div></div><span class="m_-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="m_-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="m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255m_7933761105282942887m_7606448455893681527gmail-m_8179067461764088482HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="m_-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="m_-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="m_-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="m_-4120003778743072957gmail-m_-2279680596661204241m_898819926594204255HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-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="m_-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="m_-4120003778743072957gmail-HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-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/<wbr>newlib/libc/stdlib/__atexit.c</div></div></div></blockquote></div></div></div><div dir="auto"><br></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="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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"><div><br></div>-- <br><div class="m_-4120003778743072957gmail_signature">Regards, Denis Obrezkov</div>
</font></div></div>
</blockquote></div><br></div></div></div>