Skip to content

fix(luckfox-config): handle duplicate alias emission from CONFIG_DTC_SYMBOLS#357

Open
gionag wants to merge 1 commit into
LuckfoxTECH:mainfrom
gionag:fix/luckfox-config-dtc-symbols-duplicate-alias
Open

fix(luckfox-config): handle duplicate alias emission from CONFIG_DTC_SYMBOLS#357
gionag wants to merge 1 commit into
LuckfoxTECH:mainfrom
gionag:fix/luckfox-config-dtc-symbols-duplicate-alias

Conversation

@gionag

@gionag gionag commented Apr 24, 2026

Copy link
Copy Markdown

Summary

luckfox_get_device_name() in /usr/bin/luckfox-config looks up a DT node path by grepping /tmp/.fdt_dump.txt for the alias name. On kernels built with CONFIG_DTC_SYMBOLS=y (the setting shipped by the stock luckfox_rv1106_linux_defconfig, enabled to support OF_OVERLAY / OF_DTBO), each alias string is emitted twice — once under /aliases and once under /__symbols__.

The grep therefore returns two lines. The caller splices that multi-line string straight into a dtbo template:

/dts-v1/;
/plugin/;

&{$i2c_device_name}{           <-- becomes &{/i2c@ff460000
        status="okay";                        /i2c@ff460000}{
        ...                                   ^^^^^^^^^^^^^
};                                            syntax error

dtc -I dts -O dtb then fails:

Error: /tmp/.overlay.dts:5.1-2 syntax error
FATAL ERROR: Unable to parse input tree
cat: can't open '/tmp/.overlay.dtbo': No such file or directory
Complete configuration loading

The script still exits rc=0 and prints `Complete configuration loading`, so the user sees no error — but no overlay is registered and `/dev/i2c-3` / `/dev/spidev*` / `/dev/ttyS*` never appears.

Fix

Pipe the grep through `head -1`. The `/aliases` entry is the authoritative one; `/symbols` carries the same string for overlay resolver purposes and is structurally redundant here.

Repro

  1. Kernel built with `CONFIG_DTC_SYMBOLS=y` (stock defconfig).
  2. `echo I2C3_M0_STATUS=1 >> /etc/luckfox.cfg`
  3. `luckfox-config load`
  4. Observe the dtc error in the output; `ls /sys/kernel/config/device-tree/overlays/` is empty; `/dev/i2c-3` does not appear.

Test plan

  • Reproduced on Luckfox Pico Pro Max, kernel 5.10.160 with `CONFIG_DTC_SYMBOLS=y`.
  • With patch applied: overlay registers, `/dev/i2c-3` enumerates, `i2cdetect -y 3` shows the attached devices.
  • No behaviour change on kernels without `DTC_SYMBOLS` (single-match case passes through `head -1` unchanged).

…SYMBOLS

`luckfox_get_device_name()` looks up a device node path by grepping the
`fdt_dump` output for `"<node_alias> =".` On kernels built with
`CONFIG_DTC_SYMBOLS=y` (the stock luckfox_rv1106_linux_defconfig among
others), each alias is emitted twice: once under `/aliases` and once
under `/__symbols__`. The function therefore returns two lines joined
by a newline, which luckfox_i2c_app / luckfox_spi_app / luckfox_uart_app
all splice directly into a dtbo template:

    &{$i2c_device_name}{
        status="okay";
        ...
    };

With a multi-line substitution this becomes an invalid `&{ ... }` target
spanning two lines, and the subsequent `dtc -I dts -O dtb` call fails:

    Error: /tmp/.overlay.dts:5.1-2 syntax error
    FATAL ERROR: Unable to parse input tree
    cat: can't open '/tmp/.overlay.dtbo': No such file or directory
    Complete configuration loading

— note the script still prints "Complete configuration loading" with
rc=0, so the symptom visible to users is simply that `luckfox-config
load` (and the interactive menu's I2C/SPI/UART toggles) apparently
succeed but no overlay ever lands under
/sys/kernel/config/device-tree/overlays/.

Pipe the grep output through `head -1` so only the first alias match is
used. The /aliases entry is the authoritative one; /__symbols__ carries
the same string for overlay resolver purposes and is structurally
redundant here.

Reproduction:
  * Any board whose kernel has CONFIG_DTC_SYMBOLS=y (stock luckfox
    defconfigs enable this for OF_OVERLAY/OF_DTBO support).
  * `luckfox-config load` (or the TUI) tries to enable I2C/SPI/UART.
  * /tmp/.overlay.dts is malformed; no overlay registered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant