OpenNuvoton/NUC980-linux-4.4.y

请教NUC980外挂RTC芯片RX-8025T内核配置问题。

redworlf007 opened this issue · 22 comments

1、NUC980外挂RTC芯片RX-8025T,挂在i2c0 PE12 PE10上,内核也配置了,但是系统跑起来,认不到8025。
1

2
3
4

I2C通信地址的问题吧,你内核打印log看看,我们外挂过其他型号的RTC,你这个没用过

slave mode要拿掉

image

好,我马上试试。

U-Boot 2016.11 (Dec 24 2021 - 18:19:14 +0600)

CPU: NUC980
Board: NUC980
DRAM: 64 MiB
NAND: 128 MiB
In: serial
Out: serial
Err: serial
Net: Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot: 0

Loading from nand0, offset 0x200000
Image Name: Linux-4.4.179
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2748224 Bytes = 2.6 MiB
Load Address: 00008000
Entry Point: 00008000

Booting kernel from Legacy Image at 00007fc0 ...

Image Name: Linux-4.4.179
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2748224 Bytes = 2.6 MiB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
XIP Kernel Image ... OK

Starti▒Booting Linux on physical CPU 0x0
Linux version 4.4.179 (root@zxg-virtual-machine) (gcc version 4.9.4 (Buildroot 2016.11.1) ) #49 PREEMPT Fri Apr 15 12:10:49 +06 2022
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
CPU: VIVT data cache, VIVT instruction cache
Machine: NUC980
Memory policy: Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 rootfstype=yaffs2 rootflags=inband-tags console=ttyS0,115200n8 rdinit=/sbin/init mem=64M
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 59100K/65536K available (4078K kernel code, 215K rwdata, 1132K rodata, 140K init, 211K bss, 6436K reserved, 0K cma-reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xc4800000 - 0xff800000 ( 944 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0xc0008000 - 0xc051ef1c (5212 kB)
.init : 0xc051f000 - 0xc0542000 ( 140 kB)
.data : 0xc0542000 - 0xc0577ce0 ( 216 kB)
.bss : 0xc0577ce0 - 0xc05acaec ( 212 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
Build-time adjustment of leaf fanout to 32.
NR_IRQS:545
clocksource: nuc980-timer5: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 62215505635 ns
sched_clock: 24 bits at 120kHz, resolution 8333ns, wraps every 69905062489ns
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
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)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x8400 - 0x843c
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 256 (order: -1, 3072 bytes)
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
clocksource: Switched to clocksource nuc980-timer5
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)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (double precision)
ntfs: driver 2.1.32 [Flags: R/W DEBUG].
fuse init (API version 7.23)
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
io scheduler noop registered (default)
nuc980_gpio_probe - pdev = nuc980-gpio
nuc980_dma_probe - pdev = nuc980-dma
nuc980-dma nuc980-dma: NUC980 DMA ready
nuc980-uart.0: ttyS0 at I/O 0x0 (irq = 36, base_baud = 750000) is a NUC980
nuc980-uart.1: ttyS1 at I/O 0x0 (irq = 37, base_baud = 9375000) is a NUC980
nuc980-uart.2: ttyS2 at I/O 0x0 (irq = 38, base_baud = 9375000) is a NUC980
nuc980-uart.3: ttyS3 at I/O 0x0 (irq = 43, base_baud = 9375000) is a NUC980
nuc980-uart.4: ttyS4 at I/O 0x0 (irq = 39, base_baud = 9375000) is a NUC980
nuc980-uart.5: ttyS5 at I/O 0x0 (irq = 44, base_baud = 9375000) is a NUC980
nuc980-uart.6: ttyS6 at I/O 0x0 (irq = 40, base_baud = 9375000) is a NUC980
nuc980-uart.7: ttyS7 at I/O 0x0 (irq = 45, base_baud = 9375000) is a NUC980
nuc980-uart.8: ttyS8 at I/O 0x0 (irq = 41, base_baud = 9375000) is a NUC980
nuc980-uart.9: ttyS9 at I/O 0x0 (irq = 46, base_baud = 9375000) is a NUC980
nuc980 mtd nand driver version: 20180301
nand: device found, Manufacturer ID: 0x01, Chip ID: 0xf1
nand: AMD/Spansion S34ML01G2
nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
nand: SMRA size 64, 60
nand: WARNING: nand0: the ECC used on your system is too weak compared to the one required by the NAND chip
Bad block table found at page 65472, version 0x01
Bad block table found at page 65408, version 0x01
Creating 3 MTD partitions on "nand0":
0x000000000000-0x000000200000 : "u-boot"
0x000000200000-0x000001600000 : "Kernel"
0x000001600000-0x000008000000 : "user"
fmi-sm: registered successfully! mtdid=nand0
libphy: nuc980_rmii0: probed
PPP generic driver version 2.4.2
PPP BSD Compression module registered
PPP Deflate Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled).
CSLIP: code copyright 1989 Regents of the University of California.
SLIP linefill/keepalive option.
usbcore: registered new interface driver asix
usbcore: registered new interface driver ax88179_178a
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver net1080
usbcore: registered new interface driver rndis_host
usbcore: registered new interface driver cdc_subset
usbcore: registered new interface driver zaurus
usbcore: registered new interface driver cdc_ncm
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
nuc980-ehci nuc980-ehci: Nuvoton NUC980 EHCI Host Controller
nuc980-ehci nuc980-ehci: new USB bus registered, assigned bus number 1
nuc980-ehci nuc980-ehci: irq 23, io mem 0xb0015000
nuc980-ehci nuc980-ehci: USB 2.0 started, EHCI 0.95
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver option
usbserial: USB Serial support registered for GSM modem (1-port)
i2c /dev entries driver
nuc980-i2c0 nuc980-i2c0: i2c-0: nuc980 I2C adapter
softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=1)
nuc980_sd_probe - pdev = nuc980-sdh
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
nuc980-nadc: nuc980 Normal ADC adapter
NET: Registered protocol family 17
hctosys: unable to open rtc device (rtc0)
yaffs: dev is 32505858 name is "mtdblock2" rw
yaffs: passed flags "inband-tags"
usb 1-2: new high-speed USB device number 2 using nuc980-ehci
cdc_ether 1-2:1.0 usb0: register 'cdc_ether' at usb-nuc980-ehci-2, CDC Ethernet Device, ae:0c:29:a3:9b:6d
option 1-2:1.2: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
option 1-2:1.3: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1
option 1-2:1.4: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB2
VFS: Mounted root (yaffs2 filesystem) on device 31:2.
devtmpfs: mounted
Freeing unused kernel memory: 140K
Starting logging: OK
Starting mdev...
Initializing random number generator... random: dd: uninitialized urandom read (512 bytes read, 19 bits of entropy available)
done.
Starting rpcbind: OK
Starting network: OK
Starting ntpd: OK
random: ssh-keygen: uninitialized urandom read (32 bytes read, 21 bits of entropy available)
Starting sshd: random: sshd: uninitialized urandom read (32 bytes read, 21 bits of entropy available)
OK
nuc980-emac0 nuc980-emac0: eth0 is OPENED
Starting install openGW ...
Starting Run openGWStart.sh

