Regression: memory corruption on Atmel SAMA5D31

From: Peter Rosin
Date: Wed Mar 02 2022 - 19:29:26 EST


Hi!

I'm seeing a weird problem, and I'd like some help with further
things to try in order to track down what's going on. I have
bisected the issue to

f9aa460672c9 ("driver core: Refactor fw_devlink feature")

The symptoms are that I get (seemingly) random memory corruption
when processing large amounts of data (compared to system size).
I have two known reproducers, but I'm sure there are more if I
keep digging. One is to do this:

$ dd if=/dev/urandom of=testfile bs=1024 count=40000
40000+0 records in
40000+0 records out
40960000 bytes (41 MB, 39 MiB) copied, 19.7759 s, 2.1 MB/s
$ for i in 1 2 3 4; do cat testfile | sha256sum; done
d8c85f816e08baa5ad27050bf0413e11a09f325fb0a8843b7b2b45b9333ab542 -
f223c1cbb6dbecb02d1741e7991dc98cd8d5b40ffee05bb32dc2c15eb73d6b1f -
d6f3e7f3d325c67e83a6104934dd8a7c891ebfd9a2cf59633dbe97fb2cbb9c81 -
cf8ada47e7e2fee299314440b225ba83fca3cef1f6286adc160a5d4f207caccd -

It is harder to tickle the problem if I redirect the testfile to
sha256sum w/o involving cat or give the file as an argument to
sha256sum. I can also get things to behave better by getting rid
of a bunch of USB interrupts by doing the following:

$ echo 100 > /sys/bus/usb-serial/devices/ttyUSB0/latency_timer
$ echo 100 > /sys/bus/usb-serial/devices/ttyUSB1/latency_timer
$ echo 100 > /sys/bus/usb-serial/devices/ttyUSB2/latency_timer
$ echo 100 > /sys/bus/usb-serial/devices/ttyUSB3/latency_timer

With the lower interrupt pressure I get this:

$ for i in 1 2 3 4; do cat testfile | sha256sum; done
4f9173f63cb2e13d1470e59e1b5c657f3b0f4f2e9a55ab6facffbb03f34ce04d -
4f9173f63cb2e13d1470e59e1b5c657f3b0f4f2e9a55ab6facffbb03f34ce04d -
4f9173f63cb2e13d1470e59e1b5c657f3b0f4f2e9a55ab6facffbb03f34ce04d -
4f9173f63cb2e13d1470e59e1b5c657f3b0f4f2e9a55ab6facffbb03f34ce04d -

Nice. However, I need the latency to be lower than the default
16ms, 3ms could perhaps work in theory, but preferably 1ms, so
the above 100ms is far off. The initial hash run was with latency
set to 1ms, which makes it easy to trigger the issue. The latency
timer setting is for this driver: drivers/usb/serial/ftdi_sio.c

And also, that does not help with the other reproducer, namely
to copy that same random testfile with scp to a working system...

$ scp testfile peda@xyzzy:testfile1
testfile 100% 39MB 2.0MB/s 00:19
$ scp testfile peda@xyzzy:testfile2
testfile 100% 39MB 2.1MB/s 00:18
$ scp testfile peda@xyzzy:testfile3
testfile 100% 39MB 2.1MB/s 00:18
$ scp testfile peda@xyzzy:testfile4
testfile 100% 39MB 2.1MB/s 00:19

...and then perform the sha256sum on that xyzzy host instead:

$ sha256sum testfile?
39dc3a7d05483ae7a2c64c5ed2e8e6108287bf4ddf124a2f0c1a9d0221f9ac66 testfile1
9597ef542e7cce879872a027d9ec591feb5fc766aeaec47d58eff6e8c6ab3206 testfile2
c6104a700b1d6f13eb1de84b5a91a1846a3e1576e052d51a664d2e2711a3869d testfile3
60b9c240cb331bad530c3c1d766f50d53a24e01831bfc04e48f329b738521310 testfile4
$ sha256sum testfile?
39dc3a7d05483ae7a2c64c5ed2e8e6108287bf4ddf124a2f0c1a9d0221f9ac66 testfile1
9597ef542e7cce879872a027d9ec591feb5fc766aeaec47d58eff6e8c6ab3206 testfile2
c6104a700b1d6f13eb1de84b5a91a1846a3e1576e052d51a664d2e2711a3869d testfile3
60b9c240cb331bad530c3c1d766f50d53a24e01831bfc04e48f329b738521310 testfile4

Same output every time. Of course. xyzzy is a working system...
Converting these files to hex (hexdump -C) and diffing yields this:

