<!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=US-ASCII" 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 style="color: #777777;">
<a href="https://gitlab.rtems.org/junkes">Heinz Junkes</a>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5260#note_123230">commented</a>:
</p>
<div class="md" style="position: relative; z-index: 1; color: #28272d; word-wrap: break-word;">
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">I try to adapt console-config.c.
But what I really don't understand (I don't get it) is why I can't set a breakpoint on 'input_char_pl011'. On 'output_char_pl011' works.</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: #28272d; 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; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; 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; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">(gdb) b input_char_pl011</span>
<span id="LC2" class="line" lang="plaintext">Function "input_char_pl011" not defined.</span>
<span id="LC3" class="line" lang="plaintext">Make breakpoint pending on future shared library load? (y or [n]) n</span>
<span id="LC4" class="line" lang="plaintext">(gdb) b output_char_pl011</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">and when the breakpoint is reached I see the input function in the source code in the listing?</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: #28272d; 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; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; 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; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">Make breakpoint pending on future shared library load? (y or [n]) n</span>
<span id="LC2" class="line" lang="plaintext">(gdb) b output_char_pl011</span>
<span id="LC3" class="line" lang="plaintext">Breakpoint 1 at 0x200b24: file ../../../bsps/arm/raspberrypi/console/console-config.c, line 58.</span>
<span id="LC4" class="line" lang="plaintext">(gdb) c</span>
<span id="LC5" class="line" lang="plaintext">Continuing.</span>
<span id="LC6" class="line" lang="plaintext"></span>
<span id="LC7" class="line" lang="plaintext">Thread 1 hit Breakpoint 1, output_char_pl011 (c=13 '\r') at ../../../bsps/arm/raspberrypi/console/console-config.c:58</span>
<span id="LC8" class="line" lang="plaintext">58       return arm_pl011_read_polled(&pl011_context.base);</span>
<span id="LC9" class="line" lang="plaintext">(gdb) list</span>
<span id="LC10" class="line" lang="plaintext">53</span>
<span id="LC11" class="line" lang="plaintext">54    rpi_fb_context fb_context;</span>
<span id="LC12" class="line" lang="plaintext">55</span>
<span id="LC13" class="line" lang="plaintext">56    static int input_char_pl011(void)</span>
<span id="LC14" class="line" lang="plaintext">57    {</span>
<span id="LC15" class="line" lang="plaintext">58      return arm_pl011_read_polled(&pl011_context.base);</span>
<span id="LC16" class="line" lang="plaintext">59    }</span>
<span id="LC17" class="line" lang="plaintext">60</span>
<span id="LC18" class="line" lang="plaintext">61    static void output_char_pl011(char c)</span>
<span id="LC19" class="line" lang="plaintext">62    {</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">My students have implemented the following code (with the help op ChatGPT they say) with which you can read an input:</p>
<div class="gl-relative markdown-code-block js-markdown-code" style="margin-bottom: 0;">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; 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; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; 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; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">#define PL011_UART_BASE 0x3F201000</span>
<span id="LC2" class="line" lang="plaintext">#define UART_POLL_INTERVAL 100 // Polling interval in milliseconds</span>
<span id="LC3" class="line" lang="plaintext"></span>
<span id="LC4" class="line" lang="plaintext">typedef void (*BSP_output_char_function_type)(char c);</span>
<span id="LC5" class="line" lang="plaintext">typedef int (*BSP_polling_getchar_function_type)(void);</span>
<span id="LC6" class="line" lang="plaintext"></span>
<span id="LC7" class="line" lang="plaintext">extern BSP_output_char_function_type BSP_output_char;</span>
<span id="LC8" class="line" lang="plaintext">extern BSP_polling_getchar_function_type BSP_poll_char;</span>
<span id="LC9" class="line" lang="plaintext"></span>
<span id="LC10" class="line" lang="plaintext">static int pl011_poll_getchar(void)</span>
<span id="LC11" class="line" lang="plaintext">{</span>
<span id="LC12" class="line" lang="plaintext">volatile uint32_t *regs = (volatile uint32_t *) PL011_UART_BASE;</span>
<span id="LC13" class="line" lang="plaintext"></span>
<span id="LC14" class="line" lang="plaintext">if (regs[0x18 / 4] & (1 << 4)) { // UART_FR_RXFE</span>
<span id="LC15" class="line" lang="plaintext">return -1;</span>
<span id="LC16" class="line" lang="plaintext">}</span>
<span id="LC17" class="line" lang="plaintext"></span>
<span id="LC18" class="line" lang="plaintext">return regs[0x00 / 4] & 0xFF;</span>
<span id="LC19" class="line" lang="plaintext">}</span>
<span id="LC20" class="line" lang="plaintext"></span>
<span id="LC21" class="line" lang="plaintext">rtems_task Init(rtems_task_argument arg) {</span>
<span id="LC22" class="line" lang="plaintext">printf("UART ready. Echoing:\n");</span>
<span id="LC23" class="line" lang="plaintext">BSP_poll_char = pl011_poll_getchar;</span>
<span id="LC24" class="line" lang="plaintext"></span>
<span id="LC25" class="line" lang="plaintext">while (1) {</span>
<span id="LC26" class="line" lang="plaintext">int c = BSP_poll_char(); // Try to read a character</span>
<span id="LC27" class="line" lang="plaintext"></span>
<span id="LC28" class="line" lang="plaintext">if (c >= 0) {</span>
<span id="LC29" class="line" lang="plaintext">BSP_output_char((char)c); // Echo the character</span>
<span id="LC30" class="line" lang="plaintext">}</span>
<span id="LC31" class="line" lang="plaintext">rtems_task_wake_after(RTEMS_MILLISECONDS_TO_TICKS(UART_POLL_INTERVAL)); // Poll every 100 ms</span>
<span id="LC32" class="line" lang="plaintext">}</span>
<span id="LC33" class="line" lang="plaintext">}</span>
<span id="LC34" class="line" lang="plaintext"></span>
<span id="LC35" class="line" lang="plaintext">#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER</span>
<span id="LC36" class="line" lang="plaintext">#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER</span>
<span id="LC37" class="line" lang="plaintext"></span>
<span id="LC38" class="line" lang="plaintext">#define CONFIGURE_MAXIMUM_TASKS 1</span>
<span id="LC39" class="line" lang="plaintext">#define CONFIGURE_RTEMS_INIT_TASKS_TABLE</span>
<span id="LC40" class="line" lang="plaintext">#define CONFIGURE_INIT</span>
<span id="LC41" class="line" lang="plaintext"></span>
<span id="LC42" class="line" lang="plaintext">#include <rtems/confdefs.h></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #737278;">

<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5260#note_123230">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/2b3e9ea0443cf9f651de7c8210f54df4/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>
<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/5260#note_123230"}}</script>


</p>
</div>
</body>
</html>