SlideShare a Scribd company logo
1 of 37
Download to read offline
Metasepi team meeting #7: 
#7:
Snatch application on tiny OS
Kiwamu Okabe
Who am I?
☆ http://www.masterq.net/
☆ Twitter: @master_q
☆ Organizer of Metasepi project
☆ A developer of Ajhc Haskell compiler
☆ A Debian Maintainer
☆ 10 years' experience in developing
OS using NetBSD.
Agenda
☆ [1] Demo
☆ [2] What is Ajhc?
☆ [3] What is Metasepi?
☆ [4] What is compiler to build OS
☆ [5] How to use Ajhc
☆ [6] Snatch application on tiny OS
☆ [7] Let's Snatch it!
[1] Demo
☆ RSS reader running on mbed (ARM).
☆ Show reddit articles on LCD display.
☆ You can watch the movie following.
http://bit.ly/mbedmov
Demo hardware
Architecture: ARM Cortex-M3
RAM size: 64kB
IO: Ethernet, LED, LCD, SD Card, USB
host/device, Serial
Demo software
github.com/ajhc/demo-cortex-m3
[2] What is Ajhc?
http://ajhc.metasepi.org/
☆ Ajhc := A fork of jhc
☆ jhc := John's Haskell Compiler
☆ http://repetae.net/computer/jhc/
☆ Jhc outputs binary that has lowmemory-footprint and runs fast.
☆ Good for embedded software.
Why need Ajhc?
☆ GHC is de facto standard on Haskell.
☆ GHC := Glasgow Haskell Compiler
☆ http://www.haskell.org/ghc/
☆ Why need another Haskell compiler?
☆ To develop kernel named "Metasepi".
[3] What is Metasepi?
http://metasepi.org/
☆ Unix-like OS designed by strong type.
☆ Using ML or more strong type lang.
Haskell http://www.haskell.org/
OCaml http://caml.inria.fr/
MLton http://mlton.org/
. . . and suchlike.
Why need Metasepi?
☆ We have already Linux or Windows.
☆ But the developers are suffering.
☆ If use the kernel changed by you,
☆ you will get many runtime error.
☆ Difficult even to reproduce it.
Doesn't OSS have good quality?
☆ "The Cathedral and the Bazaar"
☆ "Given enough eyeballs, all bugs are
shallow."
http://cruel.org/freeware/cathedral.html

☆ But if you develop your own product
reusing OSS...
Low quality out of OSS umbrella
Type safety
☆ Less runtime errors.
☆ "数理科学的バグ撲滅方法論のすすめ"
http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/
Kernel desperately wants type
☆ Kernels are developed with C lang.
☆ Error on user space => SEGV
☆ Error on kernel space => halt!
☆ Should design kernel with the
greatest care.
☆ C language is safe?
[4] What is compiler to build OS
☆ Need strong type.
☆ Need flexibility such as C language.
☆ Create it if there are not!
☆ From scratch? No thank you...
☆ Look for our compiler base.
Want POSIX free compiler
Programs to print "hoge" on terminal.

The lesser depends on POSIX, the
smaller values.
Jhc output has only 20 undef
$ nm hs.out | grep
U
U
U
U
U
U
U
U
U
U
U
U
U
U
U
U
U
U
U
U

"U "
_IO_putc@@GLIBC_2.2.5
__libc_start_main@@GLIBC_2.2.5
_setjmp@@GLIBC_2.2.5
abort@@GLIBC_2.2.5
ctime@@GLIBC_2.2.5
exit@@GLIBC_2.2.5
fflush@@GLIBC_2.2.5
fprintf@@GLIBC_2.2.5
fputc@@GLIBC_2.2.5
fputs@@GLIBC_2.2.5
free@@GLIBC_2.2.5
fwrite@@GLIBC_2.2.5
getenv@@GLIBC_2.2.5
malloc@@GLIBC_2.2.5
memset@@GLIBC_2.2.5
posix_memalign@@GLIBC_2.2.5
realloc@@GLIBC_2.2.5
setlocale@@GLIBC_2.2.5
sysconf@@GLIBC_2.2.5
times@@GLIBC_2.2.5
Jhc is translator to C language
Easy to cross build
Survive burning out
Let's develop in dogfooding style. (The
method is called "Snatch".)
[5] How to use Ajhc
Case of Ubuntu 12.04 amd64.
$ sudo apt-get install haskell-platform libncurses5-dev gcc m4
$ cabal update
$ export PATH=$HOME/.cabal/bin/:$PATH
$ cabal install ajhc
$ which ajhc
/home/USER/.cabal/bin/ajhc
$ echo 'main = print "hoge"' > Hoge.hs
$ ajhc Hoge.hs
$ ./hs.out
"hoge"

