Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions extmod/vfs_blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include "shared-bindings/sdioio/SDCard.h"
#endif

#if defined(CIRCUITPY_SP1EMMC) && CIRCUITPY_SP1EMMC
#include "bindings/sp1emmc/EMMC.h"
#endif


#if MICROPY_VFS

Expand Down Expand Up @@ -75,6 +79,25 @@ void mp_vfs_blockdev_init(mp_vfs_blockdev_t *self, mp_obj_t bdev) {
self->u.ioctl[2] = (mp_obj_t)sdioio_sdcard_ioctl; // native version
}
#endif

#if defined(CIRCUITPY_SP1EMMC) && CIRCUITPY_SP1EMMC

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd definitely generalize emmcio because it is used here outside of ports.

if (mp_obj_get_type(bdev) == &sp1emmc_emmc_type) {
self->flags |= MP_BLOCKDEV_FLAG_NATIVE | MP_BLOCKDEV_FLAG_HAVE_IOCTL;
self->readblocks[0] = mp_const_none;
self->readblocks[1] = bdev;
self->readblocks[2] = (mp_obj_t)sp1emmc_emmc_readblocks_native;
if (sp1emmc_emmc_is_write_enabled(bdev)) {
self->writeblocks[0] = mp_const_none;
self->writeblocks[1] = bdev;
self->writeblocks[2] = (mp_obj_t)sp1emmc_emmc_writeblocks_native;
} else {
self->writeblocks[0] = MP_OBJ_NULL;
}
self->u.ioctl[0] = mp_const_none;
self->u.ioctl[1] = bdev;
self->u.ioctl[2] = (mp_obj_t)sp1emmc_emmc_ioctl_native;
}
#endif
if (self->u.ioctl[0] != MP_OBJ_NULL) {
// Device supports new block protocol, so indicate it
self->flags |= MP_BLOCKDEV_FLAG_HAVE_IOCTL;
Expand Down
53 changes: 38 additions & 15 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/sdioio/SDCard.c
#: ports/cxd56/common-hal/sdioio/SDCard.c
#: ports/espressif/common-hal/sdioio/SDCard.c
#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
#: ports/raspberrypi/common-hal/sdioio/SDCard.c
#: ports/stm/common-hal/sdioio/SDCard.c shared-bindings/floppyio/__init__.c
#: shared-module/sdcardio/SDCard.c
Expand Down Expand Up @@ -1707,6 +1708,43 @@ msgstr ""
msgid "You pressed the left button at start up."
msgstr ""

#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
msgid ""
"eMMC owned by the USB drive; set CIRCUITPY_EMMC_USB = false in settings.toml"
msgstr ""

#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
msgid "eMMC already in use"
msgstr ""

#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
#: ports/raspberrypi/common-hal/busio/SPI.c
msgid "SPI peripheral in use"
msgstr ""

#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
#, c-format
msgid "eMMC high-speed switch failed at %s"
msgstr ""

#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
#, c-format
msgid "eMMC init failed at %s"
msgstr ""

#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
#: shared-bindings/i2cioexpander/IOExpander.c
msgid "address out of range"
msgstr ""

Comment thread
tannewt marked this conversation as resolved.
#: ports/nordic/boards/teenage_engineering_sp1/bindings/sp1emmc/EMMC.c
#: shared-bindings/_bleio/__init__.c
#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c shared-module/bitmaptools/__init__.c
#: shared-module/displayio/Bitmap.c shared-module/displayio/Group.c
msgid "Read-only"
msgstr ""

#: ports/nordic/common-hal/_bleio/Adapter.c
msgid "timeout must be < 655.35 secs"
msgstr ""
Expand Down Expand Up @@ -1902,10 +1940,6 @@ msgstr ""
msgid "I2C peripheral in use"
msgstr ""

#: ports/raspberrypi/common-hal/busio/SPI.c
msgid "SPI peripheral in use"
msgstr ""

#: ports/raspberrypi/common-hal/busio/UART.c
msgid "UART peripheral in use"
msgstr ""
Expand Down Expand Up @@ -3613,13 +3647,6 @@ msgstr ""
msgid "not a 128-bit UUID"
msgstr ""

#: shared-bindings/_bleio/__init__.c
#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c shared-module/bitmaptools/__init__.c
#: shared-module/displayio/Bitmap.c shared-module/displayio/Group.c
msgid "Read-only"
msgstr ""

#: shared-bindings/_pew/PewPew.c
msgid "Incorrect buffer size"
msgstr ""
Expand Down Expand Up @@ -4012,10 +4039,6 @@ msgstr ""
msgid "Unsupported hash algorithm"
msgstr ""

#: shared-bindings/i2cioexpander/IOExpander.c
msgid "address out of range"
msgstr ""

#: shared-bindings/i2cioexpander/IOExpander.c
msgid "num_pins must be 8 or 16"
msgstr ""
Expand Down
44 changes: 43 additions & 1 deletion ports/nordic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@

include ../../py/circuitpy_mkenv.mk

# The SoftDevice paths are built from MCU_VARIANT and
# SOFTDEV_VERSION, which only exist once boards/$(BOARD)/mpconfigboard.mk has
# set MCU_CHIP. Skip when the rule requested is not board-specific (e.g.
# fetch-port-submodules), or the stack-missing check looks for an
# unexpanded path and fails on a tree where nothing is actually missing.
ifneq ($(VALID_BOARD),)
ifneq ($(SD), )
include bluetooth/bluetooth_common.mk
endif
endif

CROSS_COMPILE = arm-none-eabi-

Expand Down Expand Up @@ -65,7 +72,32 @@ endif
# nrfx does casts that increase alignment requirements.
CFLAGS += -Wno-cast-align

# Three places on the boot path write UICR, each conditionally, each with a
# forced reset afterwards, and each permanent: UICR can only be cleared by an
# ERASEALL, which needs a debugger and wipes the whole chip. On a board with a
# vendor bootloader and no SWD access that is a one-way change with no undo, so
# every one of them is a knob. See also NRF_NFCT_PINS_AS_GPIOS (mpconfigport.mk)
# and NRF_REGOUT0_3V3 below; teenage_engineering_sp1 turns off all three.
#
# CONFIG_GPIO_AS_PINRESET makes SystemInit write UICR PSELRESET[0..1] = 18 on
# any chip where it is unprogrammed. Boards where P0.18 is not a reset pad (or
# whose UICR must never be touched) opt out with NRF_GPIO_AS_PINRESET = 0.
NRF_GPIO_AS_PINRESET ?= 1
ifeq ($(NRF_GPIO_AS_PINRESET),1)
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
endif

# nrf_peripherals_power_init() writes UICR REGOUT0 = 3.3 V on any nRF52840 that
# is running in high-voltage mode (VDDH supplied) with REGOUT0 unprogrammed,
# because the reset default there is 1.8 V and most boards want 3.3 V. A board
# that is externally regulated never reaches the write; a battery-powered,
# VDDH-supplied board reaches it on its first boot. Opt out with
# NRF_REGOUT0_3V3 = 0 -- but only if the board is known to work at whatever
# REGOUT0 already says, since nothing else sets that voltage.
NRF_REGOUT0_3V3 ?= 1
ifeq ($(NRF_REGOUT0_3V3),1)
CFLAGS += -DCONFIG_REGOUT0_3V3
endif
CFLAGS += $(NRF_DEFINES)

CFLAGS += \
Expand Down Expand Up @@ -115,11 +147,17 @@ SRC_C += \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \


ifneq ($(SD), )
SRC_C += \
bluetooth/ble_drv.c \
common-hal/_bleio/bonding.c \
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
sd_mutex.c \

endif

SRC_PERIPHERALS := \
peripherals/nrf/cache.c \
peripherals/nrf/clocks.c \
Expand Down Expand Up @@ -177,7 +215,11 @@ UF2_FAMILY_ID_nrf52840 = 0xADA52840
UF2_FAMILY_ID_nrf52833 = 0x621E937A


ifneq ($(SD), )
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.combined.hex
else
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.hex
endif

ifeq ($(VALID_BOARD),)
$(BUILD)/firmware.elf: invalid-board
Expand Down
Loading
Loading