ARM board for beginner

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
galex
Posts: 3
Joined: Sun Feb 16, 2020 7:57 am
Libera.chat IRC: galex

ARM board for beginner

Post by galex »

Hi,

I'm started to playing the thought to develop a simple OS for an ARM board. I'm new to ARM (and OS dev in general) and couldn't find very good documentation to ARM boards. Some boards like BeagleBone AI have some more documentation then others. Raspberry PI seem to lag behind in docs but it have some as well (maybe due to its popularity).

My goal is to learn ARM assembly and write a modern(ish) 64bit OS with multiprocessor support, memory management, IPC, networking (TCP/IP), storage (FS on SSD or other storage), and maybe even some interactive terminal capability (but that's the least important)...

I'll try to write something that works on QEMU first, and then try to port it to a real-life board. The problem is that even the QEMU documentation is incomplete, and the real boards are even worse... Maybe the problem is in me but I can't really find too much about the so called "qemu 2.x" virtual board even in QEMU's own WiKi or user documentation...

What do you recommend? How to start? Is there any board out there that have a decent enough documentation for a hobby OS? (something that QEMU or any other free emulator supports would be nice)

Thanks
thewrongchristian
Member
Member
Posts: 426
Joined: Tue Apr 03, 2018 2:44 am

Re: ARM board for beginner

Post by thewrongchristian »

galex wrote:Hi,

I'm started to playing the thought to develop a simple OS for an ARM board. I'm new to ARM (and OS dev in general) and couldn't find very good documentation to ARM boards. Some boards like BeagleBone AI have some more documentation then others. Raspberry PI seem to lag behind in docs but it have some as well (maybe due to its popularity).

My goal is to learn ARM assembly and write a modern(ish) 64bit OS with multiprocessor support, memory management, IPC, networking (TCP/IP), storage (FS on SSD or other storage), and maybe even some interactive terminal capability (but that's the least important)...

I'll try to write something that works on QEMU first, and then try to port it to a real-life board. The problem is that even the QEMU documentation is incomplete, and the real boards are even worse... Maybe the problem is in me but I can't really find too much about the so called "qemu 2.x" virtual board even in QEMU's own WiKi or user documentation...

What do you recommend? How to start? Is there any board out there that have a decent enough documentation for a hobby OS? (something that QEMU or any other free emulator supports would be nice)

Thanks
I'd recommend at least looking at:

https://wiki.osdev.org/Raspberry_Pi

Referenced there is this:

https://github.com/bztsrc/raspi3-tutorial

Which sounds like it'd provide the hardware info you need to get going, and can work in qemu as well as bare metal (disclaimer, I've not tried this tutorial.)

Raspberry Pi is ideal because it's nigh on impossible to brick the hardware, so whatever mistakes you make in programming it can be quickly undone with a power cycle.
galex
Posts: 3
Joined: Sun Feb 16, 2020 7:57 am
Libera.chat IRC: galex

Re: ARM board for beginner

Post by galex »

Thanks. Will check the tutorial out. Seems quite good for first look.

However probably it would be easier to debug/develop using an emulator first. I started using qemu with x86 and x86_64 many years ago and found quite good for this use case.
I never tried with ARM before and I'm stunned how undocumented it is... I mean qemu and how/what it actually emulates. On the bright side the source code is on the internet
so will figure it out eventually.
User avatar
pvc
Member
Member
Posts: 201
Joined: Mon Jan 15, 2018 2:27 pm

Re: ARM board for beginner

Post by pvc »

I know I'll get >9000 flame for this post. But please do not get Raspberry Pi as your first OSDev ARM machine. It's very powerful system, but there is no proper documentation for it at all. Anything that's available comes from reverse engineering. In RPI, ARM CPU is just a coprocessor for Broadcom's VideoCore GPU. Get someting that has proper documentation. IMO Broadcom is even worse than NVIDIA when it comes to their documentation.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: ARM board for beginner

Post by kzinti »

I agree. The Raspberry Pi is a terrible platform for OsDev, even more so as a first ARM platform.
User avatar
zaval
Member
Member
Posts: 657
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: ARM board for beginner

Post by zaval »

pvc and kzinti said it all, I just add this.
Image

in response to this
Raspberry Pi is ideal because ...
:D
maybe it's "ideal", but not for OS development.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: ARM board for beginner

Post by bzt »

Hi,
galex wrote:Thanks. Will check the tutorial out. Seems quite good for first look.
Let me know if you have a question.
galex wrote:However probably it would be easier to debug/develop using an emulator first. I started using qemu with x86 and x86_64 many years ago and found quite good for this use case.
Definitely. I've implemented raspi3 machine for qemu, available in mainline since qemu 2.12. The ARM part is quite fully supported, however there are certain limitations in the hardware emulation. Only the most common peripherals are emulated, many are missing. For the VC, only the Mailbox interface supported, which is enough to get most of the firmware interface working, including setting up framebuffers, configuring clock frequencies etc. but not the 3D acceleration part.
galex wrote:I never tried with ARM before and I'm stunned how undocumented it is...
It is quite well documented, but @pvc, @kzinti and @zaval is right about one thing: the documentation is very difficult to come by, which makes ARM less OSdev friendly. But if you try hard enough, it is not impossible to get those.
galex wrote:I mean qemu and how/what it actually emulates. On the bright side the source code is on the internet
so will figure it out eventually.
To get the list of currently supported devices, I'd suggest to take a look at the qemu peripheral initialization code: bcm2835_peripherals.c. For Rpi3 there are some additional devices, see bcm2836.c and the QA7 multicore interrupt controller is also emulated (see bcm2836_control.c). I've also implemented the ARM Local Timer emulation, that works as well (not sure when it was merged into the mainline, but quite some time now, should be available in all current binary qemu packages).

Cheers,
bzt
galex
Posts: 3
Joined: Sun Feb 16, 2020 7:57 am
Libera.chat IRC: galex

Re: ARM board for beginner

Post by galex »

Thanks everyone. Probably my question was a bit premature :-)

