Shop OBEX P1 Docs P2 Docs Learn Events
P2 Knowledge Base - support for command-line AI agents as our P2 development coding partner - Page 2 — Parallax Forums

P2 Knowledge Base - support for command-line AI agents as our P2 development coding partner

2

Comments

  • @"Stephen Moraco"
    Thank you for making a very healthy start on all this. A huge contribution and effort.
    From little acorns grow....

  • Oh, now that I have working links, I unfortunately can see, what @Wuerfel_21 meant. (I do think, that the wording is a bit harsh!) It is indeed a very tiny acorn right now, many and all the more tricky things are just not there.
    I don't think that AI or humans should be fed with incorrect facts.

    So, would you like to check these for example:
    From https://github.com/ironsheep/P2-Knowledge-Base/blob/main/deliverables/reference/pasm2-essentials.md :

    Is this really working like this?

    I have never used augd, but I have some doubts:

    Also PA, PB and memory alignment????

    Of course this might be once something very great. But with the acorn being so small at this moment, perhaps some smaller wording might be a good idea for the time being? Instead of:

  • VonSzarvas, I have the same experience with these old links, 404, but if you go to Stephen's recent YouTube video, "Developing for the Parallax Propeller v2 with Claude Code", there is a link there to the P2 Knowledge Base. I followed that link and there are setup instructions. I had no idea what to do with them, so I copied and pasted into Claude Code on my Linux terminal. Claude knew what to do with it. It all seemed to go very smoothly and Claude says he has the P2 stuff and that we are ready to go. We will see.

  • @"Christof Eb." said:
    I still get Error 404 with your first link.

    @VonSzarvas thank you for helping me get Chrostof's point! ;-) Geez, how'd I miss this?

    The link at the top post is fixed... Thanks to both of you!

  • @"Stephen Moraco" said:

    @"Christof Eb." said:
    I still get Error 404 with your first link.

    @VonSzarvas thank you for helping me get Chrostof's point! ;-) Geez, how'd I miss this?

    The link at the top post is fixed... Thanks to both of you!

    Awesome!
    What I'd also tried to articulate was that the 4 other links in that first post also have "bad" links. The same adjustment is required on all those too.

  • @"Christof Eb." said:
    It is indeed a very tiny acorn right now; many and all the more tricky things are just not there.

    Yes, it is very tiny! It is a proof of concept, and after a full two months of working on it, it's working pretty well, as evidenced by the video demo and others' experiences trying to follow along. This is a large body of work, and my approach has been to go very wide initially, with early passes at consuming all published content for the P2. The work has progressed well, but there is still a significant amount to be done.

    I appreciate your interest. I'm hearing your suggestions and acting on them. I've revised the top-level page so that it doesn't look as active as you pointed out. As this project proceeds, I'll activate more areas... This page came about as a planning document for the entire shape. Unfortunately, when published, this came across as already being present, and there's just no way it could have been, given the amount of time spent on the project so far.

    So, thank you for keeping me honest.

    Regards,
    Stephen

  • @VonSzarvas said:
    Is it possible the correct links in your first post should be adjusted? They are all 404.
    Example- I think "Repository" should be: https://github.com/ironsheep/P2-Knowledge-Base
    If you agree then I think you can edit; but let me know if any help needed.

    Okay, I think it's all cleaned up now. (I'm moving too fast if I'm leaving these kinds of things broken.)

    Thank you all for your patience!

  • Hi @"Stephen Moraco", I found your Video on "Developing for the Parallax Propeller v2 with Claude Code " very impressive.

    I know you had had a few adverse comments about this project but hope they have not put you off in your efforts.

    My first thought, while watching the video, was that this might prove an excellent tool to help Parallax improve the written P2 documentation, after some human filtering no doubt but the AI code commenting seemed to be very well done.

    My second thought was that for a Hardware engineer, like me, that needs to use code to make stuff work, an AI Assistant / cross checker, like this, could be a real asset.

    I work in Isolation having learned P1 & now P2 programming mainly via this forum, after having done some BASIC and macro programming in the past.
    I read the Forum frequently and have been helped by many people here.
    I often look in awe at some of the code people here can write and know that a lot of it exceeds anything I could ever do on my own!
    This is perhaps where AI could help me, I sometimes find myself stumped by something that proves very simple in the end, if AI can help to point me in the right direction when I get stuck, then I think this could be a useful tool.

    One thing that I don't recall seeing you mentioning about Claud AI is the plan you are on to get the level of access you have in the above video?
    Is it the FREE tier or one of the PAID versions? Can we do anything with the P2 using the FREE tier? There is a big jump from Free to £200 year, in one step?

    I tried to follow what you did in the on-line console only to find a lot won't work there, it seems to need to be downloaded and installed locally, like you have.
    I did manage to get "~150 lines of P2 Knowledge Base integration content that needs to be added to your CLAUDE.md file" when I finally work out how to get one of those.
    On the free plan that was all I could do in one day as it had timed out.

    I have now installed VScode and need to install your config for that. I did managed to install the "Claude Code for VS Code" add-on and Node.js so I will see where that takes me.

    Thanks for your attempts to drag us into the mirky world of AI, it is a place I have avoided like the plague until now!

  • First of all Stephen thank you for making the P2 Knowledge Base. I tried it but found issues with it. I am using Windows 11, FlexProp 7.5.1 and Visual Code. When I use the QuickStart script It had errors with the -Verbose command which Powershell did not understand. Then Claude edited the script and I got the cache shown below

    When I tried having it make blink a LED on the P2 it could not do it until I had it scan the flexprop example. Then I tried doing patterns on the LED matrix and it could not do that either. Did it corrupt the Knowledge base when it edited it?

  • Stephen MoracoStephen Moraco Posts: 401
    edited 2025-10-18 03:45

    @lab_ges thank you for your kind words. My prototyping is continuing. I'm focused on getting pnut-term-ts released as soon as possible. Meanwhile, work continues strengthening p2 content representation for use by AI command-line tools, and yes, several documents are part of my prototype plans. All of this is to determine how useful this can be to us in developing embedded systems using the P2.

    I find that one of the most valuable techniques is developing for the P2 using this prototype and identifying where difficulties arise. Then I get to envision different ways to present the data to smooth out these issues. It's time-consuming and still a bit fun since I'm also developing for the P2.

  • @lab_ges said:
    One thing that I don't recall seeing you mentioning about Claud AI is the plan you are on to get the level of access you have in the above video?
    Is it the FREE tier or one of the PAID versions? Can we do anything with the P2 using the FREE tier? There is a big jump from Free to £200 year, in one step?

    Here in the US, we have Claude Code offered in many tiers. The two lowest should be usable. The free plan and the $20/Mo plan (cheaper if you pay for the year.) The $20 one will likely be more satisfying to use for getting more work done in a single session.

    However, I'm also starting to experiment with Codex and other command-line AI coding tools. Some of these have very reasonable pricing for what you get, and some of them let you work with many different AI models from the same CLI tool. Some of these are going to be more attractive for this work as a number of them allow for greater conversational context, which translates, generally, into better code solutions and better code planning solutions.

    So, I'll pass along my experiences as I find more useful things to share...

  • RaymanRayman Posts: 15,925

    Be interesting if Claude could do the bubble sort algorithm in Spin2. Going to be needing that soon...

  • JonnyMacJonnyMac Posts: 9,566
    edited 2025-11-29 15:13

    I use claude.ai manually. This week, for example, I was able to prompt it to get a SHA-256 object that matches the P1 version that is used in our laser tag devices.

    First prompt for bubble sort

    It wouldn't compile because of the phantom serial object and a misplaced local array definition. Second prompt

    Reply: You're absolutely right on both counts! Thank you for the corrections. Let me fix those issues:

    It works (in Spin Tools); that is, it sorts, but will this do what you want/need. AI is like a shovel used to dig/rough-out a pool; many times the finishing work requires us to get involved. There are areas of this program I would touch-up, but for the sake of this, I have included the direct output from claude.ai.

    CON
      _clkfreq = 200_000_000
    
    OBJ
      ser : "jm_fullduplexserial"
    
    PUB main() | i, testArray[10]
    
      ' Start serial communication
      ser.start(63, 62, 0, 230400)
    
      waitms(100)
    
      ser.str(string("Bubble Sort Demo", 13, 10))
    
      ' Initialize test array
      testArray[0] := 64
      testArray[1] := 34
      testArray[2] := 25
      testArray[3] := 12
      testArray[4] := 22
      testArray[5] := 11
      testArray[6] := 90
      testArray[7] := 88
      testArray[8] := 45
      testArray[9] := 50
    
      ' Display unsorted array
      ser.str(string("Unsorted array: ", 13, 10))
      printArray(@testArray, 10)
    
      ' Sort the array
      bubbleSort(@testArray, 10)
    
      ' Display sorted array
      ser.str(string(13, 10, "Sorted array: ", 13, 10))
      printArray(@testArray, 10)
    
      repeat
    
    PUB bubbleSort(arrPtr, n) | i, j, temp, swapped
    
      ' Outer loop for each pass
      repeat i from 0 to n-2
        swapped := false
    
        ' Inner loop for comparisons
        repeat j from 0 to n-i-2
          ' Compare adjacent elements
          if long[arrPtr][j] > long[arrPtr][j+1]
            ' Swap elements
            temp := long[arrPtr][j]
            long[arrPtr][j] := long[arrPtr][j+1]
            long[arrPtr][j+1] := temp
            swapped := true
    
        ' If no swaps were made, array is sorted
        if not swapped
          quit
    
    PUB printArray(arrPtr, n) | i
    
      repeat i from 0 to n-1
        ser.dec(long[arrPtr][i])
        if i < n-1
          ser.str(string(", "))
      ser.str(string(13, 10))
    

    Note that I didn't ask it to format in my style, which it can and does do on request -- though it sometimes needs a bit of help.

  • RaymanRayman Posts: 15,925

    Nice!

  • We're at the point where we need a clanker to implement an algorithm best known for being trivial to implement (and having terrible run time characteristics)

    Also Spin2 has a swap intrinsic now, or you can multi-assign, you wouldn't need a temp variable

  • RaymanRayman Posts: 15,925

    Might be not optimized, but better than starting from scratch?
    Think this saves a couple minutes anyway...

  • @"Stephen Moraco"
    @"Aristides Alvarez"
    I have been busy and just looked at the above stuff. As mentioned by @"Christof Eb." been waiting for documentation that was somewhat easier to use to figure out the P2. I have been hoping for something similar to the P1 coding PE kit manual that was essential for me and got me started.
    Still hoping that with all of the above work that we can get something similar. Would help tremendously. Thanks for your work.
    Martin

  • @JonnyMac said:
    I use claude.ai manually. This week, for example, I was able to prompt it to get a SHA-256 object that matches the P1 version that is used in our laser tag devices.

    First prompt for bubble sort

    It wouldn't compile because of the phantom serial object and a misplaced local array definition. Second prompt

    Reply: You're absolutely right on both counts! Thank you for the corrections. Let me fix those issues:

    It works (in Spin Tools); that is, it sorts, but will this do what you want/need. AI is like a shovel used to dig rough-out a tool; many times the finishing work requires us to get involved. There are areas of this program I would touch-up, but for the sake of this, I have included the direct output from claude.ai.

    CON
      _clkfreq = 200_000_000
    
    OBJ
      ser : "jm_fullduplexserial"
    
    PUB main() | i, testArray[10]
    
      ' Start serial communication
      ser.start(63, 62, 0, 230400)
      
      waitms(100)
      
      ser.str(string("Bubble Sort Demo", 13, 10))
      
      ' Initialize test array
      testArray[0] := 64
      testArray[1] := 34
      testArray[2] := 25
      testArray[3] := 12
      testArray[4] := 22
      testArray[5] := 11
      testArray[6] := 90
      testArray[7] := 88
      testArray[8] := 45
      testArray[9] := 50
      
      ' Display unsorted array
      ser.str(string("Unsorted array: ", 13, 10))
      printArray(@testArray, 10)
      
      ' Sort the array
      bubbleSort(@testArray, 10)
      
      ' Display sorted array
      ser.str(string(13, 10, "Sorted array: ", 13, 10))
      printArray(@testArray, 10)
      
      repeat
    
    PUB bubbleSort(arrPtr, n) | i, j, temp, swapped
    
      ' Outer loop for each pass
      repeat i from 0 to n-2
        swapped := false
        
        ' Inner loop for comparisons
        repeat j from 0 to n-i-2
          ' Compare adjacent elements
          if long[arrPtr][j] > long[arrPtr][j+1]
            ' Swap elements
            temp := long[arrPtr][j]
            long[arrPtr][j] := long[arrPtr][j+1]
            long[arrPtr][j+1] := temp
            swapped := true
        
        ' If no swaps were made, array is sorted
        if not swapped
          quit
    
    PUB printArray(arrPtr, n) | i
    
      repeat i from 0 to n-1
        ser.dec(long[arrPtr][i])
        if i < n-1
          ser.str(string(", "))
      ser.str(string(13, 10))
    

    Note that I didn't ask it to format in my style, which it can and does do on request -- though it sometimes needs a bit of help.

    Thanks for sharing!
    For me it was very informative to try out something simple with a known solution. Takeaway for me is, that for the time being the machine is not able to provide source code, which works out of the box and even produces plain errors. Let alone understand to use a feature of the language, that does not exist in other languages - swap intrinsic.
    In my feeling, it would be way more effective to use Flex's ability to mix languages and just use a proven version in C than to try to teach the machines a new language.
    The whole situation reminds me of when at work I had a student to do their thesis in my field of work. I had to explain so much and to check the results, that I could have done the work myself in the same time. There was no win for the company. Then at least it could be said, that it is something valuable to do some teaching for a student....

  • JonnyMacJonnyMac Posts: 9,566
    edited 2025-10-21 19:24

    For me it was very informative to try out something simple with a known solution.

    We all started with blinking LEDs, right? I have been very cautious with AI, and most of the time I ask it for generic code -- especially if I know I'm going to use P2 smart pins.

    ...does not exist in other languages - swap intrinsic.

    There are new built-in methods: byteswap(), wordswap(), and longswap().

    For a simple exchange of two variables I do this.

      var1, var2 := var2, var1
    

    ...which is available in Python (with a different assignment operator).

    ...that it is something valuable to do some teaching for a student.

    Agreed. A couple of scientists asked me to explain a P1 program that had been written by a former colleague. It was tricky, trying to get into the mind of the other programmer, but with my knowledge of Spin and their knowledge of the system, it all went well, and I think we all got something from the discussion.

  • RaymanRayman Posts: 15,925

    Soon as Ai figures out how to open zip files, might have a lot more source material…

  • @blittled said:
    First of all Stephen thank you for making the P2 Knowledge Base. I tried it but found issues with it. I am using Windows 11, FlexProp 7.5.1 and Visual Code. When I use the QuickStart script It had errors with the -Verbose command which Powershell did not understand. Then Claude edited the script and I got the cache shown below...

    Interesting... I hadn't tested the scripts on Windows, yet but made them thinking they would give us a start. I'll check on my installation and get them corrected. Thank you for reporting this.

    When I tried having it make blink a LED on the P2 it could not do it until I had it scan the flexprop example. Then I tried doing patterns on the LED matrix and it could not do that either. Did it corrupt the Knowledge base when it edited it?

    My initial experience with the charlieplexing drive of the LEDs was similar. It didn't grok the charlieplexing until I had it study the code from QuickBytes.

    Re corrupt: You can always flush the cache (remove the files in it manually), and it will re-populate it automatically. You likely did not damage it by what you were doing.

    I'm finding that given sufficient prompting to locate information about the P2, it's pretty strong, but I want this to be easier, still. I'm making summarizing (gathering guidance from across our docs and placing them in a single reference) changes to the download-on-demand system so that it has more ability when it first connects. I'm doing this by continually attempting to build working code with it. With each update, I'm getting closer, so successes are happening, but it's slow going from any one perspective as I'm working on many fronts at once. My most recent updates are easily picked up by having it reread the Spin2 or Pasm getting started (whichever applies to your project).

    Thank you for trying all of this. It's a prototype, but it's becoming stronger every day.

  • @Rayman said:
    Soon as Ai figures out how to open zip files, might have a lot more source material…

    Heh, the problem for me wasn't that it couldn't open them, but that it wants to spray the unzipped files/folders somewhat randomly within your project ;-) This is what motivated my helper scripts to be delivered....

  • I've also been using Zen Coder for my AI. It's nice for short term daily use until you hit your limit then it goes down to a crawl taking forever to respond. I'm also concerned that using the AI may add additional load to the forum server which is experiencing quite a few 504 Gateway errors.

  • Stephen MoracoStephen Moraco Posts: 401
    edited 2025-10-24 20:05

    @blittled said:
    I've also been using Zen Coder for my AI. It's nice for short term daily use until you hit your limit then it goes down to a crawl taking forever to respond.

    Good to hear of another success. I've seen a number of different responses to reaching limits, from slowing to a crawl to just refusing to respond to any queries. Interesting to see how different companies handle this.

    I'm also concerned that using the AI may add additional load to the forum server which is experiencing quite a few 504 Gateway errors.

    I think this is a separate issue. There is no interaction with the Parallax server that I'm aware of. Nothing in my work is accessing the server.

  • @"Stephen Moraco"
    I found the video.
    Thank you for making it.
    Studying it now.
    Martin

  • Stephen MoracoStephen Moraco Posts: 401
    edited 2025-12-09 21:36

    NEWS

    The P2 Knowledge Base work has reached a milestone - we've produced our first human-facing documentation and would like your help reviewing it.

    The Parallax Propeller has been my favorite processor for years. Functional decomposition just works. Eight cores, each owning a clean piece of the problem. The P2 adds smart pins handling I/O autonomously, making it even better. Whether you're writing Spin2 for rapid prototyping or PASM2 for cycle-counted precision, the coupling between components stays narrow - the kind of clean separation that takes years of discipline to achieve in software, but this architecture makes it the path of least resistance.

    The problem: AI assistants can't help with any of it. Claude would see Spin2 syntax that looks like Python and apply Python's rules. It would see PASM2 instructions that resemble ARM and guess from there: two languages, two confusion vectors - neither with firm definitions in AI training data.

    So I started working through the problem with Claude, asking: what would help a remote instance - one with no context - actually understand these languages? The answers shaped the approach: Download-on-Demand with atomic knowledge units fetched as needed. YAML for efficiency. The data shape informed by P2's own architecture: two distinct languages, Smart Pins as a separate domain, and debugging tools that deserve their own treatment.

    What's in the Knowledge Base

    • Hundreds of validated YAML files across three domains
    • Full PASM2 instruction set and Spin2 language constructs
    • All 32 Smart Pin modes with bilingual examples
    • Debugging and hardware subsystem documentation
    • Cross-validated against dozens of authoritative sources
    • Platform-aware bootstrap scripts (Windows, Linux, macOS)

    As we discover new perspectives and patterns, we continually grow and refine the YAML content.

    The Download-on-Demand system is operational. Remote Claude instances are bootstrapping P2 competence and accelerating development today. The impact: 3-5x acceleration in development iteration cycles when paired-coding with Claude. The knowledge base didn't replace expertise - it multiplied it.

    The same knowledge base facilitates the generation of human-facing documentation - a comprehensive synthesis that would take years of human authorship, delivered through AI-assisted processing. Our first documents are ready. Two P2 assembly language references are now available for community technical review:

    • P2 Assembly Language Reference Manual
    • P2 Assembly Programming Tutorial (De Silva style)

    Visit the P2 Knowledge Base repository Documents for access. (NOTE: You don't have to read them on github. Just click on the download link at the top right of the page once the doc opens.)

    You can report issues with or suggest changes to these documents by filing issues at the repository. Go to the issues page, select that you are filing a document issue, and fill out the form with the details.

    What's next? Spin2 documentation and Smart Pins deep-dives are in progress. The three-domain coverage (assembly, high-level language, specialized topics) continues to expand.

    We look forward to hearing what you find. Thank you for helping review these early documents!

    Stephen

  • Wuerfel_21Wuerfel_21 Posts: 5,753
    edited 2025-12-09 22:45

    New drinking game dropped: pick pages from this pdf at random and when you spot an obvious and unforced error made manifest by abuse of AI slop, take a sip.

    Disclaimer: Don't do this, it will give you alcohol poisoning

    Optional hard mode: include any cases where it's technically not wrong but also worded confusingly or the example code is bad.

  • My first impression was positive, because the text has a nice appearance. But then I saw this:

    Honestly Stephen, have you ever written and debugged any substantial assembler code for P2? This picture is so wrong, that it seems hard to believe. And it contradicts other text even in the same document.

    Why on earth do we need exactly the same information twice directly following each other?

    How exactly did you measure this: "The impact: 3-5x acceleration in development iteration cycles when paired-coding with Claude."

    #

    "Stephen is volunteering his time with Chip's support to help us with the P2 documentation.

    Please be constructive in your comments. Too much of what I read above was written in poor taste, and isn't helpful for the Propeller community. I'd like to keep this thread together without edits or deletions, so I'll be leaving the above posts in place. Going forward, I'm stepping up the moderation and will edit or delete posts, moderate or ban members if needed. Feel free to tag me if you feel I'm not seeing these things [there's a lot going on at Parallax at the moment with an event next month].

    We share the need for complete P2 documentation. Please let this effort unfold for the whole community. We will review and improve everything we produce.

    Thank you,

    Ken Gracey

    Ken Gracey, Parallax Inc.
    (916) 625-3010
    @ParallaxKen "

    Well then there is a lot of work for Parallax here, @"Ken Gracey"

  • Christof Eb.Christof Eb. Posts: 1,487
    edited 2025-12-10 08:15

    ?????
    Stephen, have you ever used _RET_ ?????

  • maccamacca Posts: 966
    edited 2025-12-10 08:36

    That's really a big improvement in the documentation (finally I must add...).

    Had a quick look at the P2-PASM-deSilva-Style.pdf I see the very first blink example is not correct: it jumps back 4 instructions but the two waitx have an implicit augd instruction added, so the correct jump back is 6 instructions. Maybe add a note about this and explain better later. Hope this wasn't generated by the IA because if it was it needs to learn about the implicit AUGx syntax.
    I also see some misleading descriptions about the ## syntax in the P2-Assembly-Language-Manual.pdf (2.7.1), this is a source of confiusion, it must be clear that the ## syntax means adding an implicit AUGx and not a simple 32-bit immediate.

    Also, in the COG Architecture on the P2-Assembly-Language-Manual.pdf seems that there is a single LUT ram shared between COG pairs, that's wrong, each COG has its own LUT ram that can be shared with the dedicated enablement instruction. And shared is a bit misleading, because it actually means that writes to a LUT on a COG is copied to the other COG LUT, if I'm not wrong, each LUT can be loaded with independent data, only wrlut instructions cause the shared copy.

    Anyway, that's a really good start.
    Good job!

Sign In or Register to comment.