您尚未登录。

楼主 # 2021-12-15 23:24:49

老鸟kkk
会员
注册时间: 2020-03-24
已发帖子: 15
积分: 20

云联芯NUC980设备树折腾-从点灯开始

非常感谢这次的活动,今天下班收到板子,晚上迫不及待开箱来点个灯,先来张全家福
_20211215230308.jpg

这次玩点跟官方不一样的,都啥年代了还不用设备树(ps:主要自己只会用设备树,请轻点喷~)
先来上个心跳灯~

启动信息:

NUC980 IBR 20180813
Boot from NAND
DDR-OK
NAND boot!D dow#S


U-Boot 2016.11 (Dec 15 2021 - 22:25:13 +0800)

CPU: NUC980
Board: NUC980
DRAM:  64 MiB
NAND:  128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   emac
Hit any key to stop autoboot:  0 
Using emac device
TFTP from server 192.168.60.239; our IP address is 192.168.60.238
Filename '980uimage'.
Load address: 0x7fc0
Loading: #################################################################
         #################################################################
         #################################################################
         #############
         1015.6 KiB/s
done
Bytes transferred = 3046936 (2e7e18 hex)
Using emac device
TFTP from server 192.168.60.239; our IP address is 192.168.60.238
Filename 'nuc980.dtb'.
Load address: 0x407fc0
Loading: ###
         985.4 KiB/s
done
Bytes transferred = 30275 (7643 hex)
## Booting kernel from Legacy Image at 00007fc0 ...
   Image Name:   Linux-4.4.207
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3046872 Bytes = 2.9 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 00407fc0
   Booting using the fdt blob at 0x407fc0
   XIP Kernel Image ... OK
   Loading Device Tree to 03e82000, end 03e8c642 ... OK

