sipeed / MaixPy-v1

MicroPython for K210 RISC-V, let's play with edge AI easier
https://wiki.sipeed.com/maixpy
Other
1.68k stars 439 forks source link

Import error "board_info" is missing in my custom build firmware #371

Closed myuunosuke closed 3 years ago

myuunosuke commented 3 years ago

Hi all, I just noticed that the "board_info" is missing in my custom build firmware... When I try to import followings, it gets import error "ImportError: cannot import name board_info".

python from board import board_info from fpioa_manager import board_info

Does anyone know what needs to be done to fix this? Thank you,

myuunosuke commented 3 years ago

I was be able to solve the problem myself.

"from fpioa_manager import board_info" seems like not available anymore. The following code which worked in the older version of firmware did not work on my newly built firmware.

from fpioa_manager import board_info

However, "from board import board_info" did work fine on my custom built firmware but I needed to run "MaixPy_scripts/board/config_maix_duino.py".

Here is the detail of what steps I did to check and solve this problem, just in case someone else gets into the same situation.

When the Maix board is erased and newly flashed with a custom firmware, the "config.json" is missing in the file system, and it will generate "AttributeError" when trying to access the board_info objects.

>>> os.listdir()
['freq.conf', 'main.py']
>>> from board import board_info
[Warning] Not loaded from /flash/config.json to board_info.
>>> board_info.PIN0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'board_info' has no attribute 'PIN0'
>>> 

To generate the "config.json" which I think stores "board_info", you will need to run "config_maix_duino.py" or any other config script that is made for your device. I used MaixPy IDE to run the code.
You can do that from REPL as well. https://maixpy.sipeed.com/en/get_started/edit_file.html

Then I tried looking up the board_info again and successfully be able to access the board_info objects.

>>> os.listdir()
['freq.conf', 'main.py', 'config.json']
>>> from board import board_info
>>> board_info.PIN0
4
>>>