Santhosh Piduri
Posts: 5
Joined: Sat Apr 22, 2017 7:09 pm

Printing characters on monitor connected to raspberry pi 3?

Sat Apr 22, 2017 7:28 pm

Recently I have started bare metal programming, starting with simple LED blink c programming that runs on bare metal. Now I need to print "helloworld" on my monitor.

Could anyone please how to start programming to complete my task in bare metal ?

Thanks in advance!

crashboogie
Posts: 34
Joined: Thu Aug 04, 2016 4:03 am

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 3:57 am

After logging into your Rpi, type this command:

Code: Select all

sudo apt-get install python3
click yes if it asks to install

after its done type

Code: Select all

sudo nano ~/hello world.py
Once you're in nano (text editor) you'll see a blank screen. Type

Code: Select all

#!/usr/bin/python
print "Hello, World!";
From here type CTRL+X, then "Y" to save the changes, and enter to confirm the name.

After this just type

Code: Select all

Sudo python ~/hello world.py
Good luck :D

crashboogie
Posts: 34
Joined: Thu Aug 04, 2016 4:03 am

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 3:59 am

Also, this article goes into some depth, and if you get stuck it'd be a good resource.

http://www.circuitbasics.com/how-to-wri ... pberry-pi/

Santhosh Piduri
Posts: 5
Joined: Sat Apr 22, 2017 7:09 pm

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 4:08 am

crashboogie wrote:Also, this article goes into some depth, and if you get stuck it'd be a good resource.

http://www.circuitbasics.com/how-to-wri ... pberry-pi/
Hello, Thank you very much for replying. I am looking for bare metal program ... to display characters in monitor. There is no operating system installed on my Raspberrypi .

W. H. Heydt
Posts: 10888
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 5:37 am

Santhosh Piduri wrote:Recently I have started bare metal programming, starting with simple LED blink c programming that runs on bare metal. Now I need to print "helloworld" on my monitor.

Could anyone please how to start programming to complete my task in bare metal ?

Thanks in advance!
Probably the best bet would be to browse through the Bare Metal Forum. Although I must say, displaying text may not be something generally done in bare metal programming. In the normal course of events--with a full OS running--there is a lot going on where you can't see it to get text onto a display. Actually *printing* (to a physical printer) might be easier. An intermediate step would probably be to see if you can write test to a terminal attached to a serial line (the original VDTs were sometimes referred to as "glass TTYs").

User avatar
rpdom
Posts: 15208
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 5:47 am

The simplest way to access the screen from bare metal is by requesting a frame buffer to be created in memory and writing pixels directly into that. If you want to write text you will need to generate the characters yourself as the Pi doesn't have anything like that built in. I've done some work on this in assembler, but not C.

This post would get better responses in the Bare Metal forum viewforum.php?f=72 (I've asked the mods to move it from General Discussion)

User avatar
Gavinmc42
Posts: 3736
Joined: Wed Aug 28, 2013 3:31 am

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 6:53 am

Grab Ultibo, install in Windows or run under Wine on a Linux box.
https://ultibo.org/

It's not really baremetal, more like polished metal :lol:
It will make a kernel.bin file that will do want you want and much more.
Get the Sensormatic3000 example running, to see some of the stuff it can do.

It you want to do it the hard way, plenty of links in the sticky.
viewtopic.php?f=72&t=72260
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Santhosh Piduri
Posts: 5
Joined: Sat Apr 22, 2017 7:09 pm

Re: Printing characters on monitor connected to raspberry pi

Sun Apr 23, 2017 3:30 pm

rpdom wrote:The simplest way to access the screen from bare metal is by requesting a frame buffer to be created in memory and writing pixels directly into that. If you want to write text you will need to generate the characters yourself as the Pi doesn't have anything like that built in. I've done some work on this in assembler, but not C.

This post would get better responses in the Bare Metal forum viewforum.php?f=72 (I've asked the mods to move it from General Discussion)
Thank you very much!

LdB
Posts: 1238
Joined: Wed Dec 07, 2016 2:29 pm

Re: Printing characters on monitor connected to raspberry pi

Mon Apr 24, 2017 4:04 am

The code in the article
https://www.codeproject.com/Articles/11 ... he-Pi-part
Will do show you what to do.

There is a 16x8 bitmap font included to provide the onscreen characters and it gives you the code for display in 3 different colour modes.

Essentially the C compiler is using Newlib and what we are doing is providing our own routines to the C system. A search on something like "newlib implementation" will give you background if you need.
A start point might be
https://www.cs.ccu.edu.tw/~pahsiung/cou ... newlib.pdf

dwelch67
Posts: 955
Joined: Sat May 26, 2012 5:32 pm

Re: Printing characters on monitor connected to raspberry pi

Mon Apr 24, 2017 2:58 pm

These are pixel based screens so to make characters you need a font, my examples have some, maybe not my raspi ones but GBA or others, not too hard to come by a fixed font (all characters the same width in pixels) is easier to start with perhaps...

You will need to use the mailboxes to get the address to the frame buffer, from there you simply write pixel data to your hearts content. In a nutshell it is that simple. Would start by writing some data, maybe a counter to see visually what that does, what corner is the 0,0 coordinate corner, etc what bytes are red, green, blue, even if you have countless examples or documentation, experiment yourself.

You can take the newlib path to get at a printf, I recommend if you do learning how that works too, take the unmodified newlib sources, then find the libcfunc and system backend files. I start by cutting the guts out of every function and making them return a passing value which can vary from one to another. then figure out which ones are used to do a printf if printf is what you are after, should be a _write and an is tty call (not in that order), might not do an fopen since stdout is a hardcoded file handle, but who knows maybe they will...Hook in your print a character routine with your keeping track of x and y, carriage returns and line feeds. Eventually you should be able to just do a printf, if that is what you are after (obviously you would ahve the ability to print hello world using a character routine to put the characters in the frame).

baantonia
Posts: 63
Joined: Fri Feb 06, 2015 2:19 pm

Re: Printing characters on monitor connected to raspberry pi

Mon Apr 24, 2017 11:04 pm

I'm gradually building up a library of routines, not great but works. Haven't looked at this for a few months, was in the process of checking out pwm. The codes target is for a pi zero but can be changed in the settings. However it does use the mailboxes and creates a framebuffer to output to the screen. https://drive.google.com/open?id=0B8dQ7 ... zlxeThqenc. pizerotest.c has the entry point kernel_main.

Return to “Bare metal, Assembly language”