$ diff -u0 testfile1.hex testfile2.hex
--- testfile1.hex 2022-03-02 23:56:38.273149516 +0100
+++ testfile2.hex 2022-03-03 00:00:57.912747033 +0100
@@ -8658,2 +8658,2 @@
-00021d10 08 2a dd c6 c8 0f 0d e2 4c 1e 46 21 f9 89 a2 54 |.*......L.F!...T|
-00021d20 23 8c 4f f1 46 f1 61 05 ee f2 d2 ee 56 79 4f 28 |#.O.F.a.....VyO(|
+00021d10 7b c8 d2 0b f4 ca 5f ba 61 b3 93 04 59 8f ed bf |{....._.a...Y...|
+00021d20 2a f8 fb 0c ad 0e 23 2a 3e cf d3 10 02 ef 04 b9 |*.....#*>.......|
@@ -20592,2 +20592,2 @@
-000506f0 1f 6c ca 6b a6 2a 39 a6 1f bd b0 67 5b 22 1a dd |.l.k.*9....g["..|
-00050700 8b 6d 86 7c 87 37 ee a8 46 4d e5 79 0e 3e 96 e6 |.m.|.7..FM.y.>..|
+000506f0 ad e6 d5 65 e6 dc c1 a3 e2 ba c9 e2 61 39 5f 5f |...e........a9__|
+00050700 bf eb 8e 5c 08 f1 f2 89 3c 57 c5 07 b9 f4 91 fc |...\....<W......|
@@ -461019,2 +461019,2 @@
-00708da0 0d 49 c3 e8 57 06 20 5a c1 27 74 29 f8 83 af 69 |.I..W. Z.'t)...i|
-00708db0 94 4d 5b 71 9f 3e e5 d2 91 cc cb cd aa ff 44 8b |.M[q.>........D.|
+00708da0 d3 b4 96 d6 40 8d 79 67 69 68 fd 10 b4 15 82 e6 |....@.ygih......|
+00708db0 5f f4 10 92 ae 39 9d 92 42 88 44 3b be 35 38 33 |_....9..B.D;.583|
@@ -902788,2 +902788,2 @@
-00dc6830 f2 41 23 1b ec 54 d5 fe f0 33 51 f7 d2 fc bf bd |.A#..T...3Q.....|
-00dc6840 e5 1f 58 df 24 2f e3 dc 65 87 b2 27 12 86 d1 9a |..X.$/..e..'....|
+00dc6830 44 82 94 b5 c9 26 08 42 bd 89 e1 96 41 66 8a b5 |D....&.B....Af..|
+00dc6840 a5 34 46 5e fd 1b c1 73 86 33 24 fd 4d e1 e1 68 |.4F^...s.3$.M..h|
@@ -931900,2 +931900,2 @@
-00e383b0 ee 64 c5 6f 38 44 5b 31 41 e1 2c 64 49 d5 f8 ad |.d.o8D[1A.,dI...|
-00e383c0 fb 85 52 4f 00 1f 80 7a f3 de ee 8e db ac d5 bb |..RO...z........|
+00e383b0 4b 4d 29 a1 0a 99 8f f7 32 71 8c de 23 ca a0 f1 |KM).....2q..#...|
+00e383c0 e2 af e3 c4 a0 95 d3 1c ed 58 c4 c5 30 da 56 b9 |.........X..0.V.|
@@ -1170109,2 +1170109,2 @@
-011dabc0 6a 7c 0c 3c 86 1a b6 48 50 d7 98 68 0c 01 e3 1c |j|.<...HP..h....|
-011dabd0 a3 a8 b0 f2 62 21 86 b9 d1 52 9d 74 9e 26 42 51 |....b!...R.t.&BQ|
+011dabc0 5b 1a 9e 23 ae 58 42 68 83 58 df d6 c1 57 6b b0 |[..#.XBh.X...Wk.|
+011dabd0 ec d5 50 8b 76 5e 96 b4 49 21 f7 e4 b7 8f a3 45 |..P.v^..I!.....E|
@@ -1880164,2 +1880164,2 @@
-01cb0630 1c 74 74 16 75 b4 de f7 ce 4b 5e 4d 97 d6 36 d4 |.tt.u....K^M..6.|
-01cb0640 44 d9 fd 69 c5 d0 f0 a6 c6 44 26 53 7f 91 f3 62 |D..i.....D&S...b|
+01cb0630 73 bc 40 ce f8 9d 99 91 1b 14 8b a8 52 2a 7b 39 |s.@.........R*{9|
+01cb0640 6b ff f5 c5 02 b9 ab c2 c2 08 5e e7 3a 5e 69 c4 |k.........^.:^i.|

Grepping (some of the above) for duplicates yields this:

$ egrep "0 (08 2a dd|23 8c 4f|7b c8 d2|2a f8 fb)" testfile1.hex
00020d40 7b c8 d2 0b f4 ca 5f ba 61 b3 93 04 59 8f ed bf |{....._.a...Y...|
00020d50 2a f8 fb 0c ad 0e 23 2a 3e cf d3 10 02 ef 04 b9 |*.....#*>.......|
00021d10 08 2a dd c6 c8 0f 0d e2 4c 1e 46 21 f9 89 a2 54 |.*......L.F!...T|
00021d20 23 8c 4f f1 46 f1 61 05 ee f2 d2 ee 56 79 4f 28 |#.O.F.a.....VyO(|
$ egrep "0 (08 2a dd|23 8c 4f|7b c8 d2|2a f8 fb)" testfile2.hex
00020d40 7b c8 d2 0b f4 ca 5f ba 61 b3 93 04 59 8f ed bf |{....._.a...Y...|
00020d50 2a f8 fb 0c ad 0e 23 2a 3e cf d3 10 02 ef 04 b9 |*.....#*>.......|
00021d10 7b c8 d2 0b f4 ca 5f ba 61 b3 93 04 59 8f ed bf |{....._.a...Y...|*
00021d20 2a f8 fb 0c ad 0e 23 2a 3e cf d3 10 02 ef 04 b9 |*.....#*>.......|*

$ egrep "0 (1f 6c ca|8b 6d 86|ad e6 d5|bf eb 8e)" testfile1.hex
0004f6f0 1f 6c ca 6b a6 2a 39 a6 1f bd b0 67 5b 22 1a dd |.l.k.*9....g["..|
0004f700 8b 6d 86 7c 87 37 ee a8 46 4d e5 79 0e 3e 96 e6 |.m.|.7..FM.y.>..|
000506f0 1f 6c ca 6b a6 2a 39 a6 1f bd b0 67 5b 22 1a dd |.l.k.*9....g["..|*
00050700 8b 6d 86 7c 87 37 ee a8 46 4d e5 79 0e 3e 96 e6 |.m.|.7..FM.y.>..|*
$ egrep "0 (1f 6c ca|8b 6d 86|ad e6 d5|bf eb 8e)" testfile2.hex
0004f6f0 1f 6c ca 6b a6 2a 39 a6 1f bd b0 67 5b 22 1a dd |.l.k.*9....g["..|
0004f700 8b 6d 86 7c 87 37 ee a8 46 4d e5 79 0e 3e 96 e6 |.m.|.7..FM.y.>..|
000506f0 ad e6 d5 65 e6 dc c1 a3 e2 ba c9 e2 61 39 5f 5f |...e........a9__|
00050700 bf eb 8e 5c 08 f1 f2 89 3c 57 c5 07 b9 f4 91 fc |...\....<W......|

$ egrep "0 (0d 49 c3|94 4d 5b|d3 b4 96|5f f4 10 92)" testfile1.hex
00707dd0 d3 b4 96 d6 40 8d 79 67 69 68 fd 10 b4 15 82 e6 |....@.ygih......|
00707de0 5f f4 10 92 ae 39 9d 92 42 88 44 3b be 35 38 33 |_....9..B.D;.583|
00708da0 0d 49 c3 e8 57 06 20 5a c1 27 74 29 f8 83 af 69 |.I..W. Z.'t)...i|
00708db0 94 4d 5b 71 9f 3e e5 d2 91 cc cb cd aa ff 44 8b |.M[q.>........D.|
$ egrep "0 (0d 49 c3|94 4d 5b|d3 b4 96|5f f4 10 92)" testfile2.hex
00707dd0 d3 b4 96 d6 40 8d 79 67 69 68 fd 10 b4 15 82 e6 |....@.ygih......|
00707de0 5f f4 10 92 ae 39 9d 92 42 88 44 3b be 35 38 33 |_....9..B.D;.583|
00708da0 d3 b4 96 d6 40 8d 79 67 69 68 fd 10 b4 15 82 e6 |....@.ygih......|*
00708db0 5f f4 10 92 ae 39 9d 92 42 88 44 3b be 35 38 33 |_....9..B.D;.583|*

I.e. testfile1 is (probably) corrupted at 000506f0..70f while
testfile2 is (probably) corrupted at 00021d10..2f and 00708da0..bf
(correpted lines marked with hand-made asterisks above)

If I keep grepping like this, the pattern is similar both within
these files and within testfile3 and testfile4. I.e. with
corruptions in 32-byte blocks at (seemingly) random positions
in the files. The corruption is always 16-byte-aligned and the bad
data seems to be a copy from exactly one page up in the file.

As stated above, I have bisected the issue to patch

f9aa460672c9 ("driver core: Refactor fw_devlink feature")

which was added between v5.10-rc3 and v5.10-rc4. Every kernel I have
tried with that patch applied have exhibited the issue, and I have
had no trouble like this with any kernel without that patch. Apart
from a whole bunch of kernels prior to v5.10-rc3, that includes some
later kernels with the patch reverted (along with the dependent
followup 2d09e6eb4a6f). The latest I have tried is 5.11.22. Those
two patches does not revert cleanly in 5.12 (and thereafter) so I
have not tried anything beyond 5.11 with the patch reverted.

I fail to understand how that patch might cause this issue. I have
compared boot messages before and after the patch and there is no
(significant) difference. Everything seems to happen in the same
order with the same result. But that comparison is of course limited
to what is logged.

In some random attempt I tried to disable the D-Cache bit, and that
makes it all very slow but it also (seemingly) fixes the issue. But
that may of course be due to vastly different timings.

Some background:

We have a "Linea" CPU module, with a design based on the Atmel (now
Microchip) SAMA5D31 evaluation board. This CPU module is used on e.g.
our TSE-850 for which there is a device tree in
arch/arm/boot/dts/at91-tse850-3.dts
It has a nand flash for the rootfs and 64 MB RAM. The 40 MB random
testfile is thus big enough to cause page cache churn.

We have used this module in thousands of delivered units (however,
not that many TSE-850) and have never observed anything like this
before. But that has been with older kernels. 4.13.<something> and
4.15.<something> was what we were on until this recent activity.

We're now developing a new product (preliminary device tree included)
and the trusty old CPU module was used again and a fresh new kernel
was built for it. I then started to notice this issue and have tried
to include as much relevant data as possible. If you need more data
or would like me to test something, please ask.

I'm stumped.

Cheers,
Peter

Attachment: .config
Description: XML document

[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.10.0-rc3+ (peda@orc) (arm-buildroot-linux-gnueabihf-gcc.br_real (Buildroot 2021.08) 10.3.0, GNU ld (GNU Binutils) 2.36.1) #65 Wed Mar 2 16:33:37 CET 2022
[ 0.000000] CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c53c7d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: Axentia ME20 1.0
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000020000000-0x0000000023ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000020000000-0x0000000023ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000020000000-0x0000000023ffffff]
[ 0.000000] On node 0 totalpages: 16384
[ 0.000000] Normal zone: 128 pages used for memmap
[ 0.000000] Normal zone: 0 pages reserved
[ 0.000000] Normal zone: 16384 pages, LIFO batch:3
[ 0.000000] CPU: All CPU(s) started in SVC mode.
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16256
[ 0.000000] Kernel command line: console=ttyS0,115200 rw oops=panic panic=30 ip=none root=ubi0:rootfs ubi.mtd=6 rootfstype=ubifs noinitrd mtdparts=atmel_nand:256k(at91bootstrap),384k(barebox),256k@768k(bareboxenv),256k(bareboxenv2),128k@1536k(oftree),5M@2M(kernel),248M@8M(rootfs),-@256M(ovlfs)
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 54036K/65536K available (7168K kernel code, 336K rwdata, 1280K rodata, 1024K init, 105K bss, 11500K reserved, 0K cma-reserved)
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] random: get_random_bytes called from start_kernel+0x288/0x3b8 with crng_init=0
[ 0.000000] clocksource: timer@f0010000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 115833966437 ns
[ 0.000028] sched_clock: 32 bits at 16MHz, resolution 60ns, wraps every 130150523873ns
[ 0.000066] Switching to timer-based delay loop, resolution 60ns
[ 0.064143] clocksource: pit: mask: 0xfffffff max_cycles: 0xfffffff, max_idle_ns: 14479245754 ns
[ 0.064900] Console: colour dummy device 80x30
[ 0.064981] Calibrating delay loop (skipped), value calculated using timer frequency.. 33.00 BogoMIPS (lpj=165000)
[ 0.065032] pid_max: default: 32768 minimum: 301
[ 0.065342] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.065395] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.066572] CPU: Testing write buffer coherency: ok
[ 0.067881] Setting up static identity map for 0x20100000 - 0x20100060
[ 0.069481] devtmpfs: initialized
[ 0.087396] VFP support v0.3: implementor 41 architecture 2 part 30 variant 5 rev 1
[ 0.088032] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.088098] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[ 0.088292] pinctrl core: initialized pinctrl subsystem
[ 0.090363] NET: Registered protocol family 16
[ 0.091498] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.131639] AT91: PM: standby: standby, suspend: ulp0
[ 0.131689] No ATAGs?
[ 0.133101] gpio-at91 fffff200.gpio: at address (ptrval)
[ 0.134559] gpio-at91 fffff400.gpio: at address (ptrval)
[ 0.136118] gpio-at91 fffff600.gpio: at address (ptrval)
[ 0.137794] gpio-at91 fffff800.gpio: at address (ptrval)
[ 0.139548] gpio-at91 fffffa00.gpio: at address (ptrval)
[ 0.141556] pinctrl-at91 ahb:apb:pinctrl@fffff200: initialized AT91 pinctrl driver
[ 0.161208] at_hdmac ffffe600.dma-controller: Atmel AHB DMA Controller ( cpy set slave ), 8 channels
[ 0.163591] at_hdmac ffffe800.dma-controller: Atmel AHB DMA Controller ( cpy set slave ), 8 channels
[ 0.166563] AT91: Detected SoC family: sama5d3
[ 0.166604] AT91: Detected SoC: sama5d31, revision 2
[ 0.169066] SCSI subsystem initialized
[ 0.169697] usbcore: registered new interface driver usbfs
[ 0.169858] usbcore: registered new interface driver hub
[ 0.170116] usbcore: registered new device driver usb
[ 0.171359] at91_i2c f0014000.i2c: using dma0chan0 (tx) and dma0chan1 (rx) for DMA transfers
[ 0.171919] i2c i2c-0: Not using recovery: no recover_bus() found
[ 0.172383] at91_i2c f0014000.i2c: AT91 i2c bus driver (hw version: 0x402).
[ 0.173759] at91_i2c f801c000.i2c: using dma1chan0 (tx) and dma1chan1 (rx) for DMA transfers
[ 0.174316] i2c i2c-2: Not using recovery: no recover_bus() found
[ 0.176517] pca953x 2-0038: supply vcc not found, using dummy regulator
[ 0.177002] pca953x 2-0038: using no AI
[ 0.179527] pca953x 2-0039: supply vcc not found, using dummy regulator
[ 0.179968] pca953x 2-0039: using no AI
[ 0.183828] at91_i2c f801c000.i2c: AT91 i2c bus driver (hw version: 0x402).
[ 0.185716] Advanced Linux Sound Architecture Driver Initialized.
[ 0.187582] clocksource: Switched to clocksource timer@f0010000
[ 0.214089] NET: Registered protocol family 2
[ 0.215420] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.215495] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.215550] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.215598] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.215866] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.215937] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 0.216304] NET: Registered protocol family 1
[ 0.218398] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[ 0.219442] io scheduler mq-deadline registered
[ 0.219491] io scheduler kyber registered
[ 0.232691] brd: module loaded
[ 0.253479] loop: module loaded
[ 0.254262] at24 0-0051: supply vcc not found, using dummy regulator
[ 0.255672] at24 0-0051: 8192 byte 24c64 EEPROM, writable, 32 bytes/write
[ 0.256292] at24 2-0050: supply vcc not found, using dummy regulator
[ 0.257759] at24 2-0050: 8192 byte 24c64 EEPROM, writable, 32 bytes/write
[ 0.258668] atmel_usart_serial: Failed to locate of_node [id: -2]
[ 0.259328] atmel_usart_serial.0.auto: ttyS1 at MMIO 0xf001c000 (irq = 20, base_baud = 4125000) is a ATMEL_SERIAL
[ 0.261597] atmel_usart_serial: Failed to locate of_node [id: -2]
[ 0.262198] atmel_usart_serial.1.auto: ttyS2 at MMIO 0xf0020000 (irq = 21, base_baud = 4125000) is a ATMEL_SERIAL
[ 0.264248] atmel_usart_serial: Failed to locate of_node [id: -2]
[ 0.264825] atmel_usart_serial.2.auto: ttyS0 at MMIO 0xffffee00 (irq = 30, base_baud = 8250000) is a ATMEL_SERIAL
[ 0.888475] printk: console [ttyS0] enabled
[ 0.897801] libphy: Fixed MDIO Bus: probed
[ 0.904936] macb f802c000.ethernet: invalid hw address, using random
[ 0.912773] libphy: MACB_mii_bus: probed
[ 0.951592] macb f802c000.ethernet eth0: Cadence MACB rev 0x0001010c at 0xf802c000 irq 38 (da:cc:3e:24:ad:a2)
[ 0.962277] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.968841] ehci-atmel: EHCI Atmel driver
[ 0.977104] atmel-ehci 700000.ehci: EHCI Host Controller
[ 0.982537] atmel-ehci 700000.ehci: new USB bus registered, assigned bus number 1
[ 0.990358] atmel-ehci 700000.ehci: irq 40, io mem 0x00700000
[ 1.020063] atmel-ehci 700000.ehci: USB 2.0 started, EHCI 1.00
[ 1.026421] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
[ 1.034749] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.041987] usb usb1: Product: EHCI Host Controller
[ 1.046843] usb usb1: Manufacturer: Linux 5.10.0-rc3+ ehci_hcd
[ 1.052716] usb usb1: SerialNumber: 700000.ehci
[ 1.058752] hub 1-0:1.0: USB hub found
[ 1.062735] hub 1-0:1.0: 3 ports detected
[ 1.068424] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 1.074708] ohci-atmel: OHCI Atmel driver
[ 1.080595] at91_ohci 600000.ohci: USB Host Controller
[ 1.085802] at91_ohci 600000.ohci: new USB bus registered, assigned bus number 2
[ 1.093467] at91_ohci 600000.ohci: irq 40, io mem 0x00600000
[ 1.164436] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 5.10
[ 1.172776] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.179987] usb usb2: Product: USB Host Controller
[ 1.184818] usb usb2: Manufacturer: Linux 5.10.0-rc3+ ohci_hcd
[ 1.190659] usb usb2: SerialNumber: at91
[ 1.196357] hub 2-0:1.0: USB hub found
[ 1.200420] hub 2-0:1.0: 2 ports detected
[ 1.206887] usbcore: registered new interface driver uas
[ 1.212449] usbcore: registered new interface driver usb-storage
[ 1.218529] usbcore: registered new interface driver ums-alauda
[ 1.224563] usbcore: registered new interface driver ums-cypress
[ 1.230688] usbcore: registered new interface driver ums-datafab
[ 1.236764] usbcore: registered new interface driver ums_eneub6250
[ 1.243051] usbcore: registered new interface driver ums-freecom
[ 1.249126] usbcore: registered new interface driver ums-isd200
[ 1.255157] usbcore: registered new interface driver ums-jumpshot
[ 1.261358] usbcore: registered new interface driver ums-karma
[ 1.267262] usbcore: registered new interface driver ums-onetouch
[ 1.273470] usbcore: registered new interface driver ums-realtek
[ 1.279568] usbcore: registered new interface driver ums-sddr09
[ 1.285600] usbcore: registered new interface driver ums-sddr55
[ 1.291634] usbcore: registered new interface driver ums-usbat
[ 1.297718] usbcore: registered new interface driver ftdi_sio
[ 1.303598] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 1.311990] atmel_usba_udc 500000.gadget: MMIO registers at [mem 0xf8030000-0xf8033fff] mapped at (ptrval)
[ 1.321837] atmel_usba_udc 500000.gadget: FIFO at [mem 0x00500000-0x005fffff] mapped at (ptrval)
[ 1.334189] g_serial gadget: Gadget Serial v2.4
[ 1.338709] g_serial gadget: g_serial ready
[ 1.345530] at91_rtc fffffeb0.rtc: registered as rtc0
[ 1.350683] at91_rtc fffffeb0.rtc: setting system clock to 2007-01-01T02:26:23 UTC (1167618383)
[ 1.359411] at91_rtc fffffeb0.rtc: AT91 Real Time Clock driver.
[ 1.365635] i2c /dev entries driver
[ 1.371400] at91-reset fffffe00.rstc: Starting after user reset
[ 1.378397] lm75 2-004a: supply vs not found, using dummy regulator
[ 1.386116] lm75 2-004a: hwmon0: sensor 'at30ts74'
[ 1.392489] at91sam9_wdt: enabled (heartbeat=15 sec, nowayout=0)
[ 1.399385] atmel_aes f8038000.aes: version: 0x135
[ 1.406967] atmel_aes f8038000.aes: Atmel AES - Using dma1chan2, dma1chan3 for DMA transfers
[ 1.416412] atmel_sha f8034000.sha: version: 0x410
[ 1.421501] atmel_sha f8034000.sha: using dma1chan4 for DMA transfers
[ 1.429768] atmel_sha f8034000.sha: Atmel SHA1/SHA256/SHA224/SHA384/SHA512
[ 1.437640] atmel_tdes f803c000.tdes: version: 0x701
[ 1.443072] atmel_tdes f803c000.tdes: using dma1chan5, dma1chan6 for DMA transfers
[ 1.453314] atmel_tdes f803c000.tdes: Atmel DES/TDES
[ 1.459147] usbcore: registered new interface driver usbhid
[ 1.464762] usbhid: USB HID core driver
[ 1.473121] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xac
[ 1.479468] nand: Micron MT29F4G08ABBDAHC
[ 1.483557] nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[ 1.492011] usb 1-2: new high-speed USB device number 2 using atmel-ehci
[ 1.499339] Bad block table found at page 262080, version 0x01
[ 1.505707] Bad block table found at page 262016, version 0x01
[ 1.511975] 8 cmdlinepart partitions found on MTD device atmel_nand
[ 1.518226] Creating 8 MTD partitions on "atmel_nand":
[ 1.523440] 0x000000000000-0x000000040000 : "at91bootstrap"
[ 1.532455] 0x000000040000-0x0000000a0000 : "barebox"
[ 1.541055] 0x0000000c0000-0x000000100000 : "bareboxenv"
[ 1.549748] 0x000000100000-0x000000140000 : "bareboxenv2"
[ 1.558604] 0x000000180000-0x0000001a0000 : "oftree"
[ 1.567271] 0x000000200000-0x000000700000 : "kernel"
[ 1.576183] 0x000000800000-0x000010000000 : "rootfs"
[ 1.586451] 0x000010000000-0x000020000000 : "ovlfs"
[ 1.607590] xt_time: kernel timezone is -0000
[ 1.612412] gre: GRE over IPv4 demultiplexor driver
[ 1.617662] Initializing XFRM netlink socket
[ 1.622226] NET: Registered protocol family 10
[ 1.628589] Segment Routing with IPv6
[ 1.632861] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 1.640410] NET: Registered protocol family 17
[ 1.660691] ubi0: attaching mtd6
[ 1.664091] random: fast init done
[ 1.691575] usb 1-2: New USB device found, idVendor=0403, idProduct=6011, bcdDevice= 8.00
[ 1.699766] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1.706991] usb 1-2: Product: Quad RS232-HS
[ 1.711201] usb 1-2: Manufacturer: FTDI
[ 1.717343] ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected
[ 1.724413] usb 1-2: Detected FT4232H
[ 1.729268] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
[ 1.737880] ftdi_sio 1-2:1.1: FTDI USB Serial Device converter detected
[ 1.744956] usb 1-2: Detected FT4232H
[ 1.749712] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB1
[ 1.758271] ftdi_sio 1-2:1.2: FTDI USB Serial Device converter detected
[ 1.765348] usb 1-2: Detected FT4232H
[ 1.770134] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB2
[ 1.778663] ftdi_sio 1-2:1.3: FTDI USB Serial Device converter detected
[ 1.785720] usb 1-2: Detected FT4232H
[ 1.790602] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB3
[ 2.863734] ubi0: scanning is finished
[ 2.878739] ubi0: attached mtd6 (name "rootfs", size 248 MiB)
[ 2.884544] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 2.891432] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 2.898209] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 2.905245] ubi0: good PEBs: 1984, bad PEBs: 0, corrupted PEBs: 0
[ 2.911348] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[ 2.918566] ubi0: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1631681466
[ 2.927754] ubi0: available PEBs: 0, total reserved PEBs: 1984, PEBs reserved for bad PEB handling: 80
[ 2.937532] ubi0: background thread "ubi_bgt0d" started, PID 63
[ 2.948405] input: keys as /devices/platform/keys/input/input0
[ 2.956048] ALSA device list:
[ 2.958985] No soundcards found.
[ 2.964228] UBIFS (ubi0:0): Mounting in unauthenticated mode
[ 2.970305] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 64
[ 3.052921] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[ 3.060411] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 3.070371] UBIFS (ubi0:0): FS size: 239857664 bytes (228 MiB, 1889 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
[ 3.081093] UBIFS (ubi0:0): reserved for root: 0 bytes (0 KiB)
[ 3.086922] UBIFS (ubi0:0): media format: w4/r0 (latest is w5/r0), UUID 67B154A3-BF3E-4742-918A-569AB897CAFD, small LPT model
[ 3.099888] VFS: Mounted root (ubifs filesystem) on device 0:13.
[ 3.107321] devtmpfs: mounted
[ 3.113200] Freeing unused kernel memory: 1024K
[ 3.117921] Run /sbin/init as init process
[ 3.122033] with arguments:
[ 3.124956] /sbin/init
[ 3.127659] noinitrd
[ 3.130214] with environment:
[ 3.133333] HOME=/
[ 3.135688] TERM=linux
[ 3.161134] random: crng init done
[ 3.818451] ubi1: attaching mtd7
[ 4.953973] ubi1: scanning is finished
[ 4.969163] ubi1: attached mtd7 (name "ovlfs", size 256 MiB)
[ 4.974881] ubi1: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 4.981769] ubi1: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 4.988549] ubi1: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 4.995554] ubi1: good PEBs: 2044, bad PEBs: 4, corrupted PEBs: 0
[ 5.001662] ubi1: user volume: 1, internal volumes: 1, max. volumes count: 128
[ 5.008886] ubi1: max/mean erase counter: 3/1, WL threshold: 4096, image sequence number: 1283539683
[ 5.018071] ubi1: available PEBs: 0, total reserved PEBs: 2044, PEBs reserved for bad PEB handling: 76
[ 5.027815] ubi1: background thread "ubi_bgt1d" started, PID 79
UBI device number 1, total 2044 LEBs (259538944 bytes, 247.5 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
ubimkvol: error!: UBI device does not have free logical eraseblocks
[ 5.143406] UBIFS (ubi1:0): Mounting in unauthenticated mode
[ 5.149436] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 85
[ 5.184097] UBIFS (ubi1:0): recovery needed
[ 5.289691] UBIFS (ubi1:0): recovery completed
[ 5.294361] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "ovl"
[ 5.301564] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 5.311518] UBIFS (ubi1:0): FS size: 247730176 bytes (236 MiB, 1951 LEBs), journal size 12443648 bytes (11 MiB, 98 LEBs)
[ 5.322421] UBIFS (ubi1:0): reserved for root: 4952683 bytes (4836 KiB)
[ 5.329036] UBIFS (ubi1:0): media format: w5/r0 (latest is w5/r0), UUID AF203193-3C1C-433E-95D2-2F69D45F490A, small LPT model
[ 6.502071] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* at91-me20.dts - Device Tree file for the Axentia ME20 1.0 board
*
* Copyright (C) 2022 Axentia Technologies AB
*
* Author: Peter Rosin <peda@xxxxxxxxxx>
*/
/dts-v1/;

