Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GrumpyOldPizza committed Mar 6, 2021
0 parents commit cb95f2c
Show file tree
Hide file tree
Showing 345 changed files with 226,232 additions and 0 deletions.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Arduino Core for STM32WB based boards

## What is it ?

ArduinoCore-stm32wb is targeted at ultra low power scenarios, sensor hubs, with BLE connectivity.


## Supported boards

### Tlera Corp
* [Firefly-STM32WB55CG](https://www.tindie.com/products/TleraCorp/firefly-stm32wb55-development-board)

### STMicroelectronics
* [NUCLEO-WB55RG](https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/stm32-nucleo-expansion-boards/p-nucleo-wb55.html)


## Installing

### Board Manager

1. [Download and install the Arduino IDE](https://www.arduino.cc/en/Main/Software) (at least version v1.6.13)
2. Start the Arduino IDE
3. Go into Preferences
4. Add ```https://grumpyoldpizza.github.io/ArduinoCore-stm32wb/package_stm32wb_boards_index.json``` as an "Additional Board Manager URL"
5. Open the Boards Manager from the Tools -> Board menu and install "Tlera Corp STM32WB Boards"
6. Select your STM32WB board from the Tools -> Board menu

#### OS Specific Setup

##### Linux

1. Go to ~/.arduino15/packages/grumpyoldpizza/hardware/stm32wb/```<VERSION>```/drivers/linux/
2. sudo cp *.rules /etc/udev/rules.d
3. reboot

##### Windows

###### STM32 BOOTLOADER driver setup for Tlera Corp boards

1. Go to ~/AppData/Local/Arduino15/packages/grumpypoldpizza/hardware/stm32wb/```<VERSION>```/drivers/windows
2. Right-click on ```STM32Bootloader.bat``` and select ```Run as administrator```

###### ST-LINK V2.1 driver setup for NUCLEO boards

1. Plugin NUCLEO board
2. Download and install [ST-Link USB Drivers](http://www.st.com/en/embedded-software/stsw-link009.html)

### From git (for core development)

1. Follow steps from Board Manager section above
2. ```cd <SKETCHBOOK>```, where ```<SKETCHBOOK>``` is your Arduino Sketch folder:
* OS X: ```~/Documents/Arduino```
* Linux: ```~/Arduino```
* Windows: ```~/Documents/Arduino```
3. Create a folder named ```hardware```, if it does not exist, and change directories to it
4. Clone this repo: ```git clone https://github.com/grumpyoldpizza/ArduinoCore-stm32wb.git TleraCorp/stm32wb```
5. Restart the Arduino IDE

## BLE / Wireless stack firmware installation

STM32WB uses encrypted/signed firmware images for the BLE stack. Please flash the ```FWUpdate``` sketch under the ```STM32WB``` examples before using BLE. The update will take up few seconds/minutes. During that time the LED will stay on, while the serial monitor will say disconnected. When done the LED will blink if the update was succesful, or simply be turned off if an error was encountered. The serial monitor should pop up again and report back the newly updated firmware versions. The ```FWInfo``` sketch can be used to verify what version is installed. At this time it should report back 1.10.0 for the BLE stack.

## Recovering from a faulty sketch for Tlera Corp Boards

Sometimes a faulty sketch can render the normal USB Serial based integration into the Arduindo IDE not working. In this case plugin the STM32WB board and toggle the RESET button while holding down the BOOT button and program a known to be working sketch to go ack to a working USB Serial setup.

## Credits

This core is based on the [Arduino SAMD Core](https://github.com/arduino/ArduinoCore-samd)

167 changes: 167 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
menu.usb=USB Type
menu.storage=Extenal Storage
menu.speed=CPU Speed

##############################################################

# Tlera Firefly
# ---------------------------------------
Firefly-WB55CG.name=Firefly-WB55CG
Firefly-WB55CG.vid.0=0x1209
Firefly-WB55CG.pid.0=0x6671

Firefly-WB55CG.build.f_cpu=64000000L
Firefly-WB55CG.build.board=STM32WB_FIREFLY
Firefly-WB55CG.build.arch=stm32wb
Firefly-WB55CG.build.core=arduino
Firefly-WB55CG.build.mcu=cortex-m4
Firefly-WB55CG.build.architecture=armv7e-m
Firefly-WB55CG.build.fpu=fpv4-sp-d16
Firefly-WB55CG.build.float-abi=hard
Firefly-WB55CG.build.vid=0x1209
Firefly-WB55CG.build.pid=0x6671
Firefly-WB55CG.build.did=0x0100
Firefly-WB55CG.build.usb_manufacturer="Tlera Corporation"
Firefly-WB55CG.build.usb_product="Firefly"
Firefly-WB55CG.build.extra_flags=-DSTM32WB55xx -fsingle-precision-constant "-D__SYSTEM_CORE_CLOCK__={build.f_cpu}" {build.usb_flags} {build.storage_flags}
Firefly-WB55CG.build.ldscript=STM32WB55xx_FLASH.ld
Firefly-WB55CG.build.openocdscript=openocd_scripts/firefly-wb55cg.cfg
Firefly-WB55CG.build.variant=Firefly-WB55CG
Firefly-WB55CG.build.variant_system_libs="-L{runtime.platform.path}/system/STM32WBxx/Lib" "-L{runtime.platform.path}/system/CMSIS/DSP/Lib" -lstm32wb55xx -larm_cortexM4lf_math
Firefly-WB55CG.build.variant_system_include="-I{runtime.platform.path}/system/CMSIS/Include" "-I{runtime.platform.path}/system/CMSIS/DSP/Include" "-I{runtime.platform.path}/system/CMSIS/Device/ST/STM32WBxx/Include" "-I{runtime.platform.path}/system/STM32WBxx/Include"

Firefly-WB55CG.upload.tool=dfu-util
Firefly-WB55CG.upload.protocol=dfu
Firefly-WB55CG.upload.address=0x08000000
Firefly-WB55CG.upload.interface=0
Firefly-WB55CG.upload.vid=0x1209
Firefly-WB55CG.upload.pid=0x6671
Firefly-WB55CG.upload.use_1200bps_touch=false
Firefly-WB55CG.upload.wait_for_upload_port=false
Firefly-WB55CG.upload.native_usb=true
Firefly-WB55CG.upload.maximum_size=786432
Firefly-WB55CG.upload.maximum_data_size=196608

Firefly-WB55CG.menu.usb.cdc=Serial
Firefly-WB55CG.menu.usb.cdc.build.usb_type=1
Firefly-WB55CG.menu.usb.cdc_msc=Serial + Mass Storage
Firefly-WB55CG.menu.usb.cdc_msc.build.usb_type=2
Firefly-WB55CG.menu.usb.none=No USB
Firefly-WB55CG.menu.usb.none.build.usb_type=0

Firefly-WB55CG.menu.storage.none=None
Firefly-WB55CG.menu.storage.none.build.storage_type=0
Firefly-WB55CG.menu.storage.sflash=SFLASH
Firefly-WB55CG.menu.storage.sflash.build.storage_type=1
Firefly-WB55CG.menu.storage.sdspi=SDCARD
Firefly-WB55CG.menu.storage.sdspi.build.storage_type=2

Firefly-WB55CG.menu.speed.64=64 MHz
Firefly-WB55CG.menu.speed.64.build.f_cpu=64000000L
Firefly-WB55CG.menu.speed.32=32 MHz
Firefly-WB55CG.menu.speed.32.build.f_cpu=32000000L
Firefly-WB55CG.menu.speed.16=16 MHz (No USB)
Firefly-WB55CG.menu.speed.16.build.f_cpu=16000000L
Firefly-WB55CG.menu.speed.2=2 MHz (No USB)
Firefly-WB55CG.menu.speed.2.build.f_cpu=2000000L

# ---------------------------------------
# Tlera Katydid
# ---------------------------------------
Katydid-WB55CG.name=Katydid-WB55CG
Katydid-WB55CG.vid.0=0x1209
Katydid-WB55CG.pid.0=0x6672

Katydid-WB55CG.build.f_cpu=64000000L
Katydid-WB55CG.build.board=STM32WB_KATYDID
Katydid-WB55CG.build.arch=stm32wb
Katydid-WB55CG.build.core=arduino
Katydid-WB55CG.build.mcu=cortex-m4
Katydid-WB55CG.build.architecture=armv7e-m
Katydid-WB55CG.build.fpu=fpv4-sp-d16
Katydid-WB55CG.build.float-abi=hard
Katydid-WB55CG.build.vid=0x1209
Katydid-WB55CG.build.pid=0x6672
Katydid-WB55CG.build.did=0x0100
Katydid-WB55CG.build.usb_manufacturer="Tlera Corporation"
Katydid-WB55CG.build.usb_product="Katydid"
Katydid-WB55CG.build.extra_flags=-DSTM32WB55xx -fsingle-precision-constant "-D__SYSTEM_CORE_CLOCK__={build.f_cpu}" {build.usb_flags}
Katydid-WB55CG.build.ldscript=STM32WB55xx_FLASH.ld
Katydid-WB55CG.build.openocdscript=openocd_scripts/firefly-wb55cg.cfg
Katydid-WB55CG.build.variant=Katydid-WB55CG
Katydid-WB55CG.build.variant_system_libs="-L{runtime.platform.path}/system/STM32WBxx/Lib" "-L{runtime.platform.path}/system/CMSIS/DSP/Lib" -lstm32wb55xx -larm_cortexM4lf_math
Katydid-WB55CG.build.variant_system_include="-I{runtime.platform.path}/system/CMSIS/Include" "-I{runtime.platform.path}/system/CMSIS/DSP/Include" "-I{runtime.platform.path}/system/CMSIS/Device/ST/STM32WBxx/Include" "-I{runtime.platform.path}/system/STM32WBxx/Include"

Katydid-WB55CG.upload.tool=dfu-util
Katydid-WB55CG.upload.protocol=dfu
Katydid-WB55CG.upload.address=0x08000000
Katydid-WB55CG.upload.interface=0
Katydid-WB55CG.upload.vid=0x1209
Katydid-WB55CG.upload.pid=0x6672
Katydid-WB55CG.upload.use_1200bps_touch=false
Katydid-WB55CG.upload.wait_for_upload_port=false
Katydid-WB55CG.upload.native_usb=true
Katydid-WB55CG.upload.maximum_size=786432
Katydid-WB55CG.upload.maximum_data_size=196608

Katydid-WB55CG.menu.usb.cdc=Serial
Katydid-WB55CG.menu.usb.cdc.build.usb_type=1
Katydid-WB55CG.menu.usb.cdc_msc=Serial + Mass Storage
Katydid-WB55CG.menu.usb.cdc_msc.build.usb_type=2
Katydid-WB55CG.menu.usb.none=No USB
Katydid-WB55CG.menu.usb.none.build.usb_type=0

Katydid-WB55CG.menu.speed.64=64 MHz
Katydid-WB55CG.menu.speed.64.build.f_cpu=64000000L
Katydid-WB55CG.menu.speed.32=32 MHz
Katydid-WB55CG.menu.speed.32.build.f_cpu=32000000L
Katydid-WB55CG.menu.speed.16=16 MHz (No USB)
Katydid-WB55CG.menu.speed.16.build.f_cpu=16000000L
Katydid-WB55CG.menu.speed.2=2 MHz (No USB)
Katydid-WB55CG.menu.speed.2.build.f_cpu=2000000L


# ST Nucleo
# ---------------------------------------
NUCLEO-WB55RG.name=NUCLEO-WB55RG
NUCLEO-WB55RG.vid.0=0x0483
NUCLEO-WB55RG.pid.0=0x374b

NUCLEO-WB55RG.build.f_cpu=64000000L
NUCLEO-WB55RG.build.board=STM32WB_NUCLEO
NUCLEO-WB55RG.build.arch=stm32wb
NUCLEO-WB55RG.build.core=arduino
NUCLEO-WB55RG.build.mcu=cortex-m4
NUCLEO-WB55RG.build.architecture=armv7e-m
NUCLEO-WB55RG.build.fpu=fpv4-sp-d16
NUCLEO-WB55RG.build.float-abi=hard
NUCLEO-WB55RG.build.extra_flags=-DSTM32WB55xx -fsingle-precision-constant "-D__SYSTEM_CORE_CLOCK__={build.f_cpu}" {build.storage_flags}
NUCLEO-WB55RG.build.ldscript=STM32WB55xx_FLASH.ld
NUCLEO-WB55RG.build.openocdscript=openocd_scripts/nucleo-wb55rg.cfg
NUCLEO-WB55RG.build.variant=NUCLEO-WB55RG
NUCLEO-WB55RG.build.variant_system_libs="-L{runtime.platform.path}/system/STM32WBxx/Lib" "-L{runtime.platform.path}/system/CMSIS/DSP/Lib" -lstm32wb55xx -larm_cortexM4lf_math
NUCLEO-WB55RG.build.variant_system_include="-I{runtime.platform.path}/system/CMSIS/Include" "-I{runtime.platform.path}/system/CMSIS/DSP/Include" "-I{runtime.platform.path}/system/CMSIS/Device/ST/STM32WBxx/Include" "-I{runtime.platform.path}/system/STM32WBxx/Include"

NUCLEO-WB55RG.upload.tool=openocd
NUCLEO-WB55RG.upload.protocol=stlink
NUCLEO-WB55RG.upload.use_1200bps_touch=false
NUCLEO-WB55RG.upload.wait_for_upload_port=false
NUCLEO-WB55RG.upload.native_usb=false
NUCLEO-WB55RG.upload.maximum_size=786432
NUCLEO-WB55RG.upload.maximum_data_size=196608

NUCLEO-WB55RG.menu.storage.none=None
NUCLEO-WB55RG.menu.storage.none.build.storage_type=0
NUCLEO-WB55RG.menu.storage.sflash=SFLASH
NUCLEO-WB55RG.menu.storage.sflash.build.storage_type=1
NUCLEO-WB55RG.menu.storage.sdspi=SDCARD
NUCLEO-WB55RG.menu.storage.sdspi.build.storage_type=2

NUCLEO-WB55RG.menu.speed.64=64 MHz
NUCLEO-WB55RG.menu.speed.64.build.f_cpu=64000000L
NUCLEO-WB55RG.menu.speed.32=32 MHz
NUCLEO-WB55RG.menu.speed.32.build.f_cpu=32000000L
NUCLEO-WB55RG.menu.speed.16=16 MHz (No USB)
NUCLEO-WB55RG.menu.speed.16.build.f_cpu=16000000L
NUCLEO-WB55RG.menu.speed.2=2 MHz (No USB)
NUCLEO-WB55RG.menu.speed.2.build.f_cpu=2000000L
127 changes: 127 additions & 0 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2014 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef Arduino_h
#define Arduino_h

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef bool boolean;
typedef uint8_t byte;
typedef uint16_t word;

// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
//
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "avr/io.h"

#include "binary.h"
#include "itoa.h"

#ifdef __cplusplus
extern "C"{
#endif // __cplusplus

#define ARM_MATH_CM4
#include "armv7m.h"
#include "stm32wbxx.h"
#undef STM32WB
#undef DAC1
#undef RTC
#undef SPI1
#undef SPI2
#undef SPI3

#include "wiring_constants.h"

#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )

void yield( void ) ;

/* system functions */
int main( void );
void init( void );

/* sketch */
void setup( void ) ;
void loop( void ) ;

#include "WVariant.h"

#ifdef __cplusplus
} // extern "C"
#endif

// The following headers are for C++ only compilation
#ifdef __cplusplus
#include "Callback.h"
#include "Tone.h"
#include "HardwareSerial.h"
#include "WCharacter.h"
#include "WMath.h"
#include "WString.h"
#endif
#include "delay.h"

// Include board variant
#include "variant.h"

#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "wiring_pulse.h"
#include "WInterrupts.h"

// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif // abs

#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

#define interrupts() __enable_irq()
#define noInterrupts() __disable_irq()

#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))

#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))

#define bit(b) (1UL << (b))

#endif // Arduino_h
Loading

0 comments on commit cb95f2c

Please sign in to comment.