title: How to enable SD card with Nios II MMU and Linux 4.9
body: <p>I fetched and built the <a href="https://github.com/altera-opensource/linux-socfpga" rel="noreferrer">linux-socfpa</a> for my Altera DE2-115. I used <a href="/questions/tagged/buildroot" class="post-tag" title="show questions tagged &#39;buildroot&#39;" rel="tag">buildroot</a> and <a href="/questions/tagged/u-boot" class="post-tag" title="show questions tagged &#39;u-boot&#39;" rel="tag">u-boot</a> to build it. It starts but there is no filesystem. I have an SD card plugged into the FPGA, is there some way I can use the SD card as a filesystem?</p>
  
  <p>System information:</p>
  
  <pre><code>Linux version 4.9.0-00104-g84d4f8a-dirty (developer@1604) (gcc version 6.2.0 (S7
  bootconsole [early0] enabled
  early_console initialized at 0xe8001400
  ERROR: Nios II DIV different for kernel and DTS
  Warning: icache size configuration mismatch (0x8000 vs 0x1000) of CONFIG_NIOS2_e
  Warning: dcache size configuration mismatch (0x8000 vs 0x800) of CONFIG_NIOS2_De
  On node 0 totalpages: 32768
  free_area_init_node: node 0, pgdat c0527bb4, node_mem_map c0545b80
    Normal zone: 256 pages used for memmap
    Normal zone: 0 pages reserved
    Normal zone: 32768 pages, LIFO batch:7
  pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
  pcpu-alloc: [0] 0 
  Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
  Kernel command line: console=ttyAL0,115200
  PID hash table entries: 512 (order: -1, 2048 bytes)
  Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
  Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
  Sorting __ex_table...
  Memory: 124516K/131072K available (2834K kernel code, 84K rwdata, 568K rodata, )
  NR_IRQS:64 nr_irqs:64 0
  clocksource: nios2-clksrc: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_nss
  Calibrating delay loop (skipped), value calculated using timer frequency.. 100.)
  pid_max: default: 32768 minimum: 301
  Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
  Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
  devtmpfs: initialized
  cpu cpu0: Error -2 creating of_node link
  clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 191s
  NET: Registered protocol family 16
  random: fast init done
  clocksource: Switched to clocksource nios2-clksrc
  NET: Registered protocol family 2
  TCP established hash table entries: 1024 (order: 0, 4096 bytes)
  TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
  TCP: Hash tables configured (established 1024 bind 1024)
  UDP hash table entries: 256 (order: 0, 4096 bytes)
  UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
  futex hash table entries: 256 (order: -1, 3072 bytes)
  workingset: timestamp_bits=30 max_order=15 bucket_order=0
  jffs2: version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.
  Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
  io scheduler noop registered
  io scheduler deadline registered
  io scheduler cfq registered (default)
  8001400.serial: ttyAL0 at MMIO 0x8001400 (irq = 3, base_baud = 3125000) is a AlT
  console [ttyAL0] enabled
  console [ttyAL0] enabled
  bootconsole [early0] disabled
  bootconsole [early0] disabled
  8001440.serial: ttyJ0 at MMIO 0x8001440 (irq = 2, base_baud = 0) is a Altera JTT
  random: crng init done
  loop: module loaded
  mousedev: PS/2 mouse device common for all mice
  NET: Registered protocol family 10
  sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
  Freeing unused kernel memory: 1788K (c02c6000 - c0485000)
  This architecture does not have kernel memory protection.
  Starting logging: OK
  Initializing random number generator... done.
  Starting network: OK
  
  Welcome to Nios II
  nios2 login: root
  login[733]: root login on 'ttyAL0'
  # ls -al
  total 4
  drwx------    2 root     root             0 Jan  1 00:00 .
  drwxr-xr-x   17 root     root             0 Apr 11  2017 ..
  -rw-------    1 root     root             7 Jan  1 00:00 .ash_history
  # df -h
  Filesystem               
  # 
  Size      Used Available Use% Mounted on
  # cat /proc/cpuinfo 
  CPU:            Nios II/fast
  MMU:            present
  FPU:            none
  Clocking:       50.00 MHz
  BogoMips:       100.00
  Calibration:    50000000 loops
  HW:
   MUL:           yes
   MULX:          no
   DIV:           no
  Icache:         4kB, line length: 32
  Dcache:         2kB, line length: 32
  TLB:            16 ways, 256 entries, 8 PID bits
  # 
  </code></pre>
  
  <p>Qsys design</p>
  
  <p><a href="https://i.stack.imgur.com/6IizG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6IizG.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/kqJQB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kqJQB.png" alt="enter image description here"></a></p>
  
  <p>There is no output from <code>cat proc/partitions</code></p>
  
  <pre><code># cat /proc/partitions                                                          
  major minor  #blocks  name   
  </code></pre>
  
  <p>Output from <code>dmesg</code></p>
  
  <pre><code># dmesg                                                                         
  Linux version 4.9.0-00104-g84d4f8a-dirty (developer@1604) (gcc version 6.2.0 (S7
  bootconsole [early0] enabled                                                    
  early_console initialized at 0xe8001400                                         
  ERROR: Nios II DIV different for kernel and DTS                                 
  Warning: icache size configuration mismatch (0x8000 vs 0x1000) of CONFIG_NIOS2_e
  Warning: dcache size configuration mismatch (0x8000 vs 0x800) of CONFIG_NIOS2_De
  On node 0 totalpages: 32768                                                     
  free_area_init_node: node 0, pgdat c0542150, node_mem_map c055fb80              
    Normal zone: 256 pages used for memmap                                        
    Normal zone: 0 pages reserved                                                 
    Normal zone: 32768 pages, LIFO batch:7                                        
  pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768                                   
  pcpu-alloc: [0] 0                                                               
  Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512      
  Kernel command line: console=ttyAL0,115200                                      
  PID hash table entries: 512 (order: -1, 2048 bytes)                             
  Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)                  
  Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)                    
  Sorting __ex_table...                                                           
  Memory: 124412K/131072K available (2919K kernel code, 85K rwdata, 588K rodata, )
  NR_IRQS:64 nr_irqs:64 0                                                         
  clocksource: nios2-clksrc: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_nss
  Calibrating delay loop (skipped), value calculated using timer frequency.. 100.)
  pid_max: default: 32768 minimum: 301                                            
  Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)                     
  Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)                
  devtmpfs: initialized                                                           
  cpu cpu0: Error -2 creating of_node link                                        
  clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 191s
  NET: Registered protocol family 16                                              
  random: fast init done                                                          
  clocksource: Switched to clocksource nios2-clksrc                               
  NET: Registered protocol family 2                                               
  TCP established hash table entries: 1024 (order: 0, 4096 bytes)                 
  TCP bind hash table entries: 1024 (order: 0, 4096 bytes)                        
  TCP: Hash tables configured (established 1024 bind 1024)                        
  UDP hash table entries: 256 (order: 0, 4096 bytes)                              
  UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)                         
  futex hash table entries: 256 (order: -1, 3072 bytes)                           
  workingset: timestamp_bits=30 max_order=15 bucket_order=0                       
  jffs2: version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.                           
  Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)            
  io scheduler noop registered                                                    
  io scheduler deadline registered                                                
  io scheduler cfq registered (default)                                           
  8001400.serial: ttyAL0 at MMIO 0x8001400 (irq = 3, base_baud = 3125000) is a AlT
  console [ttyAL0] enabled                                                        
  bootconsole [early0] disabled                                                   
  8001440.serial: ttyJ0 at MMIO 0x8001440 (irq = 2, base_baud = 0) is a Altera JTT
  random: crng init done                                                          
  loop: module loaded                                                             
  mousedev: PS/2 mouse device common for all mice                                 
  NET: Registered protocol family 10                                              
  sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver                             
  Freeing unused kernel memory: 1788K (c02db000 - c049a000)                       
  This architecture does not have kernel memory protection.                       
  # 
  </code></pre>
  
  <p>I also enabled FAT file system and SPI and menuconfig. </p>
  
  <p><a href="https://i.stack.imgur.com/tbgHl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tbgHl.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/oqT1O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oqT1O.png" alt="enter image description here"></a></p>
  
  <pre><code># ls /dev/                                                                      
  console             ptyte               ttyee                                   
  cpu_dma_latency     ptytf               ttyef                                   
  full                ptyu0               ttyp0                                   
  input               ptyu1               ttyp1                                   
  kmem                ptyu2               ttyp2                                   
  kmsg                ptyu3               ttyp3                                   
  loop-control        ptyu4               ttyp4                                   
  loop0               ptyu5               ttyp5                                   
  loop1               ptyu6               ttyp6                                   
  loop2               ptyu7               ttyp7                                   
  loop3               ptyu8               ttyp8                                   
  loop4               ptyu9               ttyp9                                   
  loop5               ptyua               ttypa                                   
  loop6               ptyub               ttypb                                   
  loop7               ptyuc               ttypc                                   
  mem                 ptyud               ttypd                                   
  memory_bandwidth    ptyue               ttype                                   
  network_latency     ptyuf               ttypf                                   
  network_throughput  ptyv0               ttyq0                                   
  null                ptyv1               ttyq1                                   
  psaux               ptyv2               ttyq2                                   
  ptmx                ptyv3               ttyq3                                   
  pts                 ptyv4               ttyq4                                   
  ptya0               ptyv5               ttyq5                                   
  ptya1               ptyv6               ttyq6                                   
  ptya2               ptyv7               ttyq7                                   
  ptya3               ptyv8               ttyq8                                   
  ptya4               ptyv9               ttyq9                                   
  ptya5               ptyva               ttyqa                                   
  ptya6               ptyvb               ttyqb                                   
  ptya7               ptyvc               ttyqc                                   
  ptya8               ptyvd               ttyqd                                   
  ptya9               ptyve               ttyqe                                   
  ptyaa               ptyvf               ttyqf                                   
  ptyab               ptyw0               ttyr0                                   
  ptyac               ptyw1               ttyr1                                   
  ptyad               ptyw2               ttyr2                                   
  ptyae               ptyw3               ttyr3                                   
  ptyaf               ptyw4               ttyr4                                   
  ptyb0               ptyw5               ttyr5                                   
  ptyb1               ptyw6               ttyr6                                   
  ptyb2               ptyw7               ttyr7                                   
  ptyb3               ptyw8               ttyr8                                   
  ptyb4               ptyw9               ttyr9                                   
  ptyb5               ptywa               ttyra                                   
  ptyb6               ptywb               ttyrb                                   
  ptyb7               ptywc               ttyrc                                   
  ptyb8               ptywd               ttyrd                                   
  ptyb9               ptywe               ttyre                                   
  ptyba               ptywf               ttyrf                                   
  ptybb               ptyx0               ttys0                                   
  ptybc               ptyx1               ttys1                                   
  ptybd               ptyx2               ttys2                                   
  ptybe               ptyx3               ttys3                                   
  ptybf               ptyx4               ttys4                                   
  ptyc0               ptyx5               ttys5                                   
  ptyc1               ptyx6               ttys6                                   
  ptyc2               ptyx7               ttys7                                   
  ptyc3               ptyx8               ttys8                                   
  ptyc4               ptyx9               ttys9                                   
  ptyc5               ptyxa               ttysa                                   
  ptyc6               ptyxb               ttysb                                   
  ptyc7               ptyxc               ttysc                                   
  ptyc8               ptyxd               ttysd                                   
  ptyc9               ptyxe               ttyse                                   
  ptyca               ptyxf               ttysf                                   
  ptycb               ptyy0               ttyt0                                   
  ptycc               ptyy1               ttyt1                                   
  ptycd               ptyy2               ttyt2                                   
  ptyce               ptyy3               ttyt3                                   
  ptycf               ptyy4               ttyt4                                   
  ptyd0               ptyy5               ttyt5                                   
  ptyd1               ptyy6               ttyt6                                   
  ptyd2               ptyy7               ttyt7                                   
  ptyd3               ptyy8               ttyt8                                   
  ptyd4               ptyy9               ttyt9                                   
  ptyd5               ptyya               ttyta                                   
  ptyd6               ptyyb               ttytb                                   
  ptyd7               ptyyc               ttytc                                   
  ptyd8               ptyyd               ttytd                                   
  ptyd9               ptyye               ttyte                                   
  ptyda               ptyyf               ttytf                                   
  ptydb               ptyz0               ttyu0                                   
  ptydc               ptyz1               ttyu1                                   
  ptydd               ptyz2               ttyu2                                   
  ptyde               ptyz3               ttyu3                                   
  ptydf               ptyz4               ttyu4                                   
  ptye0               ptyz5               ttyu5                                   
  ptye1               ptyz6               ttyu6                                   
  ptye2               ptyz7               ttyu7                                   
  ptye3               ptyz8               ttyu8                                   
  ptye4               ptyz9               ttyu9                                   
  ptye5               ptyza               ttyua                                   
  ptye6               ptyzb               ttyub                                   
  ptye7               ptyzc               ttyuc                                   
  ptye8               ptyzd               ttyud                                   
  ptye9               ptyze               ttyue                                   
  ptyea               ptyzf               ttyuf                                   
  ptyeb               random              ttyv0                                   
  ptyec               shm                 ttyv1                                   
  ptyed               tty                 ttyv2                                   
  ptyee               ttyAL0              ttyv3                                   
  ptyef               ttyJ0               ttyv4                                   
  ptyp0               ttya0               ttyv5                                   
  ptyp1               ttya1               ttyv6                                   
  ptyp2               ttya2               ttyv7                                   
  ptyp3               ttya3               ttyv8                                   
  ptyp4               ttya4               ttyv9                                   
  ptyp5               ttya5               ttyva                                   
  ptyp6               ttya6               ttyvb                                   
  ptyp7               ttya7               ttyvc                                   
  ptyp8               ttya8               ttyvd                                   
  ptyp9               ttya9               ttyve                                   
  ptypa               ttyaa               ttyvf                                   
  ptypb               ttyab               ttyw0                                   
  ptypc               ttyac               ttyw1                                   
  ptypd               ttyad               ttyw2                                   
  ptype               ttyae               ttyw3                                   
  ptypf               ttyaf               ttyw4                                   
  ptyq0               ttyb0               ttyw5                                   
  ptyq1               ttyb1               ttyw6                                   
  ptyq2               ttyb2               ttyw7                                   
  ptyq3               ttyb3               ttyw8                                   
  ptyq4               ttyb4               ttyw9                                   
  ptyq5               ttyb5               ttywa                                   
  ptyq6               ttyb6               ttywb                                   
  ptyq7               ttyb7               ttywc                                   
  ptyq8               ttyb8               ttywd                                   
  ptyq9               ttyb9               ttywe                                   
  ptyqa               ttyba               ttywf                                   
  ptyqb               ttybb               ttyx0                                   
  ptyqc               ttybc               ttyx1                                   
  ptyqd               ttybd               ttyx2                                   
  ptyqe               ttybe               ttyx3                                   
  ptyqf               ttybf               ttyx4                                   
  ptyr0               ttyc0               ttyx5                                   
  ptyr1               ttyc1               ttyx6                                   
  ptyr2               ttyc2               ttyx7                                   
  ptyr3               ttyc3               ttyx8                                   
  ptyr4               ttyc4               ttyx9                                   
  ptyr5               ttyc5               ttyxa                                   
  ptyr6               ttyc6               ttyxb                                   
  ptyr7               ttyc7               ttyxc                                   
  ptyr8               ttyc8               ttyxd                                   
  ptyr9               ttyc9               ttyxe                                   
  ptyra               ttyca               ttyxf                                   
  ptyrb               ttycb               ttyy0                                   
  ptyrc               ttycc               ttyy1                                   
  ptyrd               ttycd               ttyy2                                   
  ptyre               ttyce               ttyy3                                   
  ptyrf               ttycf               ttyy4                                   
  ptys0               ttyd0               ttyy5                                   
  ptys1               ttyd1               ttyy6                                   
  ptys2               ttyd2               ttyy7                                   
  ptys3               ttyd3               ttyy8                                   
  ptys4               ttyd4               ttyy9                                   
  ptys5               ttyd5               ttyya                                   
  ptys6               ttyd6               ttyyb                                   
  ptys7               ttyd7               ttyyc                                   
  ptys8               ttyd8               ttyyd                                   
  ptys9               ttyd9               ttyye                                   
  ptysa               ttyda               ttyyf                                   
  ptysb               ttydb               ttyz0                                   
  ptysc               ttydc               ttyz1                                   
  ptysd               ttydd               ttyz2                                   
  ptyse               ttyde               ttyz3                                   
  ptysf               ttydf               ttyz4                                   
  ptyt0               ttye0               ttyz5                                   
  ptyt1               ttye1               ttyz6                                   
  ptyt2               ttye2               ttyz7                                   
  ptyt3               ttye3               ttyz8                                   
  ptyt4               ttye4               ttyz9                                   
  ptyt5               ttye5               ttyza                                   
  ptyt6               ttye6               ttyzb                                   
  ptyt7               ttye7               ttyzc                                   
  ptyt8               ttye8               ttyzd                                   
  ptyt9               ttye9               ttyze                                   
  ptyta               ttyea               ttyzf                                   
  ptytb               ttyeb               urandom                                 
  ptytc               ttyec               zero                                    
  ptytd               ttyed                                                       
  # 
  </code></pre>