OSError: SPI device already in use

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
FlyingThunder
Posts: 8
Joined: Thu Jan 31, 2019 10:34 am

OSError: SPI device already in use

Post by FlyingThunder » Wed Jun 26, 2019 11:22 am

I am aware that this is an issue that (as far as i can tell) has been fixed in a newer MicroPython version, but my problem still exists because i am using uPyCraft V1.0 and it shows up a lot when i try to run my test code.

This is the error im getting:

Code: Select all

download ok
exec(open('./boot.py').read(),globals())
[0;31mE (477191) spi_master: spi_bus_initialize(108): host already in use[0m
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 25, in <module>
OSError: SPI device already in use
This is the code im trying to run: (Dont ask me what the hell it is, i did this half a year ago and probably just assembled some things i found online, as i do not have much knowledge in MicroPython and ESP32)

Code: Select all

import gc
gc.collect()
import framebuf
gc.collect()
from machine import Pin, SPI
gc.collect()
import driver
gc.collect()



# SPIV on ESP32
sck = Pin(18)
miso = Pin(19)
mosi = Pin(23)
dc = Pin(17)
cs = Pin(5)
rst = Pin(16)
busy = Pin(4)
spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=sck, miso=miso, mosi=mosi)

e = driver.EPD(spi, cs, dc, rst, busy)
e.init()

w = 320
h = 192
x = 0
y = 0

# --------------------

# use a frame buffer
# 400 * 300 / 8 = 15000 - thats a lot of pixels
gc.collect()
buf = bytearray(w * h // 8)
fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
black = 0
white = 1
fb.fill(white)

# --------------------
Help is very appreciated, i know i didnt give much info but its so insanely hard to get started with this topic because of the lack of documentation i could find regarding uPyCraft and micropython...

Thanks in advance!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: OSError: SPI device already in use

Post by jimmo » Wed Jul 03, 2019 6:41 am

FlyingThunder wrote:
Wed Jun 26, 2019 11:22 am
I am aware that this is an issue that (as far as i can tell) has been fixed in a newer MicroPython version, but my problem still exists because i am using uPyCraft V1.0 and it shows up a lot when i try to run my test code.
Why does uPyCraft prevent you from using the latest MicroPython version?

FlyingThunder
Posts: 8
Joined: Thu Jan 31, 2019 10:34 am

Re: OSError: SPI device already in use

Post by FlyingThunder » Tue Aug 06, 2019 9:37 am

i dont know how i would change the micropython version? doesnt upycraft flash the interpreter onto the board? thats too deep for me i think

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: OSError: SPI device already in use

Post by jimmo » Tue Aug 06, 2019 10:54 am

Upycraft just updates the Python files on the device. The one board I know of where everything is flashed at once (the interpreter and your code) is the micro:bit.

You will need to flash the device to upgrade the MicroPython version. You can download the firmware from here: http://micropython.org/download (including instructions for ESP32)

Post Reply