Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Peter Zotov <whitequark@whitequark.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Ocaml on RaspberryPi bare-metal crashes
Date: Mon, 4 Nov 2013 21:38:03 +0100	[thread overview]
Message-ID: <20131104203803.GA1057@frosties> (raw)
In-Reply-To: <393565311ce19d3358ed3799df56bcda@whitequark.org>

On Mon, Nov 04, 2013 at 05:41:48PM +0400, Peter Zotov wrote:
> Goswin von Brederlow ?????????? 04.11.2013 17:10:
> >Hi,
> >
> >over the weekend I wrote some boot code and glue to make ocaml run
> >bare-metal on a RaspberryPi. Here is what I did:
> >...
> >I'm not sure why it crashes and I haven't setup exception handlers yet
> >that would tell me what or where exactly it crashes. But the only new
> >bits are the initialization of the printf module and the printf call
> >itself. Must be one or the other.
> >
> >Does anyone want to take a blind guess what could be wrong?
> 
> If I was you:
> 
> 1) I'd try to set up an emulator as close to RPi as possible and
> reproduce.
>    Qemu has an integrated gdbserver and with RPi's popularity,
> chances that
>    someone customized it already.
> 
> 2) If there's no luck with emulator, I'd link in a GDB stub for ARM
>    communicating via a hardware serial port. This one seems to be
> easy enough
>    to port:
> https://github.com/BurntBrunch/rockbox-fft/blob/master/gdb/arm-stub.c
> 
> (Incidentally, this demonstrates why you don't generally want to use
> hardware
> without accessible JTAG. :)

I think that only works with interrupts enabled. I'm not that far yet.
Still doing input/output by polling the uart.

I've now setup the exception vector base address register and
installed exception handlers that print out the name of the exception
and a register dump. That showed me 2 problems:

1) doing some kind of output (print_string or Printf.printf) uses
floating point stuff. I didn't have the FPU enabled yet so that threw
and undefined exception. Not sure if the float is used somewhere in
the IO layer or if that triggers something in the GC that uses floats.
Might not even be IO related at all but caused by allocating a heap
value. The simple tests that succeeded before all only used stack.

2) malloc() needs to return 8 byte aligned blocks or storing 64bit
values fails. Doing output initializes the stdout channel, which calls
lseek64 and stores the resultint int64_t.


So now I have ocaml running barebone on my RaspberryPi in a verry
minimal way.

ToDo:
- LED module (turn on/off the OK LED)
- Framebuffer / Graphics modules
- Timer module
- implement free()
- Threads
- USB module
  + keyboard
  + mouse
  + ethernet
- tcp/ip stack
- audio
- GPIO module

If anyone is interested I can upload what I have so far to github. But
beware it is verry much a WIP.

MfG
	Goswin

  reply	other threads:[~2013-11-04 20:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04 13:10 Goswin von Brederlow
2013-11-04 13:41 ` Peter Zotov
2013-11-04 20:38   ` Goswin von Brederlow [this message]
2013-11-04 22:38     ` David Scott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131104203803.GA1057@frosties \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    --cc=whitequark@whitequark.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox