How to run a "Hello world" on ppc board?

I am using ppc 405gp and monta vista. How to make a simple "Hello world" C program so that boot loader can load it and run it in RAM? The boot loader already has serial port enabled. I will be happy if I can see the string output on the serial monitor (I am using minicom). Is this kind of program considered running in kernel space or user space? Should I use printf or printk? Could anyone give some detailed compile and link commands?

Thanks!

Reply to
Frank
Loading thread data ...

Frank emitted:

if your serial-device on your ppc would be /dev/ttyS0 then try

/../MyHelloWorld 2>%1 >/dev/ttyS0

in your startup script. May by you have to set the right baudrate eg. first.

You could also open and configure the device from whithin your programm

const char msg[] = {"\nHallo luna.\n"};

int main(int argc, char** argv, char** envp) { int tty=open("/dev/ttYS0",..... // setup the term by ioctl if needed write(tty,msg, sizeof(msg)); close(tty); return main(0,"",""); }

mfg j.

--
Alle in diesem Text gemachte Rechtschreibfehler sind geistiges Eigentum des
Autors. Wer diese Rechtschreibfehler nachmacht oder verfälscht, kann mit
Spam nicht unter 10 Megabyte bedacht werden.
Reply to
Juergen_Sievers

Read the manuals that come with MontaVista's distribution, and get the board to boot the MontaVista kernel via TFTP and NFS. You can then cross-compile a test program, put it in the NFS exported directory on your host, and either use ssh or a serial terminal (minicom) to log in and run the program.

Blane.

Reply to
Blane Bramble

I think I didn't make myself clear. I haven't had the linux kernel running on my board yet. The board has only a boot loader. The boot loader has TFTP and serial port enabled. I am wondering if I can run a program _before_ I load the linux kernel? In another word, can I use the boot loader to load a C program and send some data to serial port so that I can monitor it through minicom?

Thanks, Frank

Reply to
Frank

Sure, if your program knows how to manage resources (memory, devices) and handle external events, in other words if your program *is* an operating system.

Reply to
Fred

You must provide more details. Which boot loader, for example?

Some of them, like U-Boot for example, allow you to use "standalone applications" which can use services provided by the boot loader, like standard functions as printf() etc.

Other boot loaders don't provide any interface to their builtin drivers, so you will probably end up re-coding your own serial driver if you need console output.

Also, there may be a C runtime environment, or there may be not.

I cannot even guess without precise information.

Best regards,

Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88   Web: www.denx.de
"In matters of principle, stand like a rock;  in  matters  of  taste,
swim with the current."                            - Thomas Jefferson
Reply to
Wolfgang Denk

The boot loader I am using is vxworks boot loader. It's a left-over of the last project. I just don't have a way to update the boot loader in flash, so I just use as it is.

Does vxworks boot loader provide console output interface?

Thanks, Frank

Reply to
Frank

The short answer to your question is "No". The VxWorks boot loader is intended to load an entire executable OS. You use the loader to load the OS, (commonly referred to as a BSP), then you can use the tornado development suite to give you an interface, or you can interact directly with a shell, if the BSP was built with one. The loader tpyically has a few built-in commands, but it cannot link new programs into itself.

Speaking only for myself,

Joe Durusau

Frank wrote:

Reply to
joe durusau

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.