Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: New developer getting started guide #19123

Merged
merged 1 commit into from
Nov 13, 2019
Merged

doc: New developer getting started guide #19123

merged 1 commit into from
Nov 13, 2019

Conversation

dbkinder
Copy link
Contributor

As presented to the TSC, Zephyr's out-of-box experience for new
developers is, well, complicated. A number of suggestions were
presented including simplifying the getting started material to present
a straight-forward path through the setup and installation steps through
to getting a sample application built, flashed, and running.

This PR is a work-in-progress towards addressing this OOB experience
with a minimal-distractions version of the GSG. Alternatives, warnings,
and material that could lead the developer astray were moved to
alternative/advanced instruction documents (based on the previous
separate Linux/macOS/Windows setup guides) and a new "Beyond the GSG"
document.

We do take advantage of a sphinx-tabs extension for synchronized tabs to
present OS-specific instructions: clicking on one tab will display all
same-named tabs throughout the doc.

We hope (and will continue evaluating) that this new GSG gets developers
set up quickly and then we can send them along to other documents to
continue learning about Zephyr and trying other sample apps.

Appreciate your feedback.

Signed-off-by: David B. Kinder [email protected]

@dbkinder dbkinder added area: Documentation area: DX Developer and User Experience labels Sep 12, 2019
@zephyrbot
Copy link
Collaborator

zephyrbot commented Sep 12, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

@dbkinder
Copy link
Contributor Author

dbkinder commented Sep 12, 2019

Take a look at the GSG page in the build artifacts for this PR to see the generated HTML, much easier than staring at the reST files :)

@dbkinder dbkinder added DNM This PR should not be merged (Do Not Merge) In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on labels Sep 12, 2019
Copy link
Contributor

@mbolivar mbolivar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is great work which obviously reflects a lot of serious research into how our documentation plays out in the real world. Thanks a lot for what I'm sure has been a dedicated and involved (and hopefully not entirely thankless) effort behind the scenes. I do have some initial feedback on the particulars, but I agree wholeheartedly with the general direction.

doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved

.. toctree::
:maxdepth: 2
#. Set environment variables:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that getting rid of this step would be useful for users? I have some patches I've been experimenting with to set up the toolchain via west configuration. I can resurrect them if you agree that'd be useful for 2.1. I personally have seen users stumble on not realizing that environment variable settings do not persist across shell sessions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exporting in the current shell is not enough. Either these need to be made persistent, or @mbolivar need to add more west magic as he just offered.

A link to https://docs.zephyrproject.org/latest/guides/env_vars.html wouldn't hurt.

Usual caveat https://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile/1452523#1452523

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been trying to address issues via documentation, but it would also be great to address them with tool changes or additions too.

doc/getting_started/index.rst Outdated Show resolved Hide resolved

You can run ``./build/zephyr/zephyr.exe --help`` to get a list of available
options.
sudo -E PATH=$PATH sh -c "west flash"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the goal here is to avoid having to teach the user about udev rules in case their user does not have permissions to write to the relevant device nodes involved in the flash process. But there are unintended consequences here which in my opinion make this advice a mistake.

In particular, west flash will regenerate the build artifacts if any of them are out of date before flashing, for consistency with the build system flash target. This has been the expected behavior in Zephyr since ancient (1.9 at least, IIRC) days.

But if you add sudo, the newly generated files can be owned by root. This makes future "west build" invocations used to do incremental builds afterwards fail due to permissions errors.

I think we cannot paper over the inherent complexity of device permissions on linux here, and ought to add information about necessary udev rules on supported platforms to the documentation as a troubleshooting step if this doesn't work.

Copy link
Collaborator

@marc-hb marc-hb Sep 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you add sudo, the newly generated files can be owned by root.

Building as root is a big no-no. Especially not after pip has downloaded a bunch of random packages from the Internet, half of them users don't need (I understand different users need the other half)

I think we cannot paper over the inherent complexity of device permissions on linux here, and ought to add information about necessary udev rules on supported platforms to the documentation as a troubleshooting step if this doesn't work.

Unfortunately agreed 100%. There's a lot that good automation and good documentation can achieve, but they can solve neither world hunger nor the complicated and fragmented state of udev security across Linux distributions. The best that can be done here is:

  1. Make sure Ubuntu 12.34 works
  2. For the 1000s of other Linux distributions, defer. Provide generic test instructions or even better: generic test code that prints: "You don't seem to have permission to access to /dev/whatever. Please check the udev part of the documentation of your Linux distribution"

BTW it would really be nice for chocolatey to run without the Adminstrator account. I digress.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand by the discussion from earlier. For whatever it's worth, flashing as root in the GSG is not OK with me.

