Skip to content

Commit

Permalink
Merge pull request #7880 from tannewt/feather_dvi
Browse files Browse the repository at this point in the history
Add PicoDVI support
  • Loading branch information
dhalbert authored Apr 20, 2023
2 parents df7f348 + f38d59b commit 7d02bff
Show file tree
Hide file tree
Showing 36 changed files with 1,134 additions and 401 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,7 @@
[submodule "ports/silabs/tools/slc_cli_linux"]
path = ports/silabs/tools/slc_cli_linux
url = https://github.com/SiliconLabs/circuitpython_slc_cli_linux
[submodule "ports/raspberrypi/lib/PicoDVI"]
path = ports/raspberrypi/lib/PicoDVI
url = https://github.com/circuitpython/PicoDVI.git
branch = circuitpython
11 changes: 8 additions & 3 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ msgstr ""

#: ports/espressif/common-hal/espulp/ULP.c
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
#: shared-bindings/digitalio/DigitalInOut.c
#: shared-bindings/microcontroller/Pin.c
Expand Down Expand Up @@ -164,11 +165,11 @@ msgstr ""
msgid "%q length must be >= %d"
msgstr ""

#: py/argcheck.c
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c py/argcheck.c
msgid "%q must be %d"
msgstr ""

#: py/argcheck.c
#: py/argcheck.c shared-bindings/displayio/Bitmap.c
msgid "%q must be %d-%d"
msgstr ""

Expand Down Expand Up @@ -468,6 +469,7 @@ msgstr ""
msgid "All event channels in use"
msgstr ""

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

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

