Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDTEST.Py - no module named pyb error #1

Open
dsssssssss9 opened this issue Apr 7, 2022 · 21 comments
Open

SDTEST.Py - no module named pyb error #1

dsssssssss9 opened this issue Apr 7, 2022 · 21 comments

Comments

@dsssssssss9
Copy link

dsssssssss9 commented Apr 7, 2022

Hi

When i run the sdtest.py example that was supplied on my unit i get the following error...

Traceback (most recent call last):
File "", line 1, in
ImportError: no module named 'pyb'

Please help

@andypiper
Copy link

How are you running this example? Are you using main.py?

@andypiper
Copy link

andypiper commented Apr 22, 2022

Confirmed that I can connect to a brand new StackyPi (it runs MicroPython 1.17 as delivered). It contains a single file (sdcard.py). I'm able to import sdcard in the REPL and then run lines of code to access it, based on the example in GitHub.

I don't see a file called sdtest.py (although, confusingly, the "Getting started" video on YouTube does show one, which does not seem to exist in this repository)

@sbcshop1
Copy link
Collaborator

sdtest.py file and main.py file are the same. we change the name so you can run as main file

@andypiper
Copy link

So to the point of this issue @dsssssssss9 how are you running the code? I haven’t seen a reference to pyb myself. My StackyPi shipped with just sdcard.py installed on it (although it would have been better if this was frozen into the MicroPython build) so I was able to import it in the REPL and access a card ok.

@dsssssssss9
Copy link
Author

dsssssssss9 commented Apr 23, 2022

Hi

I connect my StackyPi to My PC

Start up Thonny

thonny reports i am running MicroPython v1.15-13-g530c76f6c-dirty on 2021-04-25

Files list shows sdcard.py & sdest.py

i insert a blank, formatted sdcard into the StackyPi

i double click on sdtest.py to load it into thonny
this contains the following code....

