This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to install nRF5x Command Line Tools on macOS?

Hello, I want to install nRF5x Command Line Tools on macOS, I found this user guide, infocenter.nordicsemi.com/.../nRF5x_Command_Line_Tools_v1.3.pdf and on page 5, it lists that: "On Linux and Mac OS X, extract the .tar archive anywhere on your filesystem. Define the path to the extracted directory to access the commands from anywhere in the command line." I know how to extract the .tar, but I don't know how to "define the path to the extracted directory to access the commands from anywhere in the command line." What does it mean? How can I do it?

Thanks.

Parents
  • Hey kren! I understand your confusion. I will see if someone in Nordic can update this pdf and include a few lines for how you can add the mergehex and nrfjprog commands to the path.

    The "define the path to the extracted directory to access the commands from anywhere in the command line." basically means that when you open a terminal on your Mac (i.e. press 'Command + Space' to open spotlight & then enter 'terminal' & press Enter), you are able to use the commands present in nrf5x command line tools (i.e. mergehex & nrfjprog). At present, you are unable to use these commands in your terminal instance because they have not been added to the path yet. You can try this out by opening a terminal instance and typing in mergehex. You will then get an error message saying that this command is not defined.

    How to add mergehex & nrfjprog to the path:

    What you need to do is extract the tar file to a location where you want the folder to be located. I chose the Desktop folder as an example. Then, you can open up a terminal instance (as mentioned above) & navigate to where you extracted the file. If you chose the Desktop, this would mean entering the cd command (i.e. stands for change directory): cd Desktop/nRF5x-Command-Line-Tools_9_7_1_OSX/mergehex/. You can press the Tab button to auto complete (i.e. you can type cd Desk + press Tab, this should then autocomplete and give you cd Desktop/). Your nrf5x command line tools folder might be worded slightly differently, depending on which version you downloaded. Make sure to stick with the wording on your Mac, not what I wrote here.

    Once you are in that folder, you can use the pwd command to find the path to the mergehex executable file. This should then give you something similar to this: /Users/your_username/Desktop/nRF5x-Command-Line-Tools_9_7_1_OSX/mergehex

    Then, you want to add the mergehex executable to the path. This can be done by typing this command into the Terminal instance: export PATH="executable_path_location:$PATH"

    where executable_path_location refers to /Users/your_username/Desktop/nRF5x-Command-Line-Tools_9_7_1_OSX/mergehex/. Remember to add the / at the end. Then, press Enter.

    Also remember to add the $PATH at the end of the command too. This is very important!

    If you then type the command echo $PATH into the terminal instance, you should get the executable_path_location as the output, along with other bin folders, etc.

    You can repeat the same process for the nrfjprog command, just by adding the nrfjprog folder (i.e. and thereby the nrfjprog executable) to the path instead of the mergehex executable.

    If successful, you should be able to enter the command mergehex into a Terminal instance & not receive an error, but instead it should output a list of all of the possible uses of the command. The same applies to the nrjprog command.

    That was a long answer! Hope that helps! Let me know if you figured it out or need more help. :)

Reply
  • Hey kren! I understand your confusion. I will see if someone in Nordic can update this pdf and include a few lines for how you can add the mergehex and nrfjprog commands to the path.

    The "define the path to the extracted directory to access the commands from anywhere in the command line." basically means that when you open a terminal on your Mac (i.e. press 'Command + Space' to open spotlight & then enter 'terminal' & press Enter), you are able to use the commands present in nrf5x command line tools (i.e. mergehex & nrfjprog). At present, you are unable to use these commands in your terminal instance because they have not been added to the path yet. You can try this out by opening a terminal instance and typing in mergehex. You will then get an error message saying that this command is not defined.

    How to add mergehex & nrfjprog to the path:

    What you need to do is extract the tar file to a location where you want the folder to be located. I chose the Desktop folder as an example. Then, you can open up a terminal instance (as mentioned above) & navigate to where you extracted the file. If you chose the Desktop, this would mean entering the cd command (i.e. stands for change directory): cd Desktop/nRF5x-Command-Line-Tools_9_7_1_OSX/mergehex/. You can press the Tab button to auto complete (i.e. you can type cd Desk + press Tab, this should then autocomplete and give you cd Desktop/). Your nrf5x command line tools folder might be worded slightly differently, depending on which version you downloaded. Make sure to stick with the wording on your Mac, not what I wrote here.

    Once you are in that folder, you can use the pwd command to find the path to the mergehex executable file. This should then give you something similar to this: /Users/your_username/Desktop/nRF5x-Command-Line-Tools_9_7_1_OSX/mergehex

    Then, you want to add the mergehex executable to the path. This can be done by typing this command into the Terminal instance: export PATH="executable_path_location:$PATH"

    where executable_path_location refers to /Users/your_username/Desktop/nRF5x-Command-Line-Tools_9_7_1_OSX/mergehex/. Remember to add the / at the end. Then, press Enter.

    Also remember to add the $PATH at the end of the command too. This is very important!

    If you then type the command echo $PATH into the terminal instance, you should get the executable_path_location as the output, along with other bin folders, etc.

    You can repeat the same process for the nrfjprog command, just by adding the nrfjprog folder (i.e. and thereby the nrfjprog executable) to the path instead of the mergehex executable.

    If successful, you should be able to enter the command mergehex into a Terminal instance & not receive an error, but instead it should output a list of all of the possible uses of the command. The same applies to the nrjprog command.

    That was a long answer! Hope that helps! Let me know if you figured it out or need more help. :)

Children
Related