Raspberry Pi baremetal port?

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.1.0

Moderators: simonsunnyboy, thothy, Moderator Team

joska
Hardware Guru
Hardware Guru
Posts: 4148
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Raspberry Pi baremetal port?

Postby joska » Wed Mar 28, 2018 1:36 pm

This Raspberry Pi baremetal port of SDL2 was just brought to my attention:

https://github.com/maccasoft/raspberry-pi

What about using this for a baremetal port of Hatari?
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 395
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: Raspberry Pi baremetal port?

Postby Orion_ » Wed Mar 28, 2018 1:59 pm

Thanks for sharing this, I tried to do something like that for years and never was able to achieve (especially the usb and audio part)
Hatari and Aranym baremetal port would be awesome, we would have like a new fast & cheap atari machine !
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 719
Joined: Sat Oct 26, 2013 11:19 pm
Location: Brasil
Contact:

Re: Raspberry Pi baremetal port?

Postby Faucon2001 » Wed Mar 28, 2018 2:21 pm

Great idea!
Philippe

Firebee, Falcon, STE, Aranym Box, Hatari Pi Box.
My music http://www.philippeworld.net/
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/

mattsoft
Atari freak
Atari freak
Posts: 55
Joined: Fri Apr 21, 2017 7:11 pm

Re: Raspberry Pi baremetal port?

Postby mattsoft » Tue May 01, 2018 3:06 pm

What makes the baremetal SDL better than just installing the various libraries on top of Stetch light and then compiling Hatari? I use that now and it works great. ??

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 762
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Raspberry Pi baremetal port?

Postby mfro » Tue May 01, 2018 3:40 pm

mattsoft wrote:What makes the baremetal SDL better than just installing the various libraries on top of Stetch light and then compiling Hatari? I use that now and it works great. ??


If done right, a lot less overhead and more or less instant boot. No need for a full-blown Linux kernel on a machine that is supposed to do one single, simple task only.

mattsoft
Atari freak
Atari freak
Posts: 55
Joined: Fri Apr 21, 2017 7:11 pm

Re: Raspberry Pi baremetal port?

Postby mattsoft » Tue May 01, 2018 3:47 pm

Ahh, didn't realize it had the linux kernel too. interesting, i wonder how fast the boot time is. thanks!

arf
Captain Atari
Captain Atari
Posts: 176
Joined: Thu May 17, 2012 9:56 pm
Location: Germany

Re: Raspberry Pi baremetal port?

Postby arf » Tue May 01, 2018 5:50 pm

mfro wrote:
mattsoft wrote:What makes the baremetal SDL better than just installing the various libraries on top of Stetch light and then compiling Hatari? I use that now and it works great. ??


If done right, a lot less overhead and more or less instant boot. No need for a full-blown Linux kernel on a machine that is supposed to do one single, simple task only.


Hatari would need to access a filesystem, or could only work with images. The bloat in a Linux distribution is not so much the Kernel. You could boot straight from the (stripped) Kernel to Hatari, without a multiuser environment, no init-System, no systemd. And you would still benefit of having a userland below Hatari, for networking, or the filesystem.

joska
Hardware Guru
Hardware Guru
Posts: 4148
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Raspberry Pi baremetal port?

Postby joska » Tue May 01, 2018 5:56 pm

arf wrote:And you would still benefit of having a userland below Hatari, for networking, or the filesystem.


I would call that a disadvantage, not a benefit. The entire point of a baremetal port would be to let the "visible" OS (TOS/MiNT) be *the* OS, not an application under Linux. You don't need another OS for networking or filesystem access, TOS/MiNT is perfectly able to handle this itself just like on a real Atari.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

ThorstenOtto
Captain Atari
Captain Atari
Posts: 401
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi baremetal port?

Postby ThorstenOtto » Wed May 02, 2018 8:45 am