`import pyb, sdcard, os
sd = sdcard.SDCard(pyb.SPI(1), pyb.Pin.board.X5)
pyb.mount(sd, '/sd2')
os.listdir('/')``

when i click on run i get the error message shown below...

%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "", line 1, in
ImportError: no module named 'pyb'

@sbcshop1
Copy link
Collaborator

We comment this part of the code, if you use pyboard then you need to uncomment this part of code. in stackypi we don,t need this part that's why we comment these lines

@dsssssssss9
Copy link
Author

I have not commented/uncommented anything !

this is the full sdtest.py as supplied on my StackyPi

no other files or changes have been made to it in anyway - i just took it out of the box, plugged it in & ran the sdtest.py

I have no pyboard

from #2 it appears others have MicroPython 1.17 installed from the factory?

However according to Thonny mine shipped with MicroPython v1.15-13-g530c76f6c-dirty on 2021-04-25

Could this be part of my problem?

@sbcshop1
Copy link
Collaborator

Still you get the same problem? can you send me the screen shot of the that part of code to our mail id

@dsssssssss9
Copy link
Author

StackyPi factory code

this is the ENTIRETY of the code
it is the sdtest.py file that came supplied on my StackyPi from the factory

Again i have added / removed NOTHING - this is my out of the box experience!!!

@whab
Copy link

whab commented Apr 23, 2022

I guess the most basic test that should have been provided for accessing the SD card would be the following one (successfully tested on a StackyPi with MicroPython v1.15-13-g530c76f6c-dirty):

from machine import Pin, SPI
import sdcard
import os

spi=SPI(1,sck=Pin(10),mosi=Pin(11),miso=Pin(12))
sd=sdcard.SDCard(spi,Pin(9))
vfs = os.VfsFat(sd)
os.mount(vfs, "/fc")
print("List directory:")
print(os.listdir("/fc"))
os.umount("/fc")

@andypiper
Copy link

Super strange, I just followed the same steps as you on my Mac (with a StackyPi that arrived yesterday) and it reports MicroPython v1.17 on 2021-09-02; Raspberry Pi Pico with RP2040 and only has sdcard.py pre-loaded, so I guess they are different batches.

Per #2 it would be helpful to have a board definition so those of us interested could build our own firmware with an up-to-date MicroPython.

I agree that @whab has provided a nice basic test example there. It might be a good idea for us to set up a community project for StackyPi examples to complement the stuff that SBC has provided. FWIW, it looks like the code in this repo is basically just (unattributed) adjusted copies of the Pyboard samples from the main MicroPython repository.

@andypiper
Copy link

Actually, that example only works if you already have a filesystem on the card, so it probably needs something more in case you have an uninitialised card or something not in vfat format.

@andypiper
Copy link

Started a repo to collect known information and examples. Discussions are available if you want to learn along with me!

@ckuehnel
Copy link

ckuehnel commented May 2, 2022

I get the following error for the marked line:

from machine import Pin, SPI
import sdcard
import os

print("StackyPi SD Card Test")

spi=SPI(1,sck=Pin(10),mosi=Pin(11),miso=Pin(12))
sd=sdcard.SDCard(spi,Pin(9))
vfs = os.VfsFat(sd)
os.mount(vfs, "/fc")
print("List directory:")
print(os.listdir("/fc"))
os.umount("/fc")

%Run -c $EDITOR_CONTENT
StackyPi SD Card Test
Traceback (most recent call last):
File "", line 15, in
File "sdcard.py", line 54, in init
File "sdcard.py", line 87, in init_card
File "sdcard.py", line 135, in init_card_v2
OSError: timeout waiting for v2 card

Any idea?

@andypiper
Copy link

I’ll check mine in the morning, but what version of MicroPython do you have on the board @ckuehnel ?

@sbcshop1 sbcshop1 closed this as completed May 3, 2022
@sbcshop1
Copy link
Collaborator

sbcshop1 commented May 3, 2022

StackyPi factory code

this is the ENTIRETY of the code it is the sdtest.py file that came supplied on my StackyPi from the factory

Again i have added / removed NOTHING - this is my out of the box experience!!!

delete all the files inside stackypi, and newly save sdcard.py from the sd_card folder, then run main.py from sd_card folder which is inside the stackypi directory. may be in some stackypi mistakenly the "sdtest.py" file save, we apologize for this

@sbcshop1 sbcshop1 reopened this May 3, 2022
@ckuehnel
Copy link

ckuehnel commented May 3, 2022 via email

@sbcshop1
Copy link
Collaborator

sbcshop1 commented May 3, 2022

I get the following error for the marked line:

from machine import Pin, SPI import sdcard import os

print("StackyPi SD Card Test")

spi=SPI(1,sck=Pin(10),mosi=Pin(11),miso=Pin(12)) sd=sdcard.SDCard(spi,Pin(9)) vfs = os.VfsFat(sd) os.mount(vfs, "/fc") print("List directory:") print(os.listdir("/fc")) os.umount("/fc")

%Run -c $EDITOR_CONTENT
StackyPi SD Card Test
Traceback (most recent call last):
File "", line 15, in
File "sdcard.py", line 54, in init
File "sdcard.py", line 87, in init_card
File "sdcard.py", line 135, in init_card_v2
OSError: timeout waiting for v2 card

Any idea?

Kindly format the SD card with the sd card formatter, and make sure the sd card format is fat32 format

@andypiper
Copy link

It would probably be better to have the sample check if the SD card is already initialised (or, have documentation that explains that this is necessary before it is run, since I also discovered this for myself and not from the information from SBC).

The internals test code runs OK here but the temperature measurement seems to be off. I'll take a look. If you're interested, you're welcome to contribute that program to my StackyPi community project rather than having it as a comment inside an issue on this repo 😄

@ckuehnel
Copy link

ckuehnel commented May 3, 2022 via email

@andypiper
Copy link

You can just send a pull request on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants