diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index 5513fe9f37..d5491fe362 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h @@ -35,8 +35,6 @@ #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 -#define CIRCUITPY_INTERNAL_NVM_SIZE 256 - -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000 - CIRCUITPY_INTERNAL_NVM_SIZE) +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) #define AUTORESET_DELAY_MS 500 diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk index bbc2a4a049..725a12cf66 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk @@ -2,7 +2,7 @@ USB_VID = 0x239A USB_PID = 0x802A USB_PRODUCT = "STM32F411VE Discovery Board - CPy" USB_MANUFACTURER = "STMicroelectronics" -USB_REDUCED_ENDPOINT = 1 +USB_CDC_AND_MSC_ONLY = 1 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h index 416944257b..0a89d96465 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h @@ -33,6 +33,5 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) -#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define AUTORESET_DELAY_MS 500 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) \ No newline at end of file +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) \ No newline at end of file diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index a33581b644..cde3e5372c 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -34,6 +34,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi, const mcu_pin_obj_t * miso) { + mp_raise_NotImplementedError(translate("SPI not yet supported")); } void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { diff --git a/ports/stm32f4/common-hal/busio/UART.c b/ports/stm32f4/common-hal/busio/UART.c index 32653ab8b5..e1810b131e 100644 --- a/ports/stm32f4/common-hal/busio/UART.c +++ b/ports/stm32f4/common-hal/busio/UART.c @@ -41,6 +41,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout, uint16_t receiver_buffer_size) { + mp_raise_NotImplementedError(translate("UART not yet supported")); } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index 4cbd6d66fd..efdecd2643 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -32,7 +32,6 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/microcontroller/Processor.h" -#include "shared-bindings/nvm/ByteArray.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" @@ -71,15 +70,6 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = { }, }; -#if CIRCUITPY_INTERNAL_NVM_SIZE > 0 -// The singleton nvm.ByteArray object. -const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = { - .base = { - .type = &nvm_bytearray_type, - }, -}; -#endif - STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) }, { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) }, diff --git a/ports/stm32f4/common-hal/nvm/ByteArray.c b/ports/stm32f4/common-hal/nvm/ByteArray.c deleted file mode 100644 index ef70744ad6..0000000000 --- a/ports/stm32f4/common-hal/nvm/ByteArray.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Nick Moore for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -//TODO: Implement for STM32. File required by Microcontroller Init - -#include "common-hal/nvm/ByteArray.h" - -#include -#include - -// defined in linker -extern uint32_t __fatfs_flash_start_addr[]; -extern uint32_t __fatfs_flash_length[]; - -#define NVM_START_ADDR ((uint32_t)__fatfs_flash_start_addr + \ - (uint32_t)__fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE) - -uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { - return CIRCUITPY_INTERNAL_NVM_SIZE; -} - -static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) { - // - // Write a whole page to flash, buffering it first and then erasing and rewriting - // it since we can only clear a whole page at a time. - - // if (offset == 0 && len == FLASH_PAGE_SIZE) { - // nrf_nvm_safe_flash_page_write(page_addr, bytes); - // } else { - // uint8_t buffer[FLASH_PAGE_SIZE]; - // memcpy(buffer, (uint8_t *)page_addr, FLASH_PAGE_SIZE); - // memcpy(buffer + offset, bytes, len); - // nrf_nvm_safe_flash_page_write(page_addr, buffer); - // } -} - -bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, - // uint32_t start_index, uint8_t* values, uint32_t len) { - - // uint32_t address = NVM_START_ADDR + start_index; - // uint32_t offset = address % FLASH_PAGE_SIZE; - // uint32_t page_addr = address - offset; - - // while (len) { - // uint32_t write_len = MIN(len, FLASH_PAGE_SIZE - offset); - // write_page(page_addr, offset, write_len, values); - // len -= write_len; - // values += write_len; - // page_addr += FLASH_PAGE_SIZE; - // offset = 0; - // } - return true; -} - -void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, - uint32_t start_index, uint32_t len, uint8_t* values) { - memcpy(values, (uint8_t *)(NVM_START_ADDR + start_index), len); -} diff --git a/ports/stm32f4/common-hal/nvm/ByteArray.h b/ports/stm32f4/common-hal/nvm/ByteArray.h deleted file mode 100644 index ed00df9ffe..0000000000 --- a/ports/stm32f4/common-hal/nvm/ByteArray.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Nick Moore for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_NVM_BYTEARRAY_H -#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_NVM_BYTEARRAY_H - -#include "py/obj.h" - -typedef struct { - mp_obj_base_t base; -} nvm_bytearray_obj_t; - -#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_NVM_BYTEARRAY_H diff --git a/ports/stm32f4/common-hal/nvm/__init__.c b/ports/stm32f4/common-hal/nvm/__init__.c deleted file mode 100644 index 3cdc9d3a4c..0000000000 --- a/ports/stm32f4/common-hal/nvm/__init__.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Nick Moore for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// No nvm module functions. diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 6ac477c93e..1d44feec9f 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -15,10 +15,11 @@ LONGINT_IMPL = MPZ #Reduced feature set for early port CIRCUITPY_MINIMAL_BUILD = 1 +CIRCUITPY_BOARD = 1 +CIRCUITPY_DIGITALIO = 1 +CIRCUITPY_MICROCONTROLLER = 1 +CIRCUITPY_BUSIO = 1 +CIRCUITPY_TIME = 1 + #ifeq ($(MCU_SUB_VARIANT), stm32f412zx) - CIRCUITPY_BOARD = 1 - CIRCUITPY_DIGITALIO = 1 - CIRCUITPY_MICROCONTROLLER = 1 - CIRCUITPY_BUSIO = 1 - CIRCUITPY_TIME = 1 #endif diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c index fca1c1df2c..0f773961db 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c @@ -28,9 +28,6 @@ #include "py/mphal.h" #include "stm32f4/pins.h" - -//TODO -//const mcu_pin_obj_t pin_PE02 = PIN(4, GPIOE, 2); const mcu_pin_obj_t pin_PE02 = PIN(4, GPIOE, 2); const mcu_pin_obj_t pin_PE03 = PIN(4, GPIOE, 3); const mcu_pin_obj_t pin_PE04 = PIN(4, GPIOE, 4); diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 4870f15d83..19516a30ff 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -44,10 +44,10 @@ ifdef EXTERNAL_FLASH_DEVICES SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c endif else - ifneq ($(DISABLE_FILESYSTEM),1) - SRC_SUPERVISOR += supervisor/internal_flash.c - else + ifeq ($(DISABLE_FILESYSTEM),1) SRC_SUPERVISOR += supervisor/stub/internal_flash.c + else + SRC_SUPERVISOR += supervisor/internal_flash.c endif endif @@ -105,7 +105,7 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile --serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\ --output_c_file $(BUILD)/autogen_usb_descriptor.c\ --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h\ - --reduced_endpoint_mode $(USB_REDUCED_ENDPOINT) + --cdc_and_msc_only $(USB_CDC_AND_MSC_ONLY) CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf" diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index c23b413d25..6fb33a77af 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -21,7 +21,7 @@ parser.add_argument('--serial_number_length', type=int, default=32, help='length needed for the serial number in digits') parser.add_argument('--output_c_file', type=argparse.FileType('w'), required=True) parser.add_argument('--output_h_file', type=argparse.FileType('w'), required=True) -parser.add_argument('--reduced_endpoint_mode', nargs='?',const=0, type=int) +parser.add_argument('--cdc_and_msc_only', nargs='?',const=0, type=int) args = parser.parse_args() @@ -277,7 +277,7 @@ descriptor_list.extend(cdc_interfaces) descriptor_list.extend(msc_interfaces) # Only add the control interface because other audio interfaces are managed by it to ensure the # correct ordering. -if not args.reduced_endpoint_mode: +if not args.cdc_and_msc_only: descriptor_list.append(audio_control_interface) # Put the CDC IAD just before the CDC interfaces. # There appears to be a bug in the Windows composite USB driver that requests the @@ -285,7 +285,7 @@ if not args.reduced_endpoint_mode: # first. However, it still fetches the descriptor anyway. We could reorder the interfaces but # the Windows 7 Adafruit_usbser.inf file thinks CDC is at Interface 0, so we'll leave it # there for backwards compatibility. -if not args.reduced_endpoint_mode: +if not args.cdc_and_msc_only: descriptor_list.extend(hid_interfaces) configuration = standard.ConfigurationDescriptor(