|
| 1 | +.. _theCore_hello_world: |
| 2 | + |
| 3 | +Simple host hello world example |
| 4 | +------------------------------- |
| 5 | + |
| 6 | +:Location: https://github.com/theCore-embedded/example_hello_world |
| 7 | +:External HW: UART-to-USB converter for STM32F4Discovery board |
| 8 | + |
| 9 | +Supported targets (boards) |
| 10 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 11 | + |
| 12 | ++---------------------+--------------------------+-----------------------------------+ |
| 13 | +| Target name | Configuration file | Description | |
| 14 | ++=====================+==========================+===================================+ |
| 15 | +| host | host.json | Host target build | |
| 16 | ++---------------------+--------------------------+-----------------------------------+ |
| 17 | +| stm32f4_disc | stm32f4_discovery.json | STM32F4 discovery board | |
| 18 | ++---------------------+--------------------------+-----------------------------------+ |
| 19 | +| tiva_tm4c_launchpad | tiva_tm4c_launchpad.json | TM4C123G LaunchPad Evaluation Kit | |
| 20 | ++---------------------+--------------------------+-----------------------------------+ |
| 21 | + |
| 22 | +Wiring |
| 23 | +~~~~~~ |
| 24 | + |
| 25 | +* If you have Tiva TM4C Launchpad - simply connect it to the USB. |
| 26 | + |
| 27 | +* If you have STM32F4 Discovery board: |
| 28 | + |
| 29 | + #. Attach any preferable UART-to-USB |
| 30 | + converter module (`such as this`_) according to following pinout: |
| 31 | + |
| 32 | + +-------------------+-----------------+ |
| 33 | + | PD8 (USART3 TX) | module's RX | |
| 34 | + +-------------------+-----------------+ |
| 35 | + | PD9 (USART3 RX) | module's TX | |
| 36 | + +-------------------+-----------------+ |
| 37 | + | GND | module's GND | |
| 38 | + +-------------------+-----------------+ |
| 39 | + |
| 40 | + #. Connect your STM32 Discovery board to the PC. |
| 41 | + |
| 42 | +Preparing |
| 43 | +~~~~~~~~~ |
| 44 | + |
| 45 | +#. Install and initialize theCore (if not done previously):: |
| 46 | + |
| 47 | + pip3 install tcore |
| 48 | + tcore bootstrap |
| 49 | + |
| 50 | +#. Download the example:: |
| 51 | + |
| 52 | + tcore init --remote https://github.com/theCore-embedded/example_hello_world |
| 53 | + |
| 54 | +#. Step into the project directory:: |
| 55 | + |
| 56 | + cd example_hello_world |
| 57 | + |
| 58 | +Building |
| 59 | +~~~~~~~~ |
| 60 | + |
| 61 | +* For STM32 Discovery board:: |
| 62 | + |
| 63 | + tcore compile --target stm32f4_disc |
| 64 | + |
| 65 | +* For Tiva TM4C LaunchPad:: |
| 66 | + |
| 67 | + tcore compile --target tiva_tm4c_launchpad |
| 68 | + |
| 69 | +* For host:: |
| 70 | + |
| 71 | + tcore compile --target host |
| 72 | + |
| 73 | +Running |
| 74 | +~~~~~~~ |
| 75 | + |
| 76 | +#. If you wish to run the example on the embedded device, launch `minicom` |
| 77 | + with device associated with USB <-> UART converter. |
| 78 | + (``/dev/ttyUSB0`` here used as an example):: |
| 79 | + |
| 80 | + # From new terminal |
| 81 | + tcore runenv "minicom -D /dev/ttyUSB0" |
| 82 | + |
| 83 | + Or the same, but with superuser permissions:: |
| 84 | + |
| 85 | + # From new terminal |
| 86 | + tcore runenv --sudo "minicom -D /dev/ttyUSB0" |
| 87 | + |
| 88 | +#. Run: |
| 89 | + |
| 90 | + * On TivaC launchpad:: |
| 91 | + |
| 92 | + tcore --sudo flash |
| 93 | + |
| 94 | + * For old STM32F407G-DISC boards, with STLINK/V2:: |
| 95 | + |
| 96 | + tcore --sudo flash |
| 97 | + |
| 98 | + * For new STM32F407G-DISC1 boards, with STLINK/V2.1:: |
| 99 | + |
| 100 | + tcore --sudo flash --debugger-config stlink-v2.1 |
| 101 | + |
| 102 | + * For host target, execute:: |
| 103 | + |
| 104 | + ./build/host/hello_world |
| 105 | + |
| 106 | +Expected output |
| 107 | +~~~~~~~~~~~~~~~ |
| 108 | + |
| 109 | +Observe console output (either in current shell if running on host, or using |
| 110 | + minicom if running on the embedded device):: |
| 111 | + |
| 112 | + Welcome to theCore |
| 113 | + the_core v0.3.0.307 9ff344b-dirty |
| 114 | + Hello World! |
| 115 | + |
| 116 | + Starting delay demonstration... |
| 117 | + |
| 118 | + [--] Waiting for 2 seconds |
| 119 | + [--] Done waiting 2 seconds |
| 120 | + |
| 121 | + [----] Waiting for 4 seconds |
| 122 | + [----] Done waiting 4 seconds |
| 123 | + |
| 124 | + [--------] Waiting for 8 seconds |
| 125 | + [--------] Done waiting 8 seconds |
| 126 | + |
| 127 | +.. _such as this: http://www.geekfactory.mx/wp-content/uploads/2013/06/converdidor_usb_ttl_rs232_pl_2303hx_01.jpg |
0 commit comments