0

I'm building a custom linux with buildroot in combination with U-Boot on compute module 3(+). I can boot with and without U-Boot. But if the kernel is booted through U-Boot there is no I2C bus available. If the kernel is booted directly (kernel=Image) everything is working like intended. In both cases i2c_dev module is loaded and I can't see any big differences.

I added my config.txt. Here only the kernel= line changes accordingly.

Furthermore I have posted my boot script. I use a first stage bootscript to source the actual boot.scr as part of a fallback system. Shouldn't be make a difference though...

Lastly I recorded the boot process in both cases and constructed a diff. I can't make out any meaningful differences. At the very end It is visible how i2c-detect -l yields for the direct boot

i2c-1 i2c bcm2835 (i2c@7e804000) I2C adapter

But nothing for the U-Boot boot.

buildroot: 2022.02.6

Kernel: 5.10.92

U-Boot: 2022.01

config.txt:

kernel=u-boot.bin
#kernel=Image
arm_64bit=1
dtparam=spi=on
dtparam=i2c_arm=on
dtoverlay=spi0-1cs,cs0_pin=43
enable_uart=1
uart_2ndstage=1
dtdebug=1

boot.scr:

if test "${boot_kernel}" = 2; then
        echo "###Loading factory kernel###"
        load mmc 0:2 ${kernel_addr_r} images/factory/Image;
        load mmc 0:2 ${fdt_addr} images/factory/bcm2710-rpi-cm3.dtb;
elif test "${boot_kernel}" = 1; then
        echo "###Loading previous kernel###"
        load mmc 0:2 ${kernel_addr_r} images/previous/Image;
        load mmc 0:2 ${fdt_addr} images/previous/bcm2710-rpi-cm3.dtb;
else
        echo "###Loading current kernel###"
        load mmc 0:2 ${kernel_addr_r} images/latest/Image;
        load mmc 0:2 ${fdt_addr} images/latest/bcm2710-rpi-cm3.dtb;
fi

setenv bootargs 'coherent_pool=1M snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:81:BF:03 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait'
#setenv bootargs console=ttyAMA0,115200 printk.devkmsg=on usbcore.autosuspend=-1 fsck.mode=force fsck.repair=yes
env save
booti ${kernel_addr_r} - ${fdt_addr}

first_boot.scr

[...]
if test "${isa_boot_count}" > 4; then
        echo "###Loading factory kernel bootscript###"
        setenv isa_boot_kernel 2;
        load mmc 0:2 ${scriptaddr} images/factory/boot.scr;
        source ${scriptaddr}
[...]
--- out_Image   2022-10-31 09:20:35.482122089 +0100
+++ out_uboot   2022-10-31 09:39:24.338868824 +0100
@@ -118,18 +118,78 @@
 Unknown dtparam 'core_freq' - ignored
 gpioman: gpioman_get_pin_num: pin WL_ON not defined
 dtdebug: delete_node(/hat)
-brfs: File read: /mfs/sd/Image
-Loading 'Image' to 0x80000 size 0x3e04a00
-Kernel relocated to 0x200000
+brfs: File read: /mfs/sd/u-boot.bin
+Loading 'u-boot.bin' to 0x80000 size 0x7ce20
 Device tree loaded to 0x2eff8a00 (size 0x75f9)
 uart: Set PL011 baud rate to 103448.300000 Hz
 uart: Baud rate change done...
 uart: Baud rate change done...
 gpioman: gpioman_get_pin_num: pin SDCARD_CONTROL_POWER not defined