#include "at91-linea.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/pwm/pwm.h>

/ {
model = "Axentia ME20 1.0";
compatible = "axentia,me20", "axentia,linea",
"atmel,sama5d31", "atmel,sama5d3", "atmel,sama5";

phyxtal: oscillator {
compatible = "fixed-clock";

#clock-cells = <0>;
clock-frequency = <25000000>;
clock-output-names = "phyxtal";
};

phyclk: clock {
compatible = "fixed-factor-clock";
clocks = <&phyxtal>;
#clock-cells = <0>;
clock-div = <1>;
clock-mult = <2>;
clock-output-names = "phyclk";
};

reg_5v: att-regulator {
compatible = "regulator-fixed";

regulator-name = "5v-supply";
regulator-min-microvolt = <30000000>;
regulator-max-microvolt = <30000000>;
};

reg_30v: tune-regulator {
compatible = "regulator-fixed";

regulator-name = "30v-supply";
regulator-min-microvolt = <30000000>;
regulator-max-microvolt = <30000000>;
};

keys {
compatible = "gpio-keys";

pinctrl-0 = <&pinctrl_keys>;
pinctrl-names = "default";

back {
label = "BACK";
gpios = <&pioA 5 GPIO_ACTIVE_LOW>;
linux,code = <KEY_BACK>;
};

sel {
label = "SEL";
gpios = <&pioA 6 GPIO_ACTIVE_LOW>;
linux,code = <KEY_SELECT>;
};

up {
label = "UP";
gpios = <&pioA 7 GPIO_ACTIVE_LOW>;
linux,code = <KEY_UP>;
};

down {
label = "DOWN";
gpios = <&pioA 8 GPIO_ACTIVE_LOW>;
linux,code = <KEY_DOWN>;
};
};
};

&pinctrl {
me20 {
pinctrl_keys: keys {
atmel,pins = <AT91_PIOA 5 AT91_PERIPH_GPIO // BACK
AT91_PINCTRL_DEGLITCH
AT91_PIOA 6 AT91_PERIPH_GPIO // SEL
AT91_PINCTRL_DEGLITCH
AT91_PIOA 7 AT91_PERIPH_GPIO // UP
AT91_PINCTRL_DEGLITCH
AT91_PIOA 8 AT91_PERIPH_GPIO // DOWN
AT91_PINCTRL_DEGLITCH>;
};

pinctrl_usba_vbus: usba-vbus {
atmel,pins = <AT91_PIOD 30 AT91_PERIPH_GPIO // UC-ID
AT91_PINCTRL_DEGLITCH>;
};
};
};

&nand {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

at91bootstrap@0 {
label = "at91bootstrap";
reg = <0x0 0x40000>;
};

barebox@40000 {
label = "bootloader";
reg = <0x40000 0x60000>;
};

bareboxenv@c0000 {
label = "bareboxenv";
reg = <0xc0000 0x40000>;
};

bareboxenv2@100000 {
label = "bareboxenv2";
reg = <0x100000 0x40000>;
};

oftree@180000 {
label = "oftree";
reg = <0x180000 0x20000>;
};

kernel@200000 {
label = "kernel";
reg = <0x200000 0x500000>;
};

rootfs@800000 {
label = "rootfs";
reg = <0x800000 0x0f800000>;
};

ovlfs@10000000 {
label = "ovlfs";
reg = <0x10000000 0x10000000>;
};
};
};

&i2c2 {
status = "okay";

tune-b@c { /* ti,dac121c081 */
/* Clobbered by address 0x46. */
/* Broadcast address 0x48. */
compatible = "ti,dac7571";
reg = <0xc>;
vref-supply = <&reg_30v>;
label = "tune-b";
};

tune-a@d {
/* Clobbered by address 0x46. */
/* Broadcast address 0x48. */
compatible = "ti,dac7571";
reg = <0xd>;
vref-supply = <&reg_30v>;
label = "tune-a";
};

att@e {
/* Clobbered by address 0x47. */
/* Broadcast address 0x48. */
compatible = "ti,dac7571";
reg = <0xe>;
vref-supply = <&reg_5v>;
label = "att";
};

gpio-a@38 {
compatible = "nxp,pca9554";
reg = <0x38>;
gpio-controller;
#gpio-cells = <2>;

gpio-line-names =
"AF1", "AF2", "AF3", "AF4",
"HP", "PASS", "HP2", "/AMPA";
};

gpio-b@39 {
compatible = "nxp,pca9554";
reg = <0x39>;
gpio-controller;
#gpio-cells = <2>;

gpio-line-names =
"BF1", "BF2", "BF3", "BF4",
"", "", "", "/AMPB";
};

oled@3c {
compatible = "solomon,ssd1311";
reg = <0x3c>;
reset-gpios = <&pioD 29 GPIO_ACTIVE_LOW>;
solomon,opr-gpios = <&pioD 26 GPIO_ACTIVE_HIGH
&pioD 28 GPIO_ACTIVE_HIGH>;
};

temp@4a {
compatible = "atmel,at30ts74", "dallas,ds7505";
reg = <0x4a>;
};

eeprom@50 {
compatible = "st,24c64", "atmel,24c64";
reg = <0x50>;
pagesize = <32>;
wp-gpios = <&pioA 3 GPIO_ACTIVE_HIGH>;
};

tusb320@60 {
compatible = "ti,tusb320";
reg = <0x60>;
interrupt-parent = <&pioA>;
interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
};
};

