I am designing a system based around the samd51 chip. It will have an SPI screen and the buttons will be read through a shift register. Also, there will be an SD card for IO. I need a way to emulate this so I can develop a custom OS. But I can't find anything like this. What should I do to emulate this? Thanks!
Asked
Active
Viewed 130 times
1
-
At what level you want to emulate it? Run the same binary? Or just compile C code on PC with different HAL so you have screen and buttons on PC screen? – Justme Aug 15 '20 at 10:48
-
@Justme I need the screen, the buttons and the sd card – James B. Reese Aug 15 '20 at 10:49
-
2a) why are you designing an OS? There's dozens of tested (and personally, rather good) OSes for these CPUs out there, so don't do that, you're not going to write something better. b) how much do you need to simulate? Like, no CPU vendor simulator can know how your screen works, since they're not the designers of that screen, so you'll have to write an emulator for that yourself. – Marcus Müller Aug 15 '20 at 10:50
-
@MarcusMüller a) I am going to create an OS because 1) I don't feel like using a pre-made one. 2) I will implement custom syscalls. b) I want to have the SPI screen as a window on my computer, the buttons from the shift register as some keys on the keyboard and the sd card as a file or a folder on my computer. – James B. Reese Aug 15 '20 at 10:52
-
1re: a)1) "I feel like creating one": so start smaller. I wouldn't try to cast the scope of all this as large as you're doing it 2) Most of these OSes are open source, and very amendable to custom syscalls, what you're exhibiting there is called "not invented here syndrome" (which is cool for experimentation/learning!) b) well, then grab your Qemu, and add hooks to the memory area where your SAMD's SPI controller sits, and emulate what the screen would do, and then write to the QEMU framebuffer window. Sounds like a lot of work, but very educational! Same for your SD card emulation,much work. – Marcus Müller Aug 15 '20 at 10:58
-
@MarcusMüller I want to create my OS. That's it. Nothing else. No, I won't use any pre-made OS. No, I won't edit the source code of an already-existing OS to fit my needs. All I want is a custom OS made by me and me only. Thanks for the info about QEMU, that's actually what I was trying currently. – James B. Reese Aug 15 '20 at 11:04
-
Well, honestly, writing an OS that does anything is hard enough as a learning experience. Ignore the screen, the buttons and the SD card for now, start writing C or assembler for ARM/Thumb2 to get your OS to do anything useful that you can see in a debugger. There's no need to try to emulate real hardware until that happens. As soon as that works, start adding the necessary peripherals. Writing an emulator for an SPI peripheral from scratch, for hardware that you have no design documentation on, sounds like multiple manyears of work, especially if you have no software infrastructure to base on – Marcus Müller Aug 15 '20 at 11:47
-
1@MarcusMüller I have written many OSes before, some of which are used in some of my projects and all are completely useful and do at least something. – James B. Reese Aug 15 '20 at 12:11
-
That's awesome! THen the "my OS doesn't do *anything* yet, I have to learn how to adapt it to my CPU or write it from scratch"-phase will be short. Then, you can start caring about the things that make up your MCU that aren't the CPU. Not before, honestly, emulating hardware is hard. – Marcus Müller Aug 15 '20 at 12:18
-
When doing any form of microcontroller programming, it such a massive benefit to develop directly on the intended target hardware. To the point where a professional programmer will simply refuse to do anything else. Simulators/emulators are rubbish. Just buy an evaluation board and an IC debugger, while you wait for the first prototype board. Sounds like the most advanced thing you'll encounter in this project is to DMA the SPI - writing code for that anywhere else than inside the target system is madness. – Lundin Aug 17 '20 at 08:34