<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.rtems.org/JSchweikhardt">Jens Schweikhardt</a> created an issue: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5552">#5552</a>
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<h2 id="user-content-summary" dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">A simple application with 10 tasks each printing "hello world" to the UART crashes after a while (usually within 30 seconds).
The system used is risc-v 32 bit under QEMU. Everybody should be able to reproduce this without hardware.</p>
<h2 id="user-content-steps-to-reproduce" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Steps to reproduce<a href="#steps-to-reproduce" aria-label="Link to heading 'Steps to reproduce'" data-heading-content="Steps to reproduce" class="anchor" style="margin-top: 0;"></a>
</h2>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0 0 1rem; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Check out RTEMS 6.2</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Check out RSB for 6.2</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Build a toolchain for rtems6, riscv with the <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;">config.ini</code> shown below</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Compile test application as shown below</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Run application under QEMU as shown below</li>
</ul>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">This is the <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">config.ini</code> I used to build the toolchain:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">[riscv/rv32imafc]</span>
<span id="LC2" class="line" lang="plaintext">RTEMS_POSIX_API = True</span>
<span id="LC3" class="line" lang="plaintext">BSP_CONSOLE_BAUD = 115200</span>
<span id="LC4" class="line" lang="plaintext">RISCV_RAM_REGION_BEGIN = 0x80000000</span>
<span id="LC5" class="line" lang="plaintext">RISCV_RAM_REGION_SIZE = 0x08000000 # 128MB</span>
<span id="LC6" class="line" lang="plaintext">BSP_FDT_BL</span>
<span id="LC7" class="line" lang="plaintext">RISCV_ENAB RISCV_RAM_REGION_SIZE</span>
<span id="LC8" class="line" lang="plaintext">RISCV_BOOT 0x08000000</span>
<span id="LC9" class="line" lang="plaintext">RTEMS_SMP</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">This is the <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">application.c</code> file:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">#include <rtems.h></span>
<span id="LC2" class="line" lang="plaintext">#include <stdio.h></span>
<span id="LC3" class="line" lang="plaintext">#include <stdlib.h></span>
<span id="LC4" class="line" lang="plaintext">#ifndef RTEMS_SMP</span>
<span id="LC5" class="line" lang="plaintext">#error "RTEMS not compiled with RTEMS_SMP"</span>
<span id="LC6" class="line" lang="plaintext">#endif</span>
<span id="LC7" class="line" lang="plaintext"></span>
<span id="LC8" class="line" lang="plaintext">#define TASK_COUNT 10</span>
<span id="LC9" class="line" lang="plaintext">rtems_id gTid[TASK_COUNT] = { 0 };</span>
<span id="LC10" class="line" lang="plaintext"></span>
<span id="LC11" class="line" lang="plaintext">rtems_task user_application(rtems_task_argument aArgument);</span>
<span id="LC12" class="line" lang="plaintext">rtems_task Init(rtems_task_argument ignored);</span>
<span id="LC13" class="line" lang="plaintext"></span>
<span id="LC14" class="line" lang="plaintext">rtems_task Init(rtems_task_argument ignored) {</span>
<span id="LC15" class="line" lang="plaintext"> rtems_status_code status;</span>
<span id="LC16" class="line" lang="plaintext"> for (int t = 0; t < TASK_COUNT; ++t) {</span>
<span id="LC17" class="line" lang="plaintext"> /* *INDENT-OFF* */</span>
<span id="LC18" class="line" lang="plaintext"> status = rtems_task_create(</span>
<span id="LC19" class="line" lang="plaintext"> rtems_build_name('T', 's', 'k', 'A' + t),</span>
<span id="LC20" class="line" lang="plaintext"> 1 + t,</span>
<span id="LC21" class="line" lang="plaintext"> RTEMS_MINIMUM_STACK_SIZE * 16,</span>
<span id="LC22" class="line" lang="plaintext"> RTEMS_DEFAULT_MODES,</span>
<span id="LC23" class="line" lang="plaintext"> RTEMS_FLOATING_POINT,</span>
<span id="LC24" class="line" lang="plaintext"> &gTid[t]);</span>
<span id="LC25" class="line" lang="plaintext"> /* *INDENT-ON* */</span>
<span id="LC26" class="line" lang="plaintext"> if (status != RTEMS_SUCCESSFUL) {</span>
<span id="LC27" class="line" lang="plaintext"> printf("rtems_task_create failed with status of %d.\n", status);</span>
<span id="LC28" class="line" lang="plaintext"> exit(1);</span>
<span id="LC29" class="line" lang="plaintext"> }</span>
<span id="LC30" class="line" lang="plaintext"> status = rtems_task_start(gTid[t], user_application, t);</span>
<span id="LC31" class="line" lang="plaintext"> if (status != RTEMS_SUCCESSFUL) {</span>
<span id="LC32" class="line" lang="plaintext"> printf("rtems_task_start failed with status of %d.\n", status);</span>
<span id="LC33" class="line" lang="plaintext"> exit(2);</span>
<span id="LC34" class="line" lang="plaintext"> }</span>
<span id="LC35" class="line" lang="plaintext"> }</span>
<span id="LC36" class="line" lang="plaintext"> status = rtems_task_delete(rtems_task_self()); /* should not return */</span>
<span id="LC37" class="line" lang="plaintext"> printf("rtems_task_delete returned with status of %d.\n", status);</span>
<span id="LC38" class="line" lang="plaintext"> exit(3);</span>
<span id="LC39" class="line" lang="plaintext">}</span>
<span id="LC40" class="line" lang="plaintext"></span>
<span id="LC41" class="line" lang="plaintext">rtems_task user_application(rtems_task_argument aArgument) {</span>
<span id="LC42" class="line" lang="plaintext"> for (;;) {</span>
<span id="LC43" class="line" lang="plaintext"> printf("hello, world from task %c\n", 'A' + (int) aArgument);</span>
<span id="LC44" class="line" lang="plaintext"> rtems_task_wake_after(100);</span>
<span id="LC45" class="line" lang="plaintext"> }</span>
<span id="LC46" class="line" lang="plaintext">}</span>
<span id="LC47" class="line" lang="plaintext"></span>
<span id="LC48" class="line" lang="plaintext">#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER</span>
<span id="LC49" class="line" lang="plaintext">#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER</span>
<span id="LC50" class="line" lang="plaintext">#define CONFIGURE_INIT_TASK_NAME rtems_build_name( 'I', 'n', 'i', 't' )</span>
<span id="LC51" class="line" lang="plaintext">#define CONFIGURE_RTEMS_INIT_TASKS_TABLE</span>
<span id="LC52" class="line" lang="plaintext">#define CONFIGURE_INIT</span>
<span id="LC53" class="line" lang="plaintext">#define CONFIGURE_INIT_TASK_STACK_SIZE 65536</span>
<span id="LC54" class="line" lang="plaintext">#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT</span>
<span id="LC55" class="line" lang="plaintext">#define CONFIGURE_MICROSECONDS_PER_TICK 1000</span>
<span id="LC56" class="line" lang="plaintext">#define CONFIGURE_MAXIMUM_PROCESSORS 4</span>
<span id="LC57" class="line" lang="plaintext">#define CONFIGURE_MAXIMUM_TASKS (1 + CONFIGURE_MAXIMUM_PROCESSORS + TASK_COUNT)</span>
<span id="LC58" class="line" lang="plaintext">#define CONFIGURE_EXTRA_TASK_STACKS (CONFIGURE_MAXIMUM_TASKS * RTEMS_MINIMUM_STACK_SIZE * 16)</span>
<span id="LC59" class="line" lang="plaintext">#define CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS (5 * CONFIGURE_MAXIMUM_TASKS)</span>
<span id="LC60" class="line" lang="plaintext">#include <rtems/confdefs.h></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">To build:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">riscv-rtems6-gcc -march=rv32imafc -mabi=ilp32f -qrtems \</span>
<span id="LC2" class="line" lang="plaintext"> -B /path/to/riscv-rtems6/rv32imafc/lib -o application.elf application.c</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">To run:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">$ qemu-system-riscv32 -smp 4 -m 192M -nographic -M virt -bios none -kernel application.elf</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The crash looks like this, with garbled characters appearing after a while of greeting, stopping output. Now the host CPU is busy looping. You can type CTRL-A x to exit QEMU after the crash.</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">[several seconds of greetings here...]</span>
<span id="LC2" class="line" lang="plaintext">hello, world from task E</span>
<span id="LC3" class="line" lang="plaintext">hello, world from task F</span>
<span id="LC4" class="line" lang="plaintext">hello, world from task G</span>
<span id="LC5" class="line" lang="plaintext">hello, world from task H</span>
<span id="LC6" class="line" lang="plaintext">hello, world from task I</span>
<span id="LC7" class="line" lang="plaintext">hello, world from task J</span>
<span id="LC8" class="line" lang="plaintext">hello, world from task A</span>
<span id="LC9" class="line" lang="plaintext">hello, world from task B</span>
<span id="LC10" class="line" lang="plaintext">hello, world from task C</span>
<span id="LC11" class="line" lang="plaintext">hello, world from task D</span>
<span id="LC12" class="line" lang="plaintext">hello, world from task E</span>
<span id="LC13" class="line" lang="plaintext">hello, world from task F</span>
<span id="LC14" class="line" lang="plaintext">hello, world from task G</span>
<span id="LC15" class="line" lang="plaintext">hello, world from task I</span>
<span id="LC16" class="line" lang="plaintext">d from ta����!��^�T�hello, world from task H</span>
<span id="LC17" class="line" lang="plaintext">A��</span>
<span id="LC18" class="line" lang="plaintext"> ����</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Observations</p>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">You must run qemu with "-smp N" and N>1. A single hart CPU with N=1 does not crash.</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">My host is FreeBSD 14.2-RELEASE</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">My QEMU is 10.2.2</li>
</ul>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5552">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/3-e34r1xsek0bgqhhehzr94w4pu/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5552 at 1776364402
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5552"}}</script>
</p>
</div>
</body>
</html>