+
+
+U-Boot 2022.01 (Oct 19 2022 - 14:23:33 +0200)
+
+Model: Raspberry Pi Compute Module 3 Rev 1.0
+DRAM:  948 MiB
+RPI Compute Module 3 (0xa220a0)
+MMC:   mmc@7e202000: 0
+Loading Environment from FAT... WARNING at drivers/mmc/bcm2835_sdhost.c:414/bcm2835_send_command()!
+WARNING at drivers/mmc/bcm2835_sdhost.c:414/bcm2835_send_command()!
+OK
+In:    serial
+Out:   vidconsole
+Err:   vidconsole
+Model: Raspberry Pi Compute Module 3 Rev 1.0
+Hit any key to stop autoboot:  2  1  0 
+1366 bytes read in 1 ms (1.3 MiB/s)
+## Executing script at 02400000
+Loading env
+Loading Environment from FAT... OK
+isa_boot_count=None
+Boot counter variable found
+isa_boot_kernel=2
+Kernel type variable found
+Increasing boot count
+Saving Environment to FAT... OK
+###Loading current kernel bootscript###
+Failed to load 'isatech-images/latest/boot.scr'
+## Executing script at 02400000
+Loading env
+Loading Environment from FAT... OK
+isa_boot_count=1
+Boot counter variable found
+isa_boot_kernel=2
+Kernel type variable found
+Increasing boot count
+Saving Environment to FAT... OK
+###Loading current kernel bootscript###
+Failed to load 'isatech-images/latest/boot.scr'
+## Executing script at 02400000
+Loading env
+Loading Environment from FAT... OK
+isa_boot_count=2
+Boot counter variable found
+isa_boot_kernel=2
+Kernel type variable found
+Increasing boot count
+Saving Environment to FAT... OK
+###Loading factory kernel bootscript###
+875 bytes read in 1 ms (854.5 KiB/s)
+## Executing script at 02400000
+###Loading factory kernel###
+65030656 bytes read in 2690 ms (23.1 MiB/s)
+28942 bytes read in 3 ms (9.2 MiB/s)
+Saving Environment to FAT... OK
+Moving Image from 0x80000 to 0x200000, end=4100000
+## Flattened Device Tree blob at 2eff8a00
+   Booting using the fdt blob at 0x2eff8a00
+   Using Device Tree in place at 000000002eff8a00, end 000000002f002b0d
+
+Starting kernel ...
+
  Booting Linux on physical CPU 0x0000000000 [0x410fd034]
  Linux version 5.10.92-v8 (chris@mojobuild) (aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2022.02.6) 10.4.0, GNU ld (GNU Binutils) 2.36.1) #33 SMP PREEMPT Mon Oct 24 19:47:01 CEST 2022
- random: fast init done
- Machine model: Raspberry Pi Compute Module 3 Rev 1.0
+ Machine model: Raspberry Pi Compute Module 3
  efi: UEFI not found.
  Reserved memory: created CMA memory pool at 0x0000000037400000, size 64 MiB
  OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
@@ -144,15 +204,13 @@
  percpu: Embedded 31 pages/cpu s87320 r8192 d31464 u126976
  Detected VIPT I-cache on CPU0
  CPU features: detected: ARM erratum 845719
- CPU features: kernel page table isolation forced ON by KASLR
- CPU features: detected: Kernel page table isolation (KPTI)
  CPU features: detected: ARM erratum 843419
  Built 1 zonelists, mobility grouping on.  Total pages: 238896
  Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
  Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
  mem auto-init: stack:off, heap alloc:off, heap free:off
- Memory: 820208K/970752K available (10560K kernel code, 1810K rwdata, 3592K rodata, 47424K init, 984K bss, 85008K reserved, 65536K cma-reserved)
+ Memory: 820212K/970752K available (10560K kernel code, 1810K rwdata, 3592K rodata, 47424K init, 984K bss, 85004K reserved, 65536K cma-reserved)
  SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
  ftrace: allocating 32481 entries in 127 pages
  ftrace: allocated 127 pages with 7 groups
@@ -163,12 +221,11 @@
    Tracing variant of Tasks RCU enabled.
  rcu: RCU calculated value of scheduler-enlistment delay is 100 jiffies.
  NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
- random: get_random_bytes called from start_kernel+0x3b8/0x580 with crng_init=1
+ random: get_random_bytes called from start_kernel+0x3b8/0x580 with crng_init=0
  arch_timer: cp15 timer(s) running at 19.20MHz (phys).
  clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
  sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
  Console: colour dummy device 80x25
- printk: console [tty1] enabled
  Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=19200)
  pid_max: default: 32768 minimum: 301
  LSM: Security Framework initializing