You can use on Windows or Mac OS X.
Detail of usage
Please read "Ajhc User's Manual".
☆ ajhc.metasepi.org/manual.html
Also you can read in Japanese.
☆ ajhc.metasepi.org/manual_ja.html
[6] Snatch application on tiny OS
Snatch only the LED blinker thread.
☆ Board: STM32F4 Discovery
http://www.st.com/stm32f4-discovery
☆ OS: ChibiOS/RT
http://www.chibios.org/
Application code before Snatch
// File: main.c
#include "ch.h"
#include "hal.h"
#include "test.h"
static adcsample_t samples[ADC_GRP1_NUM_CHANNELS
ADC_GRP1_BUF_DEPTH];
static const ADCConversionGroup adcgrpcfg = {
// --snip-static PWMConfig pwmcfg = {
// --snip-static const SPIConfig spi2cfg = {
// --snip-static void pwmpcb(PWMDriver *pwmp) {
// --snip-void adccb(ADCDriver *adcp, adcsample_t *buffer,
// --snip-static void spicb(SPIDriver *spip) {
// --snip-static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
// --snip-int main(void) {
// --snip--

*

size_t n) {
LED blinker thread
// File: main.c
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
while (TRUE) {
palSetPad(GPIOD, GPIOD_LED3);
chThdSleepMilliseconds(500);
palClearPad(GPIOD, GPIOD_LED3);
chThdSleepMilliseconds(500);
}
}

/* Orange. */
/* Orange. */

int main(void) {
// --snip-chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO,
Thread1, NULL);
Application design
[7] Let's Snatch it!
The source code at the following.
github.com/metasepi/chibios-arafura
Run simple Haskell code #1
-- File: hs_src/Main.hs
main :: IO ()
main = return ()
// File: main.c
static char malloc_heapstart[(2*1024)];
static MemoryHeap heap_desc;
void malloc_init(void) {
chHeapInit(&heap_desc, (void *)malloc_heapstart, (2*1024));
}
int main(void) {
// --snip-{ /* Init Ajhc RTS (Haskell) */
int hsargc = 1;
char *hsargv = "q";
char **hsargvp = &hsargv;
malloc_init();
hs_init(&hsargc, &hsargvp);
_amain();
}
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO,
Thread1, NULL);
Run simple Haskell code #2
Blink LED only once #1
-- File: hs_src/Main.hs
foreign export ccall "blinkOrange" blinkOrange :: IO ()
blinkOrange :: IO ()
blinkOrange = do
c_palSetPad c_GPIOD c_GPIOD_LED3
c_chThdSleepMilliseconds 500
c_palClearPad c_GPIOD c_GPIOD_LED3
c_chThdSleepMilliseconds 500
// File: main.c
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
while (TRUE) {
blinkOrange(); // Haskell
}
}
Blink LED only once #2
Snatch blink thread code #1
-- File: hs_src/Main.hs
foreign export ccall "threadBlinkOrange" threadBlinkOrange :: IO ()
threadBlinkOrange :: IO ()
threadBlinkOrange = forever blinkOrange
// File: main.c
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
threadBlinkOrange();
}
Snatch blink thread code #2
Use forkOS API #1
-- File: hs_src/Main.hs
main :: IO ()
main = void $ forkOS threadBlinkOrange
// File: conc_custom.c
void
forkOS_createThread_init()
{
chPoolInit(&pooldesc, THD_WA_SIZE(STACKSIZE), NULL);
chPoolLoadArray(&pooldesc, (void *) pool_buf, NTHREADS);
}
jhc_threadid_t
forkOS_createThread(void *(*wrapper) (void *),void *entry,int *err)
{
Thread *tid;
tid = chThdCreateFromMemoryPool(&pooldesc, NORMALPRIO,
(tfunc_t) wrapper, entry);
if (NULL == tid) { abort(); }
return tid;
}
Use forkOS API #2
GOAL !
PR: Call For Articles
☆ http://www.paraiso-lang.org/ikmsm/
☆ Fanzine of functional programming.
☆ About Haskell or OCaml or . . .
☆ Article about Ajhc in C84 book.
☆ Call me if you read it!
http://www.paraiso-lang.org/ikmsm/books/c85.html

