Skip to content

Commit 7d02bff

Browse files
authored
Merge pull request #7880 from tannewt/feather_dvi
Add PicoDVI support
2 parents df7f348 + f38d59b commit 7d02bff

File tree

36 files changed

+1134
-401
lines changed

36 files changed

+1134
-401
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,7 @@
331331
[submodule "ports/silabs/tools/slc_cli_linux"]
332332
path = ports/silabs/tools/slc_cli_linux
333333
url = https://github.com/SiliconLabs/circuitpython_slc_cli_linux
334+
[submodule "ports/raspberrypi/lib/PicoDVI"]
335+
path = ports/raspberrypi/lib/PicoDVI
336+
url = https://github.com/circuitpython/PicoDVI.git
337+
branch = circuitpython

locale/circuitpython.pot

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ msgstr ""
126126

127127
#: ports/espressif/common-hal/espulp/ULP.c
128128
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
129+
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c
129130
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
130131
#: shared-bindings/digitalio/DigitalInOut.c
131132
#: shared-bindings/microcontroller/Pin.c
@@ -164,11 +165,11 @@ msgstr ""
164165
msgid "%q length must be >= %d"
165166
msgstr ""
166167

167-
#: py/argcheck.c
168+
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c py/argcheck.c
168169
msgid "%q must be %d"
169170
msgstr ""
170171

171-
#: py/argcheck.c
172+
#: py/argcheck.c shared-bindings/displayio/Bitmap.c
172173
msgid "%q must be %d-%d"
173174
msgstr ""
174175

@@ -468,6 +469,7 @@ msgstr ""
468469
msgid "All event channels in use"
469470
msgstr ""
470471

472+
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c
471473
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
472474
msgid "All state machines in use"
473475
msgstr ""
@@ -476,6 +478,7 @@ msgstr ""
476478
msgid "All sync event channels in use"
477479
msgstr ""
478480

481+
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c
479482
#: shared-bindings/pwmio/PWMOut.c
480483
msgid "All timers for this pin are in use"
481484
msgstr ""
@@ -1222,7 +1225,9 @@ msgid "Interrupt error."
12221225
msgstr ""
12231226

12241227
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
1225-
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c
1228+
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c
1229+
#: ports/raspberrypi/bindings/picodvi/Framebuffer.c
1230+
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c py/argcheck.c
12261231
#: shared-bindings/digitalio/DigitalInOut.c
12271232
#: shared-bindings/displayio/EPaperDisplay.c
12281233
msgid "Invalid %q"

