如何开始为 ARM 处理器编写自己的移动操作系统? [英] How can I get started on writing my own mobile OS for ARM processors?

查看:16
本文介绍了如何开始为 ARM 处理器编写自己的移动操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣创建自己的移动操作系统.我读到现有的移动操作系统在 ARM 处理器上运行并使用它们的汇编语言,而像 Linux 和 Windows 这样的桌面操作系统是用 asm 编写的.C似乎是两者共同的语言.这让我想到了一些问题:

  • 如果我想构建自己的针对 ARM Cortex 处理器的移动操作系统,我是否必须学习 ARM 汇编语言?

如果是这样,那么一旦我开始这样做:

  • 在哪里/如何测试?它可以在虚拟机中运行吗?
  • 有像 Beagleboard 这样的开发板,但我不明白为什么如果我可以使用虚拟机,我还需要购买它们 - 我在这里遗漏了什么吗?
  • 一个操作系统能否同时在 x86 和 ARM 上运行?

我确定我想构建一个可以像大多数现有移动操作系统一样在 ARM 处理器上运行的移动操作系统.

  • 我的初始步骤应该是什么?查看 android 或任何其他操作系统等开源项目会有帮助吗?
  • 在哪里可以找到 ARM 汇编语言资源和 IDE?

解决方案

1) 所有平台都需要一些汇编,你可能需要一些启动代码来覆盖编程语言的假设,例如一个 C 编译器假设你有设置堆栈(指针),并将 .bss 内存清零,.data 在正确的位置等.取决于处理器,但通常,您可能需要一些用于中断处理的代码,也可能是任务切换等.

2) 是的,有很多虚拟机,qemu、skyeye 等.

3) 指令集模拟器或虚拟机等与处理器完全匹配的情况非常罕见.仅仅因为它适用于 vm/sim 并不意味着它可以工作.与在调试器中和在调试器外运行代码没有什么不同.您应该尝试不同的模拟器以及硬件来验证模拟器的质量.一个 arm 处理器到另一个或者一个 x86 到另一个可能变化很大,导致你的软件失败,所以即使在硬件上运行也不足以解决你所有的潜在错误.

4) linux 可以在很多平台上运行是吗?Netbsd 运行得更多,是吗?根据您设计程序的方式,它可以非常便携,也可以不便携,也可以介于两者之间.这取决于你.

5) 您需要一些操作系统基础知识.也许可以得到 MicroC/OS-II 的书或其他一些类似的材料.打通任务切换等基础

6) IDE 和编辑器等是一件非常私人的事情,一个人喜欢的人会被其他人厌恶.对于 ARM 开发,您需要获取 ARM ARM(ARM 架构参考手册).曾经是单个文档的内容由于它们有这么多不同的内核和系列而分裂了.最古老的 ARMv5 或 ARMv6 ARM 曾经是独一无二的.得到那个,你至少可以编写在整个 arm 内核系列中更具可移植性的代码.您将需要获得一些 TRM(技术参考手册).获取 ARM7TDMI (ARMv4T) 的一个,就像从英特尔获取 486 手册一样,几乎所有内容(32 位 arm 指令)都与该内核兼容.可能想为其他家庭获得 TRM.了解即使旧版本(例如 rev 1.0 (r1p0) 可能被标记为过时,如果有它的手册,ARM 已将其出售给某人并且它存在于某处的某些芯片中,您可能需要知道两者之间的区别)核心(如果您密切关注).诸如 pl310 L2 缓存之类的外设经常与某些内核相连,如果您有兴趣打开和使用缓存,您可能想知道其中的内容.嗯,arm7(ARMv4,不要与 ARMv7 混淆)没有 mmu,我认为 ARM9 有,所以根据你想如何管理应用程序及其内存,你可能想要使用 ARM9 或更新的东西作为基准.

获取基于 codesourcery lite gnu 的工具链.codesourcery 现在是导师图形的一部分.为 arm 构建自己的交叉编译器或获得其他一些(emdebian 等)并不难.ARM 制作了一个很好的编译器,但它很昂贵,而且大多数支持都是有代价的,当然有一些在线谷歌搜索寻求帮助,但大多数免费帮助是基于 gcc 的.llvm 编译器工具每天都在变得更好,据我所知,它们在 iPhone 上使用.我使用 llvm 的一部分的 clang 编译器.您不必开箱即用地构建交叉编译器,它们是从语言到中间到目标程序集的交叉编译器.汇编和链接针对主机,但您可以使用 gnu binutils 汇编器和链接器进行最后一步.