More Related Content

What's hot

How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Why is Python slow? Python Nordeste 2013
Why is Python slow? Python Nordeste 2013Why is Python slow? Python Nordeste 2013
Why is Python slow? Python Nordeste 2013Daker Fernandes
 
How to rewrite the OS using C by strong type
How to rewrite the OS using C by strong typeHow to rewrite the OS using C by strong type
How to rewrite the OS using C by strong typeKiwamu Okabe
 
OVHcloud TechTalks - ML serving
OVHcloud TechTalks - ML servingOVHcloud TechTalks - ML serving
OVHcloud TechTalks - ML servingOVHcloud
 
#Include os - From bootloader to REST API with the new C++
#Include os - From bootloader to REST API with the new C++#Include os - From bootloader to REST API with the new C++
#Include os - From bootloader to REST API with the new C++IncludeOS
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel modecorehard_by
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8Phil Eaton
 
Evdokimov python arsenal for re
Evdokimov   python arsenal for reEvdokimov   python arsenal for re
Evdokimov python arsenal for reDefconRussia
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"Badoo Development
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for JavaCharles Anderson
 
Nix: What even is it though?
Nix: What even is it though?Nix: What even is it though?
Nix: What even is it though?Burke Libbey
 
Give me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbGive me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbgregthelaw
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScriptOleg Podsechin
 
GDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewGDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewUndo
 
Php code profiling_using_x_debug
Php code profiling_using_x_debugPhp code profiling_using_x_debug
Php code profiling_using_x_debugGennady Feldman
 
Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015
Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015
Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015curryon
 
Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin TechnicalMachine
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Pôle Systematic Paris-Region
 

What's hot (20)

How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Why is Python slow? Python Nordeste 2013
Why is Python slow? Python Nordeste 2013Why is Python slow? Python Nordeste 2013
Why is Python slow? Python Nordeste 2013
 
How to rewrite the OS using C by strong type
How to rewrite the OS using C by strong typeHow to rewrite the OS using C by strong type
How to rewrite the OS using C by strong type
 
OVHcloud TechTalks - ML serving
OVHcloud TechTalks - ML servingOVHcloud TechTalks - ML serving
OVHcloud TechTalks - ML serving
 
#Include os - From bootloader to REST API with the new C++
#Include os - From bootloader to REST API with the new C++#Include os - From bootloader to REST API with the new C++
#Include os - From bootloader to REST API with the new C++
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
Evdokimov python arsenal for re
Evdokimov   python arsenal for reEvdokimov   python arsenal for re
Evdokimov python arsenal for re
 
Tools
ToolsTools
Tools
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
 
Nix: What even is it though?
Nix: What even is it though?Nix: What even is it though?
Nix: What even is it though?
 
Give me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbGive me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdb
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
 
GDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewGDB: A Lot More Than You Knew
GDB: A Lot More Than You Knew
 
Php code profiling_using_x_debug
Php code profiling_using_x_debugPhp code profiling_using_x_debug
Php code profiling_using_x_debug
 
Embedded. What Why How
Embedded. What Why HowEmbedded. What Why How
Embedded. What Why How
 
Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015
Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015
Bits of Advice for the VM Writer, by Cliff Click @ Curry On 2015
 
Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
 

