SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
Part	
  1	
  :	
  Code	
  Reading	
  
of	
  

F9	
  Microkernel	
  
ben6	
  
2013-­‐10-­‐16	
  
F9	
  

Agenda	
  

•  Overview	
  of	
  F9-­‐Microkernel	
  	
  
•  Code	
  reading	
  (cscope,	
  ctags)	
  
•  Code	
  trace	
  
F9	
  

Agenda	
  

•  Overview	
  of	
  F9-­‐Microkernel	
  	
  
•  Code	
  reading	
  (cscope,	
  ctags)	
  
•  Code	
  trace	
  
F9	
  Microkernel	
  Overview	
  
•  an	
  experimental	
  microkernel	
  used	
  to	
  construct	
  
flexible	
  embedded	
  systems	
  inspired	
  by	
  famous	
  L4	
  
microkernel.	
  	
  
•  The	
  moMvaMon	
  of	
  F9	
  microkernel	
  is	
  to	
  deploy	
  
modern	
  kernel	
  techniques	
  to	
  support	
  	
  
–  running	
  real-­‐Mme	
  and	
  Mme-­‐sharing	
  applicaMons	
  (ex:	
  	
  
wireless	
  communicaMons)	
  for	
  ARM	
  Cortex-­‐M	
  series	
  
microprocessors	
  with	
  efficiency	
  (performance	
  +	
  
power	
  consumpMon)	
  	
  
–  security	
  (memory	
  protecMon	
  +	
  isolated	
  execuMon)	
  
CharacterisMcs	
  
•  F9	
  follows	
  the	
  fundamental	
  principles	
  of	
  microkernels	
  
in	
  that	
  it	
  implements	
  address	
  spaces,	
  thread	
  
management,	
  and	
  IPC	
  only	
  in	
  the	
  privileged	
  kernel.	
  
•  Designed	
  and	
  	
  customized	
  for	
  ARM	
  Cortex-­‐M,	
  
supporMng	
  NVIC	
  (Nested	
  Vectored	
  Interrupt	
  
Controller),	
  Bit	
  Banding,	
  MPU	
  (Memory	
  ProtecMon	
  
Unit)	
  
•  Energy	
  efficient	
  scheduling	
  and	
  Mckless	
  Mmer	
  
•  KProbes	
  
•  Independent	
  TCB	
  (Thread	
  Control	
  Block)	
  for	
  each	
  
thread	
  with	
  its	
  global	
  ID	
  
CharacterisMcs	
  (Cont.)	
  
•  Memory	
  management	
  
–  Memory	
  pool,	
  Flexible	
  page,	
  Address	
  space	
  

•  System	
  calls:	
  	
  
–  Grant,	
  Map,	
  Flush	
  

•  UTCB	
  concept	
  
–  	
  a	
  small	
  thread-­‐specific	
  region	
  in	
  the	
  thread's	
  virtual	
  
address	
  space,	
  which	
  is	
  always	
  mapped	
  

•  Synchronous	
  IPC	
  
•  Debugging	
  and	
  profiling	
  mechanisms	
  
F9	
  

Agenda	
  

•  Overview	
  of	
  F9-­‐Microkernel	
  	
  
•  Code	
  reading	
  (cscope,	
  ctags)	
  
•  Code	
  trace	
  
Kernel	
  Line	
  of	
  code	
  

Kernel	
  C	
  code	
  line:	
  2661	
  
Git	
  head:	
  7ae6e15bdf4d67740ef9fa2a0c6a2a194df9553b	
  
cscope	
  
•  CTRL-­‐D	
  to	
  quit	
  
•  Use	
  arrow	
  key	
  
<up>,	
  <down>	
  to	
  
select	
  
•  Type	
  symbol	
  name	
  
your	
  want	
  to	
  
search	
  
Use	
  case	
  of	
  cscope	
  
1. 

2. 
3. 
4. 

5. 

Get	
  f9-­‐kernel	
  source	
  code	
  

	
  
git	
  clone	
  h=ps://github.com/f9micro/f9-­‐kernel	
  