与 IDE/编辑器一样,您的编程风格和偏好可能会使您倾向于一种编译环境而不是另一种编译环境.

你可能会发现我在 github 上的 arm 示例有用与否,它们是低级的,板子上的示例.主要基于拇指,但在可能的情况下也有一些手臂.

I am interested in creating my own mobile OS. I read that the existing mobile OSes run on ARM processors and use their assembly language, while desktop OSes like Linux and Windows are written in asm. C appears to be a language common to both. This leads me to some questions:

  • Do I have to learn ARM assembly language if I want to build my own mobile OS targeting the ARM Cortex processor?

If so, then once I start doing it:

  • Where/how do I test it? Can it run in a virtual machine?
  • There are boards like Beagleboard, but I don't understand why I'd need to buy them if I can use a VM - am I missing something here?
  • Can a single OS run on both x86 and ARM?

I'm sure that I want to build a mobile OS which can run on ARM processors like most of the existing mobile OSes do.

  • What should my initial steps be? Will it help to look at open source projects like android or any other OS?
  • Where can I find ARM assembly language resources and IDEs?

解决方案

1) some assembly is required for all platforms, you probably need some startup code to cover the assumptions of the programming language, for example a C compiler assumes you have setup the stack (pointer), and zeroed out .bss memory, .data is in the right place, etc. Depending on the processor, but usually, you may need some code for interrupt handling, and maybe task switching, etc.

2) yes there are many virtual machines, qemu, skyeye, etc.

3) it is very rare that an instruction set simulator or virtual machine, etc exactly matches the processor. Just because it works on the vm/sim doesnt mean it works. No different than running code in a debugger and outside a debugger. You should try different simulators as well as hardware to verify the quality of the simulator. One arm processor to another or one x86 to another can vary enough to lead to your software failing so even running on hardware isnt enough to sort out all of your potential bugs.

4) linux runs on many platforms yes? Netbsd runs on even more, yes? Depending on how you design your program it can be very portable or not portable or anywhere in between. It is up to you.

5) You need some operating system basics. maybe get the MicroC/OS-II book or some other similar materials. Get through the basics of task switching, etc.

6) IDE's and editors, etc are a very personal thing, one persons favorite is loathed by others. For ARM development you need to get the ARM ARM (ARM Architectural Reference Manual). What used to be a single document has split due to them having so many different cores and families. What is the oldest looking one the ARMv5 or ARMv6 ARM is what used to be the singular one. Get that one and you can at least write code that is more portable across the whole family of arm cores. You will want to get some TRM's (Technical Reference Manuals). Get the one for the ARM7TDMI (ARMv4T), its like getting the 486 manual from intel, pretty much everything (32bit arm instructions) since is compatible back to that core. Probably want to get TRM's for other families. Understand that even though an older version for example a rev 1.0 (r1p0) might be marked as obsolete if there is a manual for it ARM has sold it to someone and it exists in some chips somewhere, and you might need to know the differences between cores (if you target that closely). Peripherals such as the pl310 L2 cache are often found attached to some cores, you will likely want to know what is in there if you have an interest in turning on and using the cache. Hmmm, the arm7 (ARMv4, not to be confused with the ARMv7) does not have an mmu, I think the ARM9 does, so depending on how you want to manage apps and their memory, you might want to use the ARM9 or something newer as a baseline.

get the codesourcery lite gnu based toolchain. codesourcery is now part of mentor graphics. It is not hard to build your own cross compiler for arm or get some other (emdebian, etc). ARM makes a good compiler but it is pricey and most support will come from them at a price, certainly some online googling for help but most free help is gcc based. the llvm compiler tools are getting better every day, they are used on iPhones from what I understand. I use the clang compiler which is part of llvm. You dont have to build a cross compiler necessarily out of the box they are a cross compiler from language to intermediate to target's assembly. assembling and linking is targeted to the host, but you can use the gnu binutils assembler and linker for that final step.

Like the IDE/editor, your programming style and preferences might lean you toward one compile environment over another.

You might find my arm examples on github useful or not, they are low level, board bring up type examples. Mostly thumb based but some arm as well where possible.

这篇关于如何开始为 ARM 处理器编写自己的移动操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