Similar to Metasepi team meeting #7: Snatch application on tiny OS

Metasepi team meeting #6: "Snatch-driven development"
Metasepi team meeting #6: "Snatch-driven development"Metasepi team meeting #6: "Snatch-driven development"
Metasepi team meeting #6: "Snatch-driven development"Kiwamu Okabe
 
Metasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKMetasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKKiwamu Okabe
 
Metasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using HaskellKiwamu Okabe
 
Share the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardJian-Hong Pan
 
Metasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoKiwamu Okabe
 
Metasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewMetasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewKiwamu Okabe
 
Functional IoT: Hardware and Platform
Functional IoT: Hardware and PlatformFunctional IoT: Hardware and Platform
Functional IoT: Hardware and PlatformKiwamu Okabe
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentCorley S.r.l.
 
Writing NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in HaskellWriting NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in HaskellKiwamu Okabe
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)Douglas Chen
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll buildMark Stoodley
 
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbersDefcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbersAlexandre Moneger
 
07 - Bypassing ASLR, or why X^W matters
07 - Bypassing ASLR, or why X^W matters07 - Bypassing ASLR, or why X^W matters
07 - Bypassing ASLR, or why X^W mattersAlexandre Moneger
 
Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.J On The Beach
 
01 linux-quick-start
01 linux-quick-start01 linux-quick-start
01 linux-quick-startNguyen Vinh
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...PROIDEA
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilersAnastasiaStulova
 

Similar to Metasepi team meeting #7: Snatch application on tiny OS (20)

Metasepi team meeting #6: "Snatch-driven development"
Metasepi team meeting #6: "Snatch-driven development"Metasepi team meeting #6: "Snatch-driven development"
Metasepi team meeting #6: "Snatch-driven development"
 
Metasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKMetasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDK
 
Metasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using Haskell
 
How to Use OpenMP on Native Activity
How to Use OpenMP on Native ActivityHow to Use OpenMP on Native Activity
How to Use OpenMP on Native Activity
 
Share the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development Board
 
Metasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on ArduinoMetasepi team meeting #19: ATS application on Arduino
Metasepi team meeting #19: ATS application on Arduino
 
Metasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewMetasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project Overview
 
Functional IoT: Hardware and Platform
Functional IoT: Hardware and PlatformFunctional IoT: Hardware and Platform
Functional IoT: Hardware and Platform
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application Development
 
Writing NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in HaskellWriting NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in Haskell
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll build
 
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbersDefcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
 
07 - Bypassing ASLR, or why X^W matters
07 - Bypassing ASLR, or why X^W matters07 - Bypassing ASLR, or why X^W matters
07 - Bypassing ASLR, or why X^W matters
 
Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.
 
01 linux-quick-start
01 linux-quick-start01 linux-quick-start
01 linux-quick-start
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
 
