Re: Challenge: CCL port to the RPi Pico (RP2040)

Tim McNerney <[email protected]> Thu, 8 Aug 2024 14:23:43 -0400
Newsgroups gmane.lisp.openmcl.devel
Message-ID <[email protected]>
--Apple-Mail-05C8E3B6-844C-424A-9107-6C47AF5F8ABF
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto">The brand spanking new RP2350 uses the ARM C=
ortex M33, an ARMv8M, which supports a Protected Memory System Architecture (=
PMSA).<div><br><div>Does that offer what the CCL garbage collector needs?</d=
iv><div><br id=3D"lineBreakAtBeginningOfSignature"><div dir=3D"ltr">--Tim</d=
iv><div dir=3D"ltr"><br><blockquote type=3D"cite">On Jul 28, 2024, at 13:11,=
 Ron Garret &lt;[email protected]&gt; wrote:<br><br></blockquote></div><blockq=
uote type=3D"cite"><div dir=3D"ltr">=EF=BB=BF<meta http-equiv=3D"Content-Typ=
e" content=3D"text/html; charset=3Dutf-8">1. &nbsp;Obtain a tool chain for t=
he Pico and get hello-world running.<div class=3D""><br class=3D""></div><di=
v class=3D"">2. &nbsp;Use that tool chain to compile the CCL sources using t=
he Arm32 Makefile.</div><div class=3D""><br class=3D""></div><div class=3D""=
>3. &nbsp;Write stubs for all the undefined symbols. &nbsp;The stubs should a=
ll be breakpoints.</div><div class=3D""><br class=3D""></div><div class=3D""=
>4 &nbsp;Recompile.</div><div class=3D""><br class=3D""></div><div class=3D"=
">5. &nbsp;Run the resulting binary and see what happens. &nbsp; If you're l=
ucky, you will hit a breakpoint in one of your stubs. &nbsp;Write a function=
al version of that stub.</div><div class=3D""><br class=3D""></div><div clas=
s=3D"">6. &nbsp;Goto 4.</div><div class=3D""><br class=3D""></div><div class=
=3D"">My guess is that the biggest challenge you're going to face is that th=
e ARM Cortex M0 doesn't have an MMU. &nbsp;AFAIK, the modern CCL GC depends o=
n that.</div><div class=3D""><br class=3D""></div><div class=3D"">rg</div><d=
iv class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div c=
lass=3D"">On Jul 28, 2024, at 8:37 AM, Jon Boone &lt;<a href=3D"mailto:ipmon=
[email protected]" class=3D"">[email protected]</a>&gt; wrote:</div><=
br class=3D"Apple-interchange-newline"><div class=3D"">

<title class=3D""></title>

<div class=3D"">
<div name=3D"messageBodySection" class=3D"">
<div dir=3D"auto" class=3D"">For those who might be interested in such a pro=
ject, where would one start?&nbsp;&nbsp;</div>
</div>
<div name=3D"messageSignatureSection" class=3D""><br class=3D"">
=E2=80=94 jb</div>
<div name=3D"messageReplySection" class=3D"">On Jul 28, 2024 at 10:54 -0400,=
 Tim McNerney &lt;<a href=3D"mailto:[email protected]" class=3D"">[email protected]=
t.edu</a>&gt;, wrote:<br class=3D"">
<blockquote type=3D"cite" style=3D"border-left-color: grey; border-left-widt=
h: thin; border-left-style: solid; margin: 5px 5px;padding-left: 10px;" clas=
s=3D"">
<div dir=3D"ltr" class=3D"">=EF=BB=BFThe popular Raspberry Pi Pico chip (RP2=
040) is a remarkable microprocessor with <i class=3D"">memory resources</i> n=
ot dissimilar from the Mac 512k, CCL=E2=80=99s debut target. Here are some q=
uick facts.&nbsp;
<div dir=3D"ltr" class=3D"">
<div class=3D"">
<ul style=3D"-webkit-text-size-adjust: auto; box-sizing: border-box; font-fa=
mily: Roboto, sans-serif;" class=3D"">
<li style=3D"box-sizing: border-box;" class=3D""><p style=3D"box-sizing: bor=
der-box; margin: 0px 0px 15px; padding: 0px; font-size: 0.95em; line-height:=
 1.5em;" class=3D"">Dual ARM Cortex-M0+ @ 133MHz</p>
