It is currently Sun Oct 22, 2017 10:22 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 92 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 7  Next
Author Message
PostPosted: Thu Sep 21, 2017 9:11 am 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 294
Location: Colorado USA
Why is it that getting a kernel on the Raspberry Pi is way more complicated then say, the NES? They're both computers, is it because the Pi has a bios? Of course, on the NES I control hardware like the controller ports, PPU, and the APU, why is the Pi so special?


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 9:13 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
It takes more code to drive a system-on-chip (SOC) that does more stuff. USB is much more complicated than SPI, SD storage is much more complicated than a simple execute-in-place (XIP) ROM, 3D graphics is much more complicated than 2bpp tiled backgrounds and sprites, HDMI output is much more complicated than shortcut-filled composite output, and provision for battery power is much more complicated than assuming a wall wart provides power that's too cheap to meter.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 9:35 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 248
the BIOS is the Kernel.

So the nes has an 8bit cpu single core, connected to a simple 8 bit graphics chip, you have what ~32 registers to init(not counting OAM RAM and attributes etc) , and everything is executed from ROM, and has SRAM.

The Pi has a quad core, 64bit CPU, that dynamically adjusts it clock frequency based upon thermals so it doesn't destroy it self, a 3D GPU, can only execute data from RAM, which is DRAM and needs a refresh system, cycle and warm up, you have to detect which output format you are using, Composite, HDMI, 480i, 480p, 720i, 720p, 1080i, 1080p, 1024x768, 640x480, 640x400, 800x600, 1920x1600 and set up the graphics buffers, allocate VRAM, program the vertex and pixel shaders, init the ABI, init the multiple peripherals, deal with the complicated timings, structure and formats of the external devices, detect, setup and get the IDs for any connected USB devices, parse their headers and formats and set up interrupts to handle their data... basically the NES is a bear bones simple piece of hacked together dodgy hardware made with sticky tape and the Raspberry Pi is good few 1000x more complicated.

A 6502 says my stack is 256 bytes and its at $100 no if no buts, no virtual memory and no cache. The Pi has a stack per thread per core, and it can be where you want it to be, and that works thanks to your virtual memory system that abstracts and caches data to/from the internal caches and DRAM and patches up the addresses for it.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 9:49 am 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 294
Location: Colorado USA
So hen you say the bios is the kernel, are you saying that the bios does all that so the programmer doesn't have to? Or do I still have to do that.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 10:17 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 248
The BIOS will get you part way, excatly how far I don't know, what is and isn't in it changes over time and what model Pi you are on and which OS you are using and its been a while since I booted my PI. It will probably get you a code entry point and set up the basics for the CPU and GPU. However output resolution and the like is probably an OS Kernel thing and not a BIOS Kernel thing. The Pi will have multiple layers, Boot BIOS, BIOS, "Kernel mode"Kernel and Userland Kernel. If you look at the Bare Metal forum there are people who have made small setups and systems that will get various features here and there(terminal access, GPIO access, SD card readers, USB keyboard driver etc ) which might be enough for what you want. But honestly don't waste your time on it at the moment, and just make a Rasbian elf and modify the linux boot script to call it upon boot, and focus more on making your game then spending 3 weeks looking at Rx/Tx terminal trying to work out why it doesn't send an A back. Once you have the game get it working bare metal, that way you will be able to make the call on what you do and don't need, and being able to step through code in a debugger makes life a lot easier ;)


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 10:39 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6294
Location: Seattle
The NES has quite possibly the simplest programmer's interface in a mass produced full-featured computer (by which I mean "a device with input from dedicated multikey input device and outputs to a screen") to ever have existed.

