From a3673cc79b651a5be1474130313e5b6fa93572d4 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Mon, 22 Jul 2019 17:16:33 -0400 Subject: Set up for new tinyusb integration. Not yet functional. --- supervisor/shared/usb/usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'supervisor') diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 0678a3a3f..12db84308 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -40,8 +40,8 @@ extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2]; void load_serial_number(void) { // create serial number based on device unique id - uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; - common_hal_mcu_processor_get_uid(raw_id); + uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH] = {1,2,3,4}; + //common_hal_mcu_processor_get_uid(raw_id); static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; -- cgit v1.2.3 From 267468834da5207d66a8701d3b5b60a1f63e8461 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Tue, 23 Jul 2019 19:40:26 -0400 Subject: Pin down some TUSB issues --- .gitmodules | 1 + ports/stm32f4/Makefile | 2 +- ports/stm32f4/supervisor/port.c | 84 +++++++------------------------------ ports/stm32f4/supervisor/usb.c | 41 ++++++++---------- supervisor/shared/usb/tusb_config.h | 2 +- 5 files changed, 36 insertions(+), 94 deletions(-) (limited to 'supervisor') diff --git a/.gitmodules b/.gitmodules index e2845395a..639e8dc79 100644 --- a/.gitmodules +++ b/.gitmodules @@ -77,6 +77,7 @@ path = lib/tinyusb url = https://github.com/hathach/tinyusb.git branch = develop + ignore = dirty [submodule "tools/huffman"] path = tools/huffman url = https://github.com/tannewt/huffman.git diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile index 3224a85c5..5be123e44 100755 --- a/ports/stm32f4/Makefile +++ b/ports/stm32f4/Makefile @@ -135,7 +135,7 @@ LIBS += -lm endif # TinyUSB defines -CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_STM32F4 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 +CFLAGS += -DHSE_VALUE=8000000 -DCFG_TUSB_MCU=OPT_MCU_STM32F4 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 ###################################### diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index 515ca7c69..471b90e08 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -45,97 +45,43 @@ safe_mode_t port_init(void) { /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); /** Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 4; - RCC_OscInitStruct.PLL.PLLN = 192; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 8; + RCC_OscInitStruct.PLL.PLLQ = 7; HAL_RCC_OscConfig(&RCC_OscInitStruct); - /** Initializes the CPU, AHB and APB busses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - PeriphClkInitStruct.PLLI2S.PLLI2SN = 200; - PeriphClkInitStruct.PLLI2S.PLLI2SM = 5; - PeriphClkInitStruct.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); + + SystemCoreClockUpdate(); //GPIO setup GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin - |Audio_RST_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin : DATA_Ready_Pin */ - GPIO_InitStruct.Pin = DATA_Ready_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(DATA_Ready_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : CS_I2C_SPI_Pin */ - GPIO_InitStruct.Pin = CS_I2C_SPI_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(CS_I2C_SPI_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : INT1_Pin INT2_Pin MEMS_INT2_Pin */ - GPIO_InitStruct.Pin = INT1_Pin|INT2_Pin|MEMS_INT2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - - /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */ - GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : PA0 */ - GPIO_InitStruct.Pin = GPIO_PIN_0; - GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pins : LD4_Pin LD3_Pin LD5_Pin LD6_Pin - Audio_RST_Pin */ - GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin - |Audio_RST_Pin; + //LED pins + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */ - GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); - //Status LED chain HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET); //LED 1 HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET); //LED 2 diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 913523523..3cb5ccd0f 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -30,16 +30,7 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" #include "stm32f4xx_hal.h" - -#define USB_OTGFS_VBUS_Pin GPIO_PIN_9 -#define USB_OTGFS_VBUS_GPIO_Port GPIOA -#define USB_OTGFS_ID_Pin GPIO_PIN_10 -#define USB_OTGFS_ID_GPIO_Port GPIOA -#define USB_OTGFS_DM_Pin GPIO_PIN_11 -#define USB_OTGFS_DM_GPIO_Port GPIOA -#define USB_OTGFS_DP_Pin GPIO_PIN_12 -#define USB_OTGFS_DP_GPIO_Port GPIOA - +//#include "tusb_config.h" void init_usb_hardware(void) { // HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET); //LED 2 @@ -49,32 +40,36 @@ void init_usb_hardware(void) { PA11 ------> USB_OTG_FS_DM PA12 ------> USB_OTG_FS_DP */ - GPIO_InitStruct.Pin = USB_OTGFS_VBUS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(USB_OTGFS_VBUS_GPIO_Port, &GPIO_InitStruct); + __HAL_RCC_GPIOA_CLK_ENABLE(); - GPIO_InitStruct.Pin = USB_OTGFS_DM_Pin|USB_OTGFS_DP_Pin; + /* Configure DM DP Pins */ + GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12; + GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - //TinyUSB suggestion - GPIO_InitStruct.Pin = USB_OTGFS_ID_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + /* Configure VBUS Pin */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* This for ID line debug */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + // /* Peripheral interrupt init */ + // HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0); + // HAL_NVIC_EnableIRQ(OTG_FS_IRQn); //HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET); //LED 3 } diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index 301805275..d7c5199be 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -107,7 +107,7 @@ // USB RAM PLACEMENT //--------------------------------------------------------------------+ #define CFG_TUSB_ATTR_USBRAM -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) #ifdef __cplusplus -- cgit v1.2.3 From 981398406c61daada25f3e36601a3d0d118ac635 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 24 Jul 2019 16:23:35 -0400 Subject: Implement working (if useless) USB on F411 --- lib/tinyusb | 2 +- .../peripherals/stm32f4/stm32f411xe/clocks.c | 62 +++++++++++----------- ports/stm32f4/supervisor/usb.c | 1 - ports/stm32f4/tick.c | 8 +-- supervisor/shared/usb/usb.c | 6 ++- supervisor/shared/usb/usb_msc_flash.c | 2 +- 6 files changed, 41 insertions(+), 40 deletions(-) (limited to 'supervisor') diff --git a/lib/tinyusb b/lib/tinyusb index 0848c462b..97e2629d6 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 0848c462b3e431a9da42e96537d2b597a4579636 +Subproject commit 97e2629d647584681b2883f2081fa2cddb3d61cc diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c index 5b7a1e298..f1ce6fef9 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c @@ -28,36 +28,34 @@ void stm32f4_peripherals_clocks_init(void) { //System clock init - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - /** Configure the main internal regulator output voltage - */ - __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 4; - RCC_OscInitStruct.PLL.PLLN = 192; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 8; - HAL_RCC_OscConfig(&RCC_OscInitStruct); - /** Initializes the CPU, AHB and APB busses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3); - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - PeriphClkInitStruct.PLLI2S.PLLI2SN = 200; - PeriphClkInitStruct.PLLI2S.PLLI2SM = 5; - PeriphClkInitStruct.PLLI2S.PLLI2SR = 2; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; + RCC_OscInitStruct.PLL.PLLQ = 7; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); } diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 3cb5ccd0f..11885b3d9 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -30,7 +30,6 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" #include "stm32f4xx_hal.h" -//#include "tusb_config.h" void init_usb_hardware(void) { // HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET); //LED 2 diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c index 2596e34d1..5bd2da6ed 100644 --- a/ports/stm32f4/tick.c +++ b/ports/stm32f4/tick.c @@ -55,12 +55,12 @@ void SysTick_Handler(void) { } void tick_init() { - uint32_t ticks_per_ms = 16000000/ 1000; + uint32_t ticks_per_ms = SystemCoreClock/ 1000; SysTick_Config(ticks_per_ms); // interrupt is enabled } void tick_delay(uint32_t us) { - uint32_t ticks_per_us = 16000000 / 1000 / 1000; + uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; uint32_t us_between_ticks = SysTick->VAL / ticks_per_us; uint64_t start_ms = ticks_ms; while (us > 1000) { @@ -74,12 +74,12 @@ void tick_delay(uint32_t us) { // us counts down! void current_tick(uint64_t* ms, uint32_t* us_until_ms) { - uint32_t ticks_per_us = 16000000 / 1000 / 1000; + uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; *ms = ticks_ms; *us_until_ms = SysTick->VAL / ticks_per_us; } void wait_until(uint64_t ms, uint32_t us_until_ms) { - uint32_t ticks_per_us = 16000000 / 1000 / 1000; + uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000; while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} } diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 12db84308..bccdca622 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -60,10 +60,14 @@ bool usb_enabled(void) { void usb_init(void) { init_usb_hardware(); - load_serial_number(); + //load_serial_number(); tusb_init(); + while(1) { + tud_task(); + } + #if MICROPY_KBD_EXCEPTION // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received // This callback always got invoked regardless of mp_interrupt_char value since we only set it once here diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index 205cb7b50..a1ab46454 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -197,7 +197,7 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) { // Invoked when received Start Stop Unit command // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 1 : active mode, if load_eject = 1 : load disk storage -bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) { +void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) { if (load_eject) { if (lun > 1) { return false; -- cgit v1.2.3 From 90b1701b6cf5bfdd44e02bff6c6fd7c9061111c0 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Fri, 26 Jul 2019 14:06:27 -0400 Subject: Add CDC REPL access --- ports/stm32f4/background.c | 2 +- ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h | 2 ++ supervisor/shared/usb/usb.c | 13 +++++++------ supervisor/supervisor.mk | 1 + tools/gen_usb_descriptor.py | 6 +++--- 5 files changed, 14 insertions(+), 10 deletions(-) (limited to 'supervisor') diff --git a/ports/stm32f4/background.c b/ports/stm32f4/background.c index e9872b045..9c4f3ab27 100644 --- a/ports/stm32f4/background.c +++ b/ports/stm32f4/background.c @@ -46,7 +46,7 @@ void run_background_tasks(void) { } running_background_tasks = true; filesystem_background(); - //usb_background(); + usb_background(); #if CIRCUITPY_DISPLAYIO displayio_refresh_displays(); diff --git a/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h index 675443282..1b1410aea 100644 --- a/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h @@ -33,6 +33,8 @@ #define FLASH_SIZE (0x7D000) #define FLASH_PAGE_SIZE (0x4000) +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + #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 diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index bccdca622..cfb39d4bb 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -34,14 +34,19 @@ #include "tusb.h" +#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8 + // Serial number as hex characters. This writes directly to the USB // descriptor. extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2]; void load_serial_number(void) { // create serial number based on device unique id - uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH] = {1,2,3,4}; + uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; //common_hal_mcu_processor_get_uid(raw_id); + for (int i=0; i<2; i++) { + ((uint32_t*) raw_id)[i] = 0; + } static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; @@ -60,14 +65,10 @@ bool usb_enabled(void) { void usb_init(void) { init_usb_hardware(); - //load_serial_number(); + load_serial_number(); tusb_init(); - while(1) { - tud_task(); - } - #if MICROPY_KBD_EXCEPTION // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received // This callback always got invoked regardless of mp_interrupt_char value since we only set it once here diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 2d50e7a8b..42a55243e 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -78,6 +78,7 @@ else shared-module/usb_midi/PortIn.c \ shared-module/usb_midi/PortOut.c \ $(BUILD)/autogen_usb_descriptor.c + CFLAGS += -DUSB_AVAILABLE endif diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 10bbf5066..db17c9766 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -273,17 +273,17 @@ cdc_iad = standard.InterfaceAssociationDescriptor( descriptor_list = [] descriptor_list.append(cdc_iad) descriptor_list.extend(cdc_interfaces) -descriptor_list.extend(msc_interfaces) +# descriptor_list.extend(msc_interfaces) # Only add the control interface because other audio interfaces are managed by it to ensure the # correct ordering. -descriptor_list.append(audio_control_interface) +# 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 # HID report descriptor with the wrong interface number if the HID interface is not given # 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. -descriptor_list.extend(hid_interfaces) +# descriptor_list.extend(hid_interfaces) configuration = standard.ConfigurationDescriptor( description="Composite configuration", -- cgit v1.2.3 From a635d46b1a3d16695afa932f53842525eab638e3 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Sun, 4 Aug 2019 17:06:51 -0400 Subject: Fix merge related issues --- .gitmodules | 1 - lib/tinyusb | 2 +- ports/stm32f4/supervisor/internal_flash.c | 2 -- ports/stm32f4/supervisor/port.c | 6 ------ supervisor/shared/usb/usb_msc_flash.c | 2 +- 5 files changed, 2 insertions(+), 11 deletions(-) (limited to 'supervisor') diff --git a/.gitmodules b/.gitmodules index 2a97c81fc..7b57cab54 100644 --- a/.gitmodules +++ b/.gitmodules @@ -77,7 +77,6 @@ path = lib/tinyusb url = https://github.com/hathach/tinyusb.git branch = develop - ignore = dirty [submodule "tools/huffman"] path = tools/huffman url = https://github.com/tannewt/huffman.git diff --git a/lib/tinyusb b/lib/tinyusb index 97e2629d6..1ee9ef4f2 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 97e2629d647584681b2883f2081fa2cddb3d61cc +Subproject commit 1ee9ef4f2b7c6acfab6c398a4f57ca22036958f7 diff --git a/ports/stm32f4/supervisor/internal_flash.c b/ports/stm32f4/supervisor/internal_flash.c index fa776ae1d..e05236948 100644 --- a/ports/stm32f4/supervisor/internal_flash.c +++ b/ports/stm32f4/supervisor/internal_flash.c @@ -39,8 +39,6 @@ /*------------------------------------------------------------------*/ /* Internal Flash API *------------------------------------------------------------------*/ -static inline uint32_t lba2addr(uint32_t block) { -} void supervisor_flash_init(void) { } diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c index af4d1b8d8..6030547ac 100644 --- a/ports/stm32f4/supervisor/port.c +++ b/ports/stm32f4/supervisor/port.c @@ -35,12 +35,6 @@ #include "stm32f4xx_hal.h" -//#include "shared-bindings/rtc/__init__.h" - -static void power_warning_handler(void) { - reset_into_safe_mode(BROWNOUT); -} - safe_mode_t port_init(void) { HAL_Init(); diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index a1ab46454..205cb7b50 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -197,7 +197,7 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) { // Invoked when received Start Stop Unit command // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 1 : active mode, if load_eject = 1 : load disk storage -void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) { +bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) { if (load_eject) { if (lun > 1) { return false; -- cgit v1.2.3 From 620d3d14ddd5ee39d256640719b3e10c927139f3 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 15 Aug 2019 13:41:51 -0400 Subject: Add conditional endpoints to descriptor script --- ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk | 1 + supervisor/supervisor.mk | 3 ++- tools/gen_usb_descriptor.py | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'supervisor') diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk index 747d34ebe..aa867c96f 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk @@ -2,6 +2,7 @@ USB_VID = 0x239A USB_PID = 0x802A USB_PRODUCT = "STM32F411VE Discovery Board - CPy" USB_MANUFACTURER = "Adafruit Industries LLC" +USB_REDUCED_ENDPOINT = 1 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 42a55243e..1022dd2a3 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -100,7 +100,8 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile --pid $(USB_PID)\ --serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\ --output_c_file $(BUILD)/autogen_usb_descriptor.c\ - --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h + --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h\ + --reduced_endpoint_mode $(USB_REDUCED_ENDPOINT) CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf" diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index a5667dd46..c23b413d2 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -21,6 +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) args = parser.parse_args() @@ -276,14 +277,16 @@ 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. -# descriptor_list.append(audio_control_interface) +if not args.reduced_endpoint_mode: + 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 # HID report descriptor with the wrong interface number if the HID interface is not given # 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. -# descriptor_list.extend(hid_interfaces) +if not args.reduced_endpoint_mode: + descriptor_list.extend(hid_interfaces) configuration = standard.ConfigurationDescriptor( description="Composite configuration", -- cgit v1.2.3 From a9d3ad86e5f400b9315fde58c9b8666a048956ca Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 15 Aug 2019 15:55:33 -0400 Subject: Fix flash size, add filesystem disable flag --- ports/stm32f4/boards/STM32F411VETx_FLASH.ld | 4 +- ports/stm32f4/boards/stm32f411.ld | 189 --------------------- .../boards/stm32f411ve_discovery/mpconfigboard.h | 2 +- .../boards/stm32f412zg_discovery/mpconfigboard.mk | 2 + ports/stm32f4/common-hal/busio/SPI.c | 1 + ports/stm32f4/supervisor/internal_flash.h | 5 +- supervisor/stub/internal_flash.c | 70 ++++++++ supervisor/supervisor.mk | 8 +- 8 files changed, 84 insertions(+), 197 deletions(-) delete mode 100644 ports/stm32f4/boards/stm32f411.ld create mode 100644 supervisor/stub/internal_flash.c (limited to 'supervisor') diff --git a/ports/stm32f4/boards/STM32F411VETx_FLASH.ld b/ports/stm32f4/boards/STM32F411VETx_FLASH.ld index fc9ffdff5..ac1ba3240 100644 --- a/ports/stm32f4/boards/STM32F411VETx_FLASH.ld +++ b/ports/stm32f4/boards/STM32F411VETx_FLASH.ld @@ -7,8 +7,8 @@ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ - FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 112K /* sectors 1,2,3 are 16K, 4 is 64K */ - FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5,6,7 are 128K */ + FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ + FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K } diff --git a/ports/stm32f4/boards/stm32f411.ld b/ports/stm32f4/boards/stm32f411.ld deleted file mode 100644 index f0d4804f9..000000000 --- a/ports/stm32f4/boards/stm32f411.ld +++ /dev/null @@ -1,189 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : Auto-generated by Ac6 System Workbench -** -** Abstract : Linker script for STM32F411RETx series -** 512Kbytes FLASH and 128Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2014 Ac6

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of Ac6 nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20020000; /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K -FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - - diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index 979b75b4c..21466f4df 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h @@ -37,6 +37,6 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE 256 -#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0x01C000 - CIRCUITPY_INTERNAL_NVM_SIZE) +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000 - CIRCUITPY_INTERNAL_NVM_SIZE) #define AUTORESET_DELAY_MS 500 \ No newline at end of file diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk index b6c27f9c0..3b3c7867f 100644 --- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk @@ -3,6 +3,8 @@ USB_PID = 0x572B USB_PRODUCT = "STM32F412ZG Discovery Board - CPy" USB_MANUFACTURER = "STMicroelectronics" +DISABLE_FILESYSTEM = 1 + MCU_SERIES = m4 MCU_VARIANT = stm32f4 MCU_SUB_VARIANT = stm32f412zx diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index dfb436fb9..98faf7b3b 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -87,3 +87,4 @@ uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t* self) { uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) { return 0; +} \ No newline at end of file diff --git a/ports/stm32f4/supervisor/internal_flash.h b/ports/stm32f4/supervisor/internal_flash.h index c8a60cc55..83b35e03c 100644 --- a/ports/stm32f4/supervisor/internal_flash.h +++ b/ports/stm32f4/supervisor/internal_flash.h @@ -33,18 +33,17 @@ #ifdef STM32F411xE #define STM32_FLASH_SIZE 0x80000 //512KiB -#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x1C000 //112KiB +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //112KiB #endif #ifdef STM32F412Zx #define STM32_FLASH_SIZE 0x100000 //1MB -#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x1C000 //112KiB +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //112KiB #endif #define STM32_FLASH_OFFSET 0x8000000 //All STM32 chips map to this flash location #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 -//#define INTERNAL_FLASH_FILESYSTEM_START_ADDR ((STM32_FLASH_SIZE + STM32_FLASH_OFFSET) - INTERNAL_FLASH_FILESYSTEM_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE) #define INTERNAL_FLASH_FILESYSTEM_NUM_BLOCKS (INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE) #define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms diff --git a/supervisor/stub/internal_flash.c b/supervisor/stub/internal_flash.c new file mode 100644 index 000000000..334281e77 --- /dev/null +++ b/supervisor/stub/internal_flash.c @@ -0,0 +1,70 @@ +/*f + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * + * 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. + */ +#include "supervisor/internal_flash.h" + +#include +#include + +#include "extmod/vfs.h" +#include "extmod/vfs_fat.h" +#include "py/mphal.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "lib/oofatfs/ff.h" + +void supervisor_flash_init(void) { +} + +uint32_t supervisor_flash_get_block_size(void) { + return 0; +} + +uint32_t supervisor_flash_get_block_count(void) { + return 0; +} + +void supervisor_flash_flush(void) { +} + +static int32_t convert_block_to_flash_addr(uint32_t block) { + return -1; +} + +mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { + return 0; // success +} + +bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) { + return true; +} + +mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) { + return 0; // success +} + +void supervisor_flash_release_cache(void) { +} + diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 1022dd2a3..4870f15d8 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -13,7 +13,7 @@ SRC_SUPERVISOR = \ supervisor/shared/translate.c ifndef $(NO_USB) -NO_USB = $(wildcard supervisor/usb.c) + NO_USB = $(wildcard supervisor/usb.c) endif ifneq ($(INTERNAL_FLASH_FILESYSTEM),) @@ -44,7 +44,11 @@ ifdef EXTERNAL_FLASH_DEVICES SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c endif else - SRC_SUPERVISOR += supervisor/internal_flash.c + ifneq ($(DISABLE_FILESYSTEM),1) + SRC_SUPERVISOR += supervisor/internal_flash.c + else + SRC_SUPERVISOR += supervisor/stub/internal_flash.c + endif endif ifeq ($(USB),FALSE) -- cgit v1.2.3 From bc7ba33892cae88ffd1b42dfa45868057a4934e8 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 15 Aug 2019 16:35:01 -0400 Subject: Add uid fetch, revert USB hacks --- ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk | 2 +- ports/stm32f4/common-hal/microcontroller/Processor.c | 9 ++++++--- ports/stm32f4/common-hal/microcontroller/Processor.h | 2 +- ports/stm32f4/mpconfigport.mk | 2 +- supervisor/shared/usb/usb.c | 3 +-- 5 files changed, 10 insertions(+), 8 deletions(-) (limited to 'supervisor') diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk index aa867c96f..bbc2a4a04 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk +++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.mk @@ -1,7 +1,7 @@ USB_VID = 0x239A USB_PID = 0x802A USB_PRODUCT = "STM32F411VE Discovery Board - CPy" -USB_MANUFACTURER = "Adafruit Industries LLC" +USB_MANUFACTURER = "STMicroelectronics" USB_REDUCED_ENDPOINT = 1 INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.c b/ports/stm32f4/common-hal/microcontroller/Processor.c index c59c340c0..7117945b3 100644 --- a/ports/stm32f4/common-hal/microcontroller/Processor.c +++ b/ports/stm32f4/common-hal/microcontroller/Processor.c @@ -28,17 +28,20 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" +#include "stm32f4xx_hal.h" + +#define STM32_UUID ((uint32_t *)0x1FFF7A10) float common_hal_mcu_processor_get_temperature(void) { return 0; } uint32_t common_hal_mcu_processor_get_frequency(void) { - return 64000000ul; + return SystemCoreClock; } void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { - for (int i=0; i<2; i++) { - ((uint32_t*) raw_id)[i] = 0; + for (int i=0; i<3; i++) { + ((uint32_t*) raw_id)[i] = STM32_UUID[i]; } } diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.h b/ports/stm32f4/common-hal/microcontroller/Processor.h index c3ca4efd5..311333e7d 100644 --- a/ports/stm32f4/common-hal/microcontroller/Processor.h +++ b/ports/stm32f4/common-hal/microcontroller/Processor.h @@ -27,7 +27,7 @@ #ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H #define MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H -#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8 +#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 12 #include "py/obj.h" diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk index 78c8e7630..3a8e6acc6 100644 --- a/ports/stm32f4/mpconfigport.mk +++ b/ports/stm32f4/mpconfigport.mk @@ -7,7 +7,7 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz INTERNAL_LIBM = 1 # Chip supplied serial number, in bytes -USB_SERIAL_NUMBER_LENGTH = 16 +USB_SERIAL_NUMBER_LENGTH = 24 # Longints can be implemented as mpz, as longlong, or not LONGINT_IMPL = MPZ diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index cfb39d4bb..b0880b1b6 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -34,7 +34,6 @@ #include "tusb.h" -#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8 // Serial number as hex characters. This writes directly to the USB // descriptor. @@ -43,7 +42,7 @@ extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2]; void load_serial_number(void) { // create serial number based on device unique id uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; - //common_hal_mcu_processor_get_uid(raw_id); + common_hal_mcu_processor_get_uid(raw_id); for (int i=0; i<2; i++) { ((uint32_t*) raw_id)[i] = 0; } -- cgit v1.2.3 From 1f42ce5f4000d630da5cb744c2a61a69a8d7a0e8 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 15 Aug 2019 17:45:40 -0400 Subject: QOL fixes, compatibility fixes, attribution --- ports/stm32f4/background.c | 3 +++ ports/stm32f4/common-hal/busio/I2C.c | 3 +++ ports/stm32f4/common-hal/busio/I2C.h | 1 + ports/stm32f4/common-hal/busio/SPI.c | 1 + .../stm32f4/common-hal/microcontroller/Processor.c | 1 + .../stm32f4/common-hal/microcontroller/__init__.c | 1 + ports/stm32f4/peripherals/stm32f4/gpio.h | 1 + .../stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c | 25 +++++++++++++++--- .../stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c | 30 ++++++++++++++-------- ports/stm32f4/supervisor/internal_flash.c | 9 ++++--- ports/stm32f4/supervisor/internal_flash.h | 1 + ports/stm32f4/supervisor/serial.c | 6 ++--- ports/stm32f4/supervisor/usb.c | 1 + supervisor/shared/usb/tusb_config.h | 2 -- 14 files changed, 62 insertions(+), 23 deletions(-) (limited to 'supervisor') diff --git a/ports/stm32f4/background.c b/ports/stm32f4/background.c index 9c4f3ab27..8e31efdc2 100644 --- a/ports/stm32f4/background.c +++ b/ports/stm32f4/background.c @@ -46,7 +46,10 @@ void run_background_tasks(void) { } running_background_tasks = true; filesystem_background(); + + #if USB_AVAILABLE usb_background(); + #endif #if CIRCUITPY_DISPLAYIO displayio_refresh_displays(); diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index 1babe33a1..019465ccc 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2016 Scott Shawcroft + * Copyright (c) 2019 Lucian Copeland 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 @@ -36,6 +37,8 @@ I2C_HandleTypeDef hi2c2; void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) { + //TODO: Rework this entire section to use LL, alongside MSP removal + hi2c2.Instance = I2C1; hi2c2.Init.ClockSpeed = 100000; hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2; diff --git a/ports/stm32f4/common-hal/busio/I2C.h b/ports/stm32f4/common-hal/busio/I2C.h index 9fe0258a1..5c801ab32 100644 --- a/ports/stm32f4/common-hal/busio/I2C.h +++ b/ports/stm32f4/common-hal/busio/I2C.h @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2016 Scott Shawcroft + * Copyright (c) 2019 Lucian Copeland 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 diff --git a/ports/stm32f4/common-hal/busio/SPI.c b/ports/stm32f4/common-hal/busio/SPI.c index 98faf7b3b..a33581b64 100644 --- a/ports/stm32f4/common-hal/busio/SPI.c +++ b/ports/stm32f4/common-hal/busio/SPI.c @@ -40,6 +40,7 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { } bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) { + return 0; } void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.c b/ports/stm32f4/common-hal/microcontroller/Processor.c index 7117945b3..c16bd3125 100644 --- a/ports/stm32f4/common-hal/microcontroller/Processor.c +++ b/ports/stm32f4/common-hal/microcontroller/Processor.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2017 Dan Halbert for Adafruit Industries + * Copyright (c) 2019 Lucian Copeland 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 diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c index 08f8f28f8..4cbd6d66f 100644 --- a/ports/stm32f4/common-hal/microcontroller/__init__.c +++ b/ports/stm32f4/common-hal/microcontroller/__init__.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2019 Lucian Copeland 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 diff --git a/ports/stm32f4/peripherals/stm32f4/gpio.h b/ports/stm32f4/peripherals/stm32f4/gpio.h index 251cdb814..34f89e792 100644 --- a/ports/stm32f4/peripherals/stm32f4/gpio.h +++ b/ports/stm32f4/peripherals/stm32f4/gpio.h @@ -25,3 +25,4 @@ */ void stm32f4_peripherals_gpio_init(void); +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state); diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c index a9ac97bae..3fd85c632 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c @@ -105,6 +105,7 @@ #define LD6_GPIO_Port GPIOD #include "stm32f4xx_hal.h" +#include "stm32f4/gpio.h" void stm32f4_peripherals_gpio_init(void) { //Enable all GPIO for now @@ -128,10 +129,26 @@ void stm32f4_peripherals_gpio_init(void) { HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); //Status LED chain - HAL_GPIO_WritePin(GPIOD, LD4_Pin, GPIO_PIN_RESET); //LED 1 - HAL_GPIO_WritePin(GPIOD, LD3_Pin, GPIO_PIN_SET); //LED 2 - HAL_GPIO_WritePin(GPIOD, LD5_Pin, GPIO_PIN_SET); //LED 3 - HAL_GPIO_WritePin(GPIOD, LD6_Pin, GPIO_PIN_SET); //LED 4 + stm32f4_peripherals_status_led(0,1); + stm32f4_peripherals_status_led(1,0); + stm32f4_peripherals_status_led(2,0); + stm32f4_peripherals_status_led(3,0); +} + +//LEDs are inverted on F411 DISCO +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { + switch(led) + { + case 0: HAL_GPIO_WritePin(GPIOD, LD4_Pin, (state ^ 1)); + break; + case 1: HAL_GPIO_WritePin(GPIOD, LD3_Pin, (state ^ 1)); + break; + case 2: HAL_GPIO_WritePin(GPIOD, LD5_Pin, (state ^ 1)); + break; + case 3: HAL_GPIO_WritePin(GPIOD, LD6_Pin, (state ^ 1)); + break; + default: break; + } } diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c index de783bafe..a22963a9c 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c @@ -178,6 +178,7 @@ */ #include "stm32f4xx_hal.h" +#include "stm32f4/gpio.h" void stm32f4_peripherals_gpio_init(void) { //Enable all GPIO for now @@ -202,17 +203,26 @@ void stm32f4_peripherals_gpio_init(void) { HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); //Status LED chain - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, GPIO_PIN_RESET); //LED 1 - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET); //LED 2 - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET); //LED 3 - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET); //LED 4 + stm32f4_peripherals_status_led(0,1); + stm32f4_peripherals_status_led(1,0); + stm32f4_peripherals_status_led(2,0); + stm32f4_peripherals_status_led(3,0); +} - //TBD, USB power - // GPIO_InitStruct.Pin = USB_OTGFS_PPWR_EN_Pin; - // GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; - // GPIO_InitStruct.Pull = GPIO_NOPULL; - // GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - // HAL_GPIO_Init(USB_OTGFS_PPWR_EN_GPIO_Port, &GPIO_InitStruct); +//LEDs are inverted on F411 DISCO +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { + switch(led) + { + case 0: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, (state ^ 1)); + break; + case 1: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, (state ^ 1)); + break; + case 2: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, (state ^ 1)); + break; + case 3: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, (state ^ 1)); + break; + default: break; + } } diff --git a/ports/stm32f4/supervisor/internal_flash.c b/ports/stm32f4/supervisor/internal_flash.c index 966b167d8..fd3241bd6 100644 --- a/ports/stm32f4/supervisor/internal_flash.c +++ b/ports/stm32f4/supervisor/internal_flash.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2019 Lucian Copeland 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 @@ -67,8 +68,8 @@ static uint8_t sector_copy[0x4000] __attribute__((aligned(4))); uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) { if (addr >= flash_layout[0].base_address) { uint32_t sector_index = 0; - for (int i = 0; i < MP_ARRAY_SIZE(flash_layout); ++i) { - for (int j = 0; j < flash_layout[i].sector_count; ++j) { + for (uint8_t i = 0; i < MP_ARRAY_SIZE(flash_layout); ++i) { + for (uint8_t j = 0; j < flash_layout[i].sector_count; ++j) { uint32_t sector_start_next = flash_layout[i].base_address + (j + 1) * flash_layout[i].sector_size; if (addr < sector_start_next) { @@ -112,7 +113,7 @@ static int32_t convert_block_to_flash_addr(uint32_t block) { } mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { - uint32_t src = convert_block_to_flash_addr(block); + int32_t src = convert_block_to_flash_addr(block); if (src == -1) { // bad block number return false; @@ -172,7 +173,7 @@ bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) { __HAL_FLASH_DATA_CACHE_ENABLE(); // reprogram the sector - for (int i = 0; i < sector_size; i++) { + for (uint32_t i = 0; i < sector_size; i++) { if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, sector_start_addr, (uint64_t)sector_copy[i]) != HAL_OK) { // error occurred during flash write HAL_FLASH_Lock(); // lock the flash diff --git a/ports/stm32f4/supervisor/internal_flash.h b/ports/stm32f4/supervisor/internal_flash.h index 83b35e03c..4575cf1d7 100644 --- a/ports/stm32f4/supervisor/internal_flash.h +++ b/ports/stm32f4/supervisor/internal_flash.h @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2019 Lucian Copeland 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 diff --git a/ports/stm32f4/supervisor/serial.c b/ports/stm32f4/supervisor/serial.c index 1532a8ae8..ce1366000 100644 --- a/ports/stm32f4/supervisor/serial.c +++ b/ports/stm32f4/supervisor/serial.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2017, 2018 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2019 Lucian Copeland 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 @@ -28,6 +29,7 @@ #include #include "supervisor/serial.h" #include "stm32f4xx_hal.h" +#include "stm32f4/gpio.h" UART_HandleTypeDef huart2; @@ -42,10 +44,8 @@ void serial_init(void) { huart2.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&huart2) == HAL_OK) { - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET); + stm32f4_peripherals_status_led(1,1); } - HAL_UART_Transmit(&huart2, (uint8_t*)"Serial On", 9, 2); - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET); } bool serial_connected(void) { diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c index 11885b3d9..4fa9045df 100644 --- a/ports/stm32f4/supervisor/usb.c +++ b/ports/stm32f4/supervisor/usb.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2018 hathach for Adafruit Industries + * Copyright (c) 2019 Lucian Copeland 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 diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index 2e85bc820..ad5825b6c 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -107,11 +107,9 @@ // USB RAM PLACEMENT //--------------------------------------------------------------------+ #define CFG_TUSB_ATTR_USBRAM - #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) - #ifdef __cplusplus } #endif -- cgit v1.2.3 From 7dbf1a8caaebf15a634930b1b3e7f3bdc559a180 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Thu, 15 Aug 2019 17:56:15 -0400 Subject: text fixes --- ports/stm32f4/supervisor/internal_flash.c | 2 +- supervisor/shared/usb/usb.c | 4 ---- supervisor/stub/internal_flash.c | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) (limited to 'supervisor') diff --git a/ports/stm32f4/supervisor/internal_flash.c b/ports/stm32f4/supervisor/internal_flash.c index fd3241bd6..953fa1439 100644 --- a/ports/stm32f4/supervisor/internal_flash.c +++ b/ports/stm32f4/supervisor/internal_flash.c @@ -1,4 +1,4 @@ -/*f +/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index b0880b1b6..0678a3a3f 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -34,7 +34,6 @@ #include "tusb.h" - // Serial number as hex characters. This writes directly to the USB // descriptor. extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2]; @@ -43,9 +42,6 @@ void load_serial_number(void) { // create serial number based on device unique id uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; common_hal_mcu_processor_get_uid(raw_id); - for (int i=0; i<2; i++) { - ((uint32_t*) raw_id)[i] = 0; - } static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; diff --git a/supervisor/stub/internal_flash.c b/supervisor/stub/internal_flash.c index 334281e77..eb1f4a106 100644 --- a/supervisor/stub/internal_flash.c +++ b/supervisor/stub/internal_flash.c @@ -1,4 +1,4 @@ -/*f +/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) -- cgit v1.2.3 From e490e6361fb695266d4ee46ca983cc86f17dafd5 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Sun, 18 Aug 2019 19:23:52 -0400 Subject: Add warnings, cosmetic fixes, remove vestigial modules --- .../boards/stm32f411ve_discovery/mpconfigboard.h | 4 +- .../boards/stm32f411ve_discovery/mpconfigboard.mk | 2 +- .../boards/stm32f412zg_discovery/mpconfigboard.h | 3 +- ports/stm32f4/common-hal/busio/SPI.c | 1 + ports/stm32f4/common-hal/busio/UART.c | 1 + .../stm32f4/common-hal/microcontroller/__init__.c | 10 --- ports/stm32f4/common-hal/nvm/ByteArray.c | 81 ---------------------- ports/stm32f4/common-hal/nvm/ByteArray.h | 36 ---------- ports/stm32f4/common-hal/nvm/__init__.c | 27 -------- ports/stm32f4/mpconfigport.mk | 11 +-- .../stm32f4/peripherals/stm32f4/stm32f411xe/pins.c | 3 - supervisor/supervisor.mk | 8 +-- tools/gen_usb_descriptor.py | 6 +- 13 files changed, 18 insertions(+), 175 deletions(-) delete mode 100644 ports/stm32f4/common-hal/nvm/ByteArray.c delete mode 100644 ports/stm32f4/common-hal/nvm/ByteArray.h delete mode 100644 ports/stm32f4/common-hal/nvm/__init__.c (limited to 'supervisor') diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h index 5513fe9f3..d5491fe36 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 bbc2a4a04..725a12cf6 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 416944257..0a89d9646 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 a33581b64..cde3e5372 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 32653ab8b..e1810b131 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 4cbd6d66f..efdecd264 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 ef70744ad..000000000 --- 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 ed00df9ff..000000000 --- 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 3cdc9d3a4..000000000 --- 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 6ac477c93..1d44feec9 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 fca1c1df2..0f773961d 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 4870f15d8..19516a30f 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 c23b413d2..6fb33a77a 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( -- cgit v1.2.3 From 479b047618416495be1505c111859e385c51be48 Mon Sep 17 00:00:00 2001 From: Hierophect Date: Wed, 4 Sep 2019 13:58:18 -0400 Subject: Reverted descriptor changes pending HID restructuring --- ports/stm32f4/common-hal/busio/I2C.c | 4 ++-- supervisor/supervisor.mk | 3 +-- tools/gen_usb_descriptor.py | 9 +++------ 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'supervisor') diff --git a/ports/stm32f4/common-hal/busio/I2C.c b/ports/stm32f4/common-hal/busio/I2C.c index 019465ccc..4d5675127 100644 --- a/ports/stm32f4/common-hal/busio/I2C.c +++ b/ports/stm32f4/common-hal/busio/I2C.c @@ -37,8 +37,8 @@ I2C_HandleTypeDef hi2c2; void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) { - //TODO: Rework this entire section to use LL, alongside MSP removal - + //TODO: Rework this entire section to use LL so we can properly assign pins + // This will also be bundled with MSP removal hi2c2.Instance = I2C1; hi2c2.Init.ClockSpeed = 100000; hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2; diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 19516a30f..0406dcf92 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -104,8 +104,7 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile --pid $(USB_PID)\ --serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\ --output_c_file $(BUILD)/autogen_usb_descriptor.c\ - --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h\ - --cdc_and_msc_only $(USB_CDC_AND_MSC_ONLY) + --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf" diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 6fb33a77a..10bbf5066 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -21,7 +21,6 @@ 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('--cdc_and_msc_only', nargs='?',const=0, type=int) args = parser.parse_args() @@ -132,7 +131,7 @@ msc_interfaces = [ bInterval=0), standard.EndpointDescriptor( description="MSC out", - bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_OUT, + bEndpointAddress=0x1 | standard.EndpointDescriptor.DIRECTION_OUT, bmAttributes=standard.EndpointDescriptor.TYPE_BULK, bInterval=0) ] @@ -277,16 +276,14 @@ 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.cdc_and_msc_only: - descriptor_list.append(audio_control_interface) +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 # HID report descriptor with the wrong interface number if the HID interface is not given # 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.cdc_and_msc_only: - descriptor_list.extend(hid_interfaces) +descriptor_list.extend(hid_interfaces) configuration = standard.ConfigurationDescriptor( description="Composite configuration", -- cgit v1.2.3