@@ -193,19 +250,19 @@
  devtmpfs: initialized
  Enabled cp15_barrier support
  Enabled setend support
- KASLR enabled
+ KASLR disabled due to lack of seed
  clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
  futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
  pinctrl core: initialized pinctrl subsystem
  DMI not present or invalid.
  NET: Registered protocol family 16
- DMA: preallocated 1024 KiB GFP_KERNEL pool for atomic allocations
- DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
- DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
+ DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
+ DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
+ DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
  thermal_sys: Registered thermal governor 'step_wise'
  cpuidle: using governor menu
  hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
- ASID allocator initialised with 32768 entries
+ ASID allocator initialised with 65536 entries
  Serial: AMBA PL011 UART driver
  bcm2835-mbox 3f00b880.mailbox: mailbox enabled
  raspberrypi-firmware soc:firmware: Attached to firmware from 2022-01-17T19:22:03, variant start
@@ -220,6 +277,10 @@
  VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
  FS-Cache: Loaded
  CacheFiles: Loaded
+ simple-framebuffer 3eaf0000.framebuffer: framebuffer at 0x3eaf0000, 0x10a800 bytes, mapped to 0x(____ptrval____)
+ simple-framebuffer 3eaf0000.framebuffer: format=a8r8g8b8, mode=656x416x32, linelength=2624
+ Console: switching to colour frame buffer device 82x26
+ simple-framebuffer 3eaf0000.framebuffer: fb0: simplefb registered!
  NET: Registered protocol family 2
  IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
  tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear)
@@ -249,11 +310,9 @@
  io scheduler mq-deadline registered
  io scheduler kyber registered
  bcm2708_fb soc:fb: FB found 1 display(s)
- Console: switching to colour frame buffer device 82x26
  bcm2708_fb soc:fb: Registered framebuffer for display 0, size 656x416
- raspberrypi-clk: probe of soc:firmware:clocks failed with error -17
  bcm2835-rng 3f104000.rng: hwrng registered
- vc-mem: phys_addr:0x00000000 mem_base=0x3ec00000 mem_size:0x40000000(1024 MiB)
+ vc-mem: phys_addr:0x00000000 mem_base=0x00000000 mem_size:0x00000000(0 MiB)
  gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
  cacheinfo: Unable to detect cache hierarchy for CPU 0
  brd: module loaded
@@ -272,14 +331,14 @@
  OTG VER PARAM: 0, OTG VER FLAG: 0
  Dedicated Tx FIFOs mode
  
- WARN::dwc_otg_hcd_init:1072: FIQ DMA bounce buffers: virt = ffffffc010461000 dma = 0x00000000f7810000 len=9024
+ WARN::dwc_otg_hcd_init:1072: FIQ DMA bounce buffers: virt = ffffffc0140c9000 dma = 0x00000000f7490000 len=9024
  FIQ FSM acceleration enabled for :
  Non-periodic Split Transactions
  Periodic Split Transactions
  High-Speed Isochronous Endpoints
  Interrupt/Control Split Transaction hack enabled
  
- WARN::hcd_init_fiq:496: MPHI regs_base at ffffffc010075000
+ WARN::hcd_init_fiq:496: MPHI regs_base at ffffffc013f65000
  dwc_otg 3f980000.usb: DWC OTG Controller
  dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
  dwc_otg 3f980000.usb: irq 74, io mem 0x00000000
@@ -314,19 +373,19 @@
  uart-pl011 3f201000.serial: cts_event_workaround enabled
  3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 99, base_baud = 0) is a PL011 rev2
  printk: console [ttyAMA0] enabled
- KGDB: Registered I/O driver kgdboc
  bcm2835-power bcm2835-power: Broadcom BCM2835 power domains driver
- sdhost: log_buf @ (____ptrval____) (cf3a0000)
+ sdhost: log_buf @ (____ptrval____) (ce7e3000)
  mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
  of_cfs_init
  of_cfs_init: OK
+ uart-pl011 3f201000.serial: no DMA platform data
  mmc0: new high speed MMC card at address 0001
  mmcblk0: mmc0:0001 4FPD3R 3.64 GiB
  mmcblk0boot0: mmc0:0001 4FPD3R partition 1 4.00 MiB
