【问题标题】:How to enable SD card with Nios II MMU and Linux 4.9如何使用 Nios II MMU 和 Linux 4.9 启用 SD 卡
【发布时间】:2017-09-07 02:26:53
【问题描述】:

我为我的 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 设计

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。

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

【问题讨论】:

  • 我不知道是否只是让 fpga 设备将一些信息打印到 dmesg。您是否检查过与此 IP 的 FPGA 引脚连接??
  • @user3249791 我不明白。你能详细说明我应该做什么吗?
  • 您在 Qsys 中有 SD 卡接口设备。您是否将本设备的导管端正确连接到 DE2-115 板上的 SD 卡插槽?
  • @user3249791 问题可能是我没有正确的引脚分配吗?我该如何检查?我也尝试连接 USB,但也没有用。
  • 转到 Quartus -> 分配 -> 引脚规划器。根据 DE2-115 原理图或手册检查引脚。

标签: buildroot u-boot linux-kernel fpga intel-fpga nios qsys


【解决方案1】:

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

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

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

【讨论】:

  • 但是我有那种带有“SD Card Avalon Interface”的Qsys。我在 menuconfig 中添加了 FAT 和 SPI 支持。没有任何效果。
  • @DjDac 我希望你已经关注了上述两个链接。如果仍然无法正常工作(假设您的硬件和 SD 卡都很好)并且您在 SD 卡期间没有收到任何内核日志dmesg,那么我只能暂停您的驱动程序集成。
  • 太复杂了。你必须给我看,而不是告诉我。如果你给我看,那么它可以工作。仅仅评论是行不通的。
  • @DjDac Surly 我们可以调查一下这个问题。但为此,我们需要了解您的硬件以及 s/w 实现(因为我认为这不仅仅是 sw/ 问题)。当您在 SPI 模式下使用 SD 卡时,您还需要注意 CS pin。在得出结论之前,您需要验证更多领域。我知道这一切都无法通过评论来实现。所以我认为你可以开始一个聊天会话,这样我们就可以快速调查这个问题并找出主要原因(希望这会起作用)。
【解决方案2】:

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

cd /

ls -lp

。如果您想使用您的 SD 卡,请尝试挂载它。

mount /dev/mmcblkp** /mnt 

使用您的 SD 卡分区 (mmcblkp1p1 or mmcblk1p2) 而不是 mmcblkp**。

【讨论】:

  • mmcblkp** 仅供参考。检查你的 SD 卡(应该是 mmcblk0 or mmcblk1 里面的 /dev)。如果您的 SD 卡在 mmcblk1p 上,则使用 SD 卡 mmcblk1p1 或 mmcblk1p2 的分区之一。你可以试试mount -t <file_system> /dev/mmcblk1p1 /mnt注意:使用正确的文件系统类型 insetad 和正确的 SD 卡分区类型
  • @DjDac 我不熟悉这个arch。但恐怕您的设备没有检测到 SD 卡。插入 SD 卡时能否提供cat /proc/partitions 和内核日志dmesg 的输出。或者您通过mmc rescan 命令从u-boot 检查SD 卡详细信息。 确保您的 SD 卡处于工作状态且格式正确
  • 当然,您需要一个用于 SD 卡的硬件、一个用于其硬件的(Linux 内核)驱动程序以及那些设备节点文件(/dev/mmcblkp**)。您是否为 Altera_UP_SD_CARD 接口加载了合适的驱动程序?
  • >我在make menuconfig中添加了对SD卡的“支持”。不,您需要一个驱动程序来控制“Altera_UP_SD_CARD_Avalon_interface”本身。也许,除了 FreeBSD 没有驱动程序。 fxr.watson.org/fxr/source/dev/altera/sdcard 所以,我也向您推荐使用“Altera SPI Core”的方法。 alterawiki.com/wiki/MMC/SD vinod maverick 先生提到的。
  • 您选择了 Altera_UP_SD_CARD_Avalon_interface IP 内核。而且你没有它的源代码。当然,您在配置方面的努力不会为内核制作合适的驱动程序。不加考虑地重新编译是毫无意义的行为。
【解决方案3】:

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

【讨论】:

  • 感谢您的回答。但是当它连接到板子时,我如何指向文件系统呢?
  • 如果您执行不需要指向的 initramfs,文件系统将在引导期间自动挂载。从那时起,您可以启动一个基本的 linux,然后使用您的 rc 脚本从 SDCARD 挂载文件系统。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多