joska wrote:[You don't need another OS for networking or filesystem access, TOS/MiNT is perfectly able to handle this itself just like on a real Atari.


That's not real true. When run in an emulator, network access only works by using the special drivers that redirect the functionality to the emulator, which in turn uses the host operating system. So you still need at least a linux kernel for this. Same for filesystem access, unless you only use harddisk images.

joska
Hardware Guru
Hardware Guru
Posts: 4148
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Raspberry Pi baremetal port?

Postby joska » Wed May 02, 2018 9:17 am

So how can TOS work on a Falcon or ST? ;)

Of course TOS/MiNT can do this on it's own. You can write a network driver that access the Raspberry Pi network controller itself. The harddisk driver can access the SD-card (or a disk image on the SD-card) itself. You don't need an underlying OS to provide these services, the emulator only has to provide access to the hardware.
Same with the graphics - the emulator should of course emulate the real thing but it can also provide access to the hardware so you can write a VDI driver for the Raspberry Pi display.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

ThorstenOtto
Captain Atari
Captain Atari
Posts: 401
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi baremetal port?

Postby ThorstenOtto » Wed May 02, 2018 9:58 am

joska wrote:You can write a network driver that access the Raspberry Pi network controller itself.


But only if at the same time, you also change the emulator to emulate that hardware. Hardware that does not even exists on a real ST.

the emulator only has to provide access to the hardware.


But that is not how emulators work. They don't provide direct access to the hosts hardware, they emulate Atari hardware, using the hosts OS.

it can also provide access to the hardware.


Nope, it can't. Emulators are not kernels, they are just normal applications. Best you can do in this case is to use an SDL version that provides access to some kind of framebuffer, but that would still be only accessible on the host side, not directly from some Atari application.

joska
Hardware Guru
Hardware Guru
Posts: 4148
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Raspberry Pi baremetal port?

Postby joska » Wed May 02, 2018 10:52 am

ThorstenOtto wrote:But only if at the same time, you also change the emulator to emulate that hardware. Hardware that does not even exists on a real ST.


Why would you need that? It does not matter if hardware doesn't exist on a real ST. TOS runs on the Milan, which has only one chip in common with the ST. It's "just" a matter of hardware support in TOS.

ThorstenOtto wrote:But that is not how emulators work. They don't provide direct access to the hosts hardware, they emulate Atari hardware, using the hosts OS.


That's a very narrow definition of an emulator. An emulator that runs "baremetal" on a piece of hardware like the RPi has no host OS but controls the hardware directly.

ThorstenOtto wrote:Nope, it can't. Emulators are not kernels, they are just normal applications. Best you can do in this case is to use an SDL version that provides access to some kind of framebuffer, but that would still be only accessible on the host side, not directly from some Atari application.


When running "baremetal" the emulator *is* the kernel. The emulator can map native hardware to the 680x0 address space if it wants to.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

ThorstenOtto
Captain Atari
Captain Atari
Posts: 401
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi baremetal port?

Postby ThorstenOtto » Wed May 02, 2018 12:08 pm

joska wrote:TOS runs on the Milan, which has only one chip in common with the ST. It's "just" a matter of hardware support in TOS.


Yes, but only a modified version of TOS. You won't be able to use that TOS version with emulators, because it is trying to access hardware that current emulators don't emulate.

An emulator that runs "baremetal" on a piece of hardware like the RPi has no host OS but controls the hardware directly.


Em, no. A emulator emulates a certain piece hardware, either ST, or TT, or Falcon. None of the current emulators is currently able to emulate a Milan, Hades, Firebee or whatever. So all they do is catch access to atari hardware, then use the host-OS to emulate it.

When running "baremetal" the emulator *is* the kernel. The emulator can map native hardware to the 680x0 address space if it wants to.


No, sorry, they can't. They don't have direct access to it.

BTW. emulators for other systems, like VirtualBox or VMware, work basically the same. You won't find a version of them that runs "baremetal" on RPi and suddenly emulates a PC running windows. They also need some host OS to do that.

joska
Hardware Guru
Hardware Guru
Posts: 4148
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Raspberry Pi baremetal port?

Postby joska » Wed May 02, 2018 1:03 pm