Starting kernel ...goto kernel

  0.000000] kernel start ..........
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.4.207 (xiao@xiao-virtual-machine) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #10 PREEMPT Thu Dec 2 22:40:07 CST 2021
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] Machine model: Nuvoton NUC980 IOT V1.0
[    0.000000] Memory policy: Data cache writeback
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 cma=64M root=/dev/nfs rw ip=192.168.60.238:192.168.60.239:192.168.60.1:255.255.255.0::eth0:off nolock nfsroot=192.168.60.239:/nfs/rootfs,v3,tcp
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 58356K/65536K available (4406K kernel code, 273K rwdata, 1292K rodata, 204K init, 227K bss, 7180K reserved, 0K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xc4800000 - 0xff800000   ( 944 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0598da4   (5700 kB)
[    0.000000]       .init : 0xc0599000 - 0xc05cc000   ( 204 kB)
[    0.000000]       .data : 0xc05cc000 - 0xc0610520   ( 274 kB)
[    0.000000]        .bss : 0xc0610520 - 0xc0649268   ( 228 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  Build-time adjustment of leaf fanout to 32.
[    0.000000] NR_IRQS:545
[    0.000000] clocksource: nuc980-timer5: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 62215505635 ns
[    0.000033] sched_clock: 24 bits at 120kHz, resolution 8333ns, wraps every 69905062489ns
[    0.000716] Console: colour dummy device 80x30
[    0.197908] console [ttyS0] enabled
[    0.201433] Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
[    0.272774] pid_max: default: 32768 minimum: 301
[    0.277641] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.284316] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.293308] CPU: Testing write buffer coherency: ok
[    0.299199] Setting up static identity map for 0x8400 - 0x843c
[    0.309974] devtmpfs: initialized
[    0.347999] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.358691] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.365391] pinctrl core: initialized pinctrl subsystem
[    0.372649] NET: Registered protocol family 16
[    0.379283] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.393433] <DT> nuc980_dt_device_init +
[    0.432066] <DT> nuc980_dt_device_init -
[    0.438041] pinctrl-nuc980 apb:pinctrl@b0000000: initialized NUC980 pinctrl driver
[    0.554608] SCSI subsystem initialized
[    0.559941] usbcore: registered new interface driver usbfs
[    0.571824] usbcore: registered new interface driver hub
[    0.578058] usbcore: registered new device driver usb
[    0.598674] clocksource: Switched to clocksource nuc980-timer5
[    0.636341] NET: Registered protocol family 2
[    0.644333] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.651899] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.658258] TCP: Hash tables configured (established 1024 bind 1024)
[    0.665224] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.671316] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.678283] NET: Registered protocol family 1
[    0.683974] RPC: Registered named UNIX socket transport module.
[    0.690066] RPC: Registered udp transport module.
[    0.694733] RPC: Registered tcp transport module.
[    0.699516] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.707341] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.881833] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    0.890158] io scheduler noop registered (default)
[    0.895574] nuc980_gpio_probe - pdev = b0004000.gpio
[    0.904824] nuc980_dma_probe - pdev = b0008000.dma
[    0.930549] nuc980-dma b0008000.dma: NUC980 DMA ready
[    0.957149] b0070000.serial: ttyS0 at I/O 0xf0070000 (irq = 36, base_baud = 750000) is a NUC980
[    0.970716] nuvoton-rng ahb:crypto_prng: nuvoton PRNG active
[    1.015824] brd: module loaded
[    1.024449] RX nuc980_qspi0_probe: dma0chan0 module removed
[    1.032108] TX nuc980_qspi0_probe: dma0chan1 module removed
[    1.064508] libphy: nuc980_rmii0: probed
[    1.142758] PPP generic driver version 2.4.2
[    1.149666] PPP BSD Compression module registered
[    1.154366] PPP Deflate Compression module registered
[    1.159966] PPP MPPE Compression module registered
[    1.164783] NET: Registered protocol family 24
[    1.169766] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.176791] nuc980-ehci b0015000.usbh_ehci: Nuvoton NUC980 EHCI Host Controller
[    1.184483] nuc980-ehci b0015000.usbh_ehci: new USB bus registered, assigned bus number 1
[    1.193508] nuc980-ehci b0015000.usbh_ehci: irq 23, io mem 0xb0015000
[    1.218841] nuc980-ehci b0015000.usbh_ehci: USB 2.0 started, EHCI 0.95
[    1.229424] hub 1-0:1.0: USB hub found
[    1.233874] hub 1-0:1.0: 2 ports detected
[    1.240016] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.246758] usb_hcd_nuc980_probe, id = -1, name: b0017000.usbh_ohci, 0
[    1.253983] nuc980-ohci b0017000.usbh_ohci: Nuvoton NUC980 OHCI Host Controller
[    1.261791] nuc980-ohci b0017000.usbh_ohci: new USB bus registered, assigned bus number 2
[    1.270374] nuc980-ohci b0017000.usbh_ohci: irq 24, io mem 0xb0017000
[    1.334674] hub 2-0:1.0: USB hub found
[    1.339299] hub 2-0:1.0: 8 ports detected
[    1.346924] usbcore: registered new interface driver cdc_wdm
[    1.354416] usbcore: registered new interface driver usb-storage
[    1.362174] usbcore: registered new interface driver usbserial
[    1.369674] usbcore: registered new interface driver option
[    1.375791] usbserial: USB Serial support registered for GSM modem (1-port)
[    1.386583] nuc980_sd_probe - pdev = b0018000.sdh
[    1.439933] do_sha - sha last has no data!
[    1.444008] alg: hash: Test 1 failed for nuc980-sha1
[    1.449191] 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.455591] 00000010: 00 00 00 00
[    1.460066] do_sha - sha last has no data!
[    1.464149] alg: hash: Test 1 failed for nuc980-sha224
[    1.469516] 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.475916] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00
[    1.482299] do_sha - sha last has no data!
[    1.486383] alg: hash: Test 1 failed for nuc980-sha256
[    1.491733] 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.498141] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.505433] do_sha - sha last has no data!
[    1.509783] alg: hash: Test 1 failed for nuc980-sha384
[    1.514891] 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.521508] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.527908] 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.535216] do_sha - sha last has no data!
[    1.539524] alg: hash: Test 1 failed for nuc980-sha512
[    1.544641] 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.551249] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.557658] 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.564291] 00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    1.571483] alg: No test for hmac-sha1 (nuc980-hmac-sha1)
[    1.577424] alg: No test for hmac-sha224 (nuc980-hmac-sha224)
[    1.583958] alg: No test for hmac-sha256 (nuc980-hmac-sha256)
[    1.590491] alg: No test for hmac-sha384 (nuc980-hmac-sha384)
[    1.596799] alg: No test for hmac-sha512 (nuc980-hmac-sha512)
[    1.602874] NUC980 Crypto engine enabled.
[   41.618783] mt29f spi0.0: WAIT timedout!!!
[   81.618766] mt29f spi0.0: wait timedout!
[   81.623041] nand: No NAND device found
[   81.627899] fbtft_of_value: buswidth = 8
[   81.632258] fbtft_of_value: debug = 0
[   81.635891] fbtft_of_value: rotate = 90
[   81.639916] fbtft_of_value: fps = 25
[   81.951091] Console: switching to colour frame buffer device 40x30
[   81.960608] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB DMA buffer memory, fps=25, spi2.0 at 50 MHz
[   81.975016] NET: Registered protocol family 17
[   82.008041] i2c-gpio: probe of apb:i2c_gpio@0 failed with error -16
[   82.020324] hctosys: unable to open rtc device (rtc0)
[   82.084041] nuc980-emac0 b0012000.emac0: eth0 is OPENED
[   82.928808] random: nonblocking pool is initialized
[   83.169399] IP-Config: Complete:
[   83.172616]      device=eth0, hwaddr=08:00:27:00:01:92, ipaddr=192.168.60.238, mask=255.255.255.0, gw=192.168.60.1
[   83.185416]      host=192.168.60.238, domain=, nis-domain=(none)
[   83.191624]      bootserver=192.168.60.239, rootserver=192.168.60.239, rootpath=
[   83.230941] VFS: Mounted root (nfs filesystem) on device 0:13.
[   83.238108] devtmpfs: mounted
[   83.243724] Freeing unused kernel memory: 204K
Starting syslogd: OK
Starting klogd: OK
Starting mdev...
modprobe: can't change directory to '/lib/modules': No such file or directory
Initializing random number generator... done.
Starting network: RTNETLINK answers: File exists
FAIL