</li>
<li style=3D"box-sizing: border-box;" class=3D""><p style=3D"box-sizing: bor=
der-box; margin: 0px 0px 15px; padding: 0px; font-size: 0.95em; line-height:=
 1.5em;" class=3D"">264kB on-chip SRAM in six independent banks</p>
</li>
<li style=3D"box-sizing: border-box;" class=3D""><p style=3D"box-sizing: bor=
der-box; margin: 0px 0px 15px; padding: 0px; font-size: 0.95em; line-height:=
 1.5em;" class=3D"">Support for up to 16MB of off-chip Flash memory via dedi=
cated QSPI bus</p>
</li>
</ul>
<div class=3D"">Some might argue it=E2=80=99s not comparable to a Mac 512. I=
 claim it is: consider that the RAM would <i class=3D"">only</i> used for th=
e heap, stack(s), and housekeeping? It is the off-chip flash support that ma=
kes all the difference. That=E2=80=99s where you can store static code and d=
ata segments that make up the bulk of a CCL image.&nbsp;</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">My big questions:</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">1) Could this chip run CCL?</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">2) Would it be worth the effort?</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">I think <b class=3D"">yes</b> on both fronts. A lot of embed=
ded code is truly modest, so a small heap is useful enough. This is the aren=
a where microPython shines=E2=80=94itself sporting a garbage collector.&nbsp=
;</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">3) Does anyone want to try?</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">CCL already has 32-bit ARM support. There is no OS interfaci=
ng work to do here (only work to make up for the <i class=3D"">lack</i> of O=
S).&nbsp;</div>
<div class=3D""><br class=3D""></div>
<div class=3D"">This could be a fun little project that would a great way to=
 become familiar with CCL internals without a lot of distractions from OS an=
d GUI issues. First get it working from a serial port console (over Bluetoot=
h maybe?) and focus on embedded applications. Slash and burn the rest, at le=
ast for starters.&nbsp;</div>
<div class=3D""><br id=3D"lineBreakAtBeginningOfSignature" class=3D"">
<div dir=3D"ltr" class=3D"">--Tim</div>
<div dir=3D"ltr" class=3D""><br class=3D"">
<blockquote type=3D"cite" class=3D"">On Jul 28, 2024, at 01:32, R. Matthew E=
merson &lt;<a href=3D"mailto:[email protected]" class=3D"">[email protected]</a>=
&gt; wrote:<br class=3D"">
<br class=3D""></blockquote>
</div>
<blockquote type=3D"cite" class=3D"">
<div dir=3D"ltr" class=3D"">=EF=BB=BF<span class=3D""></span><br class=3D"">=

