在 U-boot 期间或 U-boot 之后立即启动 spidev 程序

Starting a spidev program during U-boot or right after U-boot

所以我需要一些关于如何在内核初始化开始时制作 spidev 运行 的指导。我正在使用连接到使用 SPI 驱动的 pocketbeagle 的 ILI9341 显示器。事情是,我需要 "send" 在启动期间显示图像。为此,我需要在启动过程的最开始就启动 spidev,而且我不太确定启动 spidev 的进程是什么。我不确定它是由 systemd 进程还是其他地方启动的。

这里是我的spidev设备树声明(原文:am335x-pocketbeagle.dts):

&spi0 {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";

    channel@0 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <100000000>;
    };

    channel@1 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "spidev";
        reg = <1>;
        spi-max-frequency = <100000000>;
        status = "disabled";
    };
};

&spi1 {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";

    channel@0 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <100000000>;
    };

    channel@1 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "spidev";
        reg = <1>;
        spi-max-frequency = <100000000>;
    };
};

这是启动过程的开始(这里只显示前几秒):

U-Boot SPL 2018.01-dirty (May 06 2018 - 17:12:35)
Trying to boot from MMC1


U-Boot 2018.01-dirty (May 06 2018 - 17:12:35 -0400)

CPU  : AM335X-GP rev 2.1
I2C:   ready
DRAM:  512 MiB
No match for driver 'omap_hsmmc'
No match for driver 'omap_hsmmc'
Some drivers were not found
Reset Source: Power-on reset has occurred.
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
Using default environment