- Freeing unused kernel memory: 47424K
  mmcblk0boot1: mmc0:0001 4FPD3R partition 2 4.00 MiB
- Run /init as init process
  mmcblk0rpmb: mmc0:0001 4FPD3R partition 3 512 KiB, chardev (246:0)
+ Freeing unused kernel memory: 47424K
+ Run /init as init process
   mmcblk0: p1 p2
  systemd[1]: System time before build time, advancing clock.
  NET: Registered protocol family 10
@@ -336,8 +395,10 @@
  systemd[1]: systemd 250 running in system mode (-PAM -AUDIT -SELINUX -APPARMOR -IMA -SMACK -SECCOMP -GCRYPT -GNUTLS -OPENSSL -ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP -LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -BZIP2 -LZ4 -XZ -ZLIB -ZSTD -BPF_FRAMEWORK -XKBCOMMON -UTMP -SYSVINIT default-hierarchy=unified)
  systemd[1]: Detected architecture arm64.
  systemd[1]: Running in initial RAM disk.
+
+Welcome to Buildroot 2022.02.6!
+
  systemd[1]: Hostname set to <Isatech-Router>.
- uart-pl011 3f201000.serial: no DMA platform data
  systemd[1]: Unit initrd.target not found.
  systemd[1]: Falling back to default.target.
  systemd[1]: Queued start job for default target Multi-User System.
@@ -401,16 +462,16 @@
  systemd[1]: Starting Network Configuration...
  systemd[1]: Reloading.
  systemd[1]: /etc/systemd/system.conf.d/watchdog.conf:1: Assignment outside of section. Ignoring.
- cfg80211: Loading compiled-in X.509 certificates for regulatory database
  systemd[1]: /etc/systemd/system.conf.d/watchdog.conf:2: Assignment outside of section. Ignoring.
+ cfg80211: Loading compiled-in X.509 certificates for regulatory database
  cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
  platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
  cfg80211: failed to load regulatory.db
- systemd[1]: Found device /dev/mmcblk0p1.
+ systemd[1]: Found device /dev/ttyAMA0.
  systemd[1]: Found device /dev/mmcblk0p2.
+ systemd[1]: Found device /dev/mmcblk0p1.
  systemd[1]: Started Network Configuration.
  systemd[1]: udev-fix.service: Deactivated successfully.
- systemd[1]: Found device /dev/ttyAMA0.
  systemd[1]: Starting File System Check on /dev/mmcblk0p1...
  systemd[1]: Starting File System Check on /dev/mmcblk0p2...
  systemd[1]: Finished File System Check on /dev/mmcblk0p1.
@@ -419,42 +480,43 @@
  systemd[1]: Mounting Boot partition...
  systemd[1]: mnt-data.mount: Directory /mnt/data to mount over is not empty, mounting anyway.
  systemd[1]: Mounting Data partition...
- EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, O_DIRECT and fast_commit support!
  FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
+ EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, O_DIRECT and fast_commit support!
  systemd[1]: Mounted Boot partition.
- systemd[1]: Starting Set root password...
- EXT4-fs (mmcblk0p2): recovery complete
- systemd[1]: update-rootpw.service: Deactivated successfully.
  EXT4-fs (mmcblk0p2): mounted filesystem with journalled data mode. Opts: user_xattr,data=journal
- systemd[1]: Finished Set root password.
  systemd[1]: Mounted Data partition.
  systemd[1]: Reached target Local File Systems.
  systemd[1]: Starting Journal Service...
  systemd[1]: Commit a transient machine-id on disk was skipped because of a failed condition check (ConditionPathIsMountPoint=/etc/machine-id).
  systemd[1]: Update is Completed was skipped because all trigger condition checks failed.
