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 C8A767EE25 for ; Mon, 4 Nov 2013 14:10:17 +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.15.4; 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.15.4; 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.15.4; 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: AjICAAGcd1LU4w8EnGdsb2JhbABZgz+6S4ZsFg4BAQEBAQYNCQkUKIJmezQFKIgiARacf5ZkH4ojjg+BZoMKgQ4DmAmGKo8HgXA X-IPAS-Result: AjICAAGcd1LU4w8EnGdsb2JhbABZgz+6S4ZsFg4BAQEBAQYNCQkUKIJmezQFKIgiARacf5ZkH4ojjg+BZoMKgQ4DmAmGKo8HgXA X-IronPort-AV: E=Sophos;i="4.93,632,1378850400"; d="scan'208";a="40815390" Received: from mout.web.de ([212.227.15.4]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 04 Nov 2013 14:09:47 +0100 Received: from frosties.localnet ([37.49.32.119]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LrJwm-1VnAiy2DBU-0135wf for ; Mon, 04 Nov 2013 14:10:16 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1VdJv5-0007NQ-L3 for caml-list@inria.fr; Mon, 04 Nov 2013 14:10:15 +0100 Date: Mon, 4 Nov 2013 14:10:15 +0100 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20131104131015.GA27957@frosties> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:3JV7UONUztwxJNCVWVE/Heb73R9WIadxQtfT3Lg9mZzNqGTOdHH z8vn3YvAwBMPh5DkjyJysyuW+y80tS62ROD5EEQxcShu8pxtn24CNvSkyfOlJladbDXDXz8 9MGDqHOsPmwcy2aZq95UY9ixU/AGCEo8hGvkPexJpuXp1OLmH2BCR78DdJmOjUbJMS7IZ4n l8MJPP6DUZRcLfgqkgFbQ== Subject: [Caml-list] Ocaml on RaspberryPi bare-metal crashes 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: - Compile ocaml source into a single object file: ocamlopt -output-obj -o prog.o foo.ml - Compile a boot.S and main.c file providing the hardware interface and libc (libm, libdl) functions needed by ocaml. A lot of stuff is just stubs that will return errors or nonsense (like all the math functions return 0). But I have memory and print functions working. The main() initializes the hardware and calls caml_startup(). - Add libasmrun.a and libgcc.a from the system. - Link it all together and objcopy to binary to get a kernel image for booting. Everything compiles and links without errors. And the kernel boots and outputs its startup messages before starting ocaml. But then is where things get tricky: ---- foo.ml ---- let () = () ---------------- Ocaml starts and finishes and the kernel outputs its finished message. Everything seems to be working fine. ---- foo.ml ---- let () = Printf.printf "Hello World\n%!" ---------------- Ocaml does its startup (calls the same libc functions as before) but then the system resets before printing "Hello World\n". I don't see any sprintf() or fputs() or fwrite() calls. 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? One idea I got while writing the email is that maybe the stack is the problem. I only setup a 16k stack at boot. Does ocaml create its own stack or should I make the stack larger? Would a simple printf exceed 16k stack? MfG Goswin