#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c
#: ports/raspberrypi/bindings/picodvi/Framebuffer.c
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c py/argcheck.c
#: shared-bindings/digitalio/DigitalInOut.c
#: shared-bindings/displayio/EPaperDisplay.c
msgid "Invalid %q"
Expand Down
10 changes: 7 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,15 @@ STATIC void start_mp(supervisor_allocation *heap, supervisor_allocation *pystack
supervisor_workflow_reset();

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

if (stack_get_bottom() != NULL) {
mp_stack_set_limit(stack_get_length() - 1024);
uint32_t *stack_bottom = stack_get_bottom();
if (stack_bottom != NULL) {
size_t stack_length = stack_get_length();
mp_stack_set_top(stack_bottom + (stack_length / sizeof(uint32_t)));
mp_stack_set_limit(stack_length - 1024);
}


Expand Down
1 change: 1 addition & 0 deletions ports/broadcom/common-hal/videocore/Framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void common_hal_videocore_framebuffer_deinit(videocore_framebuffer_obj_t *self)
if (vcmailbox_release_framebuffer()) {
self->framebuffer = NULL;
}
self->base.type = &mp_type_NoneType;
}

bool common_hal_videocore_framebuffer_deinited(videocore_framebuffer_obj_t *self) {
Expand Down
47 changes: 37 additions & 10 deletions ports/raspberrypi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ INC_CYW43 := \
-isystem lib/cyw43-driver/firmware \
-isystem lib/cyw43-driver/src \
-isystem lib/lwip/src/include \
-isystem sdk/src/rp2_common/pico_async_context/include/ \
-isystem sdk/src/rp2_common/pico_async_context/include/ \
-isystem sdk/src/rp2_common/pico_cyw43_arch/include/ \
-isystem sdk/src/rp2_common/pico_cyw43_driver/include/ \
-isystem sdk/src/rp2_common/pico_lwip/include/ \
-isystem sdk/src/rp2_common/pico_rand/include/ \
-isystem sdk/src/rp2_common/pico_rand/include/ \

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
SRC_SDK_CYW43 := \
Expand Down Expand Up @@ -105,6 +105,7 @@ INC += \
-isystem sdk/src/common/pico_util/include/ \
-isystem sdk/src/rp2040/hardware_regs/include/ \
-isystem sdk/src/rp2040/hardware_structs/include/ \
-isystem sdk/src/rp2_common/cmsis/ \
-isystem sdk/src/rp2_common/hardware_adc/include/ \
-isystem sdk/src/rp2_common/hardware_base/include/ \
-isystem sdk/src/rp2_common/hardware_claim/include/ \
Expand All @@ -113,16 +114,19 @@ INC += \
-isystem sdk/src/rp2_common/hardware_dma/include/ \
-isystem sdk/src/rp2_common/hardware_flash/include/ \
-isystem sdk/src/rp2_common/hardware_gpio/include/ \
-isystem sdk/src/rp2_common/hardware_interp/include/ \
-isystem sdk/src/rp2_common/hardware_irq/include/ \
-isystem sdk/src/rp2_common/hardware_i2c/include/ \
-isystem sdk/src/rp2_common/hardware_pio/include/ \
-isystem sdk/src/rp2_common/hardware_pll/include/ \
-isystem sdk/src/rp2_common/hardware_pwm/include/ \
-isystem sdk/src/rp2_common/hardware_resets/include/ \
-isystem sdk/src/rp2_common/hardware_rtc/include/ \
-isystem sdk/src/rp2_common/hardware_spi/include/ \
-isystem sdk/src/rp2_common/hardware_sync/include/ \
-isystem sdk/src/rp2_common/hardware_timer/include/ \
-isystem sdk/src/rp2_common/hardware_uart/include/ \
-isystem sdk/src/rp2_common/hardware_vreg/include/ \
-isystem sdk/src/rp2_common/hardware_watchdog/include/ \
-isystem sdk/src/rp2_common/hardware_xosc/include/ \
-isystem sdk/src/rp2_common/pico_multicore/include/ \
Expand All @@ -131,7 +135,7 @@ INC += \
-isystem sdk/src/rp2_common/pico_printf/include/ \
-isystem sdk/src/rp2_common/pico_float/include/ \
-isystem sdk/src/rp2_common/pico_platform/include/ \
-isystem sdk/src/rp2_common/pico_runtime/printf/include/ \
-isystem sdk/src/rp2_common/pico_runtime/include/ \
-isystem sdk/src/rp2_common/pico_bootrom/include/ \
-isystem sdk/src/rp2_common/pico_unique_id/include/ \
$(INC_CYW43) \
Expand All @@ -141,7 +145,7 @@ INC += \
-I$(BUILD)

# Pico specific configuration
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
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
OPTIMIZATION_FLAGS ?= -O3
# TinyUSB defines
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
Expand Down Expand Up @@ -172,8 +176,8 @@ DISABLE_WARNINGS = -Wno-stringop-overflow -Wno-cast-align
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes

CFLAGS += \
-march=armv6-m \
-mthumb \
-march=armv6-m \
-mthumb \
-mabi=aapcs-linux \
-mcpu=cortex-m0plus \
-msoft-float \
Expand All @@ -195,13 +199,15 @@ SRC_SDK := \
src/common/pico_time/time.c \
src/common/pico_time/timeout_helper.c \
src/common/pico_util/pheap.c \
src/common/pico_util/queue.c \
src/rp2_common/hardware_adc/adc.c \
src/rp2_common/hardware_claim/claim.c \
src/rp2_common/hardware_clocks/clocks.c \
src/rp2_common/hardware_dma/dma.c \
src/rp2_common/hardware_flash/flash.c \
src/rp2_common/hardware_gpio/gpio.c \
src/rp2_common/hardware_i2c/i2c.c \
src/rp2_common/hardware_interp/interp.c \
src/rp2_common/hardware_irq/irq.c \
src/rp2_common/hardware_pio/pio.c \
src/rp2_common/hardware_pll/pll.c \
Expand All @@ -210,6 +216,7 @@ SRC_SDK := \
src/rp2_common/hardware_sync/sync.c \
src/rp2_common/hardware_timer/timer.c \
src/rp2_common/hardware_uart/uart.c \
src/rp2_common/hardware_vreg/vreg.c \
src/rp2_common/hardware_watchdog/watchdog.c \
src/rp2_common/hardware_xosc/xosc.c \
src/rp2_common/pico_bootrom/bootrom.c \
Expand All @@ -223,6 +230,7 @@ SRC_SDK := \
src/rp2_common/pico_printf/printf.c \
src/rp2_common/pico_runtime/runtime.c \
src/rp2_common/pico_stdio/stdio.c \
src/rp2_common/pico_stdlib/stdlib.c \
src/rp2_common/pico_unique_id/unique_id.c \
$(SRC_SDK_CYW43) \

Expand All @@ -240,12 +248,24 @@ SRC_C += \
background.c \
peripherals/pins.c \
lib/crypto-algorithms/sha256.c \
lib/PicoDVI/software/libdvi/dvi.c \
lib/PicoDVI/software/libdvi/dvi_serialiser.c \
lib/PicoDVI/software/libdvi/dvi_timing.c \
lib/PicoDVI/software/libdvi/tmds_encode.c \
lib/tinyusb/src/portable/raspberrypi/rp2040/dcd_rp2040.c \
lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c \
mphalport.c \
$(SRC_CYW43) \
$(SRC_LWIP) \

ifeq ($(CIRCUITPY_PICODVI),1)
SRC_C += \
bindings/picodvi/__init__.c \
bindings/picodvi/Framebuffer.c \
common-hal/picodvi/Framebuffer.c \

endif

ifeq ($(CIRCUITPY_SSL),1)
CFLAGS += -isystem $(TOP)/mbedtls/include
SRC_MBEDTLS := $(addprefix lib/mbedtls/library/, \
Expand Down Expand Up @@ -359,6 +379,7 @@ SRC_S_UPPER = sdk/src/rp2_common/hardware_divider/divider.S \
sdk/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S \
sdk/src/rp2_common/pico_mem_ops/mem_ops_aeabi.S \
sdk/src/rp2_common/pico_standard_link/crt0.S \
lib/PicoDVI/software/libdvi/tmds_encode_asm.S \

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

all: $(BUILD)/firmware.uf2

LINK_LD := $(firstword $(wildcard boards/$(BOARD)/link.ld link.ld))
$(BUILD)/firmware.elf: $(OBJ) $(LINK_LD)
BOARD_LD := $(wildcard boards/$(BOARD)/link.ld)

ifneq ($(BOARD_LD),)
LINKER_SCRIPTS = -Wl,-T,$(BOARD_LD)
endif

LINKER_SCRIPTS += -Wl,-T,link.ld

$(BUILD)/firmware.elf: $(OBJ) $(BOARD_LD) link.ld
$(STEPECHO) "LINK $@"
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
$(Q)echo $(PICO_LDFLAGS) > $(BUILD)/firmware.ldflags
$(Q)$(CC) -o $@ $(CFLAGS) @$(BUILD)/firmware.ldflags -Wl,-T,$(LINK_LD) -Wl,-Map=$@.map -Wl,-cref -Wl,--gc-sections @$(BUILD)/firmware.objs -Wl,-lc
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LINK_LD) $(BUILD)
$(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

$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
$(STEPECHO) "Create $@"
Expand Down
2 changes: 1 addition & 1 deletion ports/raspberrypi/audio_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

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

#if CIRCUITPY_AUDIOPWMIO || CIRCUITPY_AUDIOBUSIO
#if CIRCUITPY_AUDIOCORE

void audio_dma_reset(void) {
for (size_t channel = 0; channel < NUM_DMA_CHANNELS; channel++) {
Expand Down
Loading

0 comments on commit 7d02bff

Please sign in to comment.