ThorstenOtto wrote:Yes, but only a modified version of TOS. You won't be able to use that TOS version with emulators, because it is trying to access hardware that current emulators don't emulate.


TOS on the Milan is capable of accessing hardware not present in an ST because Milan-TOS has support for said hardware. TOS on the Falcon is capable of accessing hardware not present in an ST because TOS 4 has support for Falcon hardware. A TOS with appropriate hardware support will work on an emulator with hardware not present in an ST because support for this hardware will be added to this TOS (or MiNT).

ThorstenOtto wrote:
An emulator that runs "bare metal" on a piece of hardware like the RPi has no host OS but controls the hardware directly.


Em, no. A emulator emulates a certain piece hardware, either ST, or TT, or Falcon. None of the current emulators is currently able to emulate a Milan, Hades, Firebee or whatever. So all they do is catch access to atari hardware, then use the host-OS to emulate it.


Correct, an emulator emulates a certain piece of hardware. But not only that. Is ARAnyM or Hatari not emulators because they offers features the real hardware doesn't? An emulator can still be an emulator even if it extends the features of the original machine. If not, then Hatari stops being an emulator as soon as you extend the screen size.

And why is there a need for an underlying OS? For the emulated machine it does not matter if the features are provided by an underlying OS or the emulator itself. I repeat, a "bare metal" emulator runs directly on the hardware and is not limited by permissions from an underlying OS. The emulator *is* the OS, and will have full control of the hardware.

ThorstenOtto wrote:
When running "bare metal" the emulator *is* the kernel. The emulator can map native hardware to the 680x0 address space if it wants to.


No, sorry, they can't. They don't have direct access to it.


If the emulator exposes the hardware registers to the virtual machine, the virtual machine will have access to and control the actual hardware even if the access goes through the emulator. So in that sense you might say that the hardware will have to be emulated. You can (and it might even be sensible) to implement e.g. the VDI primitives in the emulator itself, exposing these to the VDI, exactly like you do in ARAnyM today. But you don't need Linux (or any other underlying OS) to use the graphics hardware on a Raspberry Pi.

https://www.youtube.com/watch?v=mfOtTq8Dysw

ThorstenOtto wrote:BTW. emulators for other systems, like VirtualBox or VMware, work basically the same. You won't find a version of them that runs "baremetal" on RPi and suddenly emulates a PC running windows. They also need some host OS to do that.


They need some host OS to do that because they are designed to use the features of an host OS. That is the entire idea of these virtual machines. When you run several virtual machines on the same piece of hardware you can't give all machines direct access to the same hardware. The access to these resources must be regulated by either the underlying OS or the emulator itself. Not to mention the security aspect... Nothing of this applies to a bare metal emulator that emulates a single instance of an obsolete machine on a piece of hardware that runs nothing else than the emulator itself.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

ThorstenOtto
Captain Atari
Captain Atari
Posts: 401
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi baremetal port?

Postby ThorstenOtto » Wed May 02, 2018 2:11 pm

joska wrote:TOS on the Milan is capable of accessing hardware not present in an ST because Milan-TOS has support for said hardware.


Yes, as long as that TOS runs on a Milan.

A TOS with appropriate hardware support will work on an emulator with hardware not present in an ST because support for this hardware will be added to this TOS (or MiNT).


No, unless you add support to emulate that Hardware. TOS for Milan will just try to access that Hardware. Any emulator will give a bus-error when trying to do so. Depending on whether the TOS catches that bus-errors (TOS 3.x for example does not do that for all hardware, certain hardware is just expected to be there), the TOS will either crash, or just not be able to access the hardware.

Is ARAnyM or Hatari not emulators because they offers features the real hardware doesn't?


Yes, but only to programs who are aware of that (like fVDI with a special driver), or with special patches and hacks, and several restrictions, like Hatari offering Extended VDI resolutions, that only work with known TOS versions.

I repeat, a "bare metal" emulator runs directly on the hardware and is not limited by permissions from an underlying OS. The emulator *is* the OS, and will have full control of the hardware.


Of course you are free to write such a thing, but the current emulators are not designed this way.