- systemd[1]: Started Journal Service.
+ systemd[1]: Starting Set root password...
+ systemd[1]: update-rootpw.service: Deactivated successfully.
+ systemd[1]: Finished Set root password.
+[  OK  ] Finished Set root password.
+[  OK  ] Started Journal Service.
+[  OK  ] Finished Create Volatile Files and Directories.
+[  OK  ] Started Network Name Resolution.
+[  OK  ] Started Network Time Synchronization.
+[  OK  ] Reached target Network.
+[  OK  ] Reached target Host and Network Name Lookups.
+[  OK  ] Reached target System Initialization.
+[  OK  ] Reached target System Time Set.
+[  OK  ] Reached target Timer Units.
+[  OK  ] Listening on D-Bus System Message Bus Socket.
+[  OK  ] Reached target Socket Units.
+[  OK  ] Reached target Basic System.
+[  OK  ] Started D-Bus System Message Bus.
+         Starting Dropbear SSH daemon...
+[  OK  ] Started FRP sync daemon.
+         Starting Error counter reset...
+[  OK  ] Started Serial Getty on ttyAMA0.
+[  OK  ] Reached target Login Prompts.
+[  OK  ] Started iSAtech maintenance tunnel.
+[  OK  ] Started Dropbear SSH daemon.
+[  OK  ] Finished Error counter reset.
+[  OK  ] Reached target Multi-User System.
 
 Welcome to Router
 Router login: root
 # i2cdet# i2cdetect -l
-i2c-1  i2c         bcm2835 (i2c@7e804000)              I2C adapter
obvg
  • 129
  • 12

1 Answers1

1

You're seeing a difference in two booting methods simply because you are booting different kernel configurations. The kernel image may be the same, but the Device Tree blobs are different, as clearly indicated by the boot logs.

The log of the boot using U-Boot has:

+###Loading current kernel bootscript###
 ...
+###Loading current kernel bootscript###
 ...
+###Loading factory kernel bootscript###
+875 bytes read in 1 ms (854.5 KiB/s)
+## Executing script at 02400000
+###Loading factory kernel###
+65030656 bytes read in 2690 ms (23.1 MiB/s)
+28942 bytes read in 3 ms (9.2 MiB/s)
+Saving Environment to FAT... OK
+Moving Image from 0x80000 to 0x200000, end=4100000
+## Flattened Device Tree blob at 2eff8a00
+   Booting using the fdt blob at 0x2eff8a00
+   Using Device Tree in place at 000000002eff8a00, end 000000002f002b0d
+
+Starting kernel ...

So this dtb is 28942 or 0x710E bytes long.

Whereas the non-U-Boot log has:

-Loading 'Image' to 0x80000 size 0x3e04a00
-Kernel relocated to 0x200000
 ...
 Device tree loaded to 0x2eff8a00 (size 0x75f9)
 ...
 Booting Linux on physical CPU 0x0000000000 [0x410fd034]

A Device Tree blob that is 0x75F9 bytes should not be expected to describe the same board/system configuration as a dtb that is 0x710E bytes.

But if the kernel is booted through U-Boot there is no I2C bus available.

Then obviously the smaller dtb loaded by U-Boot does not specify that I2C configuration.


Furthermore I have posted my boot script. I use a first stage bootscript to source the actual boot.scr as part of a fallback system. Shouldn't be make a difference though...

Your assumption presumes that all three sets of files are identical.
Seems like that may be a faulty assumption.
Why does your boot script resort to using the "factory" image instead of the "current" image?
Looks like you need to debug this "fallback system"?

sawdust
  • 16,103
  • 3
  • 40
  • 50
  • Thank you so much for that input. You're right. I didn't realize that the device tree loaded from the rpi bootloader is not `bcm2710-rpi-cm3` I'm not quite sure which device tree is loaded though. I can of course omit the loading of another tree in my `boot.scr`, which works, but I'd like to know which tree is the right one. The fallback is WIP. That's what that whole setup is about. So while developing only factory is populated. I just included it as I was not sure if it was important. – obvg Nov 02 '22 at 11:32
  • "*... but I'd like to know which tree is the right one.*" -- That's way beyond the scope of your original question. Since you're the only one in possession of the board and the various **dtb** files/images, no one else is capable of answering additional questions. – sawdust Nov 03 '22 at 01:57
  • I'm aware. I'm following that question and will answer my original question with that additional information. Thanks for the input anyways. – obvg Nov 03 '22 at 10:34