With only 30ish total configuration registers to describe its total functionality, various Dubious Choices are practical (such as Bregalad's insistence that it is obfuscatory to name those registers instead of just using addresses) in ways that would be laughable on practically every other computer.

The 2600 has drastically more registers (roughly twice as many). DMG, roughly three times as many. The SNES has close to ten times as many (although the majority are part of the S-DSP). A modern computer will have thousands, often hundreds for each individual component.

The IC that controls my monitor (converting DVI to LVDS) has several hundred.


The RasPi has the additional problem that it's actually an ARM core running on top of some magic being done by the GPU. Exactly what, we don't know, but there are people who have been trying to make a FOSS reimplementation of that blob.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 12:04 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5732
Location: Canada
Bregalad wrote:
You do not need to care about any of this when programming in assembly for the ARM (at least not the ARMs I have myself programmed in assembly - perhaps more modern ones are different ?). You can just ignore those issues unless you absolutely want maximum performance, which you typically do not care about 99% of the time.

Yes, but I was explaining why assembly is uncommon for this platform (RPi). If it's for optimization, it's normally not used much.

Someone who wants to write in assembly because it's their favourite thing to do is an outlier. These people do exist, but it's generally only applicable as an obscure hobby. In a professional setting you would not normally be allowed to do all your work in assembly without some very good justification.

Bregalad wrote:
I wonder whether gcc is one of those "good compilers", or if they just made it "just work" with minimal care about hardcore optimisation. I'd lean toward the second possibility, considering it's free.

GCC is one of the very best, and though it is free and open source it has been professionally maintained for decades now.

Bregalad wrote:
Then do yourself a favour and do not learn C. It's bad as a low level language (assembly is better), bad as a mid level language (Pascal is better) and bad as a high level language (Python is better). The more I think about it, the less I see any advantage of using C at all. The only reason it's used is because Unix, and later it's close Linux, used it.

Over my career, I'd estimate 90% of the work has been C++, 10% other languages. Different languages are popular in different application domains, but C++ is very widely used, and very productive language. I don't think it's a "favour" to obstinately ignore a popular language; knowing C++ has literally been worth hundreds of thousands of dollars to me. (For anybody that's about to make a pedantic distinction: knowing C is a good stepping stone to learning C++.)

Python is very worth knowing as well; widely used and productive in appropriate applications. Surprised by the suggestion about Pascal, but maybe you operate in circles where it is more commonly used. I'd definitely learn it if it was in my path. I can't think of a programming language I've ever regretted learning.


lidnariq wrote:
With only 30ish total configuration registers to describe its total functionality, various Dubious Choices are practical (such as Bregalad's insistence that it is obfuscatory to name those registers instead of just using addresses) in ways that would be laughable on practically every other computer.

Heh, I also feel that the numbered address is the easier to read and remember for NES registers.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 12:50 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
rainwarrior wrote:
(For anybody that's about to make a pedantic distinction: knowing C is a good stepping stone to learning C++.)

I too learned C before C++, but not everyone agrees.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 2:05 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7234
Location: Chexbres, VD, Switzerland
Bregalad wrote:
GCC is a phenomenal compiler/optimizer.

I know already, I meant, I don't know if it accounts for internal pipeline when ordering instructions. In any cases it doesn't matter all that much, except in very rare cases.

Quote:
I promise, tons and tons of work (often paid) has gone into optimization in GCC.

I still admit I never understood how free software of such a big scal was economically possible in the 1st place.

Bregalad wrote:
I mean, for this particular project maybe, but in general no: do yourself a favour and learn C. [...]

If he had interest in C, I'd agree with your advice. But he said explicitly he does not have any interest, so I confort him in that it's fine to program using other languages. I am not so much against C than I am against the thought C is everywhere and should stay everywhere. The only reason C is so popular is:
1) It's popular (aka snowball effect)
2) It was used for Unix and Linux programming

The language itself, while decent, is far from great, and technology had made decades of progress since the late 1970s making C largely obsolete.

Quote:
but C++ is very widely used, and very productive language.

Do you account countless time to understand extremely obsure 10-pages long messages form the linker in your measurement of "productivity" ?

Quote:
knowing C++ has literally been worth hundreds of thousands of dollars to me.

Well that's great for you, I haven't been so lucky. By the way, considering how insanely complex C++ is, especially the later 11 and 14 versions, by "knowing" it do you do like me and pretend knowing it because you can use it to make your programs, or did you dedicate 10 years of your life studying the dark corners of this language ?