They need some host OS to do that because they are designed to use the features of an host OS.


Just like Aranym, Hatari, Steem and all others. None of them accesses the hardware directly. That would require not only to emulate the Atari, but also to write an os of its own.

Nothing of this applies to a bare metal emulator that emulates a single instance of an obsolete machine on a piece of hardware that runs nothing else than the emulator itself.


That's true. But as said above, they are not designed this way. They are designed to be run from an environment where they are concurrently accessing the same resources as other applications.

ranix
Atari maniac
Atari maniac
Posts: 95
Joined: Sun Jan 14, 2018 8:01 pm

Re: Raspberry Pi baremetal port?

Postby ranix » Thu May 03, 2018 3:57 am

I fail to see how the limitations of a current implementation of Hatari are worth arguing about in this thread regarding a hypothetical emulator which runs baremetal on a raspberry pi

if someone were to create an emulator which ran on baremetal and emulated an Atari that someone would obviously need to create the glue required to interface between TOS and hardware. Why you'd feel the need to point it out, and further to argue about it, baffles me.

Yes it would be easier to run Hatari with a Linux userspace underneath it. That's what I'd assume most people, in fact, actually do with Hatari. That is totally irrelevant to this hypothetical baremetal emulator

ranix
Atari maniac
Atari maniac
Posts: 95
Joined: Sun Jan 14, 2018 8:01 pm

Re: Raspberry Pi baremetal port?

Postby ranix » Thu May 03, 2018 4:02 am

arf wrote:The bloat in a Linux distribution is not so much the Kernel.

yeah it's the scheduler in the kernel :cheers:

you can try to run a real-time kernel but last I tried it was an exercise in frustration

mikro
Atari God
Atari God
Posts: 1733
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: Raspberry Pi baremetal port?

Postby mikro » Thu May 03, 2018 7:22 am

I second ranix, while Hatari in such configuration is definitely unusual I can't see a point of arguing whether this is or isn't an emulator. If somebody implements Hatari on bare metal, I will be super happy to buy RPi only because of that. :-)

joska
Hardware Guru
Hardware Guru
Posts: 4148
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Raspberry Pi baremetal port?

Postby joska » Thu May 03, 2018 1:48 pm

Thank you. Yes, of course it's not just a matter of recompiling Hatari for a new platform. The SDL-port pointed to in the first post will help a lot - it will take care of graphics, sound, keyboard and mouse. But you will still have to strip out features that depends on the presence of an underlying OS (such as access to host OS filesystem) and write the "glue" that allows the OS running on the emulator to access native hardware. But there's nothing "impossible" about this.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5020
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Raspberry Pi baremetal port?

Postby simonsunnyboy » Thu May 03, 2018 3:51 pm

Hatari with a dedicated reduced Linux base without fancy shells and extra GUIs would be cool to have.
I don't see the point in investing into a truely on-the-hardware implementation. Esp. if this leads only to a clone without true Atari ST hardware capabilities.

For a speedy clone, a fancy Aranym installation on a reduced Linux base might be easier to get going.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

ThorstenOtto
Captain Atari
Captain Atari
Posts: 401
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi baremetal port?

Postby ThorstenOtto » Thu May 03, 2018 3:55 pm

joska wrote:The SDL-port pointed to in the first post will help a lot - it will take care of graphics, sound, keyboard and mouse.


Maybe i under-estimated that port, and should have taken a closer look ;) Of course a lot of the OS dependencies would be solved by that.

But there's nothing "impossible" about this.


Sure, but still a lot of work.

mikro wrote:If somebody implements Hatari on bare metal, I will be super happy to buy RPi only because of that.


I still think you can achieve similar results by using something like the BeeKey. If i understand that right, it should boot up quite fast, and right into Aranym and/or Hatari. So for the user, that would look pretty much the same.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Raspberry Pi baremetal port?

Postby Foxie » Thu May 03, 2018 4:32 pm

simonsunnyboy wrote:Hatari with a dedicated reduced Linux base without fancy shells and extra GUIs would be cool to have.
I don't see the point in investing into a truely on-the-hardware implementation. Esp. if this leads only to a clone without true Atari ST hardware capabilities.


