Re: Challenge: CCL port to the RPi Pico (RP2040)
Ron Garret <[email protected]> Sun, 28 Jul 2024 10:11:35 -0700
| Newsgroups | gmane.lisp.openmcl.devel |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_8FF66574-05DB-45E7-BF0C-D263E18E3EE8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 1. Obtain a tool chain for the Pico and get hello-world running. 2. Use that tool chain to compile the CCL sources using the Arm32 = Makefile. 3. Write stubs for all the undefined symbols. The stubs should all be = breakpoints. 4 Recompile. 5. Run the resulting binary and see what happens. If you're lucky, = you will hit a breakpoint in one of your stubs. Write a functional = version of that stub. 6. Goto 4. My guess is that the biggest challenge you're going to face is that the = ARM Cortex M0 doesn't have an MMU. AFAIK, the modern CCL GC depends on = that. rg > On Jul 28, 2024, at 8:37 AM, Jon Boone <[email protected]> = wrote: >=20 > For those who might be interested in such a project, where would one = start? =20 >=20 > =E2=80=94 jb > On Jul 28, 2024 at 10:54 -0400, Tim McNerney <[email protected]>, = wrote: >> =EF=BB=BFThe popular Raspberry Pi Pico chip (RP2040) is a remarkable = microprocessor with memory resources not dissimilar from the Mac 512k, = CCL=E2=80=99s debut target. Here are some quick facts.=20 >> Dual ARM Cortex-M0+ @ 133MHz >>=20 >> 264kB on-chip SRAM in six independent banks >>=20 >> Support for up to 16MB of off-chip Flash memory via dedicated QSPI = bus >>=20 >> Some might argue it=E2=80=99s not comparable to a Mac 512. I claim it = is: consider that the RAM would only used for the heap, stack(s), and = housekeeping? It is the off-chip flash support that makes all the = difference. That=E2=80=99s where you can store static code and data = segments that make up the bulk of a CCL image.=20 >>=20 >> My big questions: >>=20 >> 1) Could this chip run CCL? >>=20 >> 2) Would it be worth the effort? >>=20 >> I think yes on both fronts. A lot of embedded code is truly modest, = so a small heap is useful enough. This is the arena where microPython = shines=E2=80=94itself sporting a garbage collector.=20 >>=20 >> 3) Does anyone want to try? >>=20 >> CCL already has 32-bit ARM support. There is no OS interfacing work = to do here (only work to make up for the lack of OS).=20 >>=20 >> 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 and = GUI issues. First get it working from a serial port console (over = Bluetooth maybe?) and focus on embedded applications. Slash and burn the = rest, at least for starters.=20 >>=20 >> --Tim >>=20 >>> On Jul 28, 2024, at 01:32, R. Matthew Emerson <[email protected]> = wrote: >>>=20 >>> =EF=BB=BF >>>=20 >>>> On Jul 27, 2024, at 8:23=E2=80=AFPM, Gr=C3=A9gory Vanuxem = <[email protected]> wrote: >>>>=20 >>>> In FriCAS built on top of Clozure CL I obtain this output in a = terminal (WSL2) >>>>=20 >>>> (gamma(x) =C3=83=C3=82=C2=A2=C3=83=C3=82=C3=83=C3=82 reals && Re(x) = > 0) || (x =C3=83=C3=82=C2=A2=C3=83=C3=82=C3=83=C3=82 integers && >>>> gamma(x) =C3=83=C3=82=C2=A2=C3=83=C3=82=C3=83=C3=82 reals) >>>>=20 >>>> instead of (SBCL) >>>>=20 >>>> (gamma(x) =E2=88=88 reals && Re(x) > 0) || (x =E2=88=89 integers && = gamma(x) =E2=88=88 reals) >>>>=20 >>>> if I (print ...) a string with, for example, =E2=88=88, in a pure = Clozure CL >>>> (recently git cloned) this is correctly printed, no problem. >>>>=20 >>>> So I wonder if I have to modify the output stream character = encoding >>>> or the output routine. >>>=20 >>> Check that the external format of the FriCAS output stream is what = you expect. In other words, if you pass an explicit :external-format = argument to cl:open, make sure it matches what your terminal requires. >>>=20 >>> Doing (describe *terminal-io*) might show something interesting. = Here=E2=80=99s what it shows for me: >>>=20 >>> ? (describe *terminal-io*) =20 >>> #<ECHOING-TWO-WAY-STREAM input #<BASIC-CHARACTER-INPUT-STREAM UTF-8 = (TTY/0) #x1824C7D6>, output #<BASIC-CHARACTER-OUTPUT-STREAM UTF-8 = (TTY/1) #x1824C2A6> #x1825FBE6> >>> Class: #<STANDARD-CLASS ECHOING-TWO-WAY-STREAM> >>> Wrapper: #<CLASS-WRAPPER ECHOING-TWO-WAY-STREAM #x18039A16> >>> Instance slots >>> SHARED-RESOURCE: NIL >>> OPEN-P: T >>> INPUT-STREAM: #<BASIC-CHARACTER-INPUT-STREAM UTF-8 (TTY/0) = #x1824C7D6> >>> OUTPUT-STREAM: #<BASIC-CHARACTER-OUTPUT-STREAM UTF-8 (TTY/1) = #x1824C2A6> >>>=20 >>> The default external format has been #<EXTERNAL-FORMAT :UTF-8/:UNIX = #x18249C6E> for quite a long time now. >>>=20 >>> = https://ccl.clozure.com/docs/ccl.html#characters-and-external-formats >>>=20 >>>=20 >>>>=20 >>>> And more importantly, how can I achieve that? >>>>=20 >>>> - Greg >>>>=20 >>>> PS: >>>> (1) -> )lisp CCL:*DEFAULT-EXTERNAL-FORMAT* >>>> Value =3D :UNIX >>>=20 >>>=20 --Apple-Mail=_8FF66574-05DB-45E7-BF0C-D263E18E3EE8 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;" class=3D"">1. = Obtain a tool chain for the Pico and get hello-world running.<div = class=3D""><br class=3D""></div><div class=3D"">2. Use that tool = chain to compile the CCL sources using the Arm32 Makefile.</div><div = class=3D""><br class=3D""></div><div class=3D"">3. Write stubs for = all the undefined symbols. The stubs should all be = breakpoints.</div><div class=3D""><br class=3D""></div><div class=3D"">4 = Recompile.</div><div class=3D""><br class=3D""></div><div = class=3D"">5. Run the resulting binary and see what happens. = If you're lucky, you will hit a breakpoint in one of your stubs. = Write a functional version of that stub.</div><div class=3D""><br = class=3D""></div><div class=3D"">6. 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 the ARM Cortex M0 doesn't have an MMU. = AFAIK, the modern CCL GC depends on that.</div><div class=3D""><br = class=3D""></div><div class=3D"">rg</div><div class=3D""><div><br = class=3D""><blockquote type=3D"cite" class=3D""><div class=3D"">On Jul = 28, 2024, at 8:37 AM, Jon Boone <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> 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 = project, where would one start? </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 <<a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>>, wrote:<br class=3D""> <blockquote type=3D"cite" style=3D"border-left-color: grey; = border-left-width: thin; border-left-style: solid; margin: 5px = 5px;padding-left: 10px;" class=3D""> <div dir=3D"ltr" class=3D"">=EF=BB=BFThe popular Raspberry Pi Pico chip = (RP2040) is a remarkable microprocessor with <i class=3D"">memory = resources</i> not dissimilar from the Mac 512k, CCL=E2=80=99s debut = target. Here are some quick facts. <div dir=3D"ltr" class=3D""> <div class=3D""> <ul style=3D"-webkit-text-size-adjust: auto; box-sizing: border-box; = font-family: Roboto, sans-serif;" class=3D""> <li style=3D"box-sizing: border-box;" class=3D""><p style=3D"box-sizing: = border-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: = border-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: = border-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 dedicated 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 the heap, stack(s), and housekeeping? It is the off-chip flash = support that makes all the difference. That=E2=80=99s where you can = store static code and data segments that make up the bulk of a CCL = image. </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 = embedded code is truly modest, so a small heap is useful enough. This is = the arena where microPython shines=E2=80=94itself sporting a garbage = collector. </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 = interfacing work to do here (only work to make up for the <i = class=3D"">lack</i> of OS). </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 and GUI issues. First get it working from a serial port console = (over Bluetooth maybe?) and focus on embedded applications. Slash and = burn the rest, at least for starters. </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 Emerson <<a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> 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 <<a = href=3D"mailto:[email protected]" class=3D"">[email protected]</a>>= wrote:</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"">In FriCAS = built on top of Clozure CL I obtain this output in a terminal = (WSL2)</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"">(gamma(x) = =C3=83=C3=82=C2=A2=C3=83=C3=82=C3=83=C3=82 reals && Re(x) > = 0) || (x =C3=83=C3=82=C2=A2=C3=83=C3=82=C3=83=C3=82 integers = &&</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)</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"">(gamma(x) =E2=88=88 = reals && Re(x) > 0) || (x =E2=88=89 integers && = 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 = string 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) this 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 to modify the output stream character encoding</span><br = class=3D""></blockquote> <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 is what you expect. In other words, if you pass an explicit = :external-format argument 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 = interesting. 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*) = </span><br class=3D""> <span class=3D"">#<ECHOING-TWO-WAY-STREAM input = #<BASIC-CHARACTER-INPUT-STREAM UTF-8 (TTY/0) #x1824C7D6>, output = #<BASIC-CHARACTER-OUTPUT-STREAM UTF-8 (TTY/1) #x1824C2A6> = #x1825FBE6></span><br class=3D""> <span class=3D"">Class: #<STANDARD-CLASS = ECHOING-TWO-WAY-STREAM></span><br class=3D""> <span class=3D"">Wrapper: #<CLASS-WRAPPER ECHOING-TWO-WAY-STREAM = #x18039A16></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: #<BASIC-CHARACTER-INPUT-STREAM UTF-8 = (TTY/0) #x1824C7D6></span><br class=3D""> <span class=3D"">OUTPUT-STREAM: #<BASIC-CHARACTER-OUTPUT-STREAM UTF-8 = (TTY/1) #x1824C2A6></span><br class=3D""> <span class=3D""></span><br class=3D""> <span class=3D"">The default external format has been = #<EXTERNAL-FORMAT :UTF-8/:UNIX #x18249C6E> 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-form= ats" = class=3D"">https://ccl.clozure.com/docs/ccl.html#characters-and-external-f= ormats</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, how 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) -> )lisp = CCL:*DEFAULT-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></body></html>= --Apple-Mail=_8FF66574-05DB-45E7-BF0C-D263E18E3EE8--