[异常解决] How to build a gcc toolchain for nRF51 on linux (very detailed!!!)

简介:


 

1、Install gcc-arm-none-eabi

https://devzone.nordicsemi.com/tutorials/7/ This link shows that development with GCC and Eclipse, As it say we should download 、extract and configure arm-none-eabi-gcc. But I find it's hard to download arm-none-eabi-gcc in China(You can chose XunLei to download). Besides I find a easy way to install it in Ubuntu-16.04 as following:

beautifulzzzz@lpc:~$ arm-none-eabi-gcc --version
The program 'arm-none-eabi-gcc' is currently not installed. You can install it by typing:
sudo apt install gcc-arm-none-eabi
beautifulzzzz@lpc:~$ sudo apt install gcc-arm-none-eabi

 

2、Download Nordic nRF5x SDK

Download the least nRF5x SDK from http://developer.nordicsemi.com/nRF5_SDK/ (the same to the arm-none-eabi-gcc, you can chose the XunLei to download) ,and then extract it in SDK-DIR(as you wish). The following shows the composition of SDK:

复制代码
beautifulzzzz@lpc:~/Documents/nRF5_SDK_12.2.0_f012efa$ tree -L 2
. ├── components │   ├── ant │   ├── ble │   ├── boards │   ├── device │   ├── drivers_ext │   ├── drivers_nrf │   ├── libraries │   ├── nfc │   ├── proprietary_rf │   ├── sdk_validation.h │   ├── serialization │   ├── softdevice │   └── toolchain ├── documentation │   ├── index.html │   ├── license.txt │   ├── NordicS.jpg │   ├── nRF5x_series_logo.png │   └── release_notes.txt ├── examples │   ├── ant │   ├── ble_central │   ├── ble_central_and_peripheral │   ├── ble_peripheral │   ├── crypto │   ├── dfu │   ├── dtm │   ├── multiprotocol │   ├── nfc │   ├── peripheral │   ├── proprietary_rf │   └── readme.txt ├── external │   ├── cifra_AES128-EAX │   ├── fatfs │   ├── freertos │   ├── licenses_external.txt │   ├── micro-ecc │   ├── nano-pb │   ├── nfc_adafruit_library │   ├── nrf_cc310 │   ├── protothreads │   ├── rtx │   ├── segger_rtt │   └── tiny-AES128 ├── licenses.txt ├── nRF5x_MDK_8_11_1_IAR.msi ├── nRF5x_MDK_8_11_1_Keil4.msi └── svd ├── nrf51.svd ├── nrf52840.svd └── nrf52.svd
复制代码

 

3、Before Use Makefile To Bulid nRF51 Project

To build an example in the SDK you first need to set the toolchain path in makefile.windows or makefile.posix depending on platform you are using. That is, the .posix should be edited if your are working on either Linux or OS X. These files are located in:

<SDK>/components/toolchain/gcc

Open the file in a text editor, and make sure that the GNU_INSTALL_ROOT variable is pointing to your Gnu tools for ARM embedded Processors install directory.

Correct values for my current setup(my arm-none-eabi-gcc install in /usr/bin):

GNU_INSTALL_ROOT :=/usr
GNU_VERSION := 4.9.3
GNU_PREFIX := arm-none-eabi

 

4、Use Makefile To Bulid nRF51 Project

Now you can try to build one of the example projects. Will use the blinky example here to keep it simple:

Open terminal and change directory to:

<SDK>/examples/peripheral/<board name>/blank/armgcc/

Type 'make'. GNU Make should start the build using the Makefile and output the result in the _build directory. If everything works you should get the output shown in the screenshot below. 

If you instead get an error saying something like "the sysem cannot find the files specified" it typically means that the GNU toolchain path is set incorrectly. Verify the path in makefile.windows/posix if you get this.

 

5、Install JLink-driver-for-linux

Refer to the blog: [异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议,downloading the corresponding version driver is ok. But I find that the older version driver(older then 5.12) cna't find!!!

Unfortunately my JLink version is 4.80. Finally, I find a Jlink-Linux-v480h-x64  in CSDN: http://download.csdn.net/download/u013903297/6990853 and I also upload it in: https://pan.baidu.com/s/1qXN2uOc. This file is not *.deb file, so we should install it as following:

beautifulzzzz@lpc:~/Downloads$ sudo cp JLink_Linux_V480h_x86_64.tgz /dev/bus
...
beautifulzzzz@lpc:/dev/bus$ sudo tar zxvf JLink_Linux_V480h_x86_64.tgz
beautifulzzzz@lpc:/dev/bus$ sudo rm JLink_Linux_V480h_x86_64.tgz 

Now plug the JLink device into the USB and then goto the install-path(here is /dev/bus/JLink_Linux_V480h_x86_64), type ./JLinkExe command, you will see(as following screenshot) a Contex-M0 device was fond and the target interface speed is 100khz. If could not find a device, please check whether the JLink device is inserted or the JLink driver version is correct.

 

6、Loadfile into nRf5x

Now you can use some JLink commands to erase、load、run、quit...

复制代码
/* Open Jlink Commander from terminal in _build directory */ 
JLinkExe  -device <nRF51/nRF52>
> erase // Optional: erase target if not already blank
> loadfile <name>.hex // loads FW
> r // Reset and halt
> g // Run
> q //  Exit
复制代码

If you get an error (Error: Programming failed @ address 0x00000000 (block verification error)) when tpye erase\loadfile command, you should write one and two to the memory at 4001E50C and 4001E504:(get this from: Getting started with nRF51 development on Mac OS X)

Afer erase whole chip, loading the file into nRF51 is simple—— For simplicity in this tutorial copy the softdevice (S110) .hex file to the _build folder of the Heart Rate Monitor example. The programming is performed from the _build folder:

复制代码
_build em$ JLinkExe -device nrf51822_xxaa -if swd -speed 4000
[...]
J-Link>loadbin s110_nrf51822_7.0.0_softdevice.bin 0
J-Link>loadbin ble_app_hrs_s110_xxaa.hex 0x16000
J-Link>r
J-Link>g
J-Link>exit
复制代码

Setting the correct device is crucial, and the speed setting is needed to make the programming fast enough. The softdevice is first programmed in the beginning (location 0) and the application is programmed immediately after (0x16000 for S110 v7.0). After the programming a reset is needed ('r' + 'g').

 

Next I will write use MakeFile to achieve automating tasks~



本文转自beautifulzzzz博客园博客,原文链接:http://www.cnblogs.com/zjutlitao/p/6238704.html,如需转载请自行联系原作者

相关文章
|
5月前
|
XML 缓存 Linux
在Linux环境下解决Visual Studio Code字体显示异常和字体替换方法。
解决Linux下VS Code字体显示异常,需要对Linux字体渲染机制有所理解,并对VS Code的配置选项进行合理设置。替换字体时则要通过系统字体配置或VS Code设置来完成。通过上述方法,可以有效地解决字体显示问题,从而提升代码编辑的视觉体验。
847 0
|
9月前
|
安全 Linux
阿里云linux服务器使用脚本通过安全组屏蔽异常海外访问ip
公网网站可能会遭受黑客攻击导致访问异常,使用此脚本可以屏蔽掉异常IP 恢复访问。也可自行设置定时任务定期检测屏蔽。
717 28
|
7月前
|
NoSQL Linux 开发工具
Linux环境基础开发工具的使用(yum、vim、gcc、g++、gdb、make/Makefile)
本文介绍了yum 包管理工具、Vim 编辑器、gcc/g++ 编译器、gdb 调试器、编译原理及 Makefile 的使用,同时还配备了如何使用,以及图解。旨在帮助读者更好地理解和应用这些工具与技术。
389 0
|
小程序 Linux 开发工具
【Linux】Linux 开发工具(vim、gcc/g++、make/Makefile)+【小程序:进度条】-- 详解
【Linux】Linux 开发工具(vim、gcc/g++、make/Makefile)+【小程序:进度条】-- 详解
|
Linux 开发工具 数据安全/隐私保护
linux异常一:feng 不在 sudoers 文件中,此事将被报告。yum提示Another app is currently holding the yum lock; waiting for
这篇文章介绍了在CentOS 7系统中安装Docker时遇到的两个常见问题及其解决方法:用户不在sudoers文件中导致权限不足,以及yum被锁定的问题。
275 2
linux异常一:feng 不在 sudoers 文件中,此事将被报告。yum提示Another app is currently holding the yum lock; waiting for
|
监控 Ubuntu Linux
使用VSCode通过SSH远程登录阿里云Linux服务器异常崩溃
通过 VSCode 的 Remote - SSH 插件远程连接阿里云 Ubuntu 22 服务器时,会因高 CPU 使用率导致连接断开。经排查发现,VSCode 连接根目录 ".." 时会频繁调用"rg"(ripgrep)进行文件搜索,导致 CPU 负载过高。解决方法是将连接目录改为"root"(或其他具体的路径),避免不必要的文件检索,从而恢复正常连接。
|
Linux 编译器 C语言
【Linux快速入门(一)】Linux与ROS学习之编译基础(gcc编译)
【Linux快速入门(一)】Linux与ROS学习之编译基础(gcc编译)
331 2
|
Linux C语言
成功解决 在Linux CentOS 7 中安装gcc
这篇文章介绍了如何在Linux CentOS 7系统中安装gcc (g++) 8工具集。由于CentOS 7默认的gcc版本是4.8,而这个版本与Qt 5.14、Qt 5.15或更高版本不兼容,可能会导致编译时出现系统头文件错误。文章中提到,即使在项目配置中添加了`CONFIG+=c++11`,如果仍然报错,那么很可能是gcc版本的问题。为了解决这个问题,文章提供了使用CentOS的Software Collections (scl)来安装更新版本的gcc的步骤。
成功解决 在Linux CentOS 7 中安装gcc
|
弹性计算 Linux 区块链
Linux系统CPU异常占用(minerd 、tplink等挖矿进程)
Linux系统CPU异常占用(minerd 、tplink等挖矿进程)
560 4
Linux系统CPU异常占用(minerd 、tplink等挖矿进程)
|
Linux 编译器 C语言
Linux内核对GCC版本的检测
Linux内核对GCC版本的检测