[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Fwd: [Caml-list] Ocaml on RaspberryPi bare-metal crashes
Begin forwarded message: > From: Goswin von Brederlow <goswin-v-b@xxxxxx> > Subject: [Caml-list] Ocaml on RaspberryPi bare-metal crashes > Date: 4 November 2013 08:10:15 GMT-5 > To: caml-list@xxxxxxxx > Reply-To: Goswin von Brederlow <goswin-v-b@xxxxxx> > > 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 > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |