From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id D422B7EE25 for ; Mon, 4 Nov 2013 21:38:05 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.17.11; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=mailfrom; client-ip=212.227.17.11; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.17.11; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvQCAMEEeFLU4xELnGdsb2JhbABZgz+6TYVFgSwWDgEBAQEBBg0JCRQogiUBAQU6PxALDgoJJQ8FKCGIAQEWCbN5H4ofBI0CglYHgyCBDgOYCYYqjwc X-IPAS-Result: AvQCAMEEeFLU4xELnGdsb2JhbABZgz+6TYVFgSwWDgEBAQEBBg0JCRQogiUBAQU6PxALDgoJJQ8FKCGIAQEWCbN5H4ofBI0CglYHgyCBDgOYCYYqjwc X-IronPort-AV: E=Sophos;i="4.93,634,1378850400"; d="scan'208";a="40897787" Received: from mout.web.de ([212.227.17.11]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 04 Nov 2013 21:37:34 +0100 Received: from frosties.localnet ([37.49.32.119]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M4qWn-1Vq29B2osH-00yzbx for ; Mon, 04 Nov 2013 21:38:04 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1VdQuR-0000NO-Sy; Mon, 04 Nov 2013 21:38:03 +0100 Date: Mon, 4 Nov 2013 21:38:03 +0100 From: Goswin von Brederlow To: Peter Zotov Cc: caml-list@inria.fr Message-ID: <20131104203803.GA1057@frosties> References: <20131104131015.GA27957@frosties> <393565311ce19d3358ed3799df56bcda@whitequark.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <393565311ce19d3358ed3799df56bcda@whitequark.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:C4ZnAbcbFS9OyuIXQbBQn4xUeqHc8GJWhbX99dtRHAiFO+NGo+W g45sLITl9bouq16qLXRbXlonKcZCkAUxPesS+jlIzDhaL/t33Z8TNU9UHreuCx2E7sw+Cpa qrWRp0YzpVBlWdXx+BdZKuh2Ek+Vj3C0rZd8uaw9l5mYt6qgjhmeG/fUEpo9cJVxHizgcB1 3iWNDA89cADxjvFrEZ/Hg== Subject: Re: [Caml-list] Ocaml on RaspberryPi bare-metal crashes 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