Gemma M0 does not execute main.py

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Gmichaels
 
Posts: 6
Joined: Mon Oct 15, 2018 1:59 am

Gemma M0 does not execute main.py

Post by Gmichaels »

So i have a new gemma M0 that was wotking well..i uploaded code via the arduino IDE, then decided to go back.

I followed the directions to re-upload the UF2 loader and it seemed to work. I reloaded the default libs and main.py, but now the LED just stays a solid blue/red (instead of cycling) and will occasionally just shut off if i try and edit and save main.py.

the board resets just fine, and i can get it to the bootloader reset mode as well..it just seems like it isnt running main.py.

Any help would be greatly appreciated.

User avatar
tannewt
 
Posts: 3298
Joined: Thu Oct 06, 2016 8:48 pm

Re: Gemma M0 does not execute main.py

Post by tannewt »

It sounds like the filesystem is unhappy. Try following these instructions and let us know how it goes: https://learn.adafruit.com/welcome-to-c ... sues-18-13

Thanks!

User avatar
Gmichaels
 
Posts: 6
Joined: Mon Oct 15, 2018 1:59 am

Re: Gemma M0 does not execute main.py

Post by Gmichaels »

Thanks Tannewt, I already tried the erasing steps. They appeared to work as described, but the problem persists unaltered.

User avatar
tannewt
 
Posts: 3298
Joined: Thu Oct 06, 2016 8:48 pm

Re: Gemma M0 does not execute main.py

Post by tannewt »

Please post a picture of your setup and a copy of your main.py. We'll see if someone can reproduce it.

User avatar
Gmichaels
 
Posts: 6
Joined: Mon Oct 15, 2018 1:59 am

Re: Gemma M0 does not execute main.py

Post by Gmichaels »

Here you go, picture is attached. Literally just a USB to the Gemma M0. the USB cable is known good data cable. It works to transfer files, gemma is recognized as CircuitPy.

Problems only started after uploading via Arduino IDE, then re-flashing UF2 with the latest circuitpy UF2 following the sites directions.

the forums will not allow me to upload a .py, so the "main.py" that i'm using is in the codeblock below:

Code: Select all

# Gemma IO demo
# Welcome to CircuitPython 2.0.0 :)

import board
import time
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn, AnalogOut
from touchio import TouchIn
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
import adafruit_dotstar as dotstar

# One pixel connected internally!
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

# Built in red LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# Analog output on A0
aout = AnalogOut(board.A0)

# Analog input on A1
analog1in = AnalogIn(board.A1)

# Capacitive touch on A2
touch2 = TouchIn(board.A2)

# Used if we do HID output, see below
kbd = Keyboard()

######################### HELPERS ##############################

# Helper to convert analog input to voltage
def getVoltage(pin):
    return (pin.value * 3.3) / 65536

# Helper to give us a nice color swirl
def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if (pos < 0):
        return [0, 0, 0]
    if (pos > 255):
        return [0, 0, 0]
    if (pos < 85):
        return [int(pos * 3), int(255 - (pos*3)), 0]
    elif (pos < 170):
        pos -= 85
        return [int(255 - pos*3), 0, int(pos*3)]
    else:
        pos -= 170
        return [0, int(pos*3), int(255 - pos*3)]

######################### MAIN LOOP ##############################

i = 0
while True:
  # spin internal LED around!
  dot[0] = wheel(i)
  dot.show()

  # set analog output to 0-3.3V (0-65535 in increments)
  aout.value = i * 256

  # Read analog voltage on A1
  print("A1: %0.2f" % getVoltage(analog1in))

  # use A2 as capacitive touch to turn on internal LED
  if touch2.value:
        print("A2 touched!")
        # optional! uncomment below & save to have it sent a keypress
        #kbd.press(Keycode.A)
        #kbd.release_all()
  led.value = touch2.value


  i = (i+1) % 256  # run from 0 to 255
gemma_m0.jpg
gemma_m0.jpg (305.17 KiB) Viewed 205 times

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: Gemma M0 does not execute main.py

Post by danhalbert »

If you updated to a 3.x version of CircuitPython from 2.x, then the library .mpy files in the lib directory that you have will be incompatible with that newer version of CircuitPython. You can download the latest versions here: https://github.com/adafruit/Adafruit_Ci ... ses/latest. Choose the "3.x-mpy" version, and replace the .mpy files in your lib directory with those new ones.

Some background here:
https://learn.adafruit.com/adafruit-gem ... -libraries
https://learn.adafruit.com/adafruit-gem ... file-18-12

User avatar
ytomku
 
Posts: 4
Joined: Wed Oct 21, 2015 2:16 pm

Re: Gemma M0 does not execute main.py

Post by ytomku »

I got mine recently. I got mine working by getting rid of main.py and putting code.py there. Not sure if that was the reason (perhaps the newest uf2 looks for code.py on the device).

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: Gemma M0 does not execute main.py

Post by danhalbert »

There's been no change between versions about looking for code.py and main.py. CircuitPython looks for code.py first, then main.py. It runs the first one it finds, and does not run more than one.

User avatar
Gmichaels
 
Posts: 6
Joined: Mon Oct 15, 2018 1:59 am

Re: Gemma M0 does not execute main.py

Post by Gmichaels »

If you updated to a 3.x version of CircuitPython from 2.x, then the library .mpy files in the lib directory that you have will be incompatible with that newer version of CircuitPython.
I was so sure this was the answer - no dice. Looks like I'll be returning this thing...it's a pity.

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: Gemma M0 does not execute main.py

Post by danhalbert »

I'm not sure what trouble you're having, but here's a complete reload of the Gemma M0, updated to CircuitPython 3.0.3, with the demo main.py file and an updated lib folder.
Go here https://learn.adafruit.com/adafruit-gemma-m0/downloads,
and download the file labeled "Update to CircuitPython 3.0.3 with lib and demo main.py file: gemma-m0-circuitpython-main-lib-3.0.3.uf2".
Here's a direct link: https://cdn-learn.adafruit.com/assets/a ... -3.0.3.uf2

Then double-click to get GEMMABOOT, and drag the .uf2 file you downloaded to there. The demo should start running.

When are you getting an error, the multicolored flashing tells you the which line the error is on: https://learn.adafruit.com/adafruit-gem ... ight-18-11. However, it's much easier to make a serial connection to the board and see the error printed out. Read about that here: https://learn.adafruit.com/adafruit-gem ... ight-18-11

User avatar
Gmichaels
 
Posts: 6
Joined: Mon Oct 15, 2018 1:59 am

Re: Gemma M0 does not execute main.py

Post by Gmichaels »

here's a complete reload of the Gemma M0, updated to CircuitPython 3.0.3, with the demo main.py file and an updated lib folder.


SOLVED!

This works! However, in the new CIRCUTPY folder there's no lib folder. The libraries are just placed in the home folder...perhaps this was the problem (I tried placing the new libraries in the lib folder).

Thanks!

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: Gemma M0 does not execute main.py

Post by danhalbert »

That's just an error on my part. You could put them in a lib folder. The lib folder is on sys.path, which says where to look for things when importing:

Code: Select all

>>> import sys
>>> sys.path

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: Gemma M0 does not execute main.py

Post by danhalbert »

I just put the libraries into a lib folder, tested it, and replaced the .uf2 on the Downloads page.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”