Quote:
Python is very worth knowing as well; widely used and productive in appropriate applications. Surprised by the suggestion about Pascal, but maybe you operate in circles where it is more commonly used. I'd definitely learn it if it was in my path. I can't think of a programming language I've ever regretted learning.

I'm in the process of learning Python those days. This makes me never want to code in C++ ever again, (and probably neither C, although it's not as bad because at least the feature creep is limited). It really shows how it's better when they thought of the language as a whole from the start instead of piling up new features on existing grammar that was never meant to support them in the 1st place.
Quote:
I can't think of a programming language I've ever regretted learning.

Couldn't agree more.

Quote:
[C language] is small and relatively simple (crazy corner cases excluded)

Sorry, but C is big and complex. It needs header files, pre-processor, compiler, linker, when many interpreted languages can just get your code working in a bang. It's harder to debug than most languages. The support for error handling (or the lack thereof outside of errno) is downright awful. It creates more limitations that aren't even there in assembly. For example strings have to end with NULL, when in assembly it's not the case.

Memory handling is very complex. Pointers and arrays are handled in an awfully confusing way. None of these problems exists in most non-C family programming languages.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 2:31 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 294
Location: Colorado USA
The reason I chose assembly language is because I assumed that making a window we be like WinAPI, which is way more sophisticated than I can understand. Is Linux not like that? I just don't like how different all the higher level languages are with all their data types, arguments, etc. I thought that assembly language on the raspberry pi would just be writing the 24-bit pixel to the screen. I find libraries and all that a pain in the neck, especially external libraries. How does it know where on the hard disk to find it?


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 2:40 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6294
Location: Seattle
Modern framebuffers often aren't linear in-order chunks of memory anymore.

You really want to use SDL. I know you think you don't want to rely on external libraries, but I promise you that you're definitely choosing a more difficult path for no greater result.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 2:46 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 294
Location: Colorado USA
I couldn't agree with bregalad any more, I hate how C has weird syntax, with the ; character and curly brackets and so many other random instructions that just shouldn't be part of the language in the first. I like assembly language, especially 6502, because it has no more instructions then are absolutely necessary, making it easier to remember every instruction, and probably the most simple syntax there is, you have an operation, then a memory address or value, and occasionally, a little ,x for indexed addressing. It would have been nice if we had a compiler version of BASIC like on computer from the late 70s through early 80s. But honestly, I kind of regret that I went with programming on a game console that's over 30 years old and nobody cares about rather then learning C, a language where I can actually get a job off of. But if there is one language that I think that people from assembly would hate, it would probably be Java...


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 2:49 pm 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 192
Pfft, the 6502 is bloated. 56 instructions? What you really wanna learn is an OISC assembly language.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 3:01 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6294
Location: Seattle
Bregalad wrote:
Sorry, but C is big and complex. It needs header files, pre-processor, compiler, linker, when many interpreted languages can just get your code working in a bang.
Which is to say, it's actually too small and simple. Your interpreted languages have many more moving parts, and scary levels of them in order to get comparable performance.

Quote:
The support for error handling (or the lack thereof outside of errno) is downright awful.
Once again, you're actually arguing that C is too small and too simple.


I don't know, maybe there's actually an interesting point to made that C is the "unhappy medium", too many abstractions over the hardware for...something... but simultaneously too few abstractions to make things easy.

But I'm about 99% certain that that position is indefensible.


Top
 Profile  
 
PostPosted: Thu Sep 21, 2017 3:02 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3074
Location: Nacogdoches, Texas
adam_smasher wrote:
OISC

Wtf? :lol:

lidnariq wrote:
Modern framebuffers often aren't linear in-order chunks of memory anymore.

How are they then? I thought a framebuffer was just a giant area of memory with each row of pixels onscreen being at a different offset in the framebuffer.

lidnariq wrote:
The SNES has close to ten times as many (although the majority are part of the S-DSP).

I didn't count, but I'm pretty sure the S-CPU and S-PPU1/2 have about 100 registers between them. Why does the S-DSP have so many?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 92 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 7  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group