Shop OBEX P1 Docs P2 Docs Learn Events
Unable to get Micropython to respond to terminal input - Page 3 — Parallax Forums

Unable to get Micropython to respond to terminal input

13

Comments

  • TubularTubular Posts: 4,705
    edited 2023-06-12 04:08

    Yes we do.
    I'm waiting to see what Chip is proposing with the flash file system, as being able to wrangle the entire 16MB flash is going to be important.

  • Good news, the SDXC card approach works fine, at least with P2Eval.

    I took a new class 10 "Team" card, ran Disk Management in win 10 (Windows-X, k)
    Right click on the 64 GB and click 'shrink volume' down below 32 GB, eg 4GB
    Format using FAT32. Quick format is fine
    Rename the Micropython .binary (P2uP_1_0_124.binary) to _BOOT_P2.BIX, then copy into the root directory of the SDXC
    Insert into the P2eval microsd socket, hit reset. Open a terminal at 115200 baud.

    This particular Team SDXC card works fine - when you press the P2eval reset button, it reboots and brings a fresh REPL back.
    Not all SDXC cards do this - some need a power cycle (or at very least some extra clock pulses).
    I believe the edge design, and p2d2, do the power cycle when the reset button is pressed. But I haven't yet tested the edge.

  • roglohrogloh Posts: 5,837
    edited 2023-06-12 04:50

    Maybe what would be handy would be a special _BOOT_P2.BIX file people could use to boot the P2 off SD and run it which then mounts the SD and looks for a file with some special name, let's say FLASHP2.BIN or something similar, and then flashes the file (up to the full 512kB).

    It may need some careful pin control logic like @pik33 mentioned where the flash and SD reads/writes can be interleaved if the SD reader + flasher code can't entirely fit in a single COG and needs some hub RAM of it's own.

    Of course if it was carefully crafted to all fit in a single COG (or two COGs with LUT control handshaking) then this could be read into RAM in a single go and then flashed in it's entirety but that's probably somewhat difficult to achieve (nice work to whoever can code all that in a single or pair of COGs using no HUB RAM :) ).

  • Here's a slightly less daunting, and more cross platform, version that also tests successfully - using the Raspberry Pi Imager utility

    Under "Choose OS", one option is 'Erase' which formats the SDXC card with FAT32. Unlike other tools it seems happy to format the entire partition with fat32, without complaint. (Windows Powershell takes forever, 15 mins?, then tells you it can't)

    Another advantage is the Pi imager doesn't let you accidently choose/format your primary partition, just the SDXC card

    Once formatted, its same steps as above - rename the binary to _BOOT_P2.BIX and copy ("send to") the SDXC card

    P2Eval boots fine from it

    --

    Initially I was wondering whether the Pi imager, which also supports .img and .iso file types, could be used to make things more streamlined and cross-platform. However using the already existing Erase (fat32 format) option is probably good enough, and saves having to create yet another source binary (img or iso). The Pi Imager also has a couple of options for creating from .zip that may also work, if we add a _BOOT_P2.BIX directly into the distributed zip file. Maybe

  • (I just tried that last option of giving Pi Imager a .zip. It doesn't work - its hard to know what its doing with the zip file but it appears the SDXC doesn't have a proper file structure, so windows can't mount it. Perhaps the zip gets blindly written as raw data, or perhaps it unzips and then writes that as raw data, or something similar)

    I'll have a quick go with flexgui 4.0.6 next

  • Just tried FlexProp 6.1.5. It half works

    The Step1 completes fine and led P56 blinks

    Step2 results in garbage to the terminal screen, because P2NMP puts out serial at 115200, but FlexProp is perhap defaults ts 230k. Adding -b115200 to the flash loading command fixes this, and once step2 completes you will see the REPL come up, and you can indeed interact with it successfully.

    However, resetting the P2eval doesn't load a fresh REPL, and I don't really know why.

    So far, this experience is a bit odd - I used to have more trouble with SDXC than the serial methods, but todays experience is the opposite.

  • Back on Proptool 2.6.2 - it appears it does in fact successfully put P2NMP into flash, it just doesn't run until you reset.

    I only found this out towards the end, when the SDXC was removed, and P2NMP was appearing from flash. I had to retrace some steps

    The Proptool error messages that appear don't truly reflect whats happening, so for now it looks like the solution is to amend the Step2 comments to tell people to ignore the warnings, and hit reset.

    It'd still be good to get things going with FlexProp again, or at least understand the blockage. And test with the edge board, perhaps tomorrow

  • pik33pik33 Posts: 2,387

    @rogloh said:
    Maybe what would be handy would be a special _BOOT_P2.BIX file people could use to boot the P2 off SD and run it which then mounts the SD and looks for a file with some special name, let's say FLASHP2.BIN or something similar, and then flashes the file (up to the full 512kB).

    It may need some careful pin control logic like @pik33 mentioned where the flash and SD reads/writes can be interleaved if the SD reader + flasher code can't entirely fit in a single COG and needs some hub RAM of it's own.

    Of course if it was carefully crafted to all fit in a single COG (or two COGs with LUT control handshaking) then this could be read into RAM in a single go and then flashed in it's entirety but that's probably somewhat difficult to achieve (nice work to whoever can code all that in a single or pair of COGs using no HUB RAM :) ).

    There is another workaround: use P2-EC32MB. The binary can be then loaded from SD to PSRAM and the P2 can be init from it. I use this in my MicroDOS, that reads the binary to the first 1 MB of PSRAM, then switches off all cogs leaving only a mover cog that moves the binary to the hub, and PSRAM cog driver. The one thing that is resident in HUB RAM while moving is the PSRAM mailbox that I moved near $7FFFF. That can be also overwritten with the last block of the binary.

  • I'll give the Rpi imager a try tomorrow, I used Linux to partition and format my Sandisk ImageMate 64GB as a 1GB partition, just got garbage on boot.

  • Ok. Out of interest will Linux format a partition in fat32 thats bigger than 32GB?

  • Wuerfel_21Wuerfel_21 Posts: 5,105
    edited 2023-06-12 08:05

    I posted the Fat32 format tool for windows earlier in this very thread. It works up to 2 TB. But yall messed with the partition tables so now you need to fix those first.

  • VonSzarvasVonSzarvas Posts: 3,486
    edited 2023-06-12 08:47

    Hi @pedward
    To comment on a couple things you mentioned earlier in-case they are relevant...

    1. You mentioned buying an Edge deal. In case that was the special version with 19.2MHz osc then your loader params may need to reflect that to avoid subtle timing/corruption issues.
    2. The older PropPlug will work, but it can slightly power the P2 when it's off, or the module whilst the P2 is held in reset. Whereas the latest PropPlug adds some circuitry to avoid that issue and should be considered as the robust choice for P2 work.
    3. DTR behaviour can be configured in Windows comport adv settings, and somewhere yonks ago in the forum I shared instructions on how to adjust to avoid the unplug and port close resets. Might still help with Win11. Mentioning here as I can't search now, but will look and test when back at base.
    4. Fresh formatting the SD is good idea. Something about the file has to be in first page of the mbr index. Forget the detail, but solution is simple with a format tool like Ada posted.
  • @Wuerfel_21 said:
    I posted the Fat32 format tool for windows earlier in this very thread. It works up to 2 TB. But yall messed with the partition tables so now you need to fix those first.

    I tried that before the Pi imager and windows powershell, but something was keeping it from gaining access to mount the SDXC. It said it was in use by another process, but I closed everything I could find that might cause an issue.

    I'm pretty sure I've used the same utility without issues in the past, but no go this time. Some windows dependency is perhaps broken. I did try making sure it had admin priveleges

  • When it does that, try formatting using rhe normal windows dialog first.

  • Or the SD assoc tool is a other option that caters for most OS types and versions:

    https://www.sdcard.org/downloads/formatter/

  • Wuerfel_21Wuerfel_21 Posts: 5,105
    edited 2023-06-12 08:57

    @VonSzarvas said:
    Or the SD assoc tool is a other option that caters for most OS types and versions:

    https://www.sdcard.org/downloads/formatter/

    But that also refuses to do large FAT32 partitions. But I think it restores the partition table, so that's something.

  • @Wuerfel_21 said:
    When it does that, try formatting using rhe normal windows dialog first.

    Ok, so after partitioning with a reduced 30GB size using disk manager, guiformat was able to FAT32 format the SDXC, and I transfferred the MP binary, and it booted and worked successfully.

    The thing is, you need to muck around with partition first, while your main "never format this" drive is right next door. The disk manager also lets you format in FAT32, once you have a suitably sized partition, which makes Guiformat somewhat redundant.

    Overall I think we're better served by the Pi Imager, because its now common, cross platform, and hides your main "never format this" drive from being a nearby option. However I'm learning its a good idea to document a few different ways of doing the same thing, just like the importance of being able to load P2NMP over serial or SDXC depending on what's available and working

  • @VonSzarvas said:
    Or the SD assoc tool is a other option that caters for most OS types and versions:

    https://www.sdcard.org/downloads/formatter/

    It seems to just put exFat onto my 64GB card, there doesn't seem to be a way to set FAT32. Maybe it the drive is smaller
    Also seems to support Windows/Mac but not Linux. That makes it somewhat useful, but doesn't have the coverage of Pi imager

  • TubularTubular Posts: 4,705
    edited 2023-06-12 09:53

    I just upgraded to latest PropTool 2.9.3, and both Step1 and 2 to install MicroPython work without any error dialogs popping up. My previous testing was with v2.6.2

    So it looks like PropTool doesn't need any additional instructions. Now to see if I can get further with FlexProp

  • Wuerfel_21Wuerfel_21 Posts: 5,105
    edited 2023-06-12 12:35

    @Tubular said:

    @Wuerfel_21 said:
    When it does that, try formatting using rhe normal windows dialog first.

    Ok, so after partitioning with a reduced 30GB size using disk manager, guiformat was able to FAT32 format the SDXC, and I transfferred the MP binary, and it booted and worked successfully.

    The thing is, you need to muck around with partition first, while your main "never format this" drive is right next door. The disk manager also lets you format in FAT32, once you have a suitably sized partition, which makes Guiformat somewhat redundant.

    No, just use the right-click menu format, no need to mess with disk management. Resizing the partition is only a solution if you don't feel iffy wasting half of your capacity (which, fair enough, filling up even 16GB is a challenge).

    Also, you can never format your boot drive even if you tried. Extra data partitions yes though.

  • pedwardpedward Posts: 1,642
    edited 2023-06-12 16:56

    @VonSzarvas said:
    Hi @pedward
    To comment on a couple things you mentioned earlier in-case they are relevant...

    1. You mentioned buying an Edge deal. In case that was the special version with 19.2MHz osc then your loader params may need to reflect that to avoid subtle timing/corruption issues.

    Nope, this was the $79 bundle with the P2E breakout board. It has the 6CA0 oscillator.

    1. The older PropPlug will work, but it can slightly power the P2 when it's off, or the module whilst the P2 is held in reset. Whereas the latest PropPlug adds some circuitry to avoid that issue and should be considered as the robust choice for P2 work.

    Yeah, I read there were some improvements and wondered if it was really best to get a latest.

  • @Tubular said:
    Ok. Out of interest will Linux format a partition in fat32 thats bigger than 32GB?

    Yes, mkfs.vfat will create a 64GB FAT32 fs.

  • Ok, so I got a 16GB Sandisk card, formatted it FAT32 in Windows 11, then copied the uP binary as _BOOT_P2.BIX to the card. I then made sure the dip switches were UDDD, inserted the card, then plugged it in to a 12v supply. After a few moments it was doing the console spam thing again.

    This P2 Edge has the 20Mhz oscillator, according to the store page for the defective ones.

    I'm not sure what else to try, I try replicating a "success" but it doesn't seem to want to play ball.

    I can confirm that the blink sample written to SD card works fine and loads more or less immediately.

    I can confirm using the SD flasher, I can write to the SD and it'll boot to REPL, but has the same behavior as when written to flash, no worky after REPL is displayed.

    When I try copying the exact same binary to the SD card, the REPL is not displayed correctly. I used the SD flasher to write the SD card, got the REPL, then I wrote the same binary as _BOOT_P2.BIY and deleted the _BOOT_P2.BIX, then reset and got the spamming garbage.

    I'm somewhat confounded by why SD flasher will produce a semi-working result but copying directly to the SD card does not.

  • I'm beginning to suspect this older Propkey doesn't work correctly. I used Windows 11, plugged in the propkey, checked device manager and confirmed it's using the FTDI drivers from 2021, I do not have any FTDI driver or Parallax driver packages installed in Programs.

    I used Proptool, hit F7, confirmed the P2 was there. Loaded step1.spin and tried to send it to ram, during the Verifying RAM phase it throws a communications error. Subsequent F7 tests say there isn't a prop connected on COM6 now.

    If the PropKey should be resetting the P2 when checking for it, then it's not working. I also have the same problem with flexprop unless it's running the blink sample. If it's running something more complex then it doesn't detect it.

  • Ok, just ordered a new propkey and p2 Edge breadboard (already have the breakout).

  • pik33pik33 Posts: 2,387
    edited 2023-06-12 18:20

    @Tubular said:
    Ok. Out of interest will Linux format a partition in fat32 thats bigger than 32GB?

    Use gparted. Create a FAT32 partition that fills the SD. Format it. That's all. I use a Pi to do this, as I have several of them on my desk. All my "big" cards including 128 GB are FAT32 formatted, for using either with a P2 or Ultibo based RPi. Theoretical limit seems to be 2 TB.

  • FWIW: I delighted with using a Pico as the front end to my P2. In fact, I have a further four on a multi-drop serial link as I/O expanders.

    P2 resources are too darned precious for me.

    I don't use the standard Pico because I prefer the bare-bones RP2040. I have 8MB of flash and because I use MMBASIC, I end up with a 6MB+ flash drive.
    I also have Pico clones with 16MB flash which give me an even bigger flash drive.

    There are now 3 flavors of this BASIC; standard, VGA (uses 2nd core) and the WiFi version for the Pico W.

    MMBasic has a built-in editor and the option of color-coded source. All that's required is a terminal.

    Python is popular but I ain't seeing it in the industrial control world.
    "Structured Text" in the PLC world is a combo of BASIC and Pascal.

    Big players in the Motion Control world:
    Trio Motion: Front end is multi-tasking BASIC.
    Galil Motion (inventors of Digital Motion Control) use a very crude implementation of BASIC with a single data-type (float).

    If one needs a super high speed communication with the Prop, the PIO assembler is also supported in MMBASIC.

    Makes life a heck of a lot easier :)

    Craig

  • one thing I found out that flexspin does not find P2 if a SD card is inserted, sometimes.

  • pik33pik33 Posts: 2,387
    edited 2023-06-13 06:23

    @msrobots said:
    one thing I found out that flexspin does not find P2 if a SD card is inserted, sometimes.

    I have a problem with flexprop loader too: the terminal has to be closed before I can upload a new version of the program, or else P2 not found. Another way is to click "compile and run" twice: first time is "not found", second time it always runs. I have SD card always inserted in the P2-EC32 module. Now I have to try if removing the SD can change this strange behavior.

    As I now use (mainly) FlexBasic to program and I have a HDMI driver that I can sent Basic's print to, I don't need the terminal (near) at all. There is "noterminal" branch in Flexprop's github, so I use it. No terminal=no problem with uploads, the program always run.

  • Something I want to bring up......... The P2 Edge will not allow you to program FLASH, once you have mounted the SD card. Resetting the P2 does not power cycle the SD card. Before you can program flash again, you must power cycle the whole setup or remove and reinsert the SD card. Pressing reset by itself will also prevent the Edge from booting from SD.

    Again, I advocate for the next iteration of Edge to powercycle the SD card with reset.

Sign In or Register to comment.