Welcome to Buildroot
laoniao login: root
Password: 
[root@laoniao]:~$:ps
PID   USER     COMMAND
    1 root     init
    2 root     [kthreadd]
    3 root     [ksoftirqd/0]
    4 root     [kworker/0:0]
    5 root     [kworker/0:0H]
    6 root     [kworker/u2:0]
    7 root     [rcu_preempt]
    8 root     [rcu_sched]
    9 root     [rcu_bh]
   10 root     [kdevtmpfs]
   11 root     [kworker/u2:1]
  157 root     [writeback]
  159 root     [crypto]
  160 root     [bioset]
  162 root     [kblockd]
  188 root     [kworker/0:1]
  189 root     [cfg80211]
  217 root     [rpciod]
  224 root     [kswapd0]
  283 root     [nfsiod]
  364 root     [bioset]
  365 root     [bioset]
  366 root     [bioset]
  367 root     [bioset]
  368 root     [bioset]
  369 root     [bioset]
  370 root     [bioset]
  371 root     [bioset]
  395 root     [spi0]
  399 root     [spi2]
  432 root     [kworker/u2:2]
  480 root     [deferwq]
  483 root     [kworker/0:1H]
  500 root     /sbin/syslogd -n
  504 root     /sbin/klogd -n
  510 root     [kworker/0:2H]
  527 root     -sh
  528 root     ps
[root@laoniao]:~$:

设备树和内核中默认配置了spi nand,板子上没有这个设备,导致中间的漫长启动时间

心跳灯效果:

离线

楼主 #1 2021-12-16 18:24:26

老鸟kkk
会员
注册时间: 2020-03-24
已发帖子: 15
积分: 20

Re: 云联芯NUC980设备树折腾-从点灯开始

分享下uboot移植过程,大佬请忽视
1.获取源码:https://gitee.com/OpenNuvoton/NUC970_U-Boot_v2016.11
2.解压到目录,后进入解压目录
3.配置gcc工具
4.清除编译:
    make distclean
5.加载默认配置:
    make nuc980_defconfig
6.先make编译下
7.网卡移植:
    make menuconfig:
    Device Drivers  --->
        [`] Network device support  --->
            [`]   NUC980 Ethernet Support
            [`]     NUC980 EMAC0 port
            (0)     PHY Address
8.uboot对设备树的支持:
    make menuconfig(设备树):
        Library routines  --->
            [`] Enable the FDT library
            [`] Support running EFI Applications in U-Boot (NEW)
9.nand分区(include/configs/nuc980_evb.h):
    #define CONFIG_MTD_PARTITIONS  1        //开启MTD分区
    #define MTDIDS_DEFAULT "nand0=nand0"
    #define MTDPARTS_DEFAULT "mtdparts=nand0:2M(u-boot),4M(kernel),1M(dts),-(rootfs)"
    #define MTD_ACTIVE_PART "nand0,3"

在内核中开启对设备树的支持:
    make menuconfig(内核):
        Boot options  --->
            [`] Flattened Device Tree support
            Device Drivers  --->
                <`> Memory Technology Device (MTD) support  --->
                   <`>   Command line partition table parsing

然后选择一个设备树文件按需修改编译(如内核源码下arch/arm/dts/nuc980-iot.dts)
附一个上面的心跳灯的设备树

ahb总线下:
        gpio-leds {
            compatible = "gpio-leds";   

            led0 {
                label = "heartbeat-led";                           
                gpios = <&gpio 0x20 1>;                   
                linux,default-trigger = "heartbeat";   
                default-state = "on";                   
            };
        };
编译uboot、内核、设备树,到这里基本上把对应文件烧进去对于云联芯的板子,貌似是直接拿的官方的,基本不需要怎么修改
另外用usb烧录不要去在意那些配置电阻,只需进入uboot命令行,用nand erase命令擦除flash的内容,板子自动会默认从usb启动

离线

楼主 #3 2022-05-11 22:05:00

老鸟kkk
会员
注册时间: 2020-03-24
已发帖子: 15
积分: 20

Re: 云联芯NUC980设备树折腾-从点灯开始

romanljw 说:

大佬好,请问下,您的led0的设备树中:
gpios = <&gpio 0x20 1>;     
里面的0x20代表的哪个引脚,谢谢大佬
另外请问大佬,后面的1是什么意思?

0x20表示GPIOB_0   1表示高电平有效

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn