如何使用Nios II MMU和Linux 4.9启用SD卡

时间:2017-04-11 15:33:13

标签: linux-kernel fpga intel-fpga nios qsys

我为Altera DE2-115获取并构建了linux-socfpa。我使用来构建它。它启动但没有文件系统。我有一个插入FPGA的SD卡,有什么方法可以将SD卡用作文件系统吗?

系统信息:

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
# 

Qsys设计

enter image description here

enter image description here

cat proc/partitions

没有输出
# cat /proc/partitions                                                          
major minor  #blocks  name   

dmesg

的输出
# 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.                       
# 

我还启用了FAT文件系统和SPI以及menuconfig。

enter image description here enter image description here

# 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                                                       
# 

3 个答案:

答案 0 :(得分:2)

您可以选择将文件系统嵌入到内核映像中。选择initramfs选项并指向您创建的文件系统。 我使用buildroot来创建我需要的所有图像以及文件系统。

答案 1 :(得分:2)

如果您想查看根文件系统本身,请尝试

cd /

ls -lp

。如果您想使用SD卡,请尝试安装它。

mount /dev/mmcblkp** /mnt 
  

使用SD卡分区(mmcblkp1p1 or mmcblk1p2)代替mmcblkp **。

答案 2 :(得分:2)

我刚看到你更新的问题。在 Qsys图片中,我没有看到 SD卡界面 理想情况下应该是)。我相信在添加这个界面之后应该是这样的:

SD card Interface 一旦你在你的情况下看到这种Qsys,我相信只有你可以安装SD卡。

我只有enabling SD card的一种方式并在nios2上使用SD card as filesystem。然而它有点旧,但我认为它会帮助你。