-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
7.0.0 crashes without import microcontroller #5469
Comments
|
Looks like you have a |
Jepler, Below is my boot.py file. The result is not used. The pin to determine what action to take is changed board to board to avoid conflict. I get the same results when I remove boot.py. Pin A3 is unused on the ItsyBitsy. ###########################################
"""CircuitPython Essentials Storage logging boot.py file"""
import board
from digitalio import DigitalInOut, Direction, Pull
import storage
# For Feather M0/M4 Express, RPi Pico, etc.
switch = DigitalInOut(board.A3)
switch.direction = Direction.INPUT
switch.pull = Pull.UP
# If the switch pin is connected to ground CircuitPython can write to the root drive
storage.remount("/", switch.value)
print("\tWrite to Flash :", (not switch.value))
print("\tWrite to SD Card:", switch.value)
print("\tboot.py Finis")
########################################### |
The code has evolved. below is the code as it stands now. Also the symptoms have changed on the ItsyBitsy only. If "import microcontroller" ((Line 13)) is not commented out the device crashes after 4 codes are transmitted ((Line 245)). No error codes given on REPL. A hard reset is required. There was an issue between .mpy and .py library files but that went away for no good reason.
|
When you say "crash", do you mean that it just hangs, as opposed to reseting into safe mode or throwing an exception? |
Crash = No exception thrown, no safe mode, it stops responding to all REPL commands Ctrl-C, Ctrl-D, etc. After ~45 seconds it disconnects from my Windows 10 machine then I get an alert box with "USB device not recognized" when it tries to connect. Pushing RESET brings it back. Bruce |
With further experimentation... It is not import microcontroller that alone is the issue. Then I made a minor change and the crashes came back at a different place. It was after 4 SKIP30 sends, now it is after 10 SKIP30 sends. It can be 10 sends at one time or two of 5 sends. I am starting to suspect complied object code size. Is there a way to find out if, where, and when the object code, variables, or lists fall on a memory boundary(s)? Bruce |
I don't think it is just size. There is memory corruption somewhere. You might leave all these imports in and turn off various parts of the program with |
Dan, I have narrowed it down to this function call: Encoder is defined much earlier by: ## Create an encoder that will take numbers and turn them into NEC IR pulses
encoder = adafruit_irremote.GenericTransmit(header=[9500, 4500], zero=[562, 562], one=[562, 1687], trail=562, debug=False) I have no control over adafruit_irremote or the intrinsic functions it calls. I doubt they are part of the issue. The code crashes after the first print call but before the second. Previously when it was crashing at 4 SKIP30 calls there was a bunch of diagnostic code and lots of crap coding. When I cleaned up a bunch of the crap code and diagnostic stuff, the issue went away. When I added in some code to make the program more flexible the crashes cam back. So size is a tell; as to what/where, I have no clue. Your idea about memory corruption is interesting because the issue only happens in my ItsyBitsy RP2040. It does not raise its ugly head on my QT Py RP2040, Feather RP2040, or Raspberry Pi Pico. I started development on the RPi Pico but wanted to make it portable to the other RP2040 platforms. (Don't tell anybody, but the AdaFruit platforms are better in several ways.) There was also an issue of bad algorithm execution on the ItsyBitsy that went away for no discernable reason. *Not working with .py library. *Working with .mpy library. *Working with .py library. Trying to isolate to an .py library issue didn't work. Both started working. So much for that idea. Bruce |
I have not been able to reproduce this on my RP2040 ItsyBitsy running CP 7.0.0. Can I ask you to add an import of the gc module and then put a 'print ("Mem Free: ", gc.mem_free())' right before the encoder.transmit line? This will show us if we're running low on memory as a possible cause. Thanks! |
Dave, Here ya go. Crash after 4 IR commands sent. No joy in Mudville. IR listener started... |
Dave, GC Supervisor
Insert print mem statement
Print mem commented out
This is line 381
|
[ @b-blake you can put code or output in triple back-ticks (or single if it's one line). I have been editing your posts a bit to do that. You can use the "< >" button in the post editor. Select what needs to be shown as code or output and then click the button. ] |
Dave, Dan, Thank you. Bruce |
Well, that's clear evidence that memory is getting stepped on. Line 377 in adafruit_irremote.mpy is |
Dave, The Line 377 error drop is the first real clue I saw. Previously all I got was a crash. If you can't reproduce my symptoms, I have .zip file with ALL that is on the ItsyBitsy. It is 980MB so quite big. If I remove the lib subdirectory it drops in size considerably. The library DTG is 10/2/2021 @ 12:59 PM. I agree the IR parts should not have an effect, but . . . IR (Infrared) Receiver Sensor - TSOP38238 PRODUCT ID: 157 Super-bright 5mm IR LED - 940nm PRODUCT ID: 387 If you toggle the AdaFruit variable to True, this remote's IR codes will be understood by the program. Bruce |
Bruce, Just curious; is there a reason you are using the esp32spi PWMOut instead of the RP2040 PWMOut that is part of pwmio? I've tried both and saw no hangs with either; but I was wondering why you did things that way. Dave |
@DavePutz Dave, is there a reason you are using the esp32spi PWMOut instead of the RP2040 PWMOut that is part of pwmio? Yes, a very sophisticated reason. It is what I copied off of the AdaFruit web site and github. If had stumbled on code that uses RP2040 PWMOut, that is what I would have used. How would I use it? P.S. I had to look up how to spell 'sophisticated' ;-) @dhalbert Dan, See above. No sophisticated reasons for what I do. My only class on programming was for FORTRAN back in 1966 and I just sat in on it while my girlfriend took the class. After that one class, I started playing with the IBM 1620 that was in the U of Wisconsin Space Astronomy Laboratory where I worked for $1.00/hour. FORGO, BASIC, QBASIC, Assembly on 3 platforms, Pearl, Python, and Circuit Python have all been self taught. Bruce |
@DavePutz Dave, OK... I made the following change.
What have I made better by doing this? Eliminating the need for adafruit_esp32spi is a plus, but is there more? Bruce |
With the above change I get the following on the second push of Skip 10;
The error goes away when I import supervisor. Bruce |
A reminder. It only happens on the ItsyBitsy. What is so unique with the ItsyBitsy? The errors/crashes do not happen on the Raspberry Pi Pico or the QT Py. To my mind the QT Py is no more than a folded ItsyBitsy. |
The ItsyBitsy vs Pi Pico vs QT Py also points to that. The ItsyBitsy has more definitions in |
@dhalbert Dan, Removing the from adafruit_esp32spi import PWMOut does not affect the bug. Bruce P.S. Dan, I am watching laundry wash, what is your excuse for not enjoying Saturday? Get a 6-pack of PBR or a bottle of T-Bird and sit by the lake and relive your teens. Take your SO with you and make bad decisions. |
Dan,
At one point I was getting wrong IR output with the .py library, but when I changed to the .mpy library the problem went a way. Bruce |
Guys, With the latest change; from pwmio import PWMOut I now can get the Feather to crash. |
Well, I've managed to re-create memory corruption using a Pico. Now the issue is hunting down the source of the problem. |
Dave, I wish you the best of luck. I am available for testing at any time. Being retired has its advantages. Bruce |
It looks like the issue can occur when an incoming pulse (even a stray IR signal) comes in while sending the pulseout.
Investigating how to handle this. |
Bruce,
|
You can zip the .uf2 and attach it to an issue comment. |
Bruce,,
|
Dave, Dan, I have not been able to cause a crash or memory violation on the three platforms that replacement *uf2 files were provided for. As I do not trust electronics, I will never say it is 100% fixed. I have been bit too many times ;-) When will this change be posted to BROWSE S3? Thank you both very much for all your help. Bruce |
Dave, I am trying adafruit-circuitpython-arduino_nano_rp2040_connect-en_US-20211025-66e7dbe.uf2 on my Nano RP2040 Connect and the issue shows its ugly head. No add or subtract of libraries makes it work. Am I using old code? Bruce |
Bruce,
As far as I know the Pull Request has not been merged, so there is
no build yet on circuitpython.org
that includes it. You can follow the Pull Request (at
#5509 )
and after it is approved and merged it will be in the latest build(s). Hope
this helps,
Dave
…On Mon, Oct 25, 2021 at 2:45 PM b-blake ***@***.***> wrote:
Dave,
I am trying
*adafruit-circuitpython-arduino_nano_rp2040_connect-en_US-20211025-66e7dbe.uf2*
on my Nano RP2040 Connect and the issue shows its ugly head. No add or
subtract of libraries makes it work.
Am I using old code?
Bruce
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5469 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKEVVOFTJVQR526W34HTUIWXUTANCNFSM5GCPYWTQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Fixed by #5509. |
My Nano RP2040 Connect is happy now. Thanks Dave and Dan. Bruce |
CircuitPython version
Code/REPL
Behavior
Crash without 'import microcontroller' even though not used.
Runs just fine with 'import microcontroller'
Description
I built an application that would take in an RCA IR code of 'change input' and put out 7 'skip 30 seconds' TiVo IR codes. The application was working fine. I wanted to find out how to reference a pin that is not defined by CircuitPython but is on the RP2040. I used 'import microcontroller' to test how to define a pin using 'from microcontroller import pin' then 'test = pin.GPIO6'. It worked fine. I have commented out lines 2 and 3 of the test code. and things work fine. If I comment out the first test line (import microcontroller) the program crashes within the 'import adafruit_irremote' library after iteration #4 of 7 each time. microcontroller is not referenced in my code or in adafruit_irremote.py code. Below is my code that works/doesn't work minus the libraries. There are no error codes displayed on REPL. The only way out is a hard reset with the reset button or pulling power. Ctrl-C has no effect.
Additional information
No response
The text was updated successfully, but these errors were encountered: