Contiki移植—cfs-coffee 文件系統在pc上的驗證

最近移植coffee fs, 爲了瞭解coffee細節,方便調試,所以在pc上編譯coffee。html

考慮到開虛擬機麻煩,費資源。所以安裝Cygwin,在Cygwin下面編譯。shell

1. Create cfs-coffee folder
  Create folder example-coffee/ in path contiki-2.5/examples/
  Copy example-shell/ file to example-coffee/
  Rename example-shell.c to example-coffee.c in the example-coffee/ui

2. Modfiy Makefile
  Modify example-coffee/Makefilespa

1 CONTIKI_PROJECT   =   example - coffee
2 all :   $(CONTIKI_PROJECT)
3
4 APPS   =   serial - shell
5 CONTIKI   =   . . / . .
6
7 include   $(CONTIKI) / Makefile . include
8

  Modfiy contiki-2.5/platform/native/Makefile.native .net

1 CONTIKI_TARGET_SOURCEFILES   =   contiki - main . c   clock . c   leds . c   leds - arch . c   \
2                                 button - sensor . c   pir - sensor . c   vib - sensor . c   xmem . c   \
3                                 sensors . c   irq . c   cfs - coffee . c
4 // 使用cfs-coffee.c取代原來的cfs-posix.c   cfs-posix-dir.c
5

Tips:x86 PC的cpu和platfrom的類型都是native,platform中使用的dev是xmem,所以cfs-coffee-arch.c將一片內存做爲device操做,這樣能夠dump內存內容來觀察coffee的工做狀況。debug

3. Modify code 
sync to spi_flash config to veriy porting state調試


#ifndef   CFS_COFFEE_ARCH_H
#define   CFS_COFFEE_ARCH_H

#include   " contiki-conf.h "
#include   " dev/xmem.h "

#define   COFFEE_SECTOR_SIZE         ( 4 * 1024UL) // 65536UL
#define   COFFEE_PAGE_SIZE         512UL     // 256UL
10 #define   COFFEE_START             0
11 #define   COFFEE_SIZE             (( 2 * 1024 * 1024 )   -   COFFEE_SECTOR_SIZE) // ((1024UL   *   1024UL)   -   COFFEE_START)
12 #define   COFFEE_NAME_LENGTH         16
13 #define   COFFEE_DYN_SIZE             (COFFEE_PAGE_SIZE * 1 )
14 #define   COFFEE_MAX_OPEN_FILES         6
15 #define   COFFEE_FD_SET_SIZE         8
16 #define   COFFEE_LOG_DIVISOR         4
17 #define   COFFEE_LOG_SIZE             8192
18 #define   COFFEE_LOG_TABLE_LIMIT         256
19 #define   COFFEE_MICRO_LOGS         0
20 // #define   COFFEE_IO_SEMANTICS         1
21
22 #define   COFFEE_WRITE(buf,   size,   offset)                 \
23         xmem_pwrite(( char   * )(buf),   (size),   COFFEE_START   +   (offset))
24
25 #define   COFFEE_READ(buf,   size,   offset)                 \
26             xmem_pread(( char   * )(buf),   (size),   COFFEE_START   +   (offset))
27
28 #define   COFFEE_ERASE(sector)                     \
29             xmem_erase(COFFEE_SECTOR_SIZE,   COFFEE_START   +   (sector)   *   COFFEE_SECTOR_SIZE)
30
31 #define   READ_HEADER(hdr,   page)                         \
32     COFFEE_READ((hdr),   sizeof   ( * hdr),   (page)   *   COFFEE_PAGE_SIZE)
33
34 #define   WRITE_HEADER(hdr,   page)                         \
35     COFFEE_WRITE((hdr),   sizeof   ( * hdr),   (page)   *   COFFEE_PAGE_SIZE)
36
37 /*   Coffee   types.   */
38 typedef   int16_t   coffee_page_t;
39
40 #endif   /*   !COFFEE_ARCH_H   */
41

Add test code to example-coffee.c code

4. Build and Debug
orm

Cygwin不包含insight packet,所以使用DDD+gdb完成debughtm

Tips1: ddd使用須要安裝Cygwin/X(x11 packet),參見http://x.cygwin.com/docs/ug/setup.html
Tips2: ddd的啓動須要先啓動Cygwin/X,在XWin中啓動ddd,啓動XWind的方法見http://x.cygwin.com/docs/ug/using.html#using-starting

我使用startxwin命令啓動XWin

在XWin中啓動ddd:

@N6S~$0VB33%%QT21_Q0%)H

啓動後的UI,可在DDD中進行調試:

image

相關文章
相關標籤/搜索