Linux has a very bad level of performance with anything that needs a fast response. That means it's a poor choice for MIDI. Even if your thread goes real-time, I'm pretty sure Linux still preempts your thread for up to 5ms every second. Not good enough.

A bare metal port of Hatari or Aranym could be extremely interesting. Instead of emulating one frame at a time, you could emulate 64 microseconds at a time. Use the Raspberry Pi's timer to provide interrupts every 64 microseconds. It could be arranged to behave nearly like a real Atari on performance. You also have I/O pins, which you can use for a cartridge. No way to do that on an IBM compatible, USB is too slow. The Pi can also output RGB TTL video, which you can use for a CRT monitor.

A while ago I thought about using a Pi zero to build a CPU accelerator. You could use Aranym's JIT, without Linux you could actually do every bus cycle on the I/O pins. Surely it would be much faster than the Apollo core. You could also map the frame buffer and fast RAM into 68000 memory space. If you mimic the bus cycles exactly, it would be very profitable by selling such an accelerator to Amiga and Mac users too.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5020
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Raspberry Pi baremetal port?

Postby simonsunnyboy » Thu May 03, 2018 4:39 pm

MIDI is not the main application for most of us. But it would be interesting to see a native driver for its special requirements.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

ctirad
Captain Atari
Captain Atari
Posts: 259
Joined: Sun Jul 15, 2012 9:44 pm

Re: Raspberry Pi baremetal port?

Postby ctirad » Thu May 03, 2018 8:39 pm

Foxie wrote:Linux has a very bad level of performance with anything that needs a fast response. That means it's a poor choice for MIDI. Even if your thread goes real-time, I'm pretty sure Linux still preempts your thread for up to 5ms every second.


Fortunately, that's not true at all.

Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 719
Joined: Sat Oct 26, 2013 11:19 pm
Location: Brasil
Contact:

Re: Raspberry Pi baremetal port?

Postby Faucon2001 » Thu May 03, 2018 9:11 pm

simonsunnyboy wrote:Hatari with a dedicated reduced Linux base without fancy shells and extra GUIs would be cool to have.
I don't see the point in investing into a truely on-the-hardware implementation. Esp. if this leads only to a clone without true Atari ST hardware capabilities.

For a speedy clone, a fancy Aranym installation on a reduced Linux base might be easier to get going.

What you are describing is BeeKey and BeePi.
BeeKey runs from an USB key on any X86 platform, boots in 15 sec straight into Aranym, and can launch Hatari from it by a simple click on the desktop (better and faster integration with Hatari to come in the future thanks to Mikro native feature work). It can also be installed on a hard drive and in this case boots in 5 sec. On a regular core i3, you get a 68040@4Ghz, up 1.5 GB memory, 16 bits sound, midi under Hatari, native hard drive, native 32 bits video, native network ... well it offers all Aranym features pre-configured + the integration of Hatari to emulate real hardware, and this without seeing the Linux host 1 sec. it can be and will be improved, but that’s the closest thing (with Afros) to what you describe.
BeePi is the same distribution for RaspberryPi and boots from a micro SD card in 7 sec.
See the link in my signature for more details. Don’t be afraid to test it and report suggestions :D

Now, even though I used a light Linux distribution , it weights 700MB without the emulation part, which is kind of crazy for a host system, and boot time though optimized is not optimum. Also on a Raspberry pi, the performance is much lower (between a CT60 and a Firebee) and Hatari can’t emulate more than a Mega STE @32 MHz, but the price is super attractive.
So I see a bare metal option as an excellent optimization and simplification, without talking about the elegance of the concept (though not simple to do); the alternative is that somebody help me to build a minimal Linux host system just enough to run Aranym and Hatari. There use to be Linux floppy distributions, so it should be feasible; I just need the help of a Linux guru to build it as it is far above my skills.
Philippe

Firebee, Falcon, STE, Aranym Box, Hatari Pi Box.
My music http://www.philippeworld.net/
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 3 guests