1.. _96b_carbon_board: 2 396Boards Carbon 4############### 5 6Overview 7******** 8 9The 96Boards is based on the STMicroelectronics STM32F401RET Cortex-M4 CPU and 10also contains a nRF51822 chip connected over SPI for BLE connectivity. 11 12The 96Boards Carbon board is built with two chips: an STMicroelectronics 13STM32F401RET Cortex-M4 CPU and an nRF51822 chip connected to 14the Cortex-M4 CPU over SPI for Bluetooth LE connectivity. Even though 15both chips exist on the same physical board, they must be programmed 16separately: 17 18- The ``96b_carbon/stm32f401xe`` configuration is used when developing programs for 19 the main chip on the board, the STM32F401RET. Users will likely want to 20 write applications targeting this chip, using the ``96b_carbon`` 21 configuration, since it is connected to all of the breakout 22 I/O headers. 23 24- The ``96b_carbon/nrf51822`` configuration should be used for programming 25 the secondary nRF51822 chip. Most users will likely not develop 26 applications for this chip, since Zephyr already provides a 27 sample application that can be flashed onto the nRF51822 28 to provide Bluetooth functionality to applications on the main 29 STM32F401RET chip. 30 31For instructions on how to set up the nRF51822 to develop Bluetooth 32applications, see :ref:`96b_carbon_nrf51_bluetooth`. 33 34After you have flashed your nRF51, you can perform basic validation 35of this Bluetooth setup using the instructions 36:ref:`below <96b_carbon_verify_bluetooth>`. 37 38.. figure:: img/96b_carbon.jpg 39 :align: center 40 :alt: 96Boards Carbon 41 42 96Boards Carbon 43 44Hardware 45******** 46 4796Boards Carbon provides the following hardware components: 48 49- STM32F401RET6 in LQFP64 package 50- ARM |reg| 32-bit Cortex |reg|-M4 CPU with FPU 51- 84 MHz max CPU frequency 52- VDD from 1.7 V to 3.6 V 53- 512 KB Flash 54- 96 KB SRAM 55- GPIO with external interrupt capability 56- 12-bit ADC with 16 channels 57- RTC 58- Advanced-control Timer 59- General Purpose Timers (7) 60- Watchdog Timers (2) 61- USART/UART (4) 62- I2C (3) 63- SPI (3) 64- SDIO 65- USB 2.0 OTG FS 66- DMA Controller 67- Bluetooth LE over SPI, provided by nRF51822 68 69More information about STM32F401RE can be found here: 70 - `STM32F401RE on www.st.com`_ 71 - `STM32F401 reference manual`_ 72 73Supported Features 74================== 75 76The Zephyr ``96b_carbon/stm32f401xe`` board configuration supports the following 77hardware features: 78 79+------------+------------+-------------------------------------+ 80| Interface | Controller | Driver/Component | 81+============+============+=====================================+ 82| NVIC | on-chip | nested vector interrupt controller | 83+------------+------------+-------------------------------------+ 84| SYSTICK | on-chip | system clock | 85+------------+------------+-------------------------------------+ 86| UART | on-chip | serial port | 87+------------+------------+-------------------------------------+ 88| GPIO | on-chip | gpio | 89+------------+------------+-------------------------------------+ 90| PINMUX | on-chip | pinmux | 91+------------+------------+-------------------------------------+ 92| FLASH | on-chip | flash | 93+------------+------------+-------------------------------------+ 94| SPI | on-chip | spi | 95+------------+------------+-------------------------------------+ 96| I2C | on-chip | i2c | 97+------------+------------+-------------------------------------+ 98| USB OTG FS | on-chip | USB device | 99+------------+------------+-------------------------------------+ 100 101More details about the board can be found at `96Boards website`_. 102 103The default configuration can be found in 104:zephyr_file:`boards/96boards/carbon/96b_carbon_stm32f401xe_defconfig` 105 106Connections and IOs 107=================== 108 109LED 110--- 111 112- LED1 / User1 LED = PD2 113- LED2 / User2 LED = PA15 114- LED3 / BT LED = PB5 115- LED4 / Power LED = VCC 116 117Push buttons 118------------ 119 120- BUTTON = BOOT0 (SW1) 121- BUTTON = RST 122 123External Connectors 124------------------- 125 126Low Speed Header 127 128+--------+-------------+----------------------+ 129| PIN # | Signal Name | STM32F401 Functions | 130+========+=============+======================+ 131| 1 | UART2_CTS | PA0 | 132+--------+-------------+----------------------+ 133| 3 | UART2_TX | PA2 | 134+--------+-------------+----------------------+ 135| 5 | UART2_RX | PA3 | 136+--------+-------------+----------------------+ 137| 7 | UART2_RTS | PA1 | 138+--------+-------------+----------------------+ 139| 9 | GND | GND | 140+--------+-------------+----------------------+ 141| 11 | USB5V | USB5V | 142+--------+-------------+----------------------+ 143| 13 | AIN12 | PC2 | 144+--------+-------------+----------------------+ 145| 15 | AIN14 | PC4 | 146+--------+-------------+----------------------+ 147| 17 | UART6_TX | PC6 | 148+--------+-------------+----------------------+ 149| 19 | GPIO | PC8 | 150+--------+-------------+----------------------+ 151| 21 | I2C1_SCL | PB6 | 152+--------+-------------+----------------------+ 153| 23 | I2C1_SCA | PB7 | 154+--------+-------------+----------------------+ 155| 25 | I2C2_SCA | PB3 | 156+--------+-------------+----------------------+ 157| 27 | I2C2_SCL | PB10 | 158+--------+-------------+----------------------+ 159| 29 | RST_BTN | RST_BTN | 160+--------+-------------+----------------------+ 161 162+--------+-------------+----------------------+ 163| PIN # | Signal Name | STM32F401 Functions | 164+========+=============+======================+ 165| 2 | SPI2_SS | PB12 | 166+--------+-------------+----------------------+ 167| 4 | SPI2_MOSI | PB15 | 168+--------+-------------+----------------------+ 169| 6 | SPI2_MISO | PB14 | 170+--------+-------------+----------------------+ 171| 8 | SPI2_SCK | PB13 | 172+--------+-------------+----------------------+ 173| 10 | GND | GND | 174+--------+-------------+----------------------+ 175| 12 | VCC2 | VCC2 | 176+--------+-------------+----------------------+ 177| 14 | AIN13 | PC3 | 178+--------+-------------+----------------------+ 179| 16 | AIN15 | PC5 | 180+--------+-------------+----------------------+ 181| 18 | UART6_RX | PC7 | 182+--------+-------------+----------------------+ 183| 20 | GPIO | PC9 | 184+--------+-------------+----------------------+ 185| 22 | I2C1_SCL | PB8 | 186+--------+-------------+----------------------+ 187| 24 | I2C1_SDA | PB9 | 188+--------+-------------+----------------------+ 189| 26 | AIN10 | PC0 | 190+--------+-------------+----------------------+ 191| 28 | AIN11 | PC1 | 192+--------+-------------+----------------------+ 193| 30 | NC | NC | 194+--------+-------------+----------------------+ 195 196More detailed information about the connectors can be found in 197`96Boards IE Specification`_. 198 199External Clock Sources 200---------------------- 201 202STM32F4 has two external oscillators. The frequency of the slow clock is 20332.768 kHz. The frequency of the main clock is 16 MHz. 204 205Serial Port 206----------- 207 20896Boards Carbon board has up to 4 U(S)ARTs. The Zephyr console output is 209assigned to USART1. Default settings are 115200 8N1. 210 211I2C 212--- 213 21496Boards Carbon board has up to 2 I2Cs. The default I2C mapping for Zephyr is: 215 216- I2C1_SCL : PB6 217- I2C1_SDA : PB7 218- I2C2_SCL : PB10 219- I2C2_SDA : PB3 220 221SPI 222--- 223 22496Boards Carbon board has up to 2 SPIs. SPI1 is used for Bluetooth communication 225over HCI. The default SPI mapping for Zephyr is: 226 227- SPI1_NSS : PA4 228- SPI1_SCK : PA5 229- SPI1_MISO : PA6 230- SPI1_MOSI : PA7 231- SPI2_NSS : PB12 232- SPI2_SCK : PB13 233- SPI2_MISO : PB14 234- SPI2_MOSI : PB15 235 236USB 237=== 238 23996Boards Carbon board has a USB OTG dual-role device (DRD) controller that 240supports both device and host functions through its mini "OTG" USB connector. 241Only USB device functions are supported in Zephyr at the moment. 242 243- USB_DM : PA11 244- USB_DP : PA12 245 246Programming and Debugging 247************************* 248 249There are 2 main entry points for flashing STM32F4X SoCs, one using the ROM 250bootloader, and another by using the SWD debug port (which requires additional 251hardware). Flashing using the ROM bootloader requires a special activation 252pattern, which can be triggered by using the BOOT0 pin. The ROM bootloader 253supports flashing via USB (DFU), UART, I2C and SPI. You can read more about 254how to enable and use the ROM bootloader by checking the application 255note `AN2606`_, page 109. 256 257Flashing 258======== 259 260Installing dfu-util 261------------------- 262 263It is recommended to use at least v0.8 of `dfu-util`_. The package available in 264debian/ubuntu can be quite old, so you might have to build dfu-util from source. 265 266Flashing an Application to 96Boards Carbon 267------------------------------------------ 268 269Connect the micro-USB cable to the USB OTG Carbon port and to your computer. 270The board should power ON. Force the board into DFU mode by keeping the BOOT0 271switch pressed while pressing and releasing the RST switch. 272 273Confirm that the board is in DFU mode: 274 275.. code-block:: console 276 277 $ sudo dfu-util -l 278 dfu-util 0.8 279 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. 280 Copyright 2010-2014 Tormod Volden and Stefan Schmidt 281 This program is Free Software and has ABSOLUTELY NO WARRANTY 282 Please report bugs to dfu-util@lists.gnumonks.org 283 Found DFU: [0483:df11] ver=2200, devnum=15, cfg=1, intf=0, alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3574364C3034" 284 Found DFU: [0483:df11] ver=2200, devnum=15, cfg=1, intf=0, alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3574364C3034" 285 Found DFU: [0483:df11] ver=2200, devnum=15, cfg=1, intf=0, alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3574364C3034" 286 Found DFU: [0483:df11] ver=2200, devnum=15, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,03*128Kg", serial="3574364C3034" 287 Found Runtime: [05ac:8290] ver=0104, devnum=2, cfg=1, intf=5, alt=0, name="UNKNOWN", serial="UNKNOWN" 288 289You should see following confirmation on your Linux host: 290 291.. code-block:: console 292 293 $ dmesg 294 usb 1-2.1: new full-speed USB device number 14 using xhci_hcd 295 usb 1-2.1: New USB device found, idVendor=0483, idProduct=df11 296 usb 1-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 297 usb 1-2.1: Product: STM32 BOOTLOADER 298 usb 1-2.1: Manufacturer: STMicroelectronics 299 usb 1-2.1: SerialNumber: 3574364C3034 300 301Then build and flash an application. Here is an example for the 302:zephyr:code-sample:`hello_world` application. 303 304.. zephyr-app-commands:: 305 :zephyr-app: samples/hello_world 306 :board: 96b_carbon/stm32f401xe 307 :goals: build flash 308 309Connect the micro-USB cable to the USB UART (FTDI) port and to your computer. 310Run your favorite terminal program to listen for output. 311 312.. code-block:: console 313 314 $ minicom -D <tty_device> -b 115200 315 316Replace :code:`<tty_device>` with the port where the board 96Boards Carbon 317can be found. For example, under Linux, :code:`/dev/ttyUSB0`. 318The ``-b`` option sets baud rate ignoring the value from config. 319 320Press the Reset button and you should see the following message in your 321terminal: 322 323.. code-block:: console 324 325 Hello World! arm 326 327.. _96b_carbon_verify_bluetooth: 328 329Verifying Bluetooth Functionality 330--------------------------------- 331 332This section contains instructions for verifying basic Bluetooth 333functionality on the board. For help on Zephyr applications 334in general, see :ref:`build_an_application`. 335 3361. Flash the nRF51 with the hci_spi sample application as described in 337 :ref:`96b_carbon_nrf51_bluetooth`. 338 339#. Install the dfu-util flashing app, as described above. 340 341#. Build and flash the ``samples/bluetooth/peripheral_hr`` application for 342 96b_carbon. See the instructions above for how to put your board 343 into DFU mode if you haven't done this before: 344 345 .. zephyr-app-commands:: 346 :zephyr-app: samples/bluetooth/peripheral_hr 347 :board: 96b_carbon/stm32f401xe 348 :goals: build flash 349 350#. Refer to the instructions in :zephyr:code-sample:`ble_peripheral_hr` for how 351 to verify functionality. 352 353Congratulations! Your 96Boards Carbon now has Bluetooth 354connectivity. Refer to :ref:`bluetooth` for additional information on 355further Bluetooth application development. 356 357Debugging 358========= 359 360The ``96b_carbon/stm32f401xe`` board can be debugged by installing a 100 mil (0.1 inch) header 361into the header at the bottom right hand side of the board, and 362attaching an SWD debugger to the 3V3 (3.3V), GND, CLK, DIO, and RST 363pins on that header. Then apply power to the 96Boards Carbon via one 364of its USB connectors. You can now attach your debugger to the 365STM32F401RET using an SWD scan. 366 367.. _dfu-util: 368 http://dfu-util.sourceforge.net/build.html 369 370.. _AN2606: 371 https://www.st.com/content/ccc/resource/technical/document/application_note/b9/9b/16/3a/12/1e/40/0c/CD00167594.pdf/files/CD00167594.pdf/jcr:content/translations/en.CD00167594.pdf 372 373.. _96Boards website: 374 http://www.96boards.org/documentation 375 376.. _STM32F401RE on www.st.com: 377 https://www.st.com/en/microcontrollers/stm32f401re.html 378 379.. _STM32F401 reference manual: 380 https://www.st.com/resource/en/reference_manual/dm00096844.pdf 381 382.. _96Boards IE Specification: 383 https://linaro.co/ie-specification 384