Skip to main content

luckfox-config

Luckfox Lyra pins have multiple multiplexing functions. Depending on the needs of the actual project, adjustments to the device tree are often required. This section introduces two methods for configuring Luckfox Lyra pin multiplexing during the compilation and system runtime stages, allowing flexible configuration of Luckfox Lyra pin interface functions.

1. luckfox-config Overview​

luckfox-config is a tool in the Luckfox Lyra root file system that allows for quick configuration of device functions on Luckfox Lyra By using the dynamic device tree mechanism and the fdt tool, most device configurations can be completed without recompiling the dtb.

  • Terminal Support

    System TypeBuildroot
    Serial PortSupported
    SSHSupported
    ADBThe arrow keys on the keyboard are not functioning.
  • Functionality

    System TypeBuildroot
    PWMSupported
    UARTSupported
    I2CSupported
    SPISupported
    CANSupported
    MIPI DSISupported

2. luckfox-config Configuration​

Note: The configuration of luckfox-config is based on the default device tree file. If the device tree has been adjusted during image compilation, some functions may not work properly.

2.1 Structure​

  • luckfox-config luckfox-config dynamic device tree configuration tool, can perform graphical interactive configuration
  • /etc/luckfox.cfg stores configuration information, which users can edit. The configuration items are loaded each time the root filesystem starts
  • luckfox-config Pin diagram is used to temporarily store key information about the system configuration, allowing users to intuitively understand the current pin configuration status.

2.2 Basic Usage​

  1. Run the following command in the development board terminal to open the graphical configuration interface:

    luckfox-config
  2. Use ↑/↓ or j/k to navigate menu items, and press Enter to select. You can also select an item using its number or letter. Press Esc or h to return to the previous menu, or Q to quit the tool. In a pin configuration form, use Tab or ↓ to move between fields, Enter to confirm, and Esc to go back. If the arrow keys do not work over ADB, use the numbers or letters shown in the menu.

  3. View the configuration status. When a pin is enabled, it will be marked with an "*" and locked. If the newly enabled interface contains locked pins, it cannot proceed. You can view the current pin lock status in the about menu of luckfox-config or by using the following command:

    luckfox-config show
    • If the pin reuse function is not specified in the pin diagram, the corresponding GPIO will be directly marked.
  4. Save the configuration

    Common pin reuse configurations (e.g., PWM, UART, I2C, SPI) take effect immediately. Devices whose drivers do not support dynamic detection (e.g., DSI) need a reboot to take effect.

    Note: Settings that need a reboot to take effect are made by directly modifying the dtb. The ENABLE status in luckfox.cfg is only for record. Simply modifying luckfox.cfg does not take effect during configuration loading.

  5. Load the configuration:

    luckfox-config load

    Note:* Settings that need a reboot to take effect are made by directly modifying the dtb. The ENABLE status in luckfox.cfg is only for record. Simply modifying luckfox.cfg does not take effect during configuration loading.

Configuration demo:

Loading terminal...

3 Common Configurations​

3.1 PWM Configuration​

  1. Enter the Advanced Options -> PWM interface, and luckfox-config will display all supported PWM configurations.

  2. Select the PWM controller and channel. The recording uses PWM1 -> Channel 0.

  3. In the configuration menu, you can perform the following actions:

    • Select Enable to configure and activate the PWM channel;
    • Select Disable to deactivate the channel;
    • Press Esc to return to the previous menu.
  4. Enter the output pin number in the RM_IO field. The recording uses RMIO6: enter 6 and press Enter to confirm.

Configuration demo:

Loading terminal...

3.2 UART Configuration​

  1. Navigate to Advanced Options -> UART and select UART1, as shown in the recording.

  2. In the configuration menu, you can perform the following actions:

    • Select Enable to configure and activate UART1;
    • Select Disable to deactivate this channel;
    • Press Esc to return to the previous menu.
  3. The recording assigns RMIO7 to TX and RMIO8 to RX for UART1. Enter 7 and 8 in the corresponding fields, then press Enter to confirm.

Configuration demo:

Loading terminal...

3.3 I2C Configuration​

note

I2C2 is used for DSI display touch input by default.

  1. Navigate to Advanced Options -> I2C and select I2C0, as shown in the recording.

  2. In the configuration menu, you can perform the following actions:

    • Select Enable to configure and activate I2C0;
    • Select Disable to deactivate this channel;
    • Press Esc to return to the previous menu.
  3. The recording assigns RMIO3 to SDA and RMIO4 to SCL for I2C0. Enter 3 and 4 in the corresponding fields.

  4. Set Speed Hz. The recording uses 400000 (400 kHz). Press Enter to confirm the configuration.

Configuration demo:

Loading terminal...

3.4 SPI Configuration​

  1. Navigate to Advanced Options -> SPI and select SPI0, as shown in the recording.

  2. In the configuration menu, you can perform the following actions:

    • Select Enable to configure and activate SPI0;
    • Select Disable to deactivate this channel;
    • Press Esc to return to the previous menu.
  3. The recording assigns RMIO24, RMIO25, RMIO26, and RMIO27 to SCLK, MOSI, MISO, and CS respectively. Enter 24, 25, 26, and 27 in the corresponding fields.

  4. Set Speed Hz. The recording uses 1000000 (1 MHz). Press Enter to confirm the configuration.

Configuration demo:

Loading terminal...

3.5 CAN Configuration​

  1. Navigate to Advanced Options -> CAN and select CAN0, as shown in the recording.

  2. In the configuration menu, you can perform the following actions:

    • Select Enable to configure and activate CAN0;
    • Select Disable to deactivate this channel;
    • Press Esc to return to the previous menu.
  3. The recording assigns RMIO10 to TX and RMIO11 to RX for CAN0. Enter 10 and 11 in the corresponding fields.

  4. Clock rate Hz sets the CAN controller clock frequency. The recording keeps the default 300000000 (300 MHz). Press Enter to confirm the configuration.

Configuration demo:

Loading terminal...

3.6 DSI Configuration​

  1. Navigate to MIPI DSI -> Set Display Panel, then select the display category and model. The supported display options are shown below:

    • Official Raspberry Pi display (Raspberry Pi Official DSI, 800 × 480 resolution):

    • Raspberry Pi compatible displays (RPI Compatible DSI):

    • Waveshare displays (WaveShare DSI):

  2. The recording selects WaveShare DSI -> 4.3-DSI-TOUCH-A (480 × 800). Press Enter to confirm. The tool displays reboot required; restart the board for the display configuration to take effect.

Configuration demo:

Loading terminal...

4. System Backup​

note

This feature only supports backing up ext4 root file systems. UBIFS root file systems stored in Flash are not supported.

The following example uses a Luckfox Lyra Pi A to back up its root file system (rootfs) to a USB flash drive.

  1. Connect a USB flash drive to the board. Make sure it is detected and has enough free space for the backup. Run the following command in the board's terminal:

    luckfox-config
  2. Select Backup Rootfs from the main menu and press Enter.

  3. In Select a partition to backup, select the rootfs partition. The recording uses /dev/mmcblk0p3 (rootfs). Press Enter to continue.

  4. In Select Backup Destination, select USB Disk (/mnt/udisk) and press Enter. The tool checks the required space, creates an ext4 image, and copies the rootfs contents. Wait for the backup to finish.

  5. The messages Backup completed successfully! and Backup successful! confirm that the backup is complete. The backup image is saved on the selected USB flash drive.

Backup demo:

Loading terminal...