Micropython for P2

124»

Comments

  • jmgjmg Posts: 13,522
    ersmith wrote: »
    jmg wrote: »
    ersmith wrote: »
    and a USB keyboard (via @garryj's single COG USB driver, ported to C by me)..
    Nice.
    How does the C version compare with the Spin and p2asm versions in garryj's thread.
    Should the C version be included in that thread's first post, with notes on Size/speed/ when to choose each version ?

    The C version is a mechanical translation using spin2cpp. It's not necessary (at all) with fastspin, but I needed it because I wanted to compile the code with the Risc-V version of gcc. So it's probably not generally useful, although I suppose it might with some tweaking be usable under PropGCC or Catalina.
    Ah, ok. Does that mean your version runs the USB code, via the Risc-V emulator code ? I'd have expected that to be too different in timing ?

  • jmg wrote: »
    ersmith wrote: »
    jmg wrote: »
    ersmith wrote: »
    and a USB keyboard (via @garryj's single COG USB driver, ported to C by me)..
    Nice.
    How does the C version compare with the Spin and p2asm versions in garryj's thread.
    Should the C version be included in that thread's first post, with notes on Size/speed/ when to choose each version ?

    The C version is a mechanical translation using spin2cpp. It's not necessary (at all) with fastspin, but I needed it because I wanted to compile the code with the Risc-V version of gcc. So it's probably not generally useful, although I suppose it might with some tweaking be usable under PropGCC or Catalina.
    Ah, ok. Does that mean your version runs the USB code, via the Risc-V emulator code ? I'd have expected that to be too different in timing ?
    The Spin/C part runs in Risc-V emulation. The PASM part runs in another COG, natively.


  • Hi Eric
    II'm experiencing an issue with your self hosted upython when using paste mode.
    After pasting code and hitting ctrl-D it crashes and video is lost too.
    I have a test cog blinking an led and its still running aftr the crash.
    I can paste the same code into my self hosted upython and all is well.

    BTW I have found that the 230400 baud rate is too fast for upython pasting and requires inserting breaks to avoid lost characters. (upython reporst syntax errors)
    Melbourne, Australia
  • ozpropdev wrote: »
    Hi Eric
    II'm experiencing an issue with your self hosted upython when using paste mode.
    After pasting code and hitting ctrl-D it crashes and video is lost too.
    I have a test cog blinking an led and its still running aftr the crash.
    I can paste the same code into my self hosted upython and all is well.
    Are you sure you didn't hit ctrl-D twice? I think that shuts down upython. I wasn't able to reproduce this issue, although I've also changed the serial driver a bit (see below).
    BTW I have found that the 230400 baud rate is too fast for upython pasting and requires inserting breaks to avoid lost characters. (upython reports syntax errors)

    I've added a buffered serial driver that should do better at keeping up with pasted data (at least for the first 512 characters). The updated upython (v10) is in the first post, as usual.

    Thanks,
    Eric
  • Hi Eric
    Sadly it's not a double ctrl-D isuue with V9.
    Repeated tests gave same outcome, screen and upython crashes.

    V10 behaves differently again and crashes during download.
    It appears to be stuck in a buffer loop cycling the same characters.

    Here's a test sample that works on my V8 based self hosted upython and on my other micropython boards.

    Cheers
    Brian
    #boyer-moore algorithm test
    
    bad_table = []
    
    def setup(x):
        global bad_table
        bad_table = [len(x)]*128
        for i in range(len(x)):
            q = len(x) - i - 1
            if q < 1:
                q = 1
            w = ord(x[i])
            print(i,q,w)
            bad_table[int(w)] = q
    
    m="the quick brown fox jumps over the lazy dog"
    
    def find(s):
        setup(s)
        t=0
        z=0
        while True:
            print(m)
            print(" "*t,end="")
            print(s)
            psx = True
            for u in range(len(s)-1,-1,-1):
                z += 1
                if s[u] != m[t+u]:
                    t += bad_table[ord(m[t+u])]
                    psx = False
                    break
            if t + len(s) > len(m):
                print("No match found!")
                break
            if psx:
                print(z," comparisons made")
                break
    
    find("over")
    


    Melbourne, Australia
  • Sorry Brian! There was a typo in the serial receive code that could cause it to get stuck repeating characters. I've uploaded v11 which does run your example correctly. Thanks for the repo case.

    Eric
  • Thanks Eric!
    V11 looks good, nice work! :cool:

    Melbourne, Australia
  • I've just posted v12 (see the first post in this thread). This one has preliminary support for microSD cards on the P2 Eval board (i.e. it expects the SD card to be SPI driven on pins 58-61) and FAT file systems. I haven't done a lot of testing yet, but it's worked with three different cards I've tried with.

    execfile, open, close, read, and write all seemed to do the right thing. So now with a VGA monitor, SD card, and USB keyboard you can do Python development entirely on your P2 Eval board, and even save your work.

    Again, I haven't done a lot of testing so be *very* careful (don't try it with any SD Cards containing data you care about!).

    One of the cards wasn't automatically detected, so I had to manually mount it with:
    import pyb
    import os
    sd=pyb.SDCard()
    sd.power(1)
    os.mount(sd, '/sd')
    
    but once that was done it seemed to work OK.

    The updated source code is posted to my github micropython repository.

    Eric
Sign In or Register to comment.