现在新版的树莓派内核由于为了兼容树莓派2和树莓派B+等以前的版本,采用了和原来不同的内核运行方式,使用了设备树的方式,更加灵活。但是由于可能不习惯这样的方式以及没太多相关这方面的介绍,导致很多用户更新了内核后出现比如接18B20无法读取设备信息,以及树莓派没有声音输出的问题。
在这里细心的用户就会发现在新内核boot分区下多了个overlays文件夹,里面有很多dtb文件,这些其实就是树莓派的设备树,打开README,就可以知道该怎么使用了。

下面是来自README的话:

Introduction
============
This directory contains Device Tree overlays. Device Tree makes it possible
to support many hardware configurations with a single kernel and without the
need to explicitly load or blacklist kernel modules. Note that this isn't a
"pure" Device Tree configuration (c.f. MACH_BCM2835) - some on-board devices
are still configured by the board support code, but the intention is to
eventually reach that goal.
On Raspberry Pi, Device Tree usage is controlled from /boot/config.txt. By
default, the Raspberry Pi kernel boots with device tree enabled. You can
completely disable DT usage (for now) by adding:
    device_tree=
to your config.txt, which should cause your Pi to revert to the old way of
doing things after a reboot.

如果要禁用设备树就直接在boot/config.txt里写device_tree=然后保存重启即可。
那么我们要怎么使用设备树呢?就拿启用W1来读取18B20数据来说,Readme里有这样一段:

Using Overlays
==============
Overlays are loaded using the "dtoverlay" directive. As an example, consider the
popular lirc-rpi module, the Linux Infrared Remote Control driver. In the
pre-DT world this would be loaded from /etc/modules, with an explicit
"modprobe lirc-rpi" command, or programmatically by lircd. With DT enabled,
this becomes a line in config.txt:
    dtoverlay=lirc-rpi
This causes the file /boot/overlays/lirc-rpi-overlay.dtb to be loaded. By
default it will use GPIOs 17 (out) and 18 (in), but this can be modified using
DT parameters:
    dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=13
Parameters always have default values, although in some cases (e.g. "w1-gpio")
it is necessary to provided multiple overlays in order to get the desired
behaviour. See the list of overlays below for a description of the parameters and their defaults.

也就是说,在使用config.txt里添加dtoverlay=【设备树名】来启动设备树,同样也可以在这里指定加载的设备树参数,实际上这个操作就和之前的内核在系统里添加模块类似,只不过这里是在内核启动的时候加载,之前的是在系统启动后加载。
那么我们就可以照搬添加w1到config.txt里面然后重启读取18B20了,Readme里也有相关参数说明:

Name:   w1-gpio
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *don't* need a GPIO to drive an external pullup.
Load:   dtoverlay=w1-gpio,<param>=<val>
Params: gpiopin                  GPIO for I/O (default "4")
        pullup                   Non-zero, "on", or "y" to enable the parasitic
                                 power (2-wire, power-on-data) feature
Name:   w1-gpio-pullup
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *do* need a GPIO to drive an external pullup.
Load:   dtoverlay=w1-gpio-pullup,<param>=<val>,...
Params: gpiopin                  GPIO for I/O (default "4")
        pullup                   Non-zero, "on", or "y" to enable the parasitic
                                 power (2-wire, power-on-data) feature
        extpullup                GPIO for external pullup (default "5")

这里提供了更多的参数进行选择,如果你打算采用寄生的连接方式这里也提供了参数实现内部上拉,当然如果你想保留原来的连接电路方式不进行电路改动的话那么我们就这样设置好了:
在config.txt里插入下面的内容:
dtoverlay=w1-gpio-pullup,gpiopin=4
这样就可以按照原来的电路连接方式连接18B20,保存重启后一样的载入w1-gpio和w1-therm后就可以读取到18B20数据了。
如果你要启用树莓派的音频的话,在里面添加一行
audio=on即可,新版的内核禁用了audio的原因是因为树莓派PWM和audio使用的是同一个接口,可能介于很多人希望使用树莓派的硬件PWM的原因,所以才这样灵活的设计让大家有更多自由使用的空间。
Readme关于audio和pwm的原文:

he Overlay and Parameter Reference
===================================
N.B. When editing this file, please preserve the indentation levels to make it simple to parse
programmatically. NO HARD TABS.
Name:   <The base DTB>
Info:   Configures the base Raspberry Pi hardware
Load:   <loaded automatically>
Params:
        audio                    Set to "on" to enable the onboard ALSA audio
                                 interface (default "off")

====================

Name:   pwm
Info:   Configures a single PWM channel
        Legal pin,function combinations for each channel:
          PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0)            52,5(Alt1)
          PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
        N.B.:
          1) Pin 18 is the only one available on all platforms, and
             it is the one used by the I2S audio interface.
             Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
          2) The onboard analogue audio output uses both PWM channels.
          3) So be careful mixing audio and PWM.
          4) Currently the clock must have been enabled and configured
             by other means.
Load:   dtoverlay=pwm-2chan,<param>=<val>
Load:   dtoverlay=pwm,<param>=<val>
Params: pin                      Output pin (default 18) - see table
        func                     Pin function (default 2 = Alt5) - see above
        clock                    PWM clock frequency (informational)