i2c /dev entries driver
nuc980-i2c0 nuc980-i2c0: i2c-0: nuc980 I2C adapter

系统启动是这样打印的,然后rx8025还是没有挂上。

https://blog.csdn.net/chenliang0224/article/details/51298682

你看看这个帖子,972上是这样的。

我在这里/home/zxg/work/nuc980bsp/linux-4.4.x/arch/arm/mach-nuc980/dev.c
static struct i2c_board_info __initdata nuc980_i2c_clients0[] = {
#ifdef CONFIG_SND_SOC_NAU8822
{I2C_BOARD_INFO("nau8822", 0x1a),},
#endif
{I2C_BOARD_INFO("rx8025", 0x32),}, //添加了这个
};

系统启动后,一直在打印:
rtc-rx8025 0-0032: power voltage drop detected
rtc-rx8025 0-0032: power-on reset detected, date is invalid

我在这里/home/zxg/work/nuc980bsp/linux-4.4.x/arch/arm/mach-nuc980/dev.c
static struct i2c_board_info __initdata nuc980_i2c_clients0[] = {
#ifdef CONFIG_SND_SOC_NAU8822
{I2C_BOARD_INFO("nau8822", 0x1a),},
#endif
{I2C_BOARD_INFO("rx8025", 0x32),}, //添加了这个
};