Nodejs
NodejsNodejs
Nodejs
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilers
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Metasepi team meeting #7: Snatch application on tiny OS

  • 1. Metasepi team meeting #7:  #7: Snatch application on tiny OS Kiwamu Okabe
  • 2. Who am I? ☆ http://www.masterq.net/ ☆ Twitter: @master_q ☆ Organizer of Metasepi project ☆ A developer of Ajhc Haskell compiler ☆ A Debian Maintainer ☆ 10 years' experience in developing OS using NetBSD.
  • 3. Agenda ☆ [1] Demo ☆ [2] What is Ajhc? ☆ [3] What is Metasepi? ☆ [4] What is compiler to build OS ☆ [5] How to use Ajhc ☆ [6] Snatch application on tiny OS ☆ [7] Let's Snatch it!
  • 4. [1] Demo ☆ RSS reader running on mbed (ARM). ☆ Show reddit articles on LCD display. ☆ You can watch the movie following. http://bit.ly/mbedmov
  • 5. Demo hardware Architecture: ARM Cortex-M3 RAM size: 64kB IO: Ethernet, LED, LCD, SD Card, USB host/device, Serial
  • 7. [2] What is Ajhc? http://ajhc.metasepi.org/ ☆ Ajhc := A fork of jhc ☆ jhc := John's Haskell Compiler ☆ http://repetae.net/computer/jhc/ ☆ Jhc outputs binary that has lowmemory-footprint and runs fast. ☆ Good for embedded software.
  • 8. Why need Ajhc? ☆ GHC is de facto standard on Haskell. ☆ GHC := Glasgow Haskell Compiler ☆ http://www.haskell.org/ghc/ ☆ Why need another Haskell compiler? ☆ To develop kernel named "Metasepi".
  • 9. [3] What is Metasepi? http://metasepi.org/ ☆ Unix-like OS designed by strong type. ☆ Using ML or more strong type lang. Haskell http://www.haskell.org/ OCaml http://caml.inria.fr/ MLton http://mlton.org/ . . . and suchlike.
  • 10. Why need Metasepi? ☆ We have already Linux or Windows. ☆ But the developers are suffering. ☆ If use the kernel changed by you, ☆ you will get many runtime error. ☆ Difficult even to reproduce it.
  • 11. Doesn't OSS have good quality? ☆ "The Cathedral and the Bazaar" ☆ "Given enough eyeballs, all bugs are shallow." http://cruel.org/freeware/cathedral.html ☆ But if you develop your own product reusing OSS...
  • 12. Low quality out of OSS umbrella
  • 13. Type safety ☆ Less runtime errors. ☆ "数理科学的バグ撲滅方法論のすすめ" http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/
  • 14. Kernel desperately wants type ☆ Kernels are developed with C lang. ☆ Error on user space => SEGV ☆ Error on kernel space => halt! ☆ Should design kernel with the greatest care. ☆ C language is safe?
  • 15. [4] What is compiler to build OS ☆ Need strong type. ☆ Need flexibility such as C language. ☆ Create it if there are not! ☆ From scratch? No thank you... ☆ Look for our compiler base.
  • 16. Want POSIX free compiler Programs to print "hoge" on terminal. The lesser depends on POSIX, the smaller values.
  • 17. Jhc output has only 20 undef $ nm hs.out | grep U U U U U U U U U U U U U U U U U U U U "U " _IO_putc@@GLIBC_2.2.5 __libc_start_main@@GLIBC_2.2.5 _setjmp@@GLIBC_2.2.5 abort@@GLIBC_2.2.5 ctime@@GLIBC_2.2.5 exit@@GLIBC_2.2.5 fflush@@GLIBC_2.2.5 fprintf@@GLIBC_2.2.5 fputc@@GLIBC_2.2.5 fputs@@GLIBC_2.2.5 free@@GLIBC_2.2.5 fwrite@@GLIBC_2.2.5 getenv@@GLIBC_2.2.5 malloc@@GLIBC_2.2.5 memset@@GLIBC_2.2.5 posix_memalign@@GLIBC_2.2.5 realloc@@GLIBC_2.2.5 setlocale@@GLIBC_2.2.5 sysconf@@GLIBC_2.2.5 times@@GLIBC_2.2.5
  • 18. Jhc is translator to C language
  • 19. Easy to cross build
  • 20. Survive burning out Let's develop in dogfooding style. (The method is called "Snatch".)
  • 21. [5] How to use Ajhc Case of Ubuntu 12.04 amd64. $ sudo apt-get install haskell-platform libncurses5-dev gcc m4 $ cabal update $ export PATH=$HOME/.cabal/bin/:$PATH $ cabal install ajhc $ which ajhc /home/USER/.cabal/bin/ajhc $ echo 'main = print "hoge"' > Hoge.hs $ ajhc Hoge.hs $ ./hs.out "hoge" You can use on Windows or Mac OS X.
  • 22. Detail of usage Please read "Ajhc User's Manual". ☆ ajhc.metasepi.org/manual.html Also you can read in Japanese. ☆ ajhc.metasepi.org/manual_ja.html
  • 23. [6] Snatch application on tiny OS Snatch only the LED blinker thread. ☆ Board: STM32F4 Discovery http://www.st.com/stm32f4-discovery ☆ OS: ChibiOS/RT http://www.chibios.org/
  • 24. Application code before Snatch // File: main.c #include "ch.h" #include "hal.h" #include "test.h" static adcsample_t samples[ADC_GRP1_NUM_CHANNELS ADC_GRP1_BUF_DEPTH]; static const ADCConversionGroup adcgrpcfg = { // --snip-static PWMConfig pwmcfg = { // --snip-static const SPIConfig spi2cfg = { // --snip-static void pwmpcb(PWMDriver *pwmp) { // --snip-void adccb(ADCDriver *adcp, adcsample_t *buffer, // --snip-static void spicb(SPIDriver *spip) { // --snip-static WORKING_AREA(waThread1, 128); static msg_t Thread1(void *arg) { // --snip-int main(void) { // --snip-- * size_t n) {
  • 25. LED blinker thread // File: main.c static WORKING_AREA(waThread1, 128); static msg_t Thread1(void *arg) { (void)arg; chRegSetThreadName("blinker"); while (TRUE) { palSetPad(GPIOD, GPIOD_LED3); chThdSleepMilliseconds(500); palClearPad(GPIOD, GPIOD_LED3); chThdSleepMilliseconds(500); } } /* Orange. */ /* Orange. */ int main(void) { // --snip-chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  • 27. [7] Let's Snatch it! The source code at the following. github.com/metasepi/chibios-arafura
  • 28. Run simple Haskell code #1 -- File: hs_src/Main.hs main :: IO () main = return () // File: main.c static char malloc_heapstart[(2*1024)]; static MemoryHeap heap_desc; void malloc_init(void) { chHeapInit(&heap_desc, (void *)malloc_heapstart, (2*1024)); } int main(void) { // --snip-{ /* Init Ajhc RTS (Haskell) */ int hsargc = 1; char *hsargv = "q"; char **hsargvp = &hsargv; malloc_init(); hs_init(&hsargc, &hsargvp); _amain(); } chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  • 30. Blink LED only once #1 -- File: hs_src/Main.hs foreign export ccall "blinkOrange" blinkOrange :: IO () blinkOrange :: IO () blinkOrange = do c_palSetPad c_GPIOD c_GPIOD_LED3 c_chThdSleepMilliseconds 500 c_palClearPad c_GPIOD c_GPIOD_LED3 c_chThdSleepMilliseconds 500 // File: main.c static WORKING_AREA(waThread1, 128); static msg_t Thread1(void *arg) { (void)arg; chRegSetThreadName("blinker"); while (TRUE) { blinkOrange(); // Haskell } }
  • 31. Blink LED only once #2
  • 32. Snatch blink thread code #1 -- File: hs_src/Main.hs foreign export ccall "threadBlinkOrange" threadBlinkOrange :: IO () threadBlinkOrange :: IO () threadBlinkOrange = forever blinkOrange // File: main.c static WORKING_AREA(waThread1, 128); static msg_t Thread1(void *arg) { (void)arg; threadBlinkOrange(); }
  • 34. Use forkOS API #1 -- File: hs_src/Main.hs main :: IO () main = void $ forkOS threadBlinkOrange // File: conc_custom.c void forkOS_createThread_init() { chPoolInit(&pooldesc, THD_WA_SIZE(STACKSIZE), NULL); chPoolLoadArray(&pooldesc, (void *) pool_buf, NTHREADS); } jhc_threadid_t forkOS_createThread(void *(*wrapper) (void *),void *entry,int *err) { Thread *tid; tid = chThdCreateFromMemoryPool(&pooldesc, NORMALPRIO, (tfunc_t) wrapper, entry); if (NULL == tid) { abort(); } return tid; }
  • 37. PR: Call For Articles ☆ http://www.paraiso-lang.org/ikmsm/ ☆ Fanzine of functional programming. ☆ About Haskell or OCaml or . . . ☆ Article about Ajhc in C84 book. ☆ Call me if you read it! http://www.paraiso-lang.org/ikmsm/books/c85.html