将 newlib 移植到自定义 ARM 设置

发布于 2024-10-11 17:08:47 字数 1184 浏览 7 评论 0原文

这是我的第一篇文章,它涵盖了我一年来一直在努力工作的内容。

本质上它可以归结为以下几点:我有一份 newlib 的副本,我正试图在 LPC2388(NXP 的 ARM7TDMI)上使用它。这是在使用arm-elf-gcc的linux机器上

我的问题是我一直在看很多谈论移植newlib的教程,他们都谈论存根(比如退出,打开,读/写) ,sbrk),并且我非常清楚如何实现所有这些功能。但是我应该把它们放在哪里

我从sources.redhat.com/pub/newlib/newlib-1.18.0.tar.gz获得了newlib发行版,在浏览之后我发现了“syscalls.c”(在newlib-1.18.0/newlib/libc/sys/中) arm),其中包含我必须更新的所有存根,但它们都填充了看起来相当完整的代码(如果没有 crt0.S,它似乎无法工作,而 crt0.S 本身并不能工作)与我的芯片一起工作)。

我应该自己删除这些函数并重新编写它们吗?或者我应该把它们写在其他地方。我应该在 newlib/libc/sys 中使用我的“架构”名称创建一个全新的文件夹并更改目标以匹配吗?

我也很好奇在将其作为开源项目发布后是否有适当的礼仪来分发此类内容。我目前有一个脚本,可以下载 binutils、arm-elf-gcc、newlib 和 gdb,并编译它们。如果我正在修改 newlib 目录中的文件,我是否应该提交一个脚本自动应用的补丁?或者我应该将修改后的 newlib 添加到存储库中?

感谢您抽空阅读!接下来是我正在做的事情的更详细的分解。


对于那些想要/需要有关我的设置的更多信息的人:

