Telash
Posts: 4
Joined: Tue Apr 26, 2016 3:24 pm

Minimalistic C-Development

Tue Apr 26, 2016 3:49 pm

Hi!

I just got my first Raspberry Pi and am exited to start developing.

The plan is to make my own GUI and all the programs on it to be developed by my self. So all I want on it is the linux terminal and Vi for C-programing. The rest in an OS I realy dont want. I want to make my own stuff. I started with installing raspbian, and I'm sure it a great OS, but its just WAY to bloated for my needs.

My main computer has windows 7, so it has to be possible to install from there to a SD-card.

Any suggestions?

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Minimalistic C-Development

Tue Apr 26, 2016 4:07 pm

Telash wrote: So all I want on it is the linux terminal and Vi for C-programing. The rest in an OS I realy dont want. I want to make my own stuff. I started with installing raspbian, and I'm sure it a great OS, but its just WAY to bloated for my needs.
Don't you need the C compiler? You'll need to write your own standard library and system's calls library and the systems calls themselves. Not to mention you'll need to build the actual bare metal booting scheme from the ground up.

I suspect you'd be happier if you had your build pi and your testing pi, so two of them. In any case, you can get an idea what it is like to have the OS kernal and a few other things but not a lot more by running Tiny Core for the pi: http://tinycorelinux.net/7.x/armv6/rele ... re-7.0.zip . I think you'll quickly find out why most people use computers with operating systems. At least to build into their vision in a calculated manner.

User avatar
joan
Posts: 14759
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Minimalistic C-Development

Tue Apr 26, 2016 4:11 pm

Telash wrote:Hi!

I just got my first Raspberry Pi and am exited to start developing.

The plan is to make my own GUI and all the programs on it to be developed by my self. So all I want on it is the linux terminal and Vi for C-programing. The rest in an OS I realy dont want. I want to make my own stuff. I started with installing raspbian, and I'm sure it a great OS, but its just WAY to bloated for my needs.

My main computer has windows 7, so it has to be possible to install from there to a SD-card.

Any suggestions?
That's what Raspbian Lite is for.

jahboater
Posts: 5209
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Minimalistic C-Development

Tue Apr 26, 2016 4:18 pm

stderr wrote: Don't you need the C compiler? You'll need to write your own standard library and system's calls library and the systems calls themselves. Not to mention you'll need to build the actual bare metal booting scheme from the ground up.
The OP was only wanting to write his own GUI (!!).

As Joan said, Raspbian Lite is perfect. It does of course have a C compiler, libc, and Vi.

Let us know when you have replaced X or wayland.
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

User avatar
PeterO
Posts: 5623
Joined: Sun Jul 22, 2012 4:14 pm

Re: Minimalistic C-Development

Tue Apr 26, 2016 4:39 pm

jahboater wrote:
stderr wrote: Don't you need the C compiler? You'll need to write your own standard library and system's calls library and the systems calls themselves. Not to mention you'll need to build the actual bare metal booting scheme from the ground up.
The OP was only wanting to write his own GUI (!!).

As Joan said, Raspbian Lite is perfect. It does of course have a C compiler, libc, and Vi.

Let us know when you have replaced X or wayland.
You could use OpenGL ES instead. I have written GUI applications that include clickable widgets on top of OpenGL ES :-)

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Minimalistic C-Development

Tue Apr 26, 2016 4:56 pm

jahboater wrote:The OP was only wanting to write his own GUI (!!).
The original poster said the following:

"The plan is to make my own GUI and all the programs on it to be developed by my self. So all I want on it is the linux terminal and Vi for C-programing. The rest in an OS I realy dont want. I want to make my own stuff."

So that's what I was responding to. Now perhaps you might argue that wanting the "linux terminal" means he wants the underlying OS and kernel resources required to provide that. But the problem is where does that end, does he get bash and python and gcc and all the rest just asking for the "linux terminal"? Because what is a linux terminal without a shell?

Since vi is a separate request, I say no, he only gets his choice of the code for a terminal program and for vi, not vim, the real vi and with the arrow keys hardwired to not work so he has to hit escape and use the h,j,k,l.
As Joan said, Raspbian Lite is perfect. It does of course have a C compiler, libc, and Vi.
There is a thread over at T. core making fun of R. jessie lite because it is going to need at least a 2 gig sdcard. Contrast that with tiny core which easily fits on a 128 meg sdcard and can boot to X. Of course there's little else which is kind of what I was getting at. He'll have to add most anything that isn't part of busybox or the distribution itself. They have a command line program that accesses their repository, so if they have it, it's not that hard to add.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Minimalistic C-Development

Tue Apr 26, 2016 5:36 pm

