This document provides comprehensive instructions for flashing custom firmware to the PicoCalc LuckFox Lyra device.
The PicoCalc LuckFox Lyra uses Rockchip RK3506 SoC and can be flashed via USB using Rockchip's flashing tools. The device supports flashing to both internal storage and SD card.
- PicoCalc LuckFox Lyra device
- USB-C cable
- MicroSD card
- Computer running Linux
- Built firmware (see README.md for build instructions)
- USB access (automated setup available, see USB Permissions Setup)
The PicoCalc (with LuckFox Lyra installed) features two USB-C ports:
- UPPER PORT: Used for serial communication through the MCU and for charging the device
- LOWER PORT: LuckFox Lyra (RK3506) - USE THIS FOR FLASHING
- Located on the LuckFox Lyra board inside the device
- Requires removing the back cover to access
- Used for manual entry into loader mode
For the best experience, set up USB permissions to allow flashing without sudo:
Run the provided setup script:
./scripts/setup_usb_permissions.shThis script will:
- Install the necessary udev rules
- Add your user to the appropriate group (
plugdevordialout) - Allow flashing without sudo privileges
After running the script, log out and log back in for the changes to take effect.
If you prefer to set up permissions manually:
# Install udev rule
sudo cp scripts/99-rockchip.rules /etc/udev/rules.d/
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger
# Add user to appropriate group (plugdev preferred, dialout fallback)
sudo usermod -a -G plugdev $USER # or dialout if plugdev doesn't exist
# Log out and back in for changes to take effectTo verify the setup is working:
# Check if your user is in the appropriate group
groups
# Should show either 'plugdev' or 'dialout' among the groups
# With device connected in loader mode, check detection
lsusb | grep Rockchip
# The device should show as: Bus XXX Device XXX: ID 2207:350f Fuzhou Rockchip Electronics CompanyThe provided flash.sh script automates the flashing process with proper safety checks.
# Flash the update image (default)
./flash.sh
# Flash specific image type
./flash.sh update
./flash.sh recovery
./flash.sh firmwareThe script will:
- Check prerequisites and USB permissions
- Offer to set up USB permissions if needed
- Display detailed instructions
- Confirm the operation
- Execute the flash process
For advanced users or troubleshooting:
# Flash update image manually
./scripts/rkflash.sh update
# Flash other image types
./scripts/rkflash.sh recovery
./scripts/rkflash.sh firmwareThe device must be in "loader mode" to accept firmware updates. There are two methods:
If the device is running Linux:
- Boot the PicoCalc normally
- Access the Linux shell (SSH, serial console, ADB, or direct access)
⚠️ IMPORTANT: Eject any external SD card before proceeding - The device may hang during reboot if an SD card is inserted- Run the command:
reboot loader - The device will reboot into loader mode
- Connect USB-C cable to the LOWER port
If software access is unavailable:
- Power off the PicoCalc
- Remove the back cover to access the LuckFox Lyra board
- Locate the BOOT button on the board
- Hold the BOOT button down
- While holding the button, connect USB-C cable to the LOWER port
- Keep holding the button for 2-3 seconds after connection
- Release the button - device should be in loader mode
-
Insert SD Card: Place a microSD card into the SD card slot on the LuckFox Lyra
- The SD card will receive the flashed firmware
- Minimum 1GB recommended, 8GB+ for development
-
Prepare USB Connection: Have USB-C cable ready but don't connect yet
Ensure you have built the firmware first:
# Build the complete firmware
./build.sh
# Verify the update image exists
ls -la output/firmware/update.imgChoose one of the methods described above to put the device in loader mode.
- Connect USB-C cable to the LOWER USB-C port on the PicoCalc
- Connect the other end to your computer
- Verify detection:
lsusb | grep Rockchipshould show the device
Run the flash script:
./flash.shFollow the on-screen prompts and confirm when ready.
- Wait for flashing to complete (typically 2-5 minutes)
- Disconnect USB cable
- Power cycle the PicoCalc
- The device should boot with the new firmware
Symptoms: lsusb doesn't show Rockchip device
Solutions:
- Verify using the LOWER USB-C port
- Try different USB cable
- Ensure device is properly in loader mode
- Check USB permissions:
sudo ./flash.sh - Try different USB port on computer
Symptoms: Flash process starts but fails during transfer
Solutions:
- Check SD card is properly inserted
- Verify SD card is not write-protected
- Try a different SD card
- Ensure stable USB connection
- Close other applications that might access USB devices
Symptoms: "Permission denied" errors during flashing
Solutions:
- Recommended: Run USB permissions setup:
./scripts/setup_usb_permissions.sh - Alternative: Run with sudo:
sudo ./flash.sh - Manual: Add user to appropriate group:
sudo usermod -a -G plugdev $USER(ordialoutifplugdevdoesn't exist)
Symptoms: "shm_open: Permission denied" or "Test Device Fail" errors
Solutions:
- Remove stale shared memory files:
sudo rm -f /dev/shm/upgrade_tool_mutex - Ensure no other instances of upgrade_tool are running
- Run with sudo if the issue persists:
sudo ./flash.sh - This is a known limitation of the Rockchip upgrade_tool on some systems
Symptoms: Device doesn't boot or shows no display
Solutions:
- Verify SD card is properly seated
- Try reflashing with a known-good image
- Check if device enters loader mode (may need recovery)
The automatic setup script handles most cases, but for advanced users or troubleshooting:
# Create udev rule file manually
sudo tee /etc/udev/rules.d/99-rockchip.rules << 'EOF'
# Rockchip RK3506 in loader mode (for flashing)
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", ATTR{idProduct}=="350f", MODE="0666", GROUP="plugdev", TAG+="uaccess"
# Rockchip RK3506 in maskrom mode (for low-level recovery)
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", ATTR{idProduct}=="350a", MODE="0666", GROUP="plugdev", TAG+="uaccess"
# Additional Rockchip product IDs that might be used
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", ATTR{idProduct}=="350*", MODE="0666", GROUP="plugdev", TAG+="uaccess"
EOF
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger
# Add user to appropriate group (plugdev preferred, dialout fallback)
sudo usermod -a -G plugdev $USER # or dialout if plugdev doesn't exist
# Log out and back in for group changes to take effect# Check if udev rule is installed
ls -la /etc/udev/rules.d/99-rockchip.rules
# Check group membership
groups
# Check if device is detected
lsusb | grep 2207:350f
# Check device permissions (with device connected)
find /dev/bus/usb -name "*" | xargs ls -la | grep "2207:350f"- File:
output/firmware/update.img - Description: Complete firmware package including bootloader, kernel, and rootfs
- Use Case: Normal firmware updates, complete system replacement
- Flash Target: SD card
- File:
output/firmware/recovery.img(if built) - Description: Minimal recovery system for emergencies
- Use Case: Recovery from bad firmware, system rescue
- Flash Target: Internal storage recovery partition
- File: Individual partition images
- Description: Flash specific partitions only
- Use Case: Development, partial updates
- Flash Target: Specific partitions
For debugging boot issues, connect a serial console:
- Pins: Located on LuckFox Lyra board
- Settings: 115200 8N1
- Use: Monitor boot process, access console if display fails
The firmware uses the following partition layout (from parameter.txt):
- uboot: U-Boot bootloader (4MB @ 0x2000)
- boot: Kernel and device tree (12MB @ 0x4000)
- amp: AMP/MCU firmware (2MB @ 0xa000)
- rootfs: Root filesystem (grows from 0x10000)
To modify the build configuration:
# Edit device-specific config
vi base/device/rockchip/.chips/rk3506/picocalc_luckfox_lyra_buildroot_sdmmc_defconfig
# Rebuild after changes
./build.sh clean
./build.sh- Always use the correct USB port (LOWER USB-C)
- Ensure stable power during flashing
- Don't disconnect during flash process
- Keep backups of working firmware
- Test new firmware thoroughly before deploying
If you encounter issues:
- Check this troubleshooting section
- Verify hardware connections and cable
- Try the alternative loader mode method
- Check system logs:
dmesg | tail -20 - Create an issue with:
- Error messages
- Hardware revision
- Build configuration used
- Steps taken before the error