Generate	
  cscope.files	
  to	
  be	
  scanned	
  

–  cd	
  f9-­‐kernel;	
  find	
  .	
  -­‐name	
  "*.c"	
  -­‐o	
  	
  -­‐name	
  "*.h"	
  >	
  cscope.files	
  

Generate	
  Cscope	
  database	
  

cscope	
  -­‐b	
  -­‐q	
  -­‐k	
  

Using	
  the	
  database	
  

–  default	
  Cscope	
  browser	
  
cscope	
  -­‐d	
  
(be	
  able	
  to	
  use	
  vim	
  or	
  other	
  editor	
  support	
  cscope	
  database)	
  

RegeneraHng	
  database	
  when	
  source	
  code	
  changes	
  

– 

Use	
  same	
  command	
  step	
  4.	
  

Reference:	
  hhp://cscope.sourceforge.net/large_projects.html	
  
vim	
  +	
  ctags	
  
•  sudo	
  apt-­‐get	
  install	
  ctags	
  
•  Generate	
  tags	
  
	
  
ctags	
  –R	
  *	
  

•  key	
  definiMon	
  at	
  vim	
  
	
  

CTRL	
  

+	
  ]	
  è	
  goto	
  the	
  funcMon	
  definiMon	
  

CTRL	
  

+	
  t	
  	
  è	
  back	
  to	
  previous	
  funcMon	
  call	
  
PART	
  1	
  

F9	
  KERNEL	
  ENTRY	
  
F9-­‐kernel	
  Entry	
  
•  plamorm/f9.ld	
  	
  	
  	
  	
  è	
  F9	
  ldscript	
  

__l4_start	
  
F9-­‐kernel	
  Entry	
  
•  plamorm/f9.ld	
  

Header	
  of	
  f9.bin	
  is	
  
isr_vector	
  table	
  for	
  
Cortex-­‐M	
  MCU	
  
f9-­‐kernel:	
  __l4_start	
  
kernel/init.c	
  
•  Be	
  reset	
  
handler	
  
•  F9	
  startup	
  
entry	
  
__l4_start	
  
•  IniMal	
  hooks	
  
•  Copy	
  data	
  
segment	
  for	
  1st	
  
iniMalizaMon	
  
•  Clear	
  segments	
  
•  IniMalize	
  system	
  
clock	
  
•  Call	
  main()	
  entry	
  
start.c	
  :	
  main.c	
  
•  IniMal	
  for	
  level	
  plamorm	
  
hooks	
  
•  Irq	
  iniMal	
  and	
  disable	
  
interrupt	
  
•  Setup	
  FloaMng	
  Point	
  Unit	
  
•  Show	
  banner	
  
•  IniMal	
  for	
  Level	
  kernel	
  
hooks	
  
•  Create	
  and	
  idle	
  and	
  root	
  
thread	
  
•  Create	
  Mmer	
  64	
  Mcks	
  for	
  
delivering	
  ipc	
  
•  Init	
  LAST	
  stage	
  hooks	
  
•  Switch	
  to	
  iniMal	
  kernel	
  
thread	
  
Enable/disable	
  irq	
  
inline	
  	
  assembly	
  
Syntax:	
  

	
  