Model: BeagleBoard.org PocketBeagle
<ethaddr> not set. Validating first E-fuse MAC
Net:   usb_ether
Press SPACE to abort autoboot in 2 seconds
board_name=[A335PBGL] ...
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
** Bad device 0:2 0x82000000 **
** Bad device 0:2 0x82000000 **
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
Checking for: /uEnv.txt ...
Checking for: /boot.scr ...
Checking for: /boot/boot.scr ...
Checking for: /boot/uEnv.txt ...
gpio: pin 55 (gpio 55) value is 1
24 bytes read in 15 ms (1000 Bytes/s)
Loaded environment from /boot/uEnv.txt
Checking if uname_r is set in /boot/uEnv.txt...
gpio: pin 56 (gpio 56) value is 1
Running uname_boot ...
loading /boot/vmlinuz-4.4.113-ti-r149 ...
9431560 bytes read in 612 ms (14.7 MiB/s)
loading /boot/dtbs/4.4.113-ti-r149/am335x-pocketbeagle.dtb ...
130113 bytes read in 84 ms (1.5 MiB/s)
uboot_overlays: add [enable_uboot_overlays=1] to /boot/uEnv.txt to enable...
debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait]                                                                                                                                                              ...
debug: [bootz 0x82000000 - 0x88000000] ...
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Device Tree to 8ffdd000, end 8ffffc40 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 4.4.113-ti-r149 (luis@luis) (gcc version 5.5.0 (Lin                                                                                                                                                             aro GCC 5.5-2017.10) ) #2 SMP Fri Jun 29 16:50:45 EDT 2018
[    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instructio                                                                                                                                                             n cache
[    0.000000] Machine model: TI AM335x PocketBeagle
[    0.000000] cma: Reserved 48 MiB at 0x9c800000
[    0.000000] Memory policy: Data cache writeback
[    0.000000] CPU: All CPU(s) started in SVC mode.
[    0.000000] AM335X ES2.1 (sgx neon )
[    0.000000] PERCPU: Embedded 13 pages/cpu @df8f2000 s24192 r8192 d20864 u5324                                                                                                                                                             8
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pag                                                                                                                                                             es: 129408
[    0.000000] Kernel command line: console=ttyO0,115200n8 root=/dev/mmcblk0p1 r                                                                                                                                                             o rootfstype=ext4 rootwait
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 448072K/522240K available (12533K kernel code, 1016K rwda                                                                                                                                                             ta, 4064K rodata, 824K init, 857K bss, 25016K reserved, 49152K cma-reserved, 0K                                                                                                                                                              highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc103d760   (16598 kB)
[    0.000000]       .init : 0xc103e000 - 0xc110c000   ( 824 kB)
[    0.000000]       .data : 0xc110c000 - 0xc120a0e8   (1017 kB)
[    0.000000]        .bss : 0xc120d000 - 0xc12e355c   ( 858 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  Build-time adjustment of leaf fanout to 32.
[    0.000000]  RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=1
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrup                                                                                                                                                             ts
[    0.000000] OMAP clockevent source: timer2 at 24000000 Hz
[    0.000022] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478                                                                                                                                                             484971ns
[    0.000048] clocksource: timer1: mask: 0xffffffff max_cycles: 0xffffffff, max                                                                                                                                                             _idle_ns: 79635851949 ns
[    0.000061] OMAP clocksource: timer1 at 24000000 Hz
[    0.001914] clocksource_probe: no matching clocksources found
[    0.002223] Console: colour dummy device 80x30
[    0.002254] WARNING: Your 'console=ttyO0' has been replaced by 'ttyS0'
[    0.002262] This ensures that you still see kernel messages. Please
[    0.002268] update your kernel commandline.
[    0.002289] Calibrating delay loop... 995.32 BogoMIPS (lpj=1990656)
[    0.021215] pid_max: default: 32768 minimum: 301
[    0.021365] Security Framework initialized
[    0.021380] Yama: becoming mindful.
[    0.021418] AppArmor: AppArmor disabled by boot time parameter
[    0.021590] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.021603] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.022464] Initializing cgroup subsys io
[    0.022497] Initializing cgroup subsys memory
[    0.022543] Initializing cgroup subsys devices
[    0.022561] Initializing cgroup subsys freezer
[    0.022578] Initializing cgroup subsys net_cls
[    0.022592] Initializing cgroup subsys perf_event
[    0.022607] Initializing cgroup subsys net_prio
[    0.022630] Initializing cgroup subsys pids
[    0.022688] CPU: Testing write buffer coherency: ok
[    0.022747] ftrace: allocating 37522 entries in 111 pages
[    0.128715] CPU0: thread -1, cpu 0, socket -1, mpidr 0
[    0.128838] Setting up static identity map for 0x80008280 - 0x800082e0
[    0.133343] Brought up 1 CPUs
[    0.133369] SMP: Total of 1 processors activated (995.32 BogoMIPS).
[    0.133377] CPU: All CPU(s) started in SVC mode.
[    0.134975] devtmpfs: initialized
[    0.172782] VFP support v0.3: implementor 41 architecture 3 part 30 variant c                                                                                                                                                              rev 3
[    0.223366] omap_hwmod: debugss: _wait_target_disable failed
[    0.277491] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, ma                                                                                                                                                             x_idle_ns: 7645041785100000 ns
[    0.277527] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.281782] xor: measuring software checksum speed
[    0.321202]    arm4regs  :  1219.000 MB/sec
[    0.361191]    8regs     :   957.000 MB/sec
[    0.401188]    32regs    :  1089.000 MB/sec
[    0.441187]    neon      :  1725.000 MB/sec
[    0.441195] xor: using function: neon (1725.000 MB/sec)
[    0.441228] pinctrl core: initialized pinctrl subsystem
[    0.442711] NET: Registered protocol family 16
[    0.445513] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.446456] cpuidle: using governor ladder
[    0.446477] cpuidle: using governor menu
[    0.452463] OMAP GPIO hardware version 0.1
[    0.475562] No ATAGs?
[    0.475601] hw-breakpoint: debug architecture 0x4 unsupported.
[    0.476766] omap4_sram_init:Unable to allocate sram needed to handle errata I                                                                                                                                                             688
[    0.476789] omap4_sram_init:Unable to get sram pool needed to handle errata I                                                                                                                                                             688
[    0.557214] raid6: neonx2   gen()  1887 MB/s
[    0.625198] raid6: neonx2   xor()  1161 MB/s
[    0.625207] raid6: using algorithm neonx2 gen() 1887 MB/s
[    0.625214] raid6: .... xor() 1161 MB/s, rmw enabled
[    0.625221] raid6: using intx1 recovery algorithm
[    0.635476] edma 49000000.edma: TI EDMA DMA engine driver
[    0.640859] vgaarb: loaded
[    0.641610] SCSI subsystem initialized
[    0.642367] usbcore: registered new interface driver usbfs
[    0.642449] usbcore: registered new interface driver hub
[    0.642560] usbcore: registered new device driver usb
[    0.643413] omap_i2c 44e0b000.i2c: could not find pctldev for node /ocp/l4_wk                                                                                                                                                             up@44c00000/scm@210000/pinmux@800/pinmux_i2c0_pins, deferring probe
[    0.644286] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 400 kHz
[    0.644967] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 400 kHz
[    0.645404] media: Linux media interface: v0.10
[    0.645482] Linux video capture interface: v2.00
[    0.645611] pps_core: LinuxPPS API ver. 1 registered
[    0.645620] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giome                                                                                                                                                             tti <giometti@linux.it>
[    0.645655] PTP clock support registered
[    0.646615] omap-mailbox 480c8000.mailbox: omap mailbox rev 0x400
[    0.648938] NetLabel: Initializing
[    0.648955] NetLabel:  domain hash size = 128
[    0.648961] NetLabel:  protocols = UNLABELED CIPSOv4
[    0.649029] NetLabel:  unlabeled traffic allowed by default
[    0.649769] clocksource: Switched to clocksource timer1
[    0.773340] NET: Registered protocol family 2
[    0.774347] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.774397] TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
[    0.774456] TCP: Hash tables configured (established 4096 bind 4096)
[    0.774539] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.774560] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.774925] NET: Registered protocol family 1
[    0.775551] RPC: Registered named UNIX socket transport module.
[    0.775567] RPC: Registered udp transport module.
[    0.775574] RPC: Registered tcp transport module.
[    0.775580] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.776750] hw perfevents: enabled with armv7_cortex_a8 PMU driver, 5 counter                                                                                                                                                             s available
[    0.780201] audit: initializing netlink subsys (disabled)
[    0.780300] audit: type=2000 audit(0.712:1): initialized
[    0.790964] zbud: loaded
[    0.791713] VFS: Disk quotas dquot_6.6.0
[    0.791995] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.795073] NFS: Registering the id_resolver key type
[    0.795149] Key type id_resolver registered
[    0.795157] Key type id_legacy registered
[    0.795187] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.795579] fuse init (API version 7.23)
[    0.796227] SGI XFS with ACLs, security attributes, realtime, no debug enable                                                                                                                                                             d
[    0.805645] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 2                                                                                                                                                             47)
[    0.806079] io scheduler noop registered
[    0.806100] io scheduler deadline registered
[    0.806175] io scheduler cfq registered (default)
[    0.808070] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
[    0.809173] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0
[    0.809332] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1
[    0.809521] gpio-of-helper ocp:cape-universal: Allocated GPIO id=2
[    0.809670] gpio-of-helper ocp:cape-universal: Allocated GPIO id=3
[    0.810219] gpio-of-helper ocp:cape-universal: Allocated GPIO id=4
[    0.810400] gpio-of-helper ocp:cape-universal: Allocated GPIO id=5
[    0.810547] gpio-of-helper ocp:cape-universal: Allocated GPIO id=6
[    0.810691] gpio-of-helper ocp:cape-universal: Allocated GPIO id=7
[    0.810844] gpio-of-helper ocp:cape-universal: Allocated GPIO id=8
[    0.811050] gpio-of-helper ocp:cape-universal: Allocated GPIO id=9
[    0.811224] gpio-of-helper ocp:cape-universal: Allocated GPIO id=10
[    0.811392] gpio-of-helper ocp:cape-universal: Allocated GPIO id=11
[    0.811539] gpio-of-helper ocp:cape-universal: Allocated GPIO id=12
[    0.811692] gpio-of-helper ocp:cape-universal: Allocated GPIO id=13
[    0.811838] gpio-of-helper ocp:cape-universal: Allocated GPIO id=14
[    0.811988] gpio-of-helper ocp:cape-universal: Allocated GPIO id=15
[    0.812144] gpio-of-helper ocp:cape-universal: Allocated GPIO id=16
[    0.812293] gpio-of-helper ocp:cape-universal: Allocated GPIO id=17
[    0.812445] gpio-of-helper ocp:cape-universal: Allocated GPIO id=18
[    0.812598] gpio-of-helper ocp:cape-universal: Allocated GPIO id=19
[    0.812752] gpio-of-helper ocp:cape-universal: Allocated GPIO id=20
[    0.812907] gpio-of-helper ocp:cape-universal: Allocated GPIO id=21
[    0.813055] gpio-of-helper ocp:cape-universal: Allocated GPIO id=22
[    0.813189] gpio-of-helper ocp:cape-universal: Allocated GPIO id=23
[    0.813332] gpio-of-helper ocp:cape-universal: Allocated GPIO id=24
[    0.813467] gpio-of-helper ocp:cape-universal: Allocated GPIO id=25
[    0.813602] gpio-of-helper ocp:cape-universal: Allocated GPIO id=26
[    0.813842] gpio-of-helper ocp:cape-universal: Allocated GPIO id=27
[    0.814192] gpio-of-helper ocp:cape-universal: Allocated GPIO id=28
[    0.814350] gpio-of-helper ocp:cape-universal: Allocated GPIO id=29
[    0.814491] gpio-of-helper ocp:cape-universal: Allocated GPIO id=30
[    0.814629] gpio-of-helper ocp:cape-universal: Allocated GPIO id=31
[    0.814774] gpio-of-helper ocp:cape-universal: Allocated GPIO id=32
[    0.814911] gpio-of-helper ocp:cape-universal: Allocated GPIO id=33
[    0.815048] gpio-of-helper ocp:cape-universal: Allocated GPIO id=34
[    0.815196] gpio-of-helper ocp:cape-universal: Allocated GPIO id=35
[    0.815338] gpio-of-helper ocp:cape-universal: Allocated GPIO id=36
[    0.815485] gpio-of-helper ocp:cape-universal: Allocated GPIO id=37
[    0.815624] gpio-of-helper ocp:cape-universal: Allocated GPIO id=38
[    0.815762] gpio-of-helper ocp:cape-universal: Allocated GPIO id=39
[    0.815909] gpio-of-helper ocp:cape-universal: Allocated GPIO id=40
[    0.816053] gpio-of-helper ocp:cape-universal: Allocated GPIO id=41
[    0.816194] gpio-of-helper ocp:cape-universal: Allocated GPIO id=42
[    0.816343] gpio-of-helper ocp:cape-universal: Allocated GPIO id=43
[    0.816354] gpio-of-helper ocp:cape-universal: ready
[    0.822156] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    0.824170] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
[    0.827881] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 158, base_baud =                                                                                                                                                              3000000) is a 8250
[    1.921701] console [ttyS0] enabled

"Important" GPIO 和 I2C 之类的东西似乎 运行 在引导过程的最开始就已启动。我怎么能用 spidev 做同样的事情?

我有点不清楚 pocketbeagle 的设备树在引导过程中的什么位置 "declared"? /dev/spidev 在引导过程中的哪个位置可用?我怎样才能让它更早开始?

将@sawdust 和我的评论总结成一个答案: