Semihosting is a mechanism that enables code running on an ARM target to communicate and use the Input/Output facilities on a host computer that is running a debugger. Examples of these facilities include keyboard input, screen output, and disk I/O. For example, you can use this mechanism to enable functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host instead of having a screen and keyboard on the target system. This is useful because development hardware often does not have all the input and output facilities of the final system. Semihosting enables the host computer to provide these facilities. Semihosting is implemented by a set of defined software instructions, for example, SVCs, that generate exceptions from program control. The application invokes the appropriate semihosting call and the debug agent then handles the exception. The debug agent provides the required communication with the host. The semihosting interface is common across all debug agents provided by ARM. Semihosted operations work when you are debugging applications on your development platform, as shown in the following figure: In many cases, semihosting is invoked by code within library functions. The application can also invoke the semihosting operation directly. Note ARM processors prior to ARMv7 use the SVC instructions, formerly known as SWI instructions, to make semihosting calls. However, if you are compiling for an ARMv6-M or ARMv7-M, for example a Cortex-M1 or Cortex-M3 processor, semihosting is implemented using the BKPT instruction. Concepts The semihosting interface Can I change the semihosting operation numbers?. Using ARM C and C++ Libraries and Floating Point Support: The ARM C and C++ libraries. Reference Semihosting operations Debug agent interaction SVC...
包含 ARM 标签的文章
关于 gcc-arm-none-eabi 浮点数
Windows (mingw-w64-i686) hosted cross toolchains AArch32 bare-metal target (arm-none-eabi) https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads 使用 arm-none-eabi-gcc 交叉编译链只能编译 ARM 架构的裸机系统(包括 ARM Linux 的 boot、kernel,不适用编译 Linux 应用 Application) 有关浮点数: 查看 gcc 的默认 define: $ ./arm-none-eabi-gcc -x c - -E -dM </dev/null|grep SOFT #define __SOFTFP__ 1 -mfloat-abi=name Specifies which floating-point ABI to use. Permissible values are: ‘soft’,‘softfp’ and ‘hard’. ABI,application binary interface (ABI),应用程序 二进制接口。 softfp 与 hard 都使用硬件 FPU 指令,但使用软件接口。hard 则使用硬件接口。所以 soft 与 softfp 兼容,他们与 hard 不兼容。 当 -mfloat-abi=soft 时 会定义 #define __SOFTFP__ 1 当为 softfp 或 hard 时,不会定义 __SOFTFP__ 而 __VFP_FP__ 总是定义的(#define __VFP_FP__ 1),即使 -mfloat-abi=soft 时。 源码头文件有这样的定义: #elif defined ( __GNUC__ ) #if defined (__VFP_FP__) && !defined(__SOFTFP__) #if (__FPU_PRESENT == 1) #define __FPU_USED 1 #else #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0 #endif #else #define __FPU_USED 0 #endif 也就是说,在定义了 softfp 或 hard 时,当 __FPU_PRESENT 为 1 时,会定义 #define __FPU_USED 1,也就是要启用 FPU。__FPU_PRESENT 需要用户自己定义。 当使用 hard 或者 softfp 时,必须同时指定 FPU: -mfpu= option supports the following FPU types: vfp, vfpv3, vfpv3-fp16, vfpv3-d16, vfpv3-d16-fp16, vfpv3xd, vfpv3xd-fp16, neon, neon-fp16, vfpv4, vfpv4-d16, fpv4-sp-d16, neon-vfpv4, fp-armv8, neon-fp-armv8, and crypto-neon-fp-armv8. cortex-m4 选择:fpv4-sp-d...
ARM 开发板使用 NFS 挂载 Ubuntu 文件夹
采用 NFS 实现远程挂载,ARM 开发板可以直接运行主机上的程序,而不需要下载到开发板上。 1、查看开发板 Linux 内核是否支持 NFS 执行 cat /proc/filesystems, 若有一行为 nodev nfs 则开发板 Linux 内核支持 NFS,反之需要配置内核;也可以使用动态模块的形式编译。 2、主机安装 nfs 服务 sudo apt-get install nfs-kernel-server 配置 nfs 输出目录: vim /etc/exports 在该文件中添加一行: /home/user *(rw,sync,no_root_squash) # 根据实际情况修改 /home/user 为想要的路径就行了 * 表示任意 IP 地址的主机,如果是 192.168.1.100,就表示只允许 192.168.1.100 挂载。 rw: 可擦写的权限 ,ro: 只读的权限。 sync: 资料同步写入到内存与硬盘当中 ;async: 资料会先暂存于内存当中,而非直接写入硬盘。 no_root_squash:登入 NFS 主机使用分享目录的使用者,如果是 root 的话,那么对于这个分享的目录来说,他就具有 root 的权限!root_squash:在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被压缩成为匿名使用者,通常他的 UID 与 GID 都会变成 nobody 那个系统账号的身份。 主机启动NFS服务: sudo service nfs start # 或者 sudo service nfs-kernel-server restart 3、在开发板上挂载主机上的文件夹 mkdir /mnt/nfs mount -t nfs -o nolock 172.16.9.93:/home/matt /mnt/nfs 172.16.9.93 是主机 IP,/home/user/test 是主机共享目录,/mnt 表示将该共享目录挂载到 ARM 开发板 /mnt 目录下。 错误: mount: wrong fs type, bad option, bad superblock on... 解决方法: sudo apt-get install nfs-commo...
Cortex-M3 HardFault_Handler 调试心得
这几天在 MDK 下调试 STM32 在进入 HardFault_Handler 异常中端原因的问题上花费了不少周折 简单来说应该采取下面的查找思路: 1、进入 HardFault_Handler 后根据 LR 确定异常发生处所使用的栈指针是 MSP 还是 PSP 2、查看 PSP(假设是 PSP)的值,在 RAM 中找到 PSP 所指的区域 3、地址按从低到高的顺序分别存放了 R0,R1,R2,R3,R12,LR,PC,XPSR 的顺序找出 PC 的值 4、根据 PC 的值找到异常程序的位置 5、分析异常程序位置的 FLASH 及 RAM 访问相关方面是否有异常值,一般是 RAM 被异常修改导致从此处取到了错误的访问地址引起的。 在 HardFault_Handler 打断点,在 Call Stack + Locals 窗口查看调用顺序,在某个入口点右键执行 Show Caller Code 跳到响应程序的位置再仔细查看出错原因...
解决错误 modinfo can't open '...modules.dep' No such file or directory
在 ARM 开发板上查看模块信息提示题中的错误: modinfo: can't open '/lib/modules/3.2.0/modules.dep': No such file or directory 解决办法是: 1、创建文件夹:/lib/modules/$(uname -r) 2、cp xx.ko /lib/modules/3.2.0/ 3、depmod 4、mv /lib/modules/3.2.0/modules.dep.bb /lib/modules/3.2.0/modules.dep 5、modinfo xx.ko 这下就正常了 又发现: 其它模块不用重复这样做 为什么其它模块不需要这样做的?是不是只要有 modules.dep 这么一个文件名的文件存在于这里就可以来了? 再次发现: 在这里创建一个空文件就行了! touch modules.dep 那么,在 /lib/modules/3.2.0/ 中没有 ko 文件的时候,直接执行 depmod 命令是不是也可以产生空文件?答案是:是的,不过产生的是 modules.dep.bb 。为什么不直接产生 modules.dep 呢?还不清楚。有一点是可以肯定的,modinfo 使用前提是存在 modules.dep,空的就行,模块信息是从 ko 文件中获取的,跟 modules.dep 没关系。不过,为什么非要存在 modules.dep 文件呢?这也还不清楚。 我在 Ubuntu 18.04 中做了测试,内核版本是 4.15.0-36,执行 depmod 没有 modules.dep.bb 产生,直接产生 modules.dep,并且文件的内容格式与 3.2.0 中的也不一...
ARM DS-5(ARM Development Studio 5)
ARM DS-5 是 ARM 公司 2009 年推出的一款可扩展多功能,可调试裸板、Linux、Android 系统,支持所有 ARM 内核的软件开发工具。 自 2007 年 ARM 公司停止对 ADS 的维护更新后,ARM 在基于 eclipse 集成环境的基础上,相继推出了 RVDS(RealView Development Suite)和 DS-5 两款重量级开发软件。其中 DS-5 以同时集成 ARM Compiler 和 GCC 可轻松调试 Linux 系统而占优势。 ARM DS-5 开发工具链帮助工程师为 ARM 应用处理器(如 Cortex™-A 系列,Cortex-R 实时处理器和其他 ARM 嵌入式处理器)开发强大且高度优化的嵌入式软件 。 DS-5 工具链包括一流的 ARM C / C ++ 编译器,强大的 Linux / Android™/ RTOS 调试器,ARM Streamline™ 系统性能分析器和实时系统仿真模型, 所有这些都方便地封装在基于 Eclipse 的用户友好的集成开发环境(IDE)中。 DS-5 有三个不同的版本,它们是通过同一安装包进行许可证管理。 DS-5 Ultimate Edition 支持最新的 ARM 处理器和技术,如 ARMv8。 DS-5 专业版支持所有 ARM 处理器,包括 ARMv7,提供卓越的调试和跟踪功能以及 ARM 编译器。 DS-5 社区版是免费的,可以使用 DS-5 调试器和 Streamline 的有限功能集。功能包括裸机和 Linux 应用程序调试。 应用程序处理器支持: ARMv5: ARM926EJ-S ARMv6: ARM1136JF-S ARM1176JZ-S ARMv7: Cortex-A5 Cortex-A8 Cortex-A9 Cortex-A15 价格(20171108 Digi-Key): Ultimate 相比 Professional 多 ARMv8 processors、Compiler Safety Package Ultimate DS5UE-KD-40001 floating 1year 56,113.46HKD Ultimate DS5UE-KD-30001 node-locked 1year 44,635.76HKD Professional DS5PE-KD-40001 floating 1year 35,070.92HKD Professional DS5PE-KD-30001 node-locked 1year 28,056.77HKD Professional DS5PE-KD-40000 floating 永久 70,141.84HKD Professional DS5PE-KD-30000 node-locked 永久 56,113.46HKD 仿真器: DS-5 官方推荐的仿真器 DSTREAM,售价大约在 2 万 3 千人民币(201711)。 DS-5 vs MDK KEIL MDK-ARM 是用于满足开发者基于ARM7/9, ARM Cortex-M 处理器的开发需求,包括它自带的 RTX 实时操作系统和中间库,都是属于 MCU 应用领域的。 DS-5 是用于创建 Linux/Andriod 的复杂嵌入式系统应用和系统平台驱动接口,DS-5 支持设备添加,包括多核调试和支持,主要针对复杂的多核调试,片上系统开发而推出...
ARM 交叉编译工具链
交叉编译 交叉编译通俗地讲就是在一种平台上编译出能运行在体系结构不同的另一种平台上的程序,比如在 PC 平台(X86 CPU)上编译出能运行在以 ARM 为内核的 CPU 平台上的程序,编译得到的程序在 X86 CPU 平台上是不能运行的,必须放到 ARM CPU 平台上才能运行,虽然两个平台用的都是 Linux 系统。 交叉编译工具链是一个由编译器、连接器和解释器组成的综合开发环境,交叉编译工具链主要由 binutils、gcc 和 glibc 三个部分组成。有时出于减小 libc 库大小的考虑,也可以用别的 c 库来代替 glibc,例如 uClibc、dietlibc 和 newlib。建立交叉编译工具链是一个相当复杂的过程,如果不想自己经历复杂繁琐的编译过程,网上有一些编译好的可用的交叉编译工具链可以下载,但就以 学习为目的来说读者有必要学习自己制作一个交叉编译工具链(目前来看,对于初学者没有太大必要自己交叉编译一个工具链)。 分类和说明 从授权上,分为免费授权版和付费授权版。 免费版目前有三大主流工具商提供,第一是 GNU(提供源码,自行编译制作),第二是 Codesourcery,第三是 Linora。 arm-none-linux-gnueabi-gcc:是 Codesourcery 公司(目前已经被 Mentor 收购)基于 GCC 推出的的 ARM 交叉编译工具。可用于交叉编译 ARM(32位)系统中所有环节的代码,包括裸机程序、u-boot、Linux kernel、filesystem 和 App 应用程序。 arm-linux-gnueabihf-gcc:是由 Linaro 公司基于 GCC 推出的的 ARM 交叉编译工具。可用于交叉编译 ARM(32位)系统中所有环节的代码,包括裸机程序、u-boot、Linux kernel、filesystem 和 App 应用程序。 aarch64-linux-gnu-gcc:是由 Linaro 公司基于 GCC 推出的的 ARM 交叉编译工具。可用于交叉编译 ARMv8 64 位目标中的裸机程序、u-boot、Linux kernel、filesystem 和 App 应用程序。 arm-none-elf-gcc:是 Codesourcery 公司(目前已经被 Mentor 收购)基于 GCC 推出的的 ARM 交叉编译工具。可用于交叉编译ARM MCU(32位)芯片,如 ARM7、ARM9、Cortex-M/R 芯片程序。 arm-none-eabi-gcc:是 GNU 推出的的ARM交叉编译工具。可用于交叉编译 ARM MCU(32位)芯片,如 ARM7、ARM9、Cortex-M/R 芯片程序。 收费版有 ARM 原厂提供的 armcc、IAR 提供的编译器等等,因为这些价格都比较昂贵,不适合学习用户使用,所以不做讲...
编译用于在 Windows 系统下开发 ARM Linux 的 Qt 库
1、在 https://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/ 下载 Windows 版 ARM 交叉编译工具链。 Sourcery CodeBench Lite Edition Sourcery CodeBench Lite Edition is a free, unsupported version of Sourcery CodeBench, available for select processors. Sourcery CodeBench is a complete development environment for embedded C/C++ development. Sourcery CodeBench Lite Edition includes: GNU C and C++ compilers GNU assembler and linker C and C++ runtime libraries GNU debugger 我使用的是 arm-2014.05-29-arm-none-linux-gnuea...