系统启动后,一直在打印:
rtc-rx8025 0-0032: power voltage drop detected
rtc-rx8025 0-0032: power-on reset detected, date is invalid

用这个命令:i2cdetect 0
6

返回32地址,但是系统没有识别到rx8025。

我把rx8025的供电断掉,再用i2cdetect 0测试,就不返回32了,再把供电恢复,又能返回32.
以上说明i2c测试,rx8025是有应答的,但是系统驱动未能把芯片挂载到Linux上,原因暂时未知。

大神,在么?帮忙看看这个是驱动哪里有问题,谢谢了。

Hi,
Did you pull-up both I2C_SDA and SCK pins with resistors? Maybe you should have a investigation using logic analyzer.

Hi, Did you pull-up both I2C_SDA and SCK pins with resistors? Maybe you should have a investigation using logic analyzer.

两个4.7K的上拉电阻,我用示波器测了下,sck和sda上有波形,但我还没有具体看是啥数据。

7

看看,我用i2c-tool,读地址0x32器件的寄存0 1 2 可以读回来数据。

这个器件地址是0x32,读 0寄存器
i2cget -f -y 0 0x32 0

8

逻辑分析仪抓的数据,rx8025有应答,i2c通讯成功,但是Linux驱动不识别这个芯片。
我在内核配置上已经选中了,帮忙看看啥问题?谢谢了。

Hi, Did you pull-up both I2C_SDA and SCK pins with resistors? Maybe you should have a investigation using logic analyzer.

你好,用逻辑分析仪的结果见楼上。

我感觉是980的Linux驱动哪里有问题,就没有挂载rx8025

/home/zxg/work/nuc980bsp/linux-4.4.x/arch/arm/mach-nuc980/dev.c
我在这里这样改了:
/* I2C /
#if defined(CONFIG_I2C_BUS_NUC980_P0) || defined(CONFIG_I2C_BUS_NUC980_P0_MODULE)
// port 0
/
I2C clients */
static struct i2c_board_info __initdata nuc980_i2c_clients0[] = {
#ifdef CONFIG_SND_SOC_NAU8822
{I2C_BOARD_INFO("nau8822", 0x1a),},
#endif
{I2C_BOARD_INFO("rx8025", 0x32),},
};

系统启动后
9

内核崩溃了。

现在最新的测试结果,RX8025的I2C是通讯成功的,RX8025的FOUT脚上输出32.768的方波,说明芯片硬件工作正常。

目前这个内核奔溃的问题,应该是驱动程序里面指针越界,但是还没有定位到是哪里的问题。

/home/zxg/work/nuc980bsp/linux-4.4.x/arch/arm/mach-nuc980/dev.c

我发现在我修改之前,dev.c里面,压根就没有{I2C_BOARD_INFO("rx8025", 0x32),}, 这句,那么系统怎么找到rx8025的驱动?这里应该有问题。

各位大神,能不能帮忙给看看,到底哪里的问题?我怀疑是驱动的问题。。。。

10

我感觉要改设备树,那个方框里面是我加的,好像还没改对。。。

这个问题我搞好了,我用的内核版本4.4.179的版i2c驱动有bug,我升级到最新的内核版本289,问题解决了。