我正在构建一个松散地基于 Uzebox 项目的 ARM 视频游戏控制台 ( http ://belogic.com/uzebox/)。

当我尝试找出答案时,我一直在利用许多不同的资源做各种各样的事情。您可以在这里阅读我的冒险之旅的开始(sparkfun 论坛,当我自己弄清楚时,没有人回应):forum.sparkfun.com/viewtopic.php?f=11&t=22072

我遵循了所有这些通读了 Stackoverflow 上有关移植 newlib 的问题,并看到了一些不同的教程(例如 wiki.osdev.org/Porting_Newlib ),但他们也告诉我实现存根而不提及何处、谁、什么、何时或如何!

this is my first post, and it covers something which I've been trying to get working on and off for about a year now.

Essentially it boils down to the following: I have a copy of newlib which I'm trying to get working on an LPC2388 (an ARM7TDMI from NXP). This is on a linux box using arm-elf-gcc

The question I have is that I've been looking at a lot of the tutorials talking about porting newlib, and they all talk about the stubs (like exit, open, read/write, sbrk), and I have a pretty good idea of how to implement all of these functions. But where should I put them?

I have the newlib distribution from sources.redhat.com/pub/newlib/newlib-1.18.0.tar.gz and after poking around I found "syscalls.c" (in newlib-1.18.0/newlib/libc/sys/arm) which contains all of the stubs which I have to update, but they're all filled in with rather finished looking code (which does NOT seem to work without the crt0.S, which itself does not work with my chip).

Should I just be wiping out those functions myself, and re-writing them? Or should I write them somewhere else. Should I make a whole new folder in newlib/libc/sys with the name of my "architecture" and change the target to match?

I'm also curious if there's proper etiquette on distribution of something like this after releasing it as an open source project. I currently have a script which downloads binutils, arm-elf-gcc, newlib, and gdb, and compiles them. If I am modifying files which are in the newlib directory, should I hand a patch which my script auto-applies? Or should I add the modified newlib to the repository?

Thanks for bothering to read! Following this is a more detailed breakdown of what I'm doing.


For those who want/need more info about my setup:

I'm building a ARM videogame console based loosely on the Uzebox project ( http://belogic.com/uzebox/ ).

I've been doing all sorts of things pulling from a lot of different resources as I try and figure it out. You can read about the start of my adventures here (sparkfun forums, no one responds as I figure it out on my own): forum.sparkfun.com/viewtopic.php?f=11&t=22072

I followed all of this by reading through the Stackoverflow questions about porting newlib and saw a few of the different tutorials (like wiki.osdev.org/Porting_Newlib ) but they also suffer from telling me to implements stubs without mentioning where, who, what, when, or how!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心作怪 2024-10-18 17:08:47

但是我应该把它们放在哪里呢?

您可以将它们放在您喜欢的位置,只要它们存在于最终链接中即可。您可以将它们合并到 libc 库本身中,或者您可以保持通用,并将系统调用作为单独的目标特定对象文件或库。

您可能需要创建自己的目标特定 crt0.s 并为您的目标组装和链接它。

Quantum Leaps 的 Miro Samek 提供了关于启动和运行 GNU/ARM 开发的优秀教程 这里。这些示例基于 Atmel AT91 部件,因此您需要了解一些有关 NXP 设备的信息才能适应启动代码。

此处提供了 LPC2xxx 的现成 Newlib 移植层,但这些文件的链接似乎已损坏。 Martin Thomas 的 WinARM 项目中使用了相同的移植层。这是 GNU ARM GCC 的 Windows 端口,但其中包含的示例是特定于目标的,而不是特定于主机的。

您应该只需要修改 Newlib 上的移植层,并且由于它是特定于目标和应用程序的,因此您不需要(实际上可能不应该)将代码提交到项目。

But where should I put them?

You can put them where you like, so long as they exist in the final link. You might incorporate them in the libc library itself, or you might keep that generic, and have the syscalls as a separate target specific object file or library.

You may need to create your own target specific crt0.s and assemble and link it for your target.

A good tutorial by Miro Samek of Quantum Leaps on getting GNU/ARM development up and running is available here. The examples are based on an Atmel AT91 part so you will need to know a little about your NXP device to adapt the start-up code.

A ready made Newlib porting layer for LPC2xxx was available here, but the links ot teh files appear to be broken. The same porting layer is used in Martin Thomas' WinARM project. This is a Windows port of GNU ARM GCC, but the examples included in it are target specific not host specific.

You should only need to modify the porting layer on Newlib, and since it is target and application specific, you need not (in fact probably should not) submit your code to the project.

回心转意 2024-10-18 17:08:47

当我使用 newlib 时,这正是我所做的,毁掉了 crt0.s、syscalls.c 和 libcfunc.c。我个人的偏好是根据嵌入式应用程序链接 crt0.s 和 syscalls.c 的替代品(将 libcfunc 中的几个函数滚动到 syscalls.c 替代品中)。

我从来没有兴趣将任何这些工作推回发行版,因此无法帮助您。

不过,您走在正确的道路上,crt0.S 和 syscalls.c 是您想要针对您的目标进行自定义的地方。就我个人而言,我对 C 库(和 printf)感兴趣,并且主要会中性所有函数以返回 0 或 1 或任何使函数正常工作而不妨碍链接的方法,定期使文件我/O 函数对 ROM/RAM 中的链接数据进行操作。基本上没有替换或修改 newlib 中的任何其他文件,我取得了相当大的成功,所以你走在正确的道路上。

When I was using newlib that is exactly what I did, blew away crt0.s, syscalls.c and libcfunc.c. My personal preference was to link in the replacement for crt0.s and syscalls.c (rolled the few functions in libcfunc into the syscalls.c replacement) based on the embedded application.

I never had an interest in pushing any of that work back into the distro, so cannot help you there.

You are on the right path though, crt0.S and syscalls.c are where you want to work to customize for your target. Personally I was interested in a C library (and printf) and would primarily neuter all of the functions to return 0 or 1 or whatever it took to get the function to just work and not get in the way of linking, periodically making the file I/O functions operate on linked in data in rom/ram. Basically without replacing or modifying any other files in newlib I had a fair amount of success, so you are on the right path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文