Telash wrote: I just got my first Raspberry Pi and am exited to start developing.
Good for you, welcome to the community of programmers !
Telash wrote: The plan is to make my own GUI and all the programs on it to be developed by my self. So all I want on it is the linux terminal and Vi for C-programing.
This is an outstanding goal... while you're at it... and I'm serious, go for making a blob free kernel too. That way, if you GPLv3 your code, your distro will make it on the FSF list of approved free software only gnu+linux distros...
Telash wrote: The rest in an OS I realy dont want. I want to make my own stuff.
I love it! ... you go Telash!
Telash wrote: I started with installing raspbian, and I'm sure it a great OS, but its just WAY to bloated for my needs.
That's what Jessie Raspbian lite is for...
Telash wrote: My main computer has windows 7, so it has to be possible to install from there to a SD-card.
Very possible... but if you're serious about programming gnu+linux for the Raspberry PI, get yourself a notebook computer (I personally recommend the HP Pavillion G series) and put one of the FSF distros on it... like Trisquel, or GnuSense, or one of those "free" OSs.
Telash wrote: Any suggestions?
You are going to want a complete set of development tools on your PI. Start with Jessie lite, and build from there... take a look at the GNU.org site for a list of gnu development tools, and why you want them... also take a look at the FSF.org site and read up about free software and the free software movement... we want you! <-----
marcus
:ugeek:

Telash
Posts: 4
Joined: Tue Apr 26, 2016 3:24 pm

Re: Minimalistic C-Development

Tue Apr 26, 2016 6:21 pm

Thank you all for your replies! So many, and so fast :) And an extra thankyou to Marcus.

Ofcource everything I make will be copyleft, however, how do I go about making a kernel? I am not new to C in any way, have done alot of C+SDL development for desktops, and have done a few embedded projects with assembly, but thats all realy.
I know that I have the logical mind and the enthusiasm for making just about anything, and a kernel+GUI sounds great! However, I still dont have the know-how on how to start. Maybe you can give me a push in the right direction?
Would I be coding in assembly or C for example? I like assembly, but it quickly becomes tedious to work in, so I prefer C.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Minimalistic C-Development

Tue Apr 26, 2016 7:23 pm

@PeterO <=======
Telash wrote:So all I want on it is the linux terminal and Vi for C-programing. The rest in an OS I realy dont want. I want to make my own stuff.
--emphasis mine


Everything I said to Telash is on-topic; and ...

... @Telash ... the kernel is just another tarball of sources. They can be compiled just like any other sources/ although, they take much longer to compile. ;)

Unfortunately, most of them contain what we call kernel blobs... long tiresome sets of numbers (binary strings of hidden evil , mostly drivers ) which must be removed if the kernel is going to be blessed as kosher. see?

So, ignore PeterO and go for it! (we need you, and we want you)
marcus
:ugeek:

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12665
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Minimalistic C-Development

Tue Apr 26, 2016 9:14 pm

could I please ask for the regulars of this thread to keep their discussion civil, or I must take more drastic actions than deleting a few posts. please behave like adults, please!

Telash
Posts: 4
Joined: Tue Apr 26, 2016 3:24 pm

Re: Minimalistic C-Development

Tue Apr 26, 2016 9:35 pm

I try this again, and will try to be as specific as possible.

I want to have as little preinstall as possible. Think bare metal, but with the posibility to develop in C directly on the raspberry pi.
So as someone mentioned, I need a compiler, and I need some kind of extremely minimalistic editor, and somekind of drivers where the raspberry comunicate with my keyboard and my screen. Thats all. So, what should I go for?

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Minimalistic C-Development

Tue Apr 26, 2016 9:48 pm

Telash wrote:I need a compiler, and I need some kind of extremely [minimal] editor, and some kind of drivers [so that] the raspberry communicates with my keyboard and my screen. Thats all. So, what should I go for?
Raspbian Jessie Lite

Start with Jessie Lite. Learn how to use the editor (vim); often referred to as vi. Learn how to open a terminal, and how to launch the gcc compiler. You might also be interested in trying the clang LLVM compiler (you'll have to load it from the repositories). As I said before, check out the GNU.org site for a list of gnu development tools, including dbg (the debugger).

Most important, have fun; don't become cynical, and never give up--- we all had to start someplace, and you're starting right here! Good for you-- Go! You might be the next guy out in a couple of years with the next hot distro (I have a hope for you)..
marcus
:ugeek:

Telash
Posts: 4
Joined: Tue Apr 26, 2016 3:24 pm

Re: Minimalistic C-Development

Tue Apr 26, 2016 10:02 pm

Thanks alot mate, sounds like a perfect way to start realy. Hope you are here to help me again when its time for my next step.

tasulife
Posts: 1
Joined: Fri Dec 07, 2012 8:14 pm

Re: Minimalistic C-Development

Mon May 09, 2016 9:12 pm

Hi Telash!

I've been wanting to do what you're saying for a really long time. I have been studying operating systems and "bare metal computing" for similar reasons - I want to understand the "minimal" requirements to execute my own programs.

I think a good place for you to gain inspiration is from this resource:
https://github.com/dwelch67/raspberrypi

This man has done a lot of bare metal computing on the rasperry PI and gives you a good sense of the level of effort for various things.

In general, my sense of things is that you should be able to run bare metal "c" programs on the raspberry pi by doing the following:

- get an arm assembler
- get an arm c compiler

- write some c-stack setup code in assembly, then call the c "main" program
- write a c "main" function, and compile it in "standalone" mode. This means you have no stdio, no stdlib, no c runtime (so no "new/maloc) etc etc etc. it will run in "realtime" because there's no kernel. This is very much like microcontroller code.

- build and link the assembly and c program together
- you must name the binary kernel.img or kernel7.img (based on your raspi version)
- copy this file to your sd card, insert and run.

At the begninng stages, you might want to use QEMU to emulate the rasperry pi, because you can inspect all the registers from qemu.

Have you made any progress? Best.

Return to “C/C++”