If your flash tool installer doesn't set up udev rules properly, its installer is broken.

(Nordics' tools installed via .deb do take care of this properly, e.g.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really, really not OK with flashing as root. I don't like that this was marked resolved without any changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbolivar Do you have a counter proposal that would generically work for some set of supported boards? I'm trying to find a simple path for a new developer to get a first sample app running on a board. I tried saying using sudo is not the proper way, but we'll use it for this quick start. Let's talk offline and figure this out.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring the security disaster for a moment, a build directory that can't be cleaned because it has a random number of files owned by root is everything but new user friendly!

Do you have a counter proposal that would generically work for some set of supported boards?

A generic solution that works across a wide range of boards and Linux distros is probably impossible. On the other hand, a single udev rule that works reliably on one specific Ubuntu version for a reasonable number of boards shouldn't be rocket science.

Breaking news: security is rarely user-friendly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talking with the bug triage folks, they recommend removing the sudo and just do west flash and add a troubleshooting note about udev rules. As you mention, security isn't free.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talking with the bug triage folks, they recommend removing the sudo and just do west flash and add a troubleshooting note about udev rules. As you mention, security isn't free.

That's reasonable. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a build directory that can't be cleaned because it has a random number of files owned by root is everything but new user friendly!

^^ also, it's not just a security thing. This is also an issue.

Copy link
Member

@aescolar aescolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks David, just some thoughts after a quick look

.. tip::

Need help with something? See :ref:`help`.
#. **Set up a command-line development environment** for Linux*, macOS*, or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the "*" at the end of each OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not consistent about marking company trademarks in our documentation... :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just looks strange or broken right now, so I would either remove it or fix it

doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved

You can run ``./build/zephyr/zephyr.exe --help`` to get a list of available
options.
sudo -E PATH=$PATH sh -c "west flash"
Copy link
Collaborator

@marc-hb marc-hb Sep 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you add sudo, the newly generated files can be owned by root.

Building as root is a big no-no. Especially not after pip has downloaded a bunch of random packages from the Internet, half of them users don't need (I understand different users need the other half)

I think we cannot paper over the inherent complexity of device permissions on linux here, and ought to add information about necessary udev rules on supported platforms to the documentation as a troubleshooting step if this doesn't work.

Unfortunately agreed 100%. There's a lot that good automation and good documentation can achieve, but they can solve neither world hunger nor the complicated and fragmented state of udev security across Linux distributions. The best that can be done here is:

  1. Make sure Ubuntu 12.34 works
  2. For the 1000s of other Linux distributions, defer. Provide generic test instructions or even better: generic test code that prints: "You don't seem to have permission to access to /dev/whatever. Please check the udev part of the documentation of your Linux distribution"

BTW it would really be nice for chocolatey to run without the Adminstrator account. I digress.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an very thorough review due to lack of time, apologies for any miss or noise.

doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved

.. toctree::
:maxdepth: 2
#. Set environment variables:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exporting in the current shell is not enough. Either these need to be made persistent, or @mbolivar need to add more west magic as he just offered.

A link to https://docs.zephyrproject.org/latest/guides/env_vars.html wouldn't hurt.

Usual caveat https://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile/1452523#1452523


.. code-block:: console

pip3 install --user cmake
cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should really be a checksum here.... Is there a SDK issue filed for this already?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just add cmake to scripts/requirements.txt and get rid of this???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't make everyone else install an entirely separate cmake into ~/.local just because Ubuntu 18.04 and 18.10 have outdated versions.

doc/getting_started/index.rst Outdated Show resolved Hide resolved
cd ~
west init zephyrproject
cd zephyrproject
west update
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about the pip3 sequence above

@dbkinder
Copy link
Contributor Author

Thanks for the comments all. I'm waiting for some additional feedback from a usability test using this new GSG and will be sending an update.

@carlescufi carlescufi requested a review from ru-fu September 19, 2019 10:23
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty nice! But I think we need some changes to make this work properly.

doc/getting_started/installation_linux.rst Show resolved Hide resolved
doc/guides/beyond-GSG.rst Show resolved Hide resolved
doc/guides/beyond-GSG.rst Show resolved Hide resolved
.. tip::

Need help with something? See :ref:`help`.
#. **Set up a command-line development environment** for Linux*, macOS*, or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just looks strange or broken right now, so I would either remove it or fix it

doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
====================

Zephyr development depends on up-to-date releases of common build system
tools so first, make sure you're development system OS is updated:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your

doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/getting_started/index.rst Outdated Show resolved Hide resolved
doc/guides/beyond-GSG.rst Show resolved Hide resolved
doc/guides/beyond-GSG.rst Show resolved Hide resolved
Advanced Setup and tool chain alternatives
******************************************

Here are some alternative instructions for more advanced platform setup
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to decide what we want to have here - repetition of the GSG, alternative setups, or troubleshooting. Currently, it's a bit of a mix.


.. _gs_toolchain:

Set Up a Toolchain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a link to this section from the GSG, because you need to install one (unless you're on Linux and installed the SDK).

../getting_started/toolchain_host.rst
../getting_started/toolchain_custom_cmake.rst

Cloning the Zephyr Repositories
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of giving more detail in this guide than in the GSG, but it must be made clearer what is repetition and what is additional content. Also, we should have links from each section in the GSG to the "more information if you need it" section here.

@dbkinder
Copy link
Contributor Author

I've incorporated changes based on your comments and additional DX usability testing. Overall, this updated and simplified GSG approach has significantly improved the initial setup experience of Zephyr. When the SDK improvements are released we can submit a new PR to update these instructions with some further simplifications and time improvements, followed by more DX improvements over time.

@dbkinder dbkinder removed DNM This PR should not be merged (Do Not Merge) In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on labels Oct 30, 2019
@dbkinder dbkinder changed the title doc: WIP New developer getting started guide doc: New developer getting started guide Oct 30, 2019
@dbkinder
Copy link
Contributor Author

And you can view the build artifacts for this PR to see the generated HTML, much easier than staring at the reST files :)

@dbkinder dbkinder requested a review from MaureenHelm October 30, 2019 21:07
@dbkinder dbkinder dismissed mbolivar’s stale review November 11, 2019 21:36

we can remove any extra packages being installed after investigating this further.

@dbkinder
Copy link
Contributor Author

@mbolivar @nashif @andrewboie @ru-fu @carlescufi @aescolar @marc-hb I'm hoping this PR is close enough to get merged as an improvement to the existing GSG and we can continue with other DX improvements (and improvements to this documentation) in subsequent PRs...

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is pretty big and github is not able to show the difference force-pushed since a last review. I'm out, sorry.

Copy link
Contributor

@mbolivar mbolivar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 just from a quick check that sudo make flash is still there; haven't had time to look at the new batch of changes otherwise

@dleach02 dleach02 added the TSC Topics that need TSC discussion label Nov 12, 2019
@dleach02
Copy link
Member

@dbkinder , What if we consider a reference link to a new page on udev needs? We can then add the appropriate udev rules as they are identified for the various target boards. That would than remove the desire to have the sudo command for west flash

@andrewboie
Copy link
Contributor

Worth pointing out: if you clone the openocd-git repo:

git clone https://git.code.sf.net/p/openocd/code openocd-code

There's a file contrib/60-openocd.rules which at least for me has allowed me to flash every Zephyr supported board I have tried so far. There might not be support for every board, but at least it gets you pretty far:

$ cat contrib/60-openocd.rules 
# Copy this file to /etc/udev/rules.d/
# If rules fail to reload automatically, you can refresh udev rules
# with the command "udevadm control --reload"

ACTION!="add|change", GOTO="openocd_rules_end"
SUBSYSTEM!="usb|tty|hidraw", GOTO="openocd_rules_end"

# Please keep this list sorted by VID:PID

# opendous and estick
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="204f", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Original FT232/FT245 VID:PID
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Original FT2232 VID:PID
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Original FT4232 VID:PID
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Original FT232H VID:PID
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", MODE="660", GROUP="plugdev", TAG+="uaccess"

# DISTORTEC JTAG-lock-pick Tiny 2
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="8220", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TUMPA, TUMPA Lite
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="8a98", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="8a99", MODE="660", GROUP="plugdev", TAG+="uaccess"

# XDS100v2
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="a6d0", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Xverve Signalyzer Tool (DT-USB-ST), Signalyzer LITE (DT-USB-SLITE)
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bca0", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bca1", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TI/Luminary Stellaris Evaluation Board FTDI (several)
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bcd9", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TI/Luminary Stellaris In-Circuit Debug Interface FTDI (ICDI) Board
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bcda", MODE="660", GROUP="plugdev", TAG+="uaccess"

# egnite Turtelizer 2
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bdc8", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Section5 ICEbear
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="c140", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="c141", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Amontec JTAGkey and JTAGkey-tiny
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="cff8", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TI ICDI
ATTRS{idVendor}=="0451", ATTRS{idProduct}=="c32a", MODE="660", GROUP="plugdev", TAG+="uaccess"

# STMicroelectronics ST-LINK V1
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3744", MODE="660", GROUP="plugdev", TAG+="uaccess"

# STMicroelectronics ST-LINK/V2
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="660", GROUP="plugdev", TAG+="uaccess"

# STMicroelectronics ST-LINK/V2.1
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3752", MODE="660", GROUP="plugdev", TAG+="uaccess"

# STMicroelectronics STLINK-V3
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374d", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374f", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3753", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Cypress KitProg in KitProg mode
ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="f139", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Cypress KitProg in CMSIS-DAP mode
ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="f138", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Hilscher NXHX Boards
ATTRS{idVendor}=="0640", ATTRS{idProduct}=="0028", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Hitex STR9-comStick
ATTRS{idVendor}=="0640", ATTRS{idProduct}=="002c", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Hitex STM32-PerformanceStick
ATTRS{idVendor}=="0640", ATTRS{idProduct}=="002d", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Altera USB Blaster
ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6001", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Amontec JTAGkey-HiSpeed
ATTRS{idVendor}=="0fbb", ATTRS{idProduct}=="1000", MODE="660", GROUP="plugdev", TAG+="uaccess"

# SEGGER J-Link
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0101", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0102", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0103", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0104", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0105", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0107", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0108", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1010", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1011", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1012", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1013", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1014", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1016", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1017", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1018", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Raisonance RLink
ATTRS{idVendor}=="138e", ATTRS{idProduct}=="9000", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Debug Board for Neo1973
ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5118", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Olimex ARM-USB-OCD
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="0003", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Olimex ARM-USB-OCD-TINY
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="0004", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Olimex ARM-JTAG-EW
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="001e", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Olimex ARM-USB-OCD-TINY-H
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="002a", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Olimex ARM-USB-OCD-H
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="002b", MODE="660", GROUP="plugdev", TAG+="uaccess"

# USBprog with OpenOCD firmware
ATTRS{idVendor}=="1781", ATTRS{idProduct}=="0c63", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TI/Luminary Stellaris In-Circuit Debug Interface (ICDI) Board
ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TI XDS110 Debug Probe (Launchpads and Standalone)
ATTRS{idVendor}=="0451", ATTRS{idProduct}=="bef3", MODE="660", GROUP="plugdev", TAG+="uaccess"

# TI Tiva-based ICDI and XDS110 probes in DFU mode
ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00ff", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Ambiq Micro EVK and Debug boards.
ATTRS{idVendor}=="2aec", ATTRS{idProduct}=="6010", MODE="664", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="2aec", ATTRS{idProduct}=="6011", MODE="664", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="2aec", ATTRS{idProduct}=="1106", MODE="664", GROUP="plugdev", TAG+="uaccess"

# Marvell Sheevaplug
ATTRS{idVendor}=="9e88", ATTRS{idProduct}=="9e8f", MODE="660", GROUP="plugdev", TAG+="uaccess"

# Keil Software, Inc. ULink
ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2710", MODE="660", GROUP="plugdev", TAG+="uaccess"

# CMSIS-DAP compatible adapters
ATTRS{product}=="*CMSIS-DAP*", MODE="660", GROUP="plugdev", TAG+="uaccess"

LABEL="openocd_rules_end"

Ideally though, the documentation for every board contains information on the necessary udev string to get it going.

@dbkinder
Copy link
Contributor Author

Ideally though, the documentation for every board contains information on the necessary udev string to get it going.

Alas, a quick look shows that only 4 boards (out of over 200) mention udev rules in their documentation. Not sure I'm ready to submit PR(s) to touch all the board docs, so maybe indeed the notion of a udev troubleshooting section in the linux-specific doc is the answer. (And have west flash mention udev rules if it has trouble flashing.)

@marc-hb
Copy link
Collaborator

marc-hb commented Nov 12, 2019

so maybe indeed the notion of a udev troubleshooting section in the linux-specific doc is the answer.

For some strange reason, everyone on the internet and their dog recommends udevadm test to troubleshoot what udevd does. But udevadm test provides zero log or trace, it's only a simulator. Tentative fix: https://superuser.com/questions/677106/how-to-check-if-a-udev-rule-fired/1501568#1501568

@dbkinder
Copy link
Contributor Author

Flashing with sudo is out now, use of the openOCD udev rules file is in. @marc-hb sorry about the forced pushes hiding what changes were made. :(

Add the kitware repo corresponding to your Ubuntu release (use
``cat /etc/os-release`` to check):

- For Ubuntu Bionic Beaver (18.04) use:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbkinder Ubuntu 18.10 ships CMake 3.12, so these instructions won't work for that version of Ubuntu, and the user will still have an out of date CMake.

Ubuntu 19.04 (and thus all subsequent versions) ship a recent enough version.

To fix these instructions for 18.10, you could just add a generic reference to their download page:

https://cmake.org/download/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something here, but since CMake is available with pip, couldn't we just add cmake to scripts/requirements.txt and just standardize on that for every host OS?


sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'

- For Ubuntu Xeniel Xerus (16.04) use:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- For Ubuntu Xeniel Xerus (16.04) use:
- For Ubuntu Xenial Xerus (16.04) use:

@mbolivar
Copy link
Contributor

There's a file contrib/60-openocd.rules which at least for me has allowed me to flash every Zephyr supported board I have tried so far. There might not be support for every board, but at least it gets you pretty far:

There's an openocd rules file in the SDK, FWIW.

Installing that file into /etc/udev/rules.d only works if your user is in the plugdev group, of course. And then you have to reset the udev state machines or unplug/replug in your device.

Fiddling with udev rules is a very annoying rite of passage doing embedded development on Linux in my experience, unfortunately. I blame greg KH :).

@marc-hb
Copy link
Collaborator

marc-hb commented Nov 13, 2019

@marc-hb sorry about the forced pushes hiding what changes were made. :(

At the high risk of stating the obvious: this is a github limitation, nothing about you (or any other user) github's preferred review model is based on "fixup" commits and squash. So it's compatible with neither force pushes nor the review of a series of multiple commits. Off-topic sorry, in the unlikely urge to discuss further use #14444 or the #github-usage channel on Slack

Copy link
Contributor

@mbolivar mbolivar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for being willing to do extra work to help users troubleshoot udev rules, and for the awesome new GSG!

As presented to the TSC, Zephyr's out-of-box experience for new
developers is, well, complicated.  A number of suggestions were
presented including simplifying the getting started material to present
a straight-forward path through the setup and installation steps through
to getting a sample application built, flashed, and running.

This PR is a work-in-progress towards addressing this OOB experience
with a minimal-distractions version of the GSG. Alternatives, warnings,
and material that could lead the developer astray were moved to
alternative/advanced instruction documents (based on the previous
separate Linux/macOS/Windows setup guides) and a new "Beyond the GSG"
document.

We do take advantage of a sphinx-tabs extension for synchronized tabs to
present OS-specific instructions: clicking on one tab will display all
same-named tabs throughout the doc.

We hope (and will continue evaluating) that this new GSG gets developers
set up quickly and then we can send them along to other documents to
continue learning about Zephyr and trying other sample apps.

Thanks for all your previous feedback that I've worked
into this new version.

Signed-off-by: David B. Kinder <[email protected]>
@mbolivar
Copy link
Contributor

@dbkinder thanks for rounding up some of the discussion on udev rules into the force-push you just made. That wasn't necessary IMO, but I appreciate it!

This comment could eventually be added too, if you want to improve this further:

Installing that file into /etc/udev/rules.d only works if your user is in the plugdev group

According to https://wiki.ubuntu.com/Security/Privileges, only the first user added to an Ubuntu desktop system is a member of this group. So multi-user systems (admittedly very rare) could run into issues here.

@dbkinder
Copy link
Contributor Author

Thanks @mbolivar I think I'll save that for another update. Time to get this one merged :)

@mbolivar
Copy link
Contributor

Thanks @mbolivar I think I'll save that for another update. Time to get this one merged :)

Yep yep, not asking for a change, just making a note.

@andrewboie
Copy link
Contributor

something I think is worth pointing out: you can install a suitable cmake on Ubuntu using snap. This seems a lot simpler than the current instructions.

sudo snap install cmake

@dbkinder
Copy link
Contributor Author

@andrewboie It is listed as an alternative in the linux-specific detailed doc (https://builds.zephyrproject.org/zephyrproject-rtos/zephyr/19123/docs/getting_started/installation_linux.html#cmake) along with using pip :)

I can submit an update after this big and long-delayed PR gets merged...

@MaureenHelm MaureenHelm merged commit 3312147 into zephyrproject-rtos:master Nov 13, 2019
@dbkinder
Copy link
Contributor Author

something I think is worth pointing out: you can install a suitable cmake on Ubuntu using snap. This seems a lot simpler than the current instructions.

sudo snap install cmake

I gave it a try and needed to configure the snap proxy and use the --classic option

sudo snap set system proxy.http=...
sudo snap set system proxy.https=...
sudo snap install cmake --classic

Snap puts its binaries into /snap/bin so need to add that to the PATH (not unlike the problems users have with pip --user and not adding ~/.local/bin. Sigh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Documentation area: DX Developer and User Experience TSC Topics that need TSC discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.