(Solved) STM32F765zg, can get even the simples usb test to work

Discussions about the STM32generic core
Post Reply
Spawn32
Posts: 9
Joined: Tue Nov 21, 2017 1:42 am
Location: Norway

(Solved) STM32F765zg, can get even the simples usb test to work

Post by Spawn32 » Tue Nov 21, 2017 2:58 am

Hi,
Got blink test running but can make my usb work at all, dosen show up on my computer, nothing :)
If i compile a test prog with the st's tools it work straight a way :/
Is there something spesial i need to do when compiling for the F7 under arduino stm32generic ?
have updated compiler version for F7 and get no errors...
This is the simple prog:

Code: Select all

void setup() {
// initialize digital pin LED_BUILTIN as an output.
SerialUSB.begin(9600); // Initialize Serial Monitor USB
while (!SerialUSB) ; // Wait for Serial monitor to open

// Send a welcome message to the serial monitor:
SerialUSB.println("Send character(s) to relay it over Serial");

pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second

SerialUSB.println("I am Alive :)");

digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
If i remove the while (!SerialUSB) ; // Wait for Serial monitor to open it starts it's led blink.

This is the board i added:
boards.txt

Code: Select all

################################################################################
# The Borg board

BORG_F765.name=The Borg

BORG_F765.upload.maximum_size=1048576
BORG_F765.upload.maximum_data_size=524288

BORG_F765.build.core=arduino
BORG_F765.build.board=BORG_F765

BORG_F765.build.mcu=cortex-m7 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
BORG_F765.build.series=STM32F7
BORG_F765.build.variant=BORG_F765
BORG_F765.build.extra_flags=-DSTM32F765ZG -DHSE_VALUE=12000000
BORG_F765.build.f_cpu=216000000L

BORG_F765.upload.protocol=STLink
BORG_F765.upload.tool=stlink_upload

BORG_F765.menu.upload_method.STLinkMethod=STLink
BORG_F765.menu.upload_method.STLinkMethod.upload.protocol=STLink
BORG_F765.menu.upload_method.STLinkMethod.upload.tool=stlink_upload

BORG_F765.menu.upload_method.serialMethod=Serial UART1 [TX/PA9, RX/PA10, BOOT0=1, BOOT1=0]
BORG_F765.menu.upload_method.serialMethod.upload.protocol=maple_serial
BORG_F765.menu.upload_method.serialMethod.upload.tool=serial_upload
BORG_F765.menu.upload_method.serialMethod.build.extra_flags_serial_auto=-DMENU_SERIAL_AUTO=SerialUART1

BORG_F765.menu.upload_method.DFUUploadMethod2=USB DFU - Custom bootloader (0x10000)
BORG_F765.menu.upload_method.DFUUploadMethod2.upload.protocol=pico_upload
BORG_F765.menu.upload_method.DFUUploadMethod2.upload.tool=pico_upload
BORG_F765.menu.upload_method.DFUUploadMethod2.build.extra_flags=-DSTM32F446VE -DVECT_TAB_OFFSET=0x10000 -DHSE_VALUE=12000000
BORG_F765.menu.upload_method.DFUUploadMethod2.build.ldscript=ldscript_bootloader_10000.ld
BORG_F765.menu.upload_method.DFUUploadMethod2.upload.usbID=0483:df11
BORG_F765.menu.upload_method.DFUUploadMethod2.upload.altID=2
BORG_F765.menu.upload_method.DFUUploadMethod2.upload.maximum_size=458752
BORG_F765.menu.upload_method.DFUUploadMethod2.upload.maximum_data_size=131072
BORG_F765.menu.upload_method.DFUUploadMethod2.build.extra_flags_serial_auto=-DMENU_SERIAL_AUTO=SerialUSB

BORG_F765.menu.usb.SerialUSB=Serial [Virtual COM port, PA11/PA12 pins]
BORG_F765.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL
BORG_F765.menu.usb.Disabled=Disabled, no USB

BORG_F765.menu.serial.Automatic=Automatically selected based on upload method
BORG_F765.menu.serial.SerialUSB=SerialUSB
BORG_F765.menu.serial.SerialUSB.build.extra_flags_serial=-DMENU_SERIAL=SerialUSB
BORG_F765.menu.serial.SerialUART1=SerialUART1
BORG_F765.menu.serial.SerialUART1.build.extra_flags_serial=-DMENU_SERIAL=SerialUART1


################################################################################
platform.h is the normal that follows STM32generic.

Variant.c includes the working clock setup from my st files:

Setup for 216mhz from a 12mhz crystal..

Code: Select all

#include "stm32_build_defines.h"
#include "stm32_def.h"


void SystemClock_Config(void)
{

RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

/**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 = 6;
RCC_OscInitStruct.PLL.PLLN = 216;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;

HAL_RCC_OscConfig(&RCC_OscInitStruct);

HAL_PWREx_EnableOverDrive();

/**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_DIV2;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);


PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_UART4
|RCC_PERIPHCLK_UART5|RCC_PERIPHCLK_I2C1
|RCC_PERIPHCLK_CLK48;
PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
PeriphClkInitStruct.Uart4ClockSelection = RCC_UART4CLKSOURCE_PCLK1;
PeriphClkInitStruct.Uart5ClockSelection = RCC_UART5CLKSOURCE_PCLK1;
PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLL;

HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);


/**Configure the Systick interrupt time 
*/
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

/**Configure the Systick 
*/
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
and here is the variant.h

Code: Select all

[code]ifndef VARIANT_H
#define VARIANT_H

#define LED_BUILTIN PA2

#define STM32_LED_BUILTIN_ACTIVE_HIGH

#define MOSI PE14
#define MISO PE13
#define SCK PE12
#define SS PA4

#define SDA PB9
#define SCL PB8

#define A0 PC3
#define A1 PC2
#define A2 PC1
#define A3 PC0
#define A4 PE3
#define A5 PE4

#define EEPROM_BLOCK_0_SECTOR 6
#define EEPROM_BLOCK_1_SECTOR 7
#define EEPROM_BLOCK_0_SIZE 128
#define EEPROM_BLOCK_1_SIZE 128

#define VARIANT_PIN_LIST \
PIN(A,0), \
PIN(A,1), \
PIN(A,2), \
PIN(A,3), \
PIN(A,4), \
PIN(A,5), \
PIN(A,6), \
PIN(A,7), \
PIN(A,8), \
PIN(A,9), \
PIN(A,10), \
PIN(A,11), \
PIN(A,12), \
PIN(A,13), \
PIN(A,14), \
PIN(A,15), \
PIN(B,0), \
PIN(B,1), \
PIN(B,2), \
PIN(B,3), \
PIN(B,4), \
PIN(B,5), \
PIN(B,6), \
PIN(B,7), \
PIN(B,8), \
PIN(B,9), \
PIN(B,10), \
PIN(B,11), \
PIN(B,12), \
PIN(B,13), \
PIN(B,14), \
PIN(B,15), \
PIN(C,0), \
PIN(C,1), \
PIN(C,2), \
PIN(C,3), \
PIN(C,4), \
PIN(C,5), \
PIN(C,6), \
PIN(C,7), \
PIN(C,8), \
PIN(C,9), \
PIN(C,10), \
PIN(C,11), \
PIN(C,12), \
PIN(C,13), \
PIN(C,14), \
PIN(C,15), \
PIN(D,0), \
PIN(D,1), \
PIN(D,2), \
PIN(D,3), \
PIN(D,4), \
PIN(D,5), \
PIN(D,6), \
PIN(D,7), \
PIN(D,8), \
PIN(D,9), \
PIN(D,10), \
PIN(D,11), \
PIN(D,12), \
PIN(D,13), \
PIN(D,14), \
PIN(D,15), \
PIN(E,0), \
PIN(E,1), \
PIN(E,2), \
PIN(E,3), \
PIN(E,4), \
PIN(E,5), \
PIN(E,6), \
PIN(E,7), \
PIN(E,8), \
PIN(E,9), \
PIN(E,10), \
PIN(E,11), \
PIN(E,12), \
PIN(E,13), \
PIN(E,14), \
PIN(E,15), \
PIN(H,0), \
PIN(H,1), \

#endif
Last edited by Spawn32 on Thu Nov 30, 2017 12:33 am, edited 2 times in total.
There is no " it can't be done" :)

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: STM32F765zg, can get even the simples usb test to work

Post by fpiSTM » Tue Nov 21, 2017 3:14 pm

In fact it related to daniel's core STM32GENERIC.
I will moved this post to the correct section.

Spawn32
Posts: 9
Joined: Tue Nov 21, 2017 1:42 am
Location: Norway

Re: (Solved) STM32F765zg, can get even the simples usb test to work

Post by Spawn32 » Tue Nov 21, 2017 7:11 pm

Fixed..
You need to replace the usbd_conf_F7.h in STM32GENERIC with one from the latest st cube_mx.
in line 308 of the new file, exchange _Error_Handler(__FILE__, __LINE__); to Error_Handler();

So now i have usb, nice :)
There is no " it can't be done" :)

Post Reply