&watchdog {
status = "okay";
};

/* GNSS, ttyS1 */
&usart0 {
status = "okay";

atmel,use-dma-rx;
};

/* RS232 port, ttyS2 */
&usart1 {
status = "okay";

pinctrl-0 = <&pinctrl_usart1 &pinctrl_usart1_rts_cts>;
atmel,use-dma-rx;
};

&macb1 {
status = "okay";

phy-mode = "rmii";

#address-cells = <1>;
#size-cells = <0>;

phy0: ethernet-phy@1 {
reg = <1>;
clocks = <&phyclk>;
reset-gpios = <&pioC 17 GPIO_ACTIVE_LOW>;
reset-assert-us = <100>;
smsc,disable-energy-detect;
};
};

&usb0 { /* gadget */
status = "okay";

pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usba_vbus>;
atmel,vbus-gpio = <&pioD 30 GPIO_ACTIVE_HIGH>;
};

&usb1 { /* ohci */
status = "okay";

num-ports = <2>;
};

&usb2 { /* ehci */
status = "okay";
};

/* ttyS0 */
&dbgu {
status = "okay";

dmas = <0>, <0>; /* Do not use DMA for dbgu */
};

&pioA {
gpio-line-names =
/* 0 */ "232-PS", "232-MODE", "UB-RST", "E2-WP",
/* 4 */ "GPSO/O", "B-BACK", "B-SEL", "B-UP",
/* 8 */ "B-DOWN", "/UC-INT", "", "",
/* 12 */ "", "", "", "",
/* 16 */ "", "", "SDA", "SCL",
/* 20 */ "", "ALE", "CLE", "",
/* 24 */ "", "", "", "",
/* 28 */ "", "", "LINSDA", "LINSCL";
};

