Adding a board myself?

Discussions about the STM32generic core
Post Reply
oneselflost
Posts: 14
Joined: Mon Jul 24, 2017 2:32 am

Adding a board myself?

Post by oneselflost » Wed Sep 13, 2017 5:46 pm

Hello,

How difficult would it be for me to add a board to the STM32Generic core? I am looking to add the B-L475E-IOT01A IoT Discovery board.

Thank you,
E

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Adding a board myself?

Post by danieleff » Thu Sep 14, 2017 5:05 am

Here is the description on how to add a board: https://danieleff.github.io/STM32GENERIC/add_board/

The NUCLEO_L476RG is very similar to it.

oneselflost
Posts: 14
Joined: Mon Jul 24, 2017 2:32 am

Re: Adding a board myself?

Post by oneselflost » Fri Sep 15, 2017 1:38 am

That's wonderful, Daniel - thank you!

I think I got it all - but I am stuck on the third step of "Edit the variant.h file":

"If the board has pin name - pin number assigments (for example arduino headers), Copy the VARIANT_PIN_LIST_DEFAULT from system/STM32XX/stm32_chip/stm32_STM32XXXXXX.h file, rename to VARIANT_PIN_LIST, and rearrange accordingly."

Can you explain this a little more, please?

Which file are we editing the name of?

The list in \STM32\system\STM32L4\stm32_chip\stm32_STM32L475VG.h is:
#include "stm32_GPIO_variant_7.h"
#include "stm32_REMAP_variant_1.h"
#include "stm32_I2C_variant_8.h"
#include "stm32_LPUART_variant_5.h"
#include "stm32_SDIO_variant_1.h"
#include "stm32_SPI_variant_7.h"
#include "stm32_SWPMI_variant_3.h"
#include "stm32_TIM_variant_9.h"
#include "stm32_USART_variant_10.h"
#include "stm32_ADC_variant_4.h"
#include "stm32_FREQ_variant_1.h"

But I'm not quite sure what to do with it.

Currently Arduino throws error:
C:\Users\Erik\Documents\Arduino\hardware\STM32GENERIC-master\STM32\cores\arduino/stm32/stm32_pin_list.h:4:21: fatal error: variant.h: No such file or directory --- It is most definitely there :lol:

Thank you again,
Erik

oneselflost
Posts: 14
Joined: Mon Jul 24, 2017 2:32 am

Re: Adding a board myself?

Post by oneselflost » Fri Sep 15, 2017 3:58 am

Lesson learned - Name your board with underscores rather than dashes, it will find your variants file after!

So far everything is working now. A few more pin definitions will need to be added on my end, but that'll be for another day. I am going to bed haha

Thank you again!!

oneselflost
Posts: 14
Joined: Mon Jul 24, 2017 2:32 am

Re: Adding a board myself?

Post by oneselflost » Sat Sep 16, 2017 3:18 am

So far so good. LEDs work, button inputs work - life is good!

Serial communication though.. Any thoughts on UART1 support through the ST-LINK?

Sketches compile and flash, but stand still with no apparent attempt to communicate.

Do I need to add anything to the variants files to implement this? Edit any other files?


boards.txt entry is:

Code: Select all

DISCO_B_L475E_IOT01A.name=Discovery B-L475E-IOT01A
DISCO_B_L475E_IOT01A.upload.maximum_size=1048576
DISCO_B_L475E_IOT01A.upload.maximum_data_size=131072
DISCO_B_L475E_IOT01A.build.mcu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
DISCO_B_L475E_IOT01A.build.series=STM32L4
DISCO_B_L475E_IOT01A.build.variant=DISCO_B_L475E_IOT01A
DISCO_B_L475E_IOT01A.build.board=DISCO_B_L475E_IOT01A
DISCO_B_L475E_IOT01A.build.extra_flags=-DSTM32L475VG
DISCO_B_L475E_IOT01A.massstorage_drive=NODE_L475VG
DISCO_B_L475E_IOT01A.build.f_cpu=80000000L
DISCO_B_L475E_IOT01A.upload.protocol=STLink
DISCO_B_L475E_IOT01A.upload.tool=stlink_upload

DISCO_B_L475E_IOT01A.menu.serial.SerialUART1=SerialUART1 [Through ST-Link Virtual COM port] [PB7/PB6]
DISCO_B_L475E_IOT01A.menu.serial.SerialUART1.build.extra_flags_serial=-DMENU_SERIAL=SerialUART1
DISCO_B_L475E_IOT01A.menu.serial.SerialUSB=SerialUSB
DISCO_B_L475E_IOT01A.menu.serial.SerialUSB.build.extra_flags_serial=-DMENU_SERIAL=SerialUSB
Very basic arduino sketch:

Code: Select all

void setup() {
  SerialUART1.begin(115200); 
}

void loop() {
  SerialUART1.println(millis()); 
  delay(1000); 
}

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Adding a board myself?

Post by danieleff » Sat Sep 16, 2017 6:18 am

According to the UM2153 manual page 43, it is connected to PB6/PB7.

So try:

Code: Select all

void setup() {
  SerialUART1.stm32SetTX(PB6);
  SerialUART1.stm32SetRX(PB7);
  SerialUART1.begin(115200); 
}

void loop() {
  SerialUART1.println(millis()); 
  delay(1000); 
}
There is a way to put it into the variant.cpp, but first try this.

(BTW I would be happy to include it if you create a github pull request)

oneselflost
Posts: 14
Joined: Mon Jul 24, 2017 2:32 am

Re: Adding a board myself?

Post by oneselflost » Mon Sep 18, 2017 1:29 am

I knew what pins the UART was on, it was just setting them - now that I have a link to your documentation, I should get reading haha

That worked, setting the RX and TX - thank you.

I will create a github pull request as soon as I figure out how to haha

oneselflost
Posts: 14
Joined: Mon Jul 24, 2017 2:32 am

Re: Adding a board myself?

Post by oneselflost » Mon Sep 18, 2017 2:22 am

Alright... I created a Github account, forked the repository, added the variant folder, edited the boards.txt file, and created a pull request (ErikIoT/...).

Hopefully it all works - Please let me know if I need to fix anything or clean anything up.

Post Reply