main.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,15 @@ STATIC void start_mp(supervisor_allocation *heap, supervisor_allocation *pystack
153153
supervisor_workflow_reset();
154154

155155
// Stack limit should be less than real stack size, so we have a chance
156-
// to recover from limit hit. (Limit is measured in bytes.)
156+
// to recover from limit hit. (Limit is measured in bytes.) The top of the
157+
// stack is set to our current state. Not the actual top.
157158
mp_stack_ctrl_init();
158159

159-
if (stack_get_bottom() != NULL) {
160-
mp_stack_set_limit(stack_get_length() - 1024);
160+
uint32_t *stack_bottom = stack_get_bottom();
161+
if (stack_bottom != NULL) {
162+
size_t stack_length = stack_get_length();
163+
mp_stack_set_top(stack_bottom + (stack_length / sizeof(uint32_t)));
164+
mp_stack_set_limit(stack_length - 1024);
161165
}
162166

163167

ports/broadcom/common-hal/videocore/Framebuffer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void common_hal_videocore_framebuffer_deinit(videocore_framebuffer_obj_t *self)
4242
if (vcmailbox_release_framebuffer()) {
4343
self->framebuffer = NULL;
4444
}
45+
self->base.type = &mp_type_NoneType;
4546
}
4647

4748
bool common_hal_videocore_framebuffer_deinited(videocore_framebuffer_obj_t *self) {

ports/raspberrypi/Makefile

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ INC_CYW43 := \
3333
-isystem lib/cyw43-driver/firmware \
3434
-isystem lib/cyw43-driver/src \
3535
-isystem lib/lwip/src/include \
36-
-isystem sdk/src/rp2_common/pico_async_context/include/ \
36+
-isystem sdk/src/rp2_common/pico_async_context/include/ \
3737
-isystem sdk/src/rp2_common/pico_cyw43_arch/include/ \
3838
-isystem sdk/src/rp2_common/pico_cyw43_driver/include/ \
3939
-isystem sdk/src/rp2_common/pico_lwip/include/ \
40-
-isystem sdk/src/rp2_common/pico_rand/include/ \
40+
-isystem sdk/src/rp2_common/pico_rand/include/ \
4141

4242
CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DIGNORE_GPIO23 -DIGNORE_GPIO24 -DCYW43_LOGIC_DEBUG=0 -DCYW43_NETUTILS=1
4343
SRC_SDK_CYW43 := \
@@ -105,6 +105,7 @@ INC += \
105105
-isystem sdk/src/common/pico_util/include/ \
106106
-isystem sdk/src/rp2040/hardware_regs/include/ \
107107
-isystem sdk/src/rp2040/hardware_structs/include/ \
108+
-isystem sdk/src/rp2_common/cmsis/ \
108109
-isystem sdk/src/rp2_common/hardware_adc/include/ \
109110
-isystem sdk/src/rp2_common/hardware_base/include/ \
110111
-isystem sdk/src/rp2_common/hardware_claim/include/ \
@@ -113,16 +114,19 @@ INC += \
113114
-isystem sdk/src/rp2_common/hardware_dma/include/ \
114115
-isystem sdk/src/rp2_common/hardware_flash/include/ \
115116
-isystem sdk/src/rp2_common/hardware_gpio/include/ \
117+
-isystem sdk/src/rp2_common/hardware_interp/include/ \
116118
-isystem sdk/src/rp2_common/hardware_irq/include/ \
117119
-isystem sdk/src/rp2_common/hardware_i2c/include/ \
118120
-isystem sdk/src/rp2_common/hardware_pio/include/ \
119121
-isystem sdk/src/rp2_common/hardware_pll/include/ \
122+
-isystem sdk/src/rp2_common/hardware_pwm/include/ \
120123
-isystem sdk/src/rp2_common/hardware_resets/include/ \
121124
-isystem sdk/src/rp2_common/hardware_rtc/include/ \
122125
-isystem sdk/src/rp2_common/hardware_spi/include/ \
123126
-isystem sdk/src/rp2_common/hardware_sync/include/ \
124127
-isystem sdk/src/rp2_common/hardware_timer/include/ \
125128
-isystem sdk/src/rp2_common/hardware_uart/include/ \
129+
-isystem sdk/src/rp2_common/hardware_vreg/include/ \
126130
-isystem sdk/src/rp2_common/hardware_watchdog/include/ \
127131
-isystem sdk/src/rp2_common/hardware_xosc/include/ \
128132
-isystem sdk/src/rp2_common/pico_multicore/include/ \
@@ -131,7 +135,7 @@ INC += \
131135
-isystem sdk/src/rp2_common/pico_printf/include/ \
132136
-isystem sdk/src/rp2_common/pico_float/include/ \
133137
-isystem sdk/src/rp2_common/pico_platform/include/ \
134-
-isystem sdk/src/rp2_common/pico_runtime/printf/include/ \
138+
-isystem sdk/src/rp2_common/pico_runtime/include/ \
135139
-isystem sdk/src/rp2_common/pico_bootrom/include/ \
136140
-isystem sdk/src/rp2_common/pico_unique_id/include/ \
137141
$(INC_CYW43) \
@@ -141,7 +145,7 @@ INC += \
141145
-I$(BUILD)
142146

143147
# Pico specific configuration
144-
CFLAGS += -DRASPBERRYPI -DPICO_ON_DEVICE=1 -DPICO_NO_BINARY_INFO=0 -DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=0 -DPICO_DIVIDER_CALL_IDIV0=0 -DPICO_DIVIDER_CALL_LDIV0=0 -DPICO_DIVIDER_HARDWARE=1 -DPICO_DOUBLE_ROM=1 -DPICO_FLOAT_ROM=1 -DPICO_MULTICORE=1 -DPICO_BITS_IN_RAM=0 -DPICO_DIVIDER_IN_RAM=0 -DPICO_DOUBLE_PROPAGATE_NANS=0 -DPICO_DOUBLE_IN_RAM=0 -DPICO_MEM_IN_RAM=0 -DPICO_FLOAT_IN_RAM=0 -DPICO_FLOAT_PROPAGATE_NANS=1 -DPICO_NO_FLASH=0 -DPICO_COPY_TO_RAM=0 -DPICO_DISABLE_SHARED_IRQ_HANDLERS=0 -DPICO_NO_BI_BOOTSEL_VIA_DOUBLE_RESET=0
148+
CFLAGS += -DRASPBERRYPI -DPICO_ON_DEVICE=1 -DPICO_NO_BINARY_INFO=0 -DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=0 -DPICO_DIVIDER_CALL_IDIV0=0 -DPICO_DIVIDER_CALL_LDIV0=0 -DPICO_DIVIDER_HARDWARE=1 -DPICO_DOUBLE_ROM=1 -DPICO_FLOAT_ROM=1 -DPICO_MULTICORE=1 -DPICO_BITS_IN_RAM=0 -DPICO_DIVIDER_IN_RAM=0 -DPICO_DOUBLE_PROPAGATE_NANS=0 -DPICO_DOUBLE_IN_RAM=0 -DPICO_MEM_IN_RAM=0 -DPICO_FLOAT_IN_RAM=0 -DPICO_FLOAT_PROPAGATE_NANS=1 -DPICO_NO_FLASH=0 -DPICO_COPY_TO_RAM=0 -DPICO_DISABLE_SHARED_IRQ_HANDLERS=0 -DPICO_NO_BI_BOOTSEL_VIA_DOUBLE_RESET=0 -DDVI_1BPP_BIT_REVERSE=0
145149
OPTIMIZATION_FLAGS ?= -O3
146150
# TinyUSB defines
147151
CFLAGS += -DTUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX=1 -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
@@ -172,8 +176,8 @@ DISABLE_WARNINGS = -Wno-stringop-overflow -Wno-cast-align
172176
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes
173177

174178
CFLAGS += \
175-
-march=armv6-m \
176-
-mthumb \
179+
-march=armv6-m \
180+
-mthumb \
177181
-mabi=aapcs-linux \
178182
-mcpu=cortex-m0plus \
179183
-msoft-float \
@@ -195,13 +199,15 @@ SRC_SDK := \
195199
src/common/pico_time/time.c \
196200
src/common/pico_time/timeout_helper.c \
197201
src/common/pico_util/pheap.c \
202+
src/common/pico_util/queue.c \
198203
src/rp2_common/hardware_adc/adc.c \
199204
src/rp2_common/hardware_claim/claim.c \
200205
src/rp2_common/hardware_clocks/clocks.c \
201206
src/rp2_common/hardware_dma/dma.c \
202207
src/rp2_common/hardware_flash/flash.c \
203208
src/rp2_common/hardware_gpio/gpio.c \
204209
src/rp2_common/hardware_i2c/i2c.c \
210+
src/rp2_common/hardware_interp/interp.c \
205211
src/rp2_common/hardware_irq/irq.c \
206212
src/rp2_common/hardware_pio/pio.c \
207213
src/rp2_common/hardware_pll/pll.c \
@@ -210,6 +216,7 @@ SRC_SDK := \
210216
src/rp2_common/hardware_sync/sync.c \
211217
src/rp2_common/hardware_timer/timer.c \
212218
src/rp2_common/hardware_uart/uart.c \
219+
src/rp2_common/hardware_vreg/vreg.c \
213220
src/rp2_common/hardware_watchdog/watchdog.c \
214221
src/rp2_common/hardware_xosc/xosc.c \
215222
src/rp2_common/pico_bootrom/bootrom.c \
@@ -223,6 +230,7 @@ SRC_SDK := \
223230
src/rp2_common/pico_printf/printf.c \
224231
src/rp2_common/pico_runtime/runtime.c \
225232
src/rp2_common/pico_stdio/stdio.c \
233+
src/rp2_common/pico_stdlib/stdlib.c \
226234
src/rp2_common/pico_unique_id/unique_id.c \
227235
$(SRC_SDK_CYW43) \
228236

@@ -240,12 +248,24 @@ SRC_C += \
240248
background.c \
241249
peripherals/pins.c \
242250
lib/crypto-algorithms/sha256.c \
251+
lib/PicoDVI/software/libdvi/dvi.c \
252+
lib/PicoDVI/software/libdvi/dvi_serialiser.c \
253+
lib/PicoDVI/software/libdvi/dvi_timing.c \
254+
lib/PicoDVI/software/libdvi/tmds_encode.c \
243255
lib/tinyusb/src/portable/raspberrypi/rp2040/dcd_rp2040.c \
244256
lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c \
245257
mphalport.c \
246258
$(SRC_CYW43) \
247259
$(SRC_LWIP) \
248260

261+
ifeq ($(CIRCUITPY_PICODVI),1)
262+
SRC_C += \
263+
bindings/picodvi/__init__.c \
264+
bindings/picodvi/Framebuffer.c \
265+
common-hal/picodvi/Framebuffer.c \
266+
267+
endif
268+
249269
ifeq ($(CIRCUITPY_SSL),1)
250270
CFLAGS += -isystem $(TOP)/mbedtls/include
251271
SRC_MBEDTLS := $(addprefix lib/mbedtls/library/, \
@@ -359,6 +379,7 @@ SRC_S_UPPER = sdk/src/rp2_common/hardware_divider/divider.S \
359379
sdk/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S \
360380
sdk/src/rp2_common/pico_mem_ops/mem_ops_aeabi.S \
361381
sdk/src/rp2_common/pico_standard_link/crt0.S \
382+
lib/PicoDVI/software/libdvi/tmds_encode_asm.S \
362383

363384
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
364385
OBJ += $(addprefix $(BUILD)/, $(SRC_SDK:.c=.o))
@@ -405,13 +426,19 @@ SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_M
405426

406427
all: $(BUILD)/firmware.uf2
407428

408-
LINK_LD := $(firstword $(wildcard boards/$(BOARD)/link.ld link.ld))
409-
$(BUILD)/firmware.elf: $(OBJ) $(LINK_LD)
429+
BOARD_LD := $(wildcard boards/$(BOARD)/link.ld)
430+
431+
ifneq ($(BOARD_LD),)
432+
LINKER_SCRIPTS = -Wl,-T,$(BOARD_LD)
433+
endif
434+
435+
LINKER_SCRIPTS += -Wl,-T,link.ld
436+
437+
$(BUILD)/firmware.elf: $(OBJ) $(BOARD_LD) link.ld
410438
$(STEPECHO) "LINK $@"
411439
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
412440
$(Q)echo $(PICO_LDFLAGS) > $(BUILD)/firmware.ldflags
413-
$(Q)$(CC) -o $@ $(CFLAGS) @$(BUILD)/firmware.ldflags -Wl,-T,$(LINK_LD) -Wl,-Map=$@.map -Wl,-cref -Wl,--gc-sections @$(BUILD)/firmware.objs -Wl,-lc
414-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LINK_LD) $(BUILD)
441+
$(Q)$(CC) -o $@ $(CFLAGS) @$(BUILD)/firmware.ldflags $(LINKER_SCRIPTS) -Wl,--print-memory-usage -Wl,-Map=$@.map -Wl,-cref -Wl,--gc-sections @$(BUILD)/firmware.objs -Wl,-lc
415442

416443
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
417444
$(STEPECHO) "Create $@"

ports/raspberrypi/audio_dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#include "src/rp2_common/hardware_irq/include/hardware/irq.h"
3939

40-
#if CIRCUITPY_AUDIOPWMIO || CIRCUITPY_AUDIOBUSIO
40+
#if CIRCUITPY_AUDIOCORE
4141

4242
void audio_dma_reset(void) {
4343
for (size_t channel = 0; channel < NUM_DMA_CHANNELS; channel++) {

0 commit comments

Comments
 (0)