# Adding CircuitPython support for PICO dv

**URL:** <https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012>\
**Category:** Support\
**Created:** [April 21, 2023, 1:35am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012 "2023-04-21T01:35:32Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [April 21, 2023, 1:35am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/1 "2023-04-21T01:35:32Z")

</div>

I’ve created a branch of CircuitPython with the board and pin definitions for the Pimoroni PICO dv board.

> **[Comparing adafruit:main...RetiredWizard:picodvi · adafruit/circuitpython](https://github.com/adafruit/circuitpython/compare/main...RetiredWizard:micropython:picodvi?expand=1)**
>
> CircuitPython - a Python implementation for teaching coding with microcontrollers - Comparing adafruit:main...RetiredWizard:picodvi · adafruit/circuitpython

I’ve built CircuitPython using this update and the DVI output, SD Card and I2S audio all seem to work well.

I’m not sure what Adafruit’s policy will be with respect to adding a “demo base” like this as a board since my update will only work if an RP2040 based board is installed as apposed to something like an ESP32-S2 board with a Pico form factor.

But before I submitted the PR asking Adafruit if this approach was appropriate, I thought I should run it by someone at Pimoroni and see if you had any objections to me submitting the PR or perhaps you would prefer to look over/update my attempt at the PR and submit it yourselves.

Thanks!  
RetiredWizard

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [April 21, 2023, 2:06am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/2 "2023-04-21T02:06:49Z")

</div>

Here is the test script I ran which mounts an SD card from which you can play a .WAV file by entering “/sd/filename.wav” when prompted.

Using the “absolute newest” version of CircuitPython (8.1.0 Beta 1) and the board updates from above plugging in an HDMI monitor results in REPL output being displayed. The board.DISPLAY object can be used normally with the displayio, adafruit\_turtle, gifio, etc… libraries.

```auto
import board
import bitbangio
import adafruit_sdcard
import digitalio
import storage
import audiocore
import audiobusio
fname = input("Filename:")
spi = bitbangio.SPI(board.SD_SCK,board.SD_MOSI,board.SD_MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sd = adafruit_sdcard.SDCard(spi,cs)
vfs = storage.VfsFat(sd)
storage.mount(vfs,'/sd')
f = open(fname, "rb")
wav = audiocore.WaveFile(f)
a = audiobusio.I2SOut(board.I2S_BCLK, board.I2S_OUT, board.I2S_WS)
try:
    a.play(wav)
    while a.playing:
        pass
except:
    pass
f.close()
a.deinit()

```

---

<div class="post-metadata">

**Author:** ![hel](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/hel/32/6075_2.png) [@hel](https://forums.pimoroni.com/u/hel)\
**Post date:** [April 21, 2023, 11:55am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/3 "2023-04-21T11:55:37Z")

</div>

Ooh - the CircuitPython DV stuff looks really cool, looking forward to playing with that.

I’ve dropped you a DM :)

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [April 21, 2023, 6:02pm UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/4 "2023-04-21T18:02:06Z")

</div>

I also have a number of “ready for PR” board definitions for Pimoroni products. Currently for the Badger2040w, the Plasma2040w, InkyFrame 5.7 (WIP).

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [May 5, 2023, 8:49pm UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/5 "2023-05-05T20:49:27Z")

</div>

You can find the UF2 for the Pico DV Base using a Pi Pico on the [Circuitpython.org](http://Circuitpython.org) download page now.

It doesn’t work yet with a Pico W but I’m hoping that I’ll work that out eventually as well.

---

<div class="post-metadata">

**Author:** ![brandonthetinkerer](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/brandonthetinkerer/32/9971_2.png) [@brandonthetinkerer](https://forums.pimoroni.com/u/brandonthetinkerer)\
**Post date:** [July 25, 2023, 1:30am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/6 "2023-07-25T01:30:50Z")

</div>

hey! just curious if there has been any work on getting the Pico W working with this?

I just got my _Pimoroni Pico DV Demo Base_ and only have a Pico W on hand and when I loaded up Circuitpython 8.2.0, not getting any response.

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [July 25, 2023, 9:20am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/7 "2023-07-25T09:20:50Z")

</div>

I haven’t looked at the problem any further. Trying to build CircuitPython with both the Wifi and DV features enabled ends up using a lot of the memory space and I suspect the problem I was seeing is somehow connected to memory management.

There has been some memory management work done in CP recently so it may be worth trying to rebuild with the latest version but it will be a few days before I’m able to give it a try.

If you load the released UF2 for the Pico dv from [circuitpython.org](http://circuitpython.org) it should work on the Pico W as well as it does on a standard Pico, you obviously won’t have access to any WiFi capabilities.

---

<div class="post-metadata">

**Author:** ![brandonthetinkerer](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/brandonthetinkerer/32/9971_2.png) [@brandonthetinkerer](https://forums.pimoroni.com/u/brandonthetinkerer)\
**Post date:** [July 25, 2023, 7:30pm UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/8 "2023-07-25T19:30:46Z")

</div>

ahhh – that makes sense about the wifi.

also, tells me I must be bumping up again another issue, since I am getting nothing after loading circuitpython 8.2 for [Pimoroni Pico DV Demo Base for Pico Download](https://circuitpython.org/board/pimoroni_pico_dv_base/)

it’d be great to get pico W wifi working at some point. but, I guess it would also be possible to use an esp32 co-processor for wifi? would it be possible, with the PICO dv, for the rp2040 to use SPI to communicate with an adafruit airlift type device for wifi?

looking forward to hearing about your adventures in CP memory ;-)

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [July 26, 2023, 9:37am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/9 "2023-07-26T09:37:27Z")

</div>

I don’t think a version for the normal Pico will work for the Pico W. E.G. CP for the latter will always try to drive the on-board LED differently than the CP for the normal PIco. And this is for good reason, since the GP is in use for other things.

Regarding a co-processor: I am successfully using an ESP-01S controlled via UART as a co-processor for Wifi. Works like a charm and it is very efficient. But if you need HTTPS, you might be better of with an esp32.

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [July 31, 2023, 3:15am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/10 "2023-07-31T03:15:47Z")

</div>

I finally had a chance to build with the latest CP bits and unfortunately the issue appears to be worse, the build with the latest bits doesn’t even start. I’ll have to block off some time to dig into it again.

In the mean time, if you want to play around with a Pico W on the DV Demo Base, in my earlier attempts I did find a messy work around which was to remove the DV initialization during CP startup. This hack still seems to work but that means you need to initialize the output using python code. I’ve uploaded a build with CP 8.2 on my github site here: [cp-8.2-PICOdv-w.uf2](https://github.com/RetiredWizard/PyDOS/releases/download/v1.20/cp-8.2-PICOdv-w.uf2)  
and the code to initialize the DV output is:

```auto
import displayio
displayio.release_displays()

import board
import picodvi
import framebufferio

w=640
h=480
cd=1

fb = picodvi.Framebuffer(
    width=w, height=h, color_depth=cd,
    clk_dp=board.CKP, clk_dn=board.CKN,
    red_dp=board.D0P, red_dn=board.D0N,
    green_dp=board.D1P, green_dn=board.D1N,
    blue_dp=board.D2P, blue_dn=board.D2N)

display = framebufferio.FramebufferDisplay(fb)

```

BTW, if you’re interested the original PR for this board is here: [PR#7915](https://github.com/adafruit/circuitpython/pull/7915)

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [July 31, 2023, 3:59am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/11 "2023-07-31T03:59:10Z")

</div>

I just took another look to see what Adafruit was doing with the PiCowbell DVI board and it looks like they are using the standard Pico/Pico W circuitpython builds. So I guess that’s another option, you can just grab the latest build from [circuitpython.org](http://circuitpython.org) and used the GPn pin names for the DVI output.

```auto
fb = picodvi.Framebuffer(
    width=w, height=h, color_depth=cd,
    clk_dp=board.GP7, clk_dn=board.GP6,
    red_dp=board.GP9, red_dn=board.GP8,
    green_dp=board.GP11, green_dn=board.GP10,
    blue_dp=board.GP13, blue_dn=board.GP12)

```

The PiCowbell DVI [learning guide](https://learn.adafruit.com/adafruit-picowbell-dvi-output) should apply to the Pimoroni Pico DV Demo Base pretty well, it just won’t address all the additional features of the Pimoroni board (SD Card, I2C audio, buttons…). Those features should all work though, you just have to use the GPn pin names in your code.

---

<div class="post-metadata">

**Author:** ![brandonthetinkerer](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/brandonthetinkerer/32/9971_2.png) [@brandonthetinkerer](https://forums.pimoroni.com/u/brandonthetinkerer)\
**Post date:** [August 6, 2023, 5:35am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/12 "2023-08-06T05:35:47Z")

</div>

awesome! thanks so much. that all makes perfect sense and is exactly what I need to be able to dig into it.

I have that adafruit board as well, I’m really enjoying all the video DVI video out stuff, it’s really amazing what you and the whole community have done.

thanks again!

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [August 22, 2023, 6:08am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/13 "2023-08-22T06:08:51Z")

</div>

It looks like an update to the display system changed how the framebuffer processes the display dimensions. If you’re using CircuitPython 8.2.0 or later you need to set the screen width to 320, height to 240 and the color depth to 8 not the 640,480,1 used in the examples above.

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [August 23, 2023, 3:59am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/14 "2023-08-23T03:59:39Z")

</div>

I’ve posted a PR to Circuitpython for using the Pico W on the PICO dv Demo Base. It turns out that if WiFi and the DVI output are enabled on the Pico W, there isn’t enough memory remaining to really use the board.

I’ve suggested essentially using the Pico W like a standard Pico (disabling the WiFi) but asked for suggestions from the Circuitpython Devs/Community.

> <https://github.com/adafruit/circuitpython/pull/8323>
>
> I've spent several days trying to figure out if this board makes sense with a Pi…co W and if so how it should be configured. I've built the following configurations:
> 
> 1) DVI and WiFi enabled and activated upon boot -\> WiFi doesn't function and less than 50K working RAM
> 2) WiFi enabled and activated, DVI available but not activated -\> less than 50K working RAM
> 3) WiFi/Cyw43 not included, DVI enabled and activated upon boot -\> ~90K Working RAM
> 
> I really wanted option 2 to work but with less than 50K of RAM the display can't be loaded. The SD card and I2S audio work, although the audio has a lot of crackle. I suspect the WiFi is running and not leaving enough cycles to fully load the audio file from the SD card and play it smoothly. I'm not sure I see a lot of value in adding this carrier board to a Pico W if all it adds is the SD card slot and poor quality I2S audio.
> 
> I ended up going with option 3, which turns out to give the same capabilities as plugging in a normal Pi Pico to the carrier board. I suppose this might make sense if you wanted to use the Pimoroni board but only had a Pico W available. The display, SD card and I2S audio all work well. You do obviously give up any WiFi capabilities as well as the LED since on the Pico W, the LED is driven by the CYW43 module.
> 
> I left the Pico W firmware size adjustment in place even though with this build it's not necessary. Leaving it means that if a Pico W is re-flashed with this firmware the flash file system remains intact.
> 
> I haven't tested it yet, but I suspect, simply flashing the Pimoroni Pico DV Base for the Pico on a Pico W would give you virtually the same experience as using this build except that any files on the flash filesystem would be lost.
> 
> I'd appreciate any thoughts suggestions regarding my configuration choice and whether it makes sense to add a Pico W configuration for this carrier.

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [August 24, 2023, 4:33am UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/15 "2023-08-24T04:33:33Z")

</div>

Regardless of what happens with the Pico W version Circuitpython for the dv Demo Base, I did test that loading the current (8.2.4) version of the dv Demo Base firmware for the Pico (no networking) onto the Pico W works fine. You obviously lose any networking capablities and the LED can’t be accessed but all the Pimoroni Pico dv Demo Base features work including the DVI output.

Circuit Python changed how it handled the dimensions and color depth of DVI framebuffers which broke the dv Demo Base firmware for a couple 8.x.x releases before @brandonthetinkerer noticed and reported the problem so be sure you grab at least 8.2.4 from [circuitpython.org](http://circuitpython.org).

---

<div class="post-metadata">

**Author:** ![PokeyManatee4](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/pokeymanatee4/32/10452_2.png) [@PokeyManatee4](https://forums.pimoroni.com/u/PokeyManatee4)\
**Post date:** [December 28, 2023, 6:42pm UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/16 "2023-12-28T18:42:50Z")

</div>

I have a pico right, well it isnt working(the sd part)

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [December 29, 2023, 5:30pm UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/17 "2023-12-29T17:30:44Z")

</div>

I just tried with CircuitPython 8.2.9 and 9.0.0 Alpha 6 and was able to mount an SD card fine.

If you’re trying to run the test script listed above (Apr 20, 2023), the CircuitPython I2S pin names were renamed to be more standard. You will need to replace the audiobusio line with the following:

```auto
a = audiobusio.I2SOut(board.I2S_I2S_BIT_CLOCK, board.I2S_DATA, board.I2S_WORD_SELECT)

```

EDIT: Successfully mounting SD cards can depend on the SD card being used. If you’re having trouble try a different card and make sure it’s been formatted FAT16/FAT32.

---

<div class="post-metadata">

**Author:** ![RetiredWizard](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/retiredwizard/32/9775_2.png) [@RetiredWizard](https://forums.pimoroni.com/u/RetiredWizard)\
**Post date:** [December 29, 2023, 5:33pm UTC](https://forums.pimoroni.com/t/adding-circuitpython-support-for-pico-dv/22012/18 "2023-12-29T17:33:23Z")

</div>

The I2S pin names have been renamed so the audiobusio line needs to be updated as follows:

> [@RetiredWizard](#):
>
> `a = audiobusio.I2SOut(board.I2S_BIT_CLOCK, board.I2S_DATA, board.I2S_WORD_SELECT)`