Name:   pwm-2chan
Info:   Configures both PWM channels
        Legal pin,function combinations for each channel:
          PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0)            52,5(Alt1)
          PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
        N.B.:
          1) Pin 18 is the only one available on all platforms, and
             it is the one used by the I2S audio interface.
             Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
          2) The onboard analogue audio output uses both PWM channels.
          3) So be careful mixing audio and PWM.
          4) Currently the clock must have been enabled and configured
             by other means.
Load:   dtoverlay=pwm-2chan,<param>=<val>
Params: pin                      Output pin (default 18) - see table
        pin2                     Output pin for other channel (default 19)
        func                     Pin function (default 2 = Alt5) - see above
        func2                    Function for pin2 (default 2 = Alt5)
        clock                    PWM clock frequency (informational)

更多信息大家自己去阅读/boot/overlays/README

解决树莓派新内核无法使用18B20和没有声音的问题的更多相关文章

  1. linux如何编译安装新内核支持NTFS文件系统?(以redhat7.2x64为例)

    内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性.Linux作为一个自由软件,在广大爱好者的支持下,内核版本不断更新.新的内核修订了旧内核 ...

  2. 启动新内核出现:Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004

    转载请注明出处:http://blog.csdn.net/qq_26093511/article/details/51841281 启动新内核出现错误:Kernel panic - not synci ...

  3. linux新内核中关闭硬盘的DMA

    vortex86 SIS550 Minit-5250E瘦客户机,使用CF卡启动,显示不支持DMA. 搜索得新内核已基本不再使用ide=nodma参数了,查到这篇文章:“Debian下关闭CF卡的DMA ...

  4. linux 解决Ubuntu编译内核uImage出现问题“mkimage” command not found - U-Boot images will not be built问题

    解决Ubuntu编译内核uImage出现问题“mkimage” command not found - U-Boot images will not be built问题 http://www.lin ...

  5. linux新内核的freeze框架以及意义【转】

    转自:https://blog.csdn.net/dog250/article/details/5303442 linux的电源管理发展非常迅速,比如在挂起到内存的时候,系统会冻结住所有的进程,也就是 ...

  6. delphi 解决android 9上无法使用http协议

    delphi 解决android 9上无法使用http协议 安卓9不让客户端通过非https方式访问服务端数据(不允许发送明文http请求)的问题. 解决方法: 1.选择安卓平台编译一次程序,在项目根 ...

  7. linux 增加新用户无法使用sudo命令解决办法

    昨天一不小心把自己的系统搞崩了,也没有快照,没法进行还原操作,所以只能重装系统解决了,装完系统以后一切正常,当我新增了一个用户,使用sudo命令切换到root用户时,发现怎么都切换不过去,经过百度发现 ...

  8. linux新内核的时钟机制代码

    http://blog.chinaunix.net/uid-22810130-id-384173.html 如果说cfs是linux的一个很有创意的机制的话,那么linux中另一个创意就是nohz,我 ...

  9. 发现大量的TIME_WAIT解决办法 -- 修改内核参数

    今天早上一上班,有同事就反映公司好几个网站都打不开,登陆数据库 服务器(windows),发现很卡,于是重启了下服务器,进入系统后,没过一会问题依旧,查看了下系统进程,发现mysql占用率达到99%, ...

随机推荐

  1. 洛谷——P1109 学生分组

    P1109 学生分组 题目描述 有N组学生,给出初始时每组中的学生个数,再给出每组学生人数的上界R和下界L(L<=R),每次你可以在某组中选出一个学生把他安排到另外一组中,问最少要多少次才可以使 ...

  2. hdu 1011(Starship Troopers,树形dp)

    Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...

  3. 函数的扩展--ES6

    箭头函数 由于大括号被解释为代码块,所以如果箭头函数直接返回一个对象,必须在对象外面加上括号. var f = () => ({a:1}); f(); // 返回 {a: 1} 若写成: var ...

  4. [BZOJ1444]有趣的游戏(AC自动机+矩阵乘法)

    n个等长字符串,机器会随机输出一个字符串(每个字母出现的概率为p[i]),问每个字符串第一个出现的概率是多少. 显然建出AC自动机,套路地f[i][j]表示i时刻位于节点j的概率. 构建转移矩阵,当i ...

  5. ThreadPoolExecutor(线程池)源码分析

    1. 常量和变量 private final AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0)); // 高3位为线程池的运行状态,低29 ...

  6. Codeforces Round #114 (Div. 1) D. Wizards and Roads 笛卡尔树+树贪心+阅读题

    D. Wizards and Roads 题目连接: http://www.codeforces.com/contest/167/problem/D Description In some count ...

  7. Log4j 日志级别

    转自:http://michales003.iteye.com/blog/1160605 日志记录器(Logger)是日志处理的核心组件.log4j具有5种正常级别(Level).: 1.static ...

  8. Android 自己收集的开源项目集合(持续更新 2018.2.5)

    2017.12.21 1.仿QQ说说发图片选择框架 https://github.com/yaozs/ImageShowPicker 2.炫酷开屏动画框架 https://github.com/Jos ...

  9. MFC进度条刷新处理

    m_p.SetRange(0,1000); m_p.SetStep(1); for (int i=0;i<1001;i++) { m_p.SetPos(i); Sleep(10); MSG ms ...

  10. 读取bq26500电池电量 Driver

    bq26500是用于锂离子电池.锂聚合物电池充电.放电控制和监控的集成电路芯片.利用它能够准确提供电池充电.放电.电池温度.充放电电压.电池电量等相关数据.不须要外接微处理器參与电池充电.放电等相关数 ...