&pioB {
gpio-line-names =
/* 0 */ "", "", "", "",
/* 4 */ "", "", "", "",
/* 8 */ "", "", "", "",
/* 12 */ "", "", "", "",
/* 16 */ "", "", "", "",
/* 20 */ "", "", "", "",
/* 24 */ "", "", "CTS-232", "RTS-232",
/* 28 */ "RX-232", "TX-232", "LINBRX", "LINBTX";
};

&pioC {
gpio-line-names =
/* 0 */ "ETX0", "ETX1", "ERX0", "ERX1",
/* 4 */ "ETXEN", "ECRSDV", "ERXER", "EREFCK",
/* 8 */ "EMDC", "EMDIO", "", "",
/* 12 */ "", "", "", "",
/* 16 */ "CGB-PDB", "/ETH-RST", "CGA-PDB", "1PPS",
/* 20 */ "", "", "", "",
/* 24 */ "", "", "", "",
/* 28 */ "", "", "", "";
};

&pioD {
gpio-line-names =
/* 0 */ "", "", "", "",
/* 4 */ "", "", "", "RFB-SIG>",
/* 8 */ "", "RFB-SIG<", "", "RFA-SIG>",
/* 12 */ "", "RFA-SIG<", "", "",
/* 16 */ "", "GNSS-TX", "GNSS-RX", "",
/* 20 */ "VREFEN", "", "", "",
/* 24 */ "", "", "D-OPR0", "",
/* 28 */ "D-OPR1", "/D-RES", "UC-ID", "";
};

&pioE {
gpio-line-names =
/* 0 */ "", "", "", "",
/* 4 */ "", "", "", "",
/* 8 */ "", "", "", "",
/* 12 */ "", "", "", "",
/* 16 */ "", "", "", "",
/* 20 */ "", "", "", "",
/* 24 */ "", "", "", "",
/* 28 */ "", "", "", "";
};