<!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/michallenc">Michal Lenc</a> created a merge request: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1183">!1183</a>
</p>
<div class="branch">
Project:Branches: michallenc/rtems:sja1000 to rtems/rtos/rtems:main
</div>
<div class="author">
Author: Michal Lenc
</div>
<div class="assignee">
Assignees:
</div>
<div class="reviewer">
Reviewers:
</div>
<div class="md gl-mt-5" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word; margin-top: 1rem;">
<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">This commit adds support for a stand alone SJA1000 CAN controller. This
is classical CAN only capable controller, so no FD support here. The
driver's implementation is similar to CTU CAN FD, thus interrupt handler
triggers a semaphore in main worker thread that takes care of handling
interrupts and receiving and sending messages.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The controller utilizes its one TX buffer for sending messages with
abort function available if higher priority message is present in
the software queue.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The initial idea was this controller would be a good simple template example for future CAN controllers using RTEMS stack, but we run into several issues during the development. The most notable one is RX interrupt not cleared on interrupt status register read and not even on RX interrupt disable, but only after RX buffer release command is sent. This caused problem in our design where interrupt handler only masks the interrupts and wakes up worker thread and let it process the message. SJA1000 can't unfortunately mask interrupts, just disable them, which clears the interrupt status register and still doesn't disable RX interrupt. Therefore we have to disable RX interrupts (along with all others) read the first RX message from the buffer, store it in the internal sja1000 structure and then release the buffer -> this ensures RX interrupt is no longer triggered. The rest of RX messages is read from worker thread along with the handling of other interrupts.</p>
<h3 id="user-content-testing" dir="auto" style="margin-top: 1.5rem; margin-bottom: 1rem; font-weight: 600; font-size: 1.125rem; letter-spacing: inherit; line-height: 1.25; color: #18171d;" align="initial">Testing<a href="#testing" aria-label="Link to heading 'Testing'" data-heading-content="Testing" class="anchor" style="margin-top: 0;"></a>
</h3>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The controller was tested with our test suite available in OTREES gitlab repository: <a href="https://gitlab.fel.cvut.cz/otrees/rtems/rtems-canfd" rel="nofollow noreferrer noopener" target="_blank" style="margin-top: 0;">https://gitlab.fel.cvut.cz/otrees/rtems/rtems-canfd</a> (implementation of sja1000 in <a href="https://gitlab.fel.cvut.cz/otrees/rtems/rtems-canfd/-/tree/sja1000?ref_type=heads" rel="nofollow noreferrer noopener" target="_blank">its own branch</a>). Tests were done on Xilinx Zynq platform both against CTU CAN FD RTEMS implementation and against Linux SocketCAN with CAN to USB converter (as a listening device for debugging). This includes two way communication tests (both controllers send 2k CAN messages) and chip stop tests (ensuring the software queue and hardware TX buffer are correctly flushed).</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Pavel Píša <a href="https://gitlab.rtems.org/ppisa" title="Pavel Pisa" class="gfm gfm-project_member js-user-link" data-user="20" data-original="@ppisa" data-container="body" data-placement="top" data-reference-type="user" style="color: #284779; background-color: #cbe2f9; border-radius: .25rem; margin-top: 0; padding: 0 2px;">@ppisa</a> tested the controller for abort capabilities and latency on the original NXP PCI SJA1000 CAN cards on x86. One controller was trying to send mix of <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; 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;">0x700</code> and <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; 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;">0x20</code> messages while other was spamming the bus with <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; 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;">0x500</code> mid priority messages, thus creating priority inversion issue. Additional CTU CAN FD controller on Zynq was used to generate <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; 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;">0x600</code> messages to ensure the bus is 100 % filled with mid priority messages. The monitoring below shows the high priority messages <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; 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;">0x20</code> got to the bus, therefore proving the abort capability of the controller.</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;"> can5 500 [8] 41 30 00 00 00 00 00 00</span>
<span id="LC2" class="line" lang="plaintext"> can5 600 [1] F6</span>
<span id="LC3" class="line" lang="plaintext"> can5 500 [8] 42 30 00 00 00 00 00 00</span>
<span id="LC4" class="line" lang="plaintext"> can5 600 [4] 0C 38 C2 60</span>
<span id="LC5" class="line" lang="plaintext"> can5 500 [8] 43 30 00 00 00 00 00 00</span>
<span id="LC6" class="line" lang="plaintext"> can5 600 [3] 17 58 71</span>
<span id="LC7" class="line" lang="plaintext"> can5 500 [8] 44 30 00 00 00 00 00 00</span>
<span id="LC8" class="line" lang="plaintext"> can5 020 [8] 00 DC C5 68 26 41 00 00</span>
<span id="LC9" class="line" lang="plaintext"> can5 500 [8] 45 30 00 00 00 00 00 00</span>
<span id="LC10" class="line" lang="plaintext"> can5 020 [8] 01 01 C9 68 26 41 00 00</span>
<span id="LC11" class="line" lang="plaintext"> can5 500 [8] 46 30 00 00 00 00 00 00</span>
<span id="LC12" class="line" lang="plaintext"> can5 020 [8] 02 0C CB 68 26 41 00 00</span>
<span id="LC13" class="line" lang="plaintext"> can5 500 [8] 47 30 00 00 00 00 00 00</span>
<span id="LC14" class="line" lang="plaintext"> can5 020 [8] 03 0D CD 68 26 41 00 00</span>
<span id="LC15" class="line" lang="plaintext"> can5 500 [8] 48 30 00 00 00 00 00 00</span>
<span id="LC16" class="line" lang="plaintext"> can5 600 [8] 60 BF D0 6B 45 31 AA 2E</span>
<span id="LC17" class="line" lang="plaintext"> can5 500 [8] 49 30 00 00 00 00 00 00</span>
<span id="LC18" class="line" lang="plaintext"> can5 600 [0]</span>
<span id="LC19" class="line" lang="plaintext"> can5 500 [8] 4A 30 00 00 00 00 00 00</span>
<span id="LC20" class="line" lang="plaintext"> can5 600 [8] EF 93 45 0C 7A 29 08 55</span>
<span id="LC21" class="line" lang="plaintext"> can5 500 [8] 4B 30 00 00 00 00 00 00</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<h2 id="user-content-generative-ai" dir="auto" style="margin-top: 20px; margin-bottom: 0;" align="initial">Generative AI<a href="#generative-ai" aria-label="Link to heading 'Generative AI'" data-heading-content="Generative AI" class="anchor" style="margin-top: 0;"></a>
</h2>
</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/-/merge_requests/1183">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/2-41o0ve6x61fm5gjhwn0s5p4rq/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/-/merge_requests/1183 at 1775232459
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1183"}}</script>
</p>
</div>
</body>
</html>