Skip to content

Commit

Permalink
arduino zero blinky
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Jefferies committed Jan 13, 2018
1 parent 7ee8e54 commit 9c8542e
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 46 deletions.
1 change: 1 addition & 0 deletions docs/_static/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. role:: red
3 changes: 3 additions & 0 deletions docs/_static/css/restructuredtext.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.red {
color: red;
}
Binary file added docs/images/Arduino-M0Pro-flat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ArduinoZeroPro-flat-org.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Zero_Usb_Ports.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 18 additions & 8 deletions docs/themes/mynewt/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{%- set css_files = css_files + ['_static/css/bootstrap-3.0.3.min.css'] %}
{%- set css_files = css_files + ['_static/css/v2.css'] %}
{%- set css_files = css_files + ['_static/css/custom.css'] %}
{%- set css_files = css_files + ['_static/css/restructuredtext.css'] %}
{%- set css_files = css_files + ['_static/css/sphinx_theme.css'] %}
{%- set script_files = script_files + ['_static/js/bootstrap-3.0.3.min.js'] %}
{%- set script_files = script_files + ['_static/js/affix.js'] %}
Expand Down Expand Up @@ -78,14 +79,23 @@

{% if theme_google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ theme_google_analytics[0] }}', '{{ theme_google_analytics[1] }}');
ga('send', 'pageview');
</script>
(function(i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, "script", "//www.google-analytics.com/analytics.js", "ga");

ga("create", "{{ theme_google_analytics[0] }}", "{{ theme_google_analytics[1] }}");
ga("send", "pageview");
</script>
{% endif %}

</head>
Expand Down
126 changes: 93 additions & 33 deletions docs/tutorials/blinky/arduino_zero.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
Blinky, your "Hello World!", on Arduino Zero
--------------------------------------------

.. include common.rst
This tutorial shows you how to create, build and run the Blinky
application on an Arduino Zero board.

.. contents::
:local:
:depth: 2

Prerequisites
~~~~~~~~~~~~~

Expand All @@ -19,14 +25,28 @@ This tutorial uses the Arduino Zero Pro board. The tutorial has been
tested on the following three Arduino Zero boards - Zero, M0 Pro, and
Zero-Pro.

.. figure:: ../../images/Zero_Usb_Ports.jpg
:alt: Arduino Zero
:width: 200
:align: left

.. figure:: ../../images/Arduino-M0Pro-flat.jpg
:alt: Arduino M0 Pro
:width: 160
:align: left

.. figure:: ../../images/ArduinoZeroPro-flat-org.jpg
:alt: Arduino Zero Pro
:width: 160

Mynewt has not been tested on Arduino M0 which has no internal debugger
support.

Create a Project
~~~~~~~~~~~~~~~~

Create a new project if you do not have an existing one. You can skip
this step and proceed to `fetch external packages <#fetchexternal>`__ if
this step and proceed to `Fetch External Packages`_ if
you already created a project.

Run the following commands to create a new project:
Expand Down Expand Up @@ -65,23 +85,34 @@ to your project file are highlighted.
**Note:** On Windows platforms: You need to set ``vers`` to ``0-dev``
and use the latest master branch for both repositories.

\`\`\`hl\_lines="6 14 15 16 17 18" $ more project.yml project.name:
"my\_project"
.. code-block:: yaml
:emphasize-lines: 6,14-18
project.repositories: - apache-mynewt-core - mynewt\_arduino\_zero
# project.yml
project.name: "my_project"
repository.apache-mynewt-core: type: github vers: 1-latest user: apache
repo: mynewt-core
project.repositories:
- apache-mynewt-core
- mynewt_arduino_zero
repository.mynewt\_arduino\_zero: type: github vers: 1-latest user:
runtimeco repo: mynewt\_arduino\_zero $ \`\`\`
repository.apache-mynewt-core:
type: github
vers: 1-latest
user: apache
repo: mynewt-core
repository.mynewt_arduino_zero:
type: github
vers: 1-latest
user: runtimeco
repo: mynewt_arduino_zero
Install the project dependencies using the ``newt install`` command
(you can specify ``-v`` for verbose output):

.. code-block:: console
$ newt install
$ newt install
apache-mynewt-core
mynewt_arduino_zero
$
Expand All @@ -93,17 +124,18 @@ match the installed files. In that case you will get an error message
saying so and you will need to run ``newt upgrade`` to overwrite the
existing files with the latest codebase.

| You need to create two targets for the Arduino Zero Pro board, one
for the bootloader and one for the Blinky application.
| Run the following ``newt target`` commands, from your project
directory, to create a bootloader target. We name the target
``arduino_boot``.
You need to create two targets for the Arduino Zero Pro board, one
for the bootloader and one for the Blinky application.

Run the following ``newt target`` commands, from your project
directory, to create a bootloader target. We name the target
``arduino_boot``.

.. code-block:: console
$ newt target create arduino_boot
$ newt target set arduino_boot bsp=@mynewt_arduino_zero/hw/bsp/arduino_zero
$ newt target set arduino_boot app=@apache-mynewt-core/apps/boot
$ newt target create arduino_boot
$ newt target set arduino_boot bsp=@mynewt_arduino_zero/hw/bsp/arduino_zero
$ newt target set arduino_boot app=@apache-mynewt-core/apps/boot
$ newt target set arduino_boot build_profile=optimized
Target targets/arduino_boot successfully set target.build_profile to optimized
$ newt target set arduino_boot syscfg=BSP_ARDUINO_ZERO_PRO=1
Expand All @@ -130,21 +162,25 @@ These commands perform the following:
- Sets the system configuration setting for Board Support Package to
support the Arduino Zero Pro.

See the `Concepts <../get_started/vocabulary.html>`__ section for more
information on setting options. ###Create a Target for the Blinky
Application Run the following ``newt target`` commands to create the
See the :doc:`concepts` for more
information on setting options.

Create a Target for the Blinky Application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Run the following ``newt target`` commands to create the
Blinky application target. We name the application target
``arduino_blinky``.

.. code-block:: console
$ newt target create arduino_blinky
Target targets/arduino_blinky successfully created
$ newt target set arduino_blinky app=apps/blinky
$ newt target set arduino_blinky app=apps/blinky
Target targets/arduino_blinky successfully set target.app to apps/blinky
$ newt target set arduino_blinky bsp=@mynewt_arduino_zero/hw/bsp/arduino_zero
Target targets/arduino_blinky successfully set target.bsp to @mynewt_arduino_zero/hw/bsp/arduino_zero
$ newt target set arduino_blinky build_profile=debug
$ newt target set arduino_blinky build_profile=debug
Target targets/arduino_blinky successfully set target.build_profile to debug
$ newt target set arduino_blinky syscfg=BSP_ARDUINO_ZERO_PRO=1
Target targets/arduino_boot successfully set target.syscfg to BSP_ARDUINO_ZERO_PRO=1
Expand Down Expand Up @@ -209,8 +245,7 @@ application image:
Target successfully built: targets/arduino_blinky
Connect to the Board
~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~

Connect your computer to the Arduino Zero (from now on we'll call this
the target) with a Micro-USB cable through the Programming Port as shown
Expand All @@ -223,6 +258,16 @@ internal debugger that can be accessed by Mynewt.

The images below show the Arduino Zero Programming Port.

.. figure:: ../../images/Zero_Usb_Ports.jpg
:alt: Arduino Zero
:width: 280
:align: left

.. figure:: ../../images/ArduinoZeroPro-flat-org.jpg
:alt: Arduino Zero Pro
:width: 240


Load the Bootloader onto the Board
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -238,13 +283,12 @@ the board:
The bootloader is loaded onto your board succesfully when the
``newt load`` command returns to the command prompt after the
``Loading bootloader`` status message. You can proceed to load and run
your Blinky application image (See `Run the Blinky
Application <#runimage>`__).
your Blinky application image (See `Run the Blinky Application`_).

If the ``newt load`` command outputs the following error messages, you
will need to erase the board.

::
.. code-block:: console
$ newt load arduino_boot -v
Loading bootloader
Expand Down Expand Up @@ -277,11 +321,27 @@ when you quit gdb. In addition, the output of openocd is logged to the
openocd.log file in your project's base directory instead of the
terminal.

``hl_lines="2, 5, 14" $ newt debug arduino_blinky (gdb) mon at91samd chip-erase chip erased chip erased (gdb) x/32wx 0 0x0: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x10: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x20: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x30: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x40: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x50: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x60: 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x70: 0xffffffff 0xffffffff 0xffffffff 0xffffffff (gdb) q``
.. code-block:: console
$ newt debug arduino_blinky
(gdb) mon at91samd chip-erase
chip erased
chip erased
(gdb) x/32wx 0
0x0: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x10: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x20: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x30: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x40: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x50: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x60: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
0x70: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
(gdb) q
Run the ``newt load arduino_boot`` command again after erasing the
board.

Reminder if you are using Docker: When working with actual hardware,
:red:`Reminder if you are using Docker`: When working with actual hardware,
remember that each board has an ID. If you swap boards and do not
refresh the USB Device Filter on the VirtualBox UI, the ID might be
stale and the Docker instance may not be able to see the board
Expand All @@ -300,7 +360,7 @@ After you load the bootloader successfully onto your board, you can load
and run the Blinky application.

Run the ``newt run arduino_blinky 1.0.0`` command to build the
arduino\_blinky target (if necessary), create an image with version
arduino_blinky target (if necessary), create an image with version
1.0.0, load the image onto the board, and start a debugger session.

**Note** The output of the debug session below is for Mac OS and Linux
Expand Down Expand Up @@ -334,7 +394,7 @@ you quit gdb.
Info : SWD IDCODE 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
target state: halted
target halted due to debug-request, current mode: Thread
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x0000fca6 psp: 0x20002408
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
Expand All @@ -355,10 +415,10 @@ you quit gdb.
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
0x0000fca6 in os_tick_idle ()
target state: halted
target halted due to debug-request, current mode: Thread
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x000000b8 msp: 0x20008000
target state: halted
target halted due to debug-request, current mode: Thread
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x000000b8 msp: 0x20008000
(gdb) r
The "remote" target does not support "run". Try "help target" or "continue".
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/blinky/blinky.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Blinky, your "Hello World!" on a Target Board
=============================================
Project Blinky
==============

.. toctree::
:hidden:
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Prerequisites
know how to as explained in :doc:`../get_started/project_create`.
- You have at least one of the supported development boards:

- :doc:`blinky/arduino_zero`
- :doc:`blinky/olimex`
- :doc:`blinky/nRF52`
- :doc:`Arduino Zero <blinky/arduino_zero>`
- :doc:`Olimex <blinky/olimex>`
- :doc:`nRF52 <blinky/nRF52>`

The Nordic nrf52 developer kit supports Bluetooth Low Energy. We are
always looking to add new hardware to the list, so if you want to
Expand Down

0 comments on commit 9c8542e

Please sign in to comment.