__asm__	
  __volaMle__("InstrucMon	
  List");

•  __volaMle__	
  	
  
	
  Tell	
  gcc	
  don’t	
  change	
  my	
  intrusMon	
  list	
  

•  cpsid,	
  cpsie	
  
reference:	
  
Implemented	
  interrupt	
  enabling	
  delay	
  in	
  
the	
  Cortex-­‐M3	
  and	
  Cortex-­‐M4	
  processors	
  
kMmer_event_create	
  
•  kMmer.c	
  
•  Create	
  new	
  event	
  
entry	
  	
  
•  add	
  to	
  linked	
  list	
  of	
  
event	
  table	
  
•  Add	
  entry	
  for	
  event	
  
scheduling	
  
Switch	
  to	
  kernel	
  

•  Create	
  kernel	
  thread	
  and	
  enable	
  running	
  
by	
  context	
  switch	
  
F9	
  

Agenda	
  

•  Overview	
  of	
  F9-­‐Microkernel	
  	
  
•  Code	
  reading	
  (cscope,	
  ctags)	
  
•  Code	
  trace	
  
Console	
  setup	
  before	
  code	
  trace	
  
Pl2303	
  console	
  with	
  STM32F4	
  
•  USB2TTL	
  RX	
  (white)	
  -­‐-­‐-­‐>	
  PA0	
  
•  USB2TTL	
  TX	
  (green)	
  -­‐-­‐-­‐>	
  PA1	
  

USB-­‐Serial	
  Controller	
  
Prolific	
  2303	
  
Toolchain	
  for	
  Cortex-­‐M4	
  
•  Sourcery	
  CodeBench	
  
–  ARM	
  Processors:	
  EABI	
  Release	
  
–  Verified	
  versions:	
  arm-­‐2012.03,	
  arm-­‐2013.05	
  
	
  

•  GNU	
  Tools	
  for	
  ARM	
  Embedded	
  Processors	
  
stlink	
  
Project	
  for	
  tools	
  we	
  used:	
  st-­‐
flash,	
  st-­‐uMl	
  
hhps://github.com/texane/stlink	
  
Code	
  trace:	
  st-­‐uMl	
  

Remote	
  debug	
  port	
  for	
  gdb	
  
Code	
  trace:	
  gdb	
  remote	
  
target	
  remote	
  :4242	
  
Code	
  trace	
  issue	
  
•  Debug	
  Panic	
   Git	
  HEAD:	
  7ae6e15bdf4d67740ef9fa2a0c6a2a194df9553b	
  
Discussions	
  

F9	
  

?	
  
References	
  
•  F9	
  Microkernel	
  source	
  code	
  and	
  introducMon	
  
	
  
•  Using	
  Cscope	
  on	
  large	
  projects	
  (example:	
  the	
  Linux	
  kernel)	
  
•  Ctags	
  wiki	
  
•  __asm__	
  __volaMle__	
  GCC的内嵌汇编语法	
  AT&T汇编语⾔言语法(⼀一)	
  
•  Implemented	
  interrupt	
  enabling	
  delay	
  in	
  the	
  Cortex-­‐M3	
  and	
  Cortex-­‐M4	
  
processors	
  
	
  
•  texane's	
  stlink	
  project	
  at	
  github	
  

Mais conteúdo relacionado

Mais procurados

Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCKernel TLV
 
Linux SMEP bypass techniques
Linux SMEP bypass techniquesLinux SMEP bypass techniques
Linux SMEP bypass techniquesVitaly Nikolenko
 
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
New Zephyr features: LWM2M / FOTA Framework - SFO17-113New Zephyr features: LWM2M / FOTA Framework - SFO17-113
New Zephyr features: LWM2M / FOTA Framework - SFO17-113Linaro
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLinaro
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0GlobalLogic Ukraine
 
Nodes and Networks for HPC computing
Nodes and Networks for HPC computingNodes and Networks for HPC computing
Nodes and Networks for HPC computingrinnocente
 
BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108Linaro
 
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...Kernel TLV
 
Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Sneeker Yeh
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewLinaro
 
Embedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerEmbedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerSatpal Parmar
 
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...Toradex
 
ARM Linux Embedded memory protection techniques
ARM Linux Embedded memory protection techniquesARM Linux Embedded memory protection techniques
ARM Linux Embedded memory protection techniquesPrabindh Sundareson
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New HardwareRuggedBoardGroup
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 

Mais procurados (20)

Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
Linux SMEP bypass techniques
Linux SMEP bypass techniquesLinux SMEP bypass techniques
Linux SMEP bypass techniques
 
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
New Zephyr features: LWM2M / FOTA Framework - SFO17-113New Zephyr features: LWM2M / FOTA Framework - SFO17-113
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platform
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
 
Nodes and Networks for HPC computing
Nodes and Networks for HPC computingNodes and Networks for HPC computing
Nodes and Networks for HPC computing
 
BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108
 
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
 
Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
 
Embedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerEmbedding Linux On The Encore Simputer
Embedding Linux On The Encore Simputer
 
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
 
ARM Linux Embedded memory protection techniques
ARM Linux Embedded memory protection techniquesARM Linux Embedded memory protection techniques
ARM Linux Embedded memory protection techniques
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Building
BuildingBuilding
Building
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 

Destaque

F9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 schedulingF9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 schedulingBenux Wei
 
While software engineer meets 3d printer
While software engineer meets 3d printerWhile software engineer meets 3d printer
While software engineer meets 3d printerBenux Wei
 
F9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory managementF9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory managementBenux Wei
 
F9 microkernel app development part 2 gpio meets led
F9 microkernel app development part 2 gpio meets ledF9 microkernel app development part 2 gpio meets led
F9 microkernel app development part 2 gpio meets ledBenux Wei
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

Destaque (7)

F9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 schedulingF9 Microkernel code reading part 2 scheduling
F9 Microkernel code reading part 2 scheduling
 
While software engineer meets 3d printer
While software engineer meets 3d printerWhile software engineer meets 3d printer
While software engineer meets 3d printer
 
F9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory managementF9 microkernel code reading part 4 memory management
F9 microkernel code reading part 4 memory management
 
Sf 160 kjs manual
Sf 160 kjs manualSf 160 kjs manual
Sf 160 kjs manual
 
Audi a6 adr
Audi a6 adrAudi a6 adr
Audi a6 adr
 
F9 microkernel app development part 2 gpio meets led
F9 microkernel app development part 2 gpio meets ledF9 microkernel app development part 2 gpio meets led
F9 microkernel app development part 2 gpio meets led
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Semelhante a F9 Microkernel code reading - part 1

Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-reviewabinaya m
 
LCA14: LCA14-412: GPGPU on ARM SoC session
LCA14: LCA14-412: GPGPU on ARM SoC sessionLCA14: LCA14-412: GPGPU on ARM SoC session
LCA14: LCA14-412: GPGPU on ARM SoC sessionLinaro
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modulesHao-Ran Liu
 
Introduction to Linux Kernel by Quontra Solutions
Introduction to Linux Kernel by Quontra SolutionsIntroduction to Linux Kernel by Quontra Solutions
Introduction to Linux Kernel by Quontra SolutionsQUONTRASOLUTIONS
 
Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer George Markomanolis
 
Porting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPorting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPeter Griffin
 
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...Paris Open Source Summit
 
Kernel bug hunting
Kernel bug huntingKernel bug hunting
Kernel bug huntingAndrea Righi
 
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017OpenEBS
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!Linaro
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modulesdibyajyotig
 
”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016Kuniyasu Suzaki
 
ARM IoT Firmware Emulation Workshop
ARM IoT Firmware Emulation WorkshopARM IoT Firmware Emulation Workshop
ARM IoT Firmware Emulation WorkshopSaumil Shah
 
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesPerformance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesDr. Fabio Baruffa
 
Linux BPF Superpowers
Linux BPF SuperpowersLinux BPF Superpowers
Linux BPF SuperpowersBrendan Gregg
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 
Adding a BOLT pass
Adding a BOLT passAdding a BOLT pass
Adding a BOLT passAmir42407
 

Semelhante a F9 Microkernel code reading - part 1 (20)

Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-review
 
LCA14: LCA14-412: GPGPU on ARM SoC session
LCA14: LCA14-412: GPGPU on ARM SoC sessionLCA14: LCA14-412: GPGPU on ARM SoC session
LCA14: LCA14-412: GPGPU on ARM SoC session
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
Introduction to Linux Kernel by Quontra Solutions
Introduction to Linux Kernel by Quontra SolutionsIntroduction to Linux Kernel by Quontra Solutions
Introduction to Linux Kernel by Quontra Solutions
 
Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer
 
Porting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPorting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_Griffin
 
eBPF Basics
eBPF BasicseBPF Basics
eBPF Basics
 
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
#OSSPARIS19 : A virtual machine approach for microcontroller programming : th...
 
Kernel bug hunting
Kernel bug huntingKernel bug hunting
Kernel bug hunting
 
netfilter programming
netfilter programmingnetfilter programming
netfilter programming
 
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016
 
ARM IoT Firmware Emulation Workshop
ARM IoT Firmware Emulation WorkshopARM IoT Firmware Emulation Workshop
ARM IoT Firmware Emulation Workshop
 
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesPerformance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
 
Linux BPF Superpowers
Linux BPF SuperpowersLinux BPF Superpowers
Linux BPF Superpowers
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Adding a BOLT pass
Adding a BOLT passAdding a BOLT pass
Adding a BOLT pass
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

F9 Microkernel code reading - part 1

  • 1. Part  1  :  Code  Reading   of   F9  Microkernel   ben6   2013-­‐10-­‐16  
  • 2. F9   Agenda   •  Overview  of  F9-­‐Microkernel     •  Code  reading  (cscope,  ctags)   •  Code  trace  
  • 3. F9   Agenda   •  Overview  of  F9-­‐Microkernel     •  Code  reading  (cscope,  ctags)   •  Code  trace  
  • 4. F9  Microkernel  Overview   •  an  experimental  microkernel  used  to  construct   flexible  embedded  systems  inspired  by  famous  L4   microkernel.     •  The  moMvaMon  of  F9  microkernel  is  to  deploy   modern  kernel  techniques  to  support     –  running  real-­‐Mme  and  Mme-­‐sharing  applicaMons  (ex:     wireless  communicaMons)  for  ARM  Cortex-­‐M  series   microprocessors  with  efficiency  (performance  +   power  consumpMon)     –  security  (memory  protecMon  +  isolated  execuMon)  
  • 5. CharacterisMcs   •  F9  follows  the  fundamental  principles  of  microkernels   in  that  it  implements  address  spaces,  thread   management,  and  IPC  only  in  the  privileged  kernel.   •  Designed  and    customized  for  ARM  Cortex-­‐M,   supporMng  NVIC  (Nested  Vectored  Interrupt   Controller),  Bit  Banding,  MPU  (Memory  ProtecMon   Unit)   •  Energy  efficient  scheduling  and  Mckless  Mmer   •  KProbes   •  Independent  TCB  (Thread  Control  Block)  for  each   thread  with  its  global  ID  
  • 6. CharacterisMcs  (Cont.)   •  Memory  management   –  Memory  pool,  Flexible  page,  Address  space   •  System  calls:     –  Grant,  Map,  Flush   •  UTCB  concept   –   a  small  thread-­‐specific  region  in  the  thread's  virtual   address  space,  which  is  always  mapped   •  Synchronous  IPC   •  Debugging  and  profiling  mechanisms  
  • 7. F9   Agenda   •  Overview  of  F9-­‐Microkernel     •  Code  reading  (cscope,  ctags)   •  Code  trace  
  • 8. Kernel  Line  of  code   Kernel  C  code  line:  2661   Git  head:  7ae6e15bdf4d67740ef9fa2a0c6a2a194df9553b  
  • 9. cscope   •  CTRL-­‐D  to  quit   •  Use  arrow  key   <up>,  <down>  to   select   •  Type  symbol  name   your  want  to   search  
  • 10. Use  case  of  cscope   1.  2.  3.  4.  5.  Get  f9-­‐kernel  source  code     git  clone  h=ps://github.com/f9micro/f9-­‐kernel   Generate  cscope.files  to  be  scanned   –  cd  f9-­‐kernel;  find  .  -­‐name  "*.c"  -­‐o    -­‐name  "*.h"  >  cscope.files   Generate  Cscope  database   cscope  -­‐b  -­‐q  -­‐k   Using  the  database   –  default  Cscope  browser   cscope  -­‐d   (be  able  to  use  vim  or  other  editor  support  cscope  database)   RegeneraHng  database  when  source  code  changes   –  Use  same  command  step  4.   Reference:  hhp://cscope.sourceforge.net/large_projects.html  
  • 11. vim  +  ctags   •  sudo  apt-­‐get  install  ctags   •  Generate  tags     ctags  –R  *   •  key  definiMon  at  vim     CTRL   +  ]  è  goto  the  funcMon  definiMon   CTRL   +  t    è  back  to  previous  funcMon  call  
  • 12. PART  1   F9  KERNEL  ENTRY  
  • 13. F9-­‐kernel  Entry   •  plamorm/f9.ld          è  F9  ldscript   __l4_start  
  • 14. F9-­‐kernel  Entry   •  plamorm/f9.ld   Header  of  f9.bin  is   isr_vector  table  for   Cortex-­‐M  MCU  
  • 15. f9-­‐kernel:  __l4_start   kernel/init.c   •  Be  reset   handler   •  F9  startup   entry  
  • 16. __l4_start   •  IniMal  hooks   •  Copy  data   segment  for  1st   iniMalizaMon   •  Clear  segments   •  IniMalize  system   clock   •  Call  main()  entry  
  • 17. start.c  :  main.c   •  IniMal  for  level  plamorm   hooks   •  Irq  iniMal  and  disable   interrupt   •  Setup  FloaMng  Point  Unit   •  Show  banner   •  IniMal  for  Level  kernel   hooks   •  Create  and  idle  and  root   thread   •  Create  Mmer  64  Mcks  for   delivering  ipc   •  Init  LAST  stage  hooks   •  Switch  to  iniMal  kernel   thread  
  • 18. Enable/disable  irq   inline    assembly   Syntax:     __asm__  __volaMle__("InstrucMon  List"); •  __volaMle__      Tell  gcc  don’t  change  my  intrusMon  list   •  cpsid,  cpsie   reference:   Implemented  interrupt  enabling  delay  in   the  Cortex-­‐M3  and  Cortex-­‐M4  processors  
  • 19. kMmer_event_create   •  kMmer.c   •  Create  new  event   entry     •  add  to  linked  list  of   event  table   •  Add  entry  for  event   scheduling  
  • 20. Switch  to  kernel   •  Create  kernel  thread  and  enable  running   by  context  switch  
  • 21. F9   Agenda   •  Overview  of  F9-­‐Microkernel     •  Code  reading  (cscope,  ctags)   •  Code  trace  
  • 22. Console  setup  before  code  trace   Pl2303  console  with  STM32F4   •  USB2TTL  RX  (white)  -­‐-­‐-­‐>  PA0   •  USB2TTL  TX  (green)  -­‐-­‐-­‐>  PA1   USB-­‐Serial  Controller   Prolific  2303  
  • 23. Toolchain  for  Cortex-­‐M4   •  Sourcery  CodeBench   –  ARM  Processors:  EABI  Release   –  Verified  versions:  arm-­‐2012.03,  arm-­‐2013.05     •  GNU  Tools  for  ARM  Embedded  Processors  
  • 24. stlink   Project  for  tools  we  used:  st-­‐ flash,  st-­‐uMl   hhps://github.com/texane/stlink  
  • 25. Code  trace:  st-­‐uMl   Remote  debug  port  for  gdb  
  • 26. Code  trace:  gdb  remote   target  remote  :4242  
  • 27. Code  trace  issue   •  Debug  Panic   Git  HEAD:  7ae6e15bdf4d67740ef9fa2a0c6a2a194df9553b  
  • 29. References   •  F9  Microkernel  source  code  and  introducMon     •  Using  Cscope  on  large  projects  (example:  the  Linux  kernel)   •  Ctags  wiki   •  __asm__  __volaMle__  GCC的内嵌汇编语法  AT&T汇编语⾔言语法(⼀一)   •  Implemented  interrupt  enabling  delay  in  the  Cortex-­‐M3  and  Cortex-­‐M4   processors     •  texane's  stlink  project  at  github