如何从微控制器转向嵌入式Linux?
作为与此问题相反的一种:“很低软件开发人员很难进行级别嵌入式系统编程” 我想寻求有关从低级嵌入式系统转向使用操作系统(尤其是嵌入式 Linux)的更高级系统编程的建议。
我主要使用小型微控制器硬件和软件,但现在只使用软件。 我的教育也主要是硬件和嵌入式的东西。 我没有上过很多编程课程,对软件设计或面向对象编码也不太了解。
现在我手里有一个大项目,将在嵌入式Linux中完成。 我在设计事物和保持事物可管理性方面遇到了重大问题,因为我以前并不真正需要这样做。 另外,利用多任务处理和阻塞调用而不是从主函数运行“并行”任务就像另一个世界。
从低级编程转向使用操作系统 (Linux) 的大型系统,您有哪些经验? 有什么困难,你是如何解决的? 需要什么样的心态?
从零开始学习 C++ 还是继续使用纯 C 值得吗?
As a kind of opposite to this question: "Is low-level embedded systems programming hard for software developers" I would like to ask for advice on moving from the low level embedded systems to programming for more advanced systems with OS, especially embedded Linux.
I have mostly worked with small microcontroller hardware and software, but now doing software only. My education also consists of hardware and embedded things mainly. I haven't had many programming courses and don't know much about software design or OO coding.
Now I have a big project in my hands that is going to be done in embedded Linux. I have major problems with designing things and keeping things manageable because I haven't really needed to do that before. Also making use of multitasking and blocking calls instead of running "parallel" task from main function is like another world.
What kind of experiences do you have on moving from low-level programming to bigger systems with OS (Linux)? What was hard and how did you solve it? What kind of mindset is needed?
Would it be worthwhile to learn C++ from zero or continue using plain C?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 Linux 内核替换微控制器系统的主要问题是驱动您所连接的设备。 为此,您可能必须编写驱动程序。 我会说坚持使用 C 作为语言,因为您希望保持用户空间尽可能干净。 查看 uclibc 库以获得更精简的 C 标准库。
http://www.uclibc.org/
您可能还会发现busybox很有用。 这以单个二进制文件的形式提供了许多用户空间实用程序。
http://www.busybox.net/
然后,只需从某个存储启动到实时存储即可系统并通过与硬件交互的 init 运行一些控制逻辑。 如果需要,您可以访问实时系统并运行 busybox 实用程序。 实际上,唯一的区别是用户空间比正态分布要精简得多,并且在目标方面您将“更接近”内核。
还要研究一下实时linux。
http://www.realtimelinuxfoundation.org/
如果您需要完成任务的正式承诺。 我怀疑最困难的部分是启动/持久存储以及与您的硬件的接口(如果它是奇特的)。 如果您不熟悉 Linux 启动,请
http://www.cromwell-intl.com /unix/linux-boot.html
可能有帮助。
简而言之,如果您没有深入了解 Linux,没有构建自己的发行版,或者没有内核经验,那么您可能会发现编程很困难。
http://www.linuxdevices.com/ 也可能有帮助
祝你好运
The main problems with using the Linux kernel to replace microcontroller systems is driving the devices you are interfacing with. For this you may have to write drivers. I would say stick with C as the language because you are going to want to keep the user-space as clean as possible. Look into the uclibc library for a leaner C standard library.
http://www.uclibc.org/
You may also find busybox useful. This provides many userspace utilities as a single binary.
http://www.busybox.net/
Then it is simply a matter of booting from some storage to a live system and running some controlling logic through init that interfaces with your hardware. If need be you can access the live system and run the busybox utilities. Really, the only difference is that the userspace is much leaner than in a normal distribution and you will be working 'closer' to the kernel in terms of objectives.
Also look into realtime linux.
http://www.realtimelinuxfoundation.org/
If you need some formal promise of task completion. I suspect the hardest bit will be booting/persistent storage and interfacing with your hardware if it is exotic. If you are unfamiliar with Linux booting then
http://www.cromwell-intl.com/unix/linux-boot.html
Might help.
In short, if you have not developed at a deep level for Linux, built your own distro, or have kernel experience then you might find the programming hard-going.
http://www.linuxdevices.com/ Might also help
Good Luck
为了使用 Unix/Linux,您应该了解 Unix 哲学: http:// www.faqs.org/docs/artu/ch01s06.html
我认为整本书读起来非常有趣:http://www.faqs.org/docs/artu/index.html
在这里您可以找到适用于嵌入式目标的免费 Linux 发行版以及引导加载程序以帮助您入门:http://www.denx.de/wiki/DULG/WebHome
In order to work with Unix/Linux you should get into the Unix philosophy: http://www.faqs.org/docs/artu/ch01s06.html
I consider the whole book a quite interesting read: http://www.faqs.org/docs/artu/index.html
Here you can find a free Linux distro for embedded targets plus bootloader to get you started: http://www.denx.de/wiki/DULG/WebHome
不久前我也遇到过类似的困境。 我购买并阅读了 嵌入式 Linux 入门,这是一种非常有用的方法向高级操作系统的心理过渡(从微控制器的角度来看)。
如果你有“时间‘慢慢来’”,你显然可以完成转变。 但如果您需要快速上手,您可能需要强烈考虑找一位技术导师来帮助指导您。
I was in a very similar predicament not too long ago. I bought and read Embedded Linux Primer and it was a very helpful way to make the mental-transition to a high level OS (from a microcontroller perspective).
If you have the "time to 'take your time'," you could obviously make the transition. But if you need to get up to speed quickly, you may want to strongly consider getting a technical mentor to help guide you.
您可能还会发现从 ucLinux 开始进入 Linux 很有用。 它基本上是微控制器上的 Linux。 您可以在没有虚拟内存方面作为过渡的情况下感受到内核。 查看 ucLinux 是否支持您已经熟悉的微控制器,并了解内核如何与该架构交互。
我同意《嵌入式 Linux 入门》一书非常适合让您了解嵌入式 Linux。 你现在最好还是坚持使用 C。 C++ 可以等待,它对应用程序更有用,而不是驱动程序代码。
当您熟悉 ucLinux 的运行方式后,您就可以从微处理器架构(例如具有 MMU 和虚拟内存的 ARM)上的普通 Linux 内核开始。
只是我的两分钱!
You also may find it useful to work your way into Linux by starting out with ucLinux. It's basically Linux on a microcontroller. You could get a feel for the kernel without the virtual memory aspect of it as transition. See if ucLinux supports a microcontroller that you are already familiar with and see how the kernel interacts with that architecture.
I agree that the Embedded Linux Primer book is great for getting your brain wrapped around embedded Linux. You're better off sticking with C for now. C++ can wait, and it's more useful for applications, not driver code.
When you're comfortable with how ucLinux operates, then you could start out with a normal Linux kernel on a microprocessor architecture such as ARM that has an MMU and virtual memory.
Just my two cents!