What I actually try to achieve is to select a broad that I can more or less can emulate using free/affordable tools. Write an initial toy OS to learn ARM using the emulator then port it to an actual device. If it still works I'll probably cry a little in joy... Then gradually work towards my final goal (see first post).

I've seen several posts here about Raspberry Pi boards (mostly negative) so I haven't really considered that one. However probably the part I need will be fine (I don't need graphics, sound, or anything really fancy).
bzt wrote:
galex wrote:I never tried with ARM before and I'm stunned how undocumented it is...
It is quite well documented, but @pvc, @kzinti and @zaval is right about one thing: the documentation is very difficult to come by, which makes ARM less OSdev friendly. But if you try hard enough, it is not impossible to get those.
Sorry, I mean qemu itself is a bit undocumented. Especially the "virt" ARM board. There's some documentation but things like what's the memory layout of the "virt" machine, etc. isn't very well documented. It isn't hard to figure it out, the source is quite nice and readable.

I know that it isn't a real board but for the basics (processes, threads, memory handling, etc) is fine. Also virtio is well documented so its easy to get a "console" up and running to see what's going on (in compliment to GDB).
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: ARM board for beginner

Post by bzt »

galex wrote:Sorry, I mean qemu itself is a bit undocumented. Especially the "virt" ARM board. There's some documentation but things like what's the memory layout of the "virt" machine, etc. isn't very well documented. It isn't hard to figure it out, the source is quite nice and readable.
Ah, I see. Don't expect the memory layout to be documented when it's user configurable :-) You can query the current layout using the qemu monitor and the "info mtree", "info qtree" and "info memdev" commands.
galex wrote:I know that it isn't a real board but for the basics (processes, threads, memory handling, etc) is fine. Also virtio is well documented so its easy to get a "console" up and running to see what's going on (in compliment to GDB).
Yes, but you'll never be able to test your code on real hardware. Think of it twice before you start coding for "virt" or "versatile". Even if you use "qemu -M raspi3", and your code is running fine in vm, there's no guarantee it will run on real hardware too. Qemu is a lot more permissive with memory accesses than the real CPU (for example it doesn't matter what's in MAIR system register, qemu will work, but for real CPUs, the device memory must be nGnRE and must have outter sharable attribs.) So checking your code on a real hardware from time-to-time is unavoidable.

If you want to save time and only focus on processes, threads, memory handling etc. then I'd recommend my boot loader. It will set up paging, multi-processing, frame buffer and UART, and it will load and map your ELF kernel in upper-half. Tested under qemu and on real hardware too.

Cheers,
bzt
krjdev
Posts: 7
Joined: Tue Jan 28, 2020 12:11 am
Location: Graz - Austria

Re: ARM board for beginner

Post by krjdev »

pvc wrote:I know I'll get >9000 flame for this post. But please do not get Raspberry Pi as your first OSDev ARM machine. It's very powerful system, but there is no proper documentation for it at all. Anything that's available comes from reverse engineering. In RPI, ARM CPU is just a coprocessor for Broadcom's VideoCore GPU. Get someting that has proper documentation. IMO Broadcom is even worse than NVIDIA when it comes to their documentation.
I also agree with that.

AArch64:
Therefore I bought a PINE64 Rock64 (quad core Cortex-A53) board:
https://www.pine64.org/devices/single-b ... rs/rock64/

The Wiki page from the used SoC (RK3328):
http://opensource.rock-chips.com/wiki_RK3328

On the above page there is also a TRM.

Limitations:
The ARM Mali GPU isn't documented in the TRM.

AArch32:
For ARM 32-Bit I bought a Zybo-Z7 development board fom Digilent.
It use the ZYNQ-7000 (dual core Cortex-A9 with a FPGA) from Xilinx.
https://reference.digilentinc.com/refer ... o-z7/start

Limitations:
The price of the board. About 200~250$.

Code: Select all

/* Beware of bugs in the above code;
I have only proved it correct, not tried it. */
Original quote by Donald E. Knuth
Post Reply