<span class=3D""></span><br class=3D"">
<blockquote type=3D"cite" class=3D""><span class=3D"">On Jul 27, 2024, at 8:=
23=E2=80=AFPM, Gr=C3=A9gory Vanuxem &lt;<a href=3D"mailto:[email protected]=
m" class=3D"">[email protected]</a>&gt; wrote:</span><br class=3D""></bloc=
kquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">In FriCAS &nbsp;built o=
n top of Clozure CL I obtain this output in a terminal (WSL2)</span><br clas=
s=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">(gamma(x) =C3=83=C3=82=
=C2=A2=C3=83=C3=82=C3=83=C3=82 reals &amp;&amp; Re(x) &gt; 0) || (x =C3=83=C3=
=82=C2=A2=C3=83=C3=82=C3=83=C3=82 integers &amp;&amp;</span><br class=3D""><=
/blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">gamma(x) =C3=83=C3=82=C2=
=A2=C3=83=C3=82=C3=83=C3=82 reals)</span><br class=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">instead of (SBCL)</spa=
n><br class=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">(gamma(x) =E2=88=88 re=
als &amp;&amp; Re(x) &gt; 0) || (x =E2=88=89 integers &amp;&amp; gamma(x) =E2=
=88=88 reals)</span><br class=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">if I (print ...) a str=
ing with, for example, =E2=88=88, in a pure Clozure CL</span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">(recently git cloned) t=
his is correctly printed, no problem.</span><br class=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">So I wonder if I have t=
o modify the output stream character encoding</span><br class=3D""></blockqu=
ote>
<blockquote type=3D"cite" class=3D""><span class=3D"">or the output routine.=
</span><br class=3D""></blockquote>
<span class=3D""></span><br class=3D"">
<span class=3D"">Check that the external format of the FriCAS output stream i=
s what you expect. In other words, if you pass an explicit :external-format a=
rgument to cl:open, make sure it matches what your terminal requires.</span>=
<br class=3D"">
<span class=3D""></span><br class=3D"">
<span class=3D"">Doing (describe *terminal-io*) might show something interes=
ting. Here=E2=80=99s what it shows for me:</span><br class=3D"">
<span class=3D""></span><br class=3D"">
<span class=3D"">? (describe *terminal-io*) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</=
span><br class=3D"">
<span class=3D"">#&lt;ECHOING-TWO-WAY-STREAM input #&lt;BASIC-CHARACTER-INPU=
T-STREAM UTF-8 (TTY/0) #x1824C7D6&gt;, output #&lt;BASIC-CHARACTER-OUTPUT-ST=
REAM UTF-8 (TTY/1) #x1824C2A6&gt; #x1825FBE6&gt;</span><br class=3D"">
<span class=3D"">Class: #&lt;STANDARD-CLASS ECHOING-TWO-WAY-STREAM&gt;</span=
><br class=3D"">
<span class=3D"">Wrapper: #&lt;CLASS-WRAPPER ECHOING-TWO-WAY-STREAM #x18039A=
16&gt;</span><br class=3D"">
<span class=3D"">Instance slots</span><br class=3D"">
<span class=3D"">SHARED-RESOURCE: NIL</span><br class=3D"">
<span class=3D"">OPEN-P: T</span><br class=3D"">
<span class=3D"">INPUT-STREAM: #&lt;BASIC-CHARACTER-INPUT-STREAM UTF-8 (TTY/=
0) #x1824C7D6&gt;</span><br class=3D"">
<span class=3D"">OUTPUT-STREAM: #&lt;BASIC-CHARACTER-OUTPUT-STREAM UTF-8 (TT=
Y/1) #x1824C2A6&gt;</span><br class=3D"">
<span class=3D""></span><br class=3D"">
<span class=3D"">The default external format has been #&lt;EXTERNAL-FORMAT :=
UTF-8/:UNIX #x18249C6E&gt; for quite a long time now.</span><br class=3D"">
<span class=3D""></span><br class=3D"">
<span class=3D""><a href=3D"https://ccl.clozure.com/docs/ccl.html#characters=
-and-external-formats" class=3D"">https://ccl.clozure.com/docs/ccl.html#char=
acters-and-external-formats</a></span><br class=3D"">
<span class=3D""></span><br class=3D"">
<span class=3D""></span><br class=3D"">
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">And more importantly, h=
ow can I achieve that?</span><br class=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">- Greg</span><br class=
=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D""></span><br class=3D"">=
</blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">PS:</span><br class=3D=
""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">(1) -&gt; )lisp CCL:*D=
EFAULT-EXTERNAL-FORMAT*</span><br class=3D""></blockquote>
<blockquote type=3D"cite" class=3D""><span class=3D"">Value =3D :UNIX</span>=
<br class=3D""></blockquote>
<span class=3D""></span><br class=3D"">
<span class=3D""></span><br class=3D""></div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>

</div></blockquote></div><br class=3D""></div></div></blockquote></div></div=
></body></html>=

--Apple-Mail-05C8E3B6-844C-424A-9107-6C47AF5F8ABF--