Page 1 of 1

board.py Files

Posted: Fri Jul 29, 2022 5:57 am
by quiltyja
Edit: correct typo in subject and body, board.py is the file I'm enquiring about!

Hi everyone,

I connect with rshell to an ESP32 and rshell looks for via the function below which, because my code doesn't contain a file 'board.py' and thus always defaults to "pyboard". I can change that in a simple-minded kind of way by creating a 'board.py' file, but I'd prefer to adopt any standard or convention for 'board.py' if one exists. It turns out that ''board.py' and 'import board' make really poor search terms, so I'd like to ask if anyone knows where this file is found in the MicroPython ecosystem and whether there's a standard or convention for its contents?

Code: Select all

def board_name(default):
    """Returns the boards name (if available)."""
    try:
        import board
        try:
            name = board.name
        except AttributeError:
            # There was a board.py file, but it didn't have an name attribute
            # We also ignore this as an error
            name = default
      ...
      return repr(name)

Re: boot.py Files

Posted: Fri Jul 29, 2022 6:04 am
by davef
For the ESP32 I always have the boot.py that comes with the image. So, a blank boot.py should be enough. Also, I find it useful to have a file called main.py, which at least contains:

Code: Select all

import my_application
A short delay in main.py, ie

Code: Select all

utime.sleep(5)
gives you a chance to do a CTRL-C in rshell and edit stuff.

Re: board.py Files

Posted: Fri Jul 29, 2022 6:11 am
by quiltyja
Thanks, davef, for the quick reply! I'm sorry to say that I was interrupted while writing a question about board.py and when I returned to complete the post I'd just been working on boot.py... and thus made a typo in the subject and body :oops:. I've corrected that now and the subject and body both consistently refer to board.py.

Re: board.py Files

Posted: Sat Jul 30, 2022 3:24 am
by dhylands
The documentation for rshell is here: https://github.com/dhylands/rshell and the specific stuff about board.py is here: https://github.com/dhylands/rshell#file-system

Re: board.py Files

Posted: Sat Jul 30, 2022 4:26 am
by quiltyja
Thanks for the refs to the docs dhylands, I very much appreciate your writing rshell it's been very useful! What I'd like to know particularly is whether there's a convention, however loose, for the content of 'board.py' files?

For example, the Adafrult Blinka uses a board.py file, which makes me think that there's somewhat of a convention regarding 'board.py' files... ?

Re: board.py Files

Posted: Sat Jul 30, 2022 2:39 pm
by dhylands
I'm not aware of any convention per-say. When I create them they just look something like this:

Code: Select all

name = 'custom'
I'm also not familiar with whats in Adafruit's board.py file.