Run Haskell code on mbed NXP LPC1768

Install Ajhc Haskell Compiler

$ sudo apt-get install haskell-platform gcc make m4
$ cabal install ajhc
$ export PATH=$HOME/.cabal/bin:$PATH
$ ajhc --version | head -1
ajhc 0.8.0.8 (a8461bb87b4de2b28c6cfe3fd1099e306b772dae)

Upgrade firmware

http://mbed.org/handbook/Firmware-LPC1768-LPC11U24

Use rev 141212 or later firmware, to support CMSIS-DAP.

Install pyOCD

http://mbed.org/blog/entry/Debugging-from-GDB-using-pyOCD/

$ sudo apt-get install python libusb-1.0-0-dev
$ git clone git@github.com:walac/pyusb.git
$ cd pyusb
$ sudo python setup.py install
$ git clone git@github.com:mbedmicro/mbed.git
$ cd mbed/workspace_tools/debugger
$ sudo python setup.py install

Setup toolchain

$ git clone git://github.com/ajhc/demo-cortex-m3.git
$ cd demo-cortex-m3/mbed-nxp-lpc1768
$ ./linux_install
Finished successfully
Press any key to continue...

How to build

$ cd demo-cortex-m3/mbed-nxp-lpc1768
$ ./BuildShell
$ cd samples/Haskell_TextLCD
$ ls hs_src/
Delay.hs  Led.hs  Main.hs
$ make

Write to flash

In one terminal, start the connection to the board.

$ cd demo-cortex-m3/mbed-nxp-lpc1768
$ sudo python gdbserver4mbed.py

In another terminal, connect to the debugger and flash program.

$ cd demo-cortex-m3/mbed-nxp-lpc1768
$ ./BuildShell
$ cd samples/Haskell_TextLCD
$ make gdbwrite
(gdb) c

Enjoy. :)

Detail


Please log in to post comments.