Getting started with the LuckFox Pico Pro [Part II]

In the first part of this series, we looked at accessing our LuckFox Pico Pro using an RDNIS network connection over the USB port to connect with the minimal “busybox” Linux shipped from the factory. In this second part, we’ll explore replacing that minimal system with a much more capable release of Alpine Linux to access the full potential of this tiny board.

Before starting on our upgrade, we do need to make one small change to the hardware on the board. This is the addition of header pins for TX, RX and GND connections to UART2, to allow us to connect to the serial console of the device.

LuckFox Pico Pro with SD-Card, RTC-Battery, Console Adapter & Ethernet

While the bulk of the GPIO pins will probably be soldered to the bottom of the board (to allow mounting on a larger carrier board and thus access to the GPIOs), it makes sense to mount these three pins to the top of the board, for ease of connection of a serial-to-USB module (note that this board has 3v3 I/O pins, so you’ll need to use an appropriately rated serial-to-USB module, not a 5v one).

Flashing Alpine Linux

There is already an Alpine Linux image available for this board, linked to from the LuckFox Wiki page. User “walker2048” contributed two very good articles on the Chinese “EEWorld” forum giving a very good step-by-step description of building, installing and using an Alpine Linux image (these are the posts available in English on the LuckFox Wiki), but unfortunately the articles are Windows centric and assume that you’re going to be using the SocToolKit GUI to load the image to the board. The linked Alpine Linux image is a zip file and not the “.img”  format that we’d normally “dd” to an SD-card or memory under Linux. Although there is a command-line “upgrade_tool” available for Mac and Linux users, frustratingly it also assumes a target XXXX.img file (the same as the Windows GUI SocToolKit version), but as just mentioned, that’s not the format that the Alpine Linux zip file contains. What to do?!?

There are some hints in the Alpine Linux zip package. There are a couple of text files contained within it:- sd_update.txt & tftp_update.txt.

Unfortunately, neither of them is the hoped-for “how to” text for users, but they do turn out to be how to texts for some sort of assembler or builder program. That started me off on a search for the method used to build a modified distribution from the SDK and, lo and behold, sitting right there in the luckfox-pico SDK bundle is a /tools/linux/Linux_Pack_Firmware directory. Yes!! There are both mk-update_pack.sh and mk-update_unpack.sh scripts in that directory. A quick perusal of the pack script shows that it only needs to be passed a couple of options, which identify the target chip type and the input source location (also where the “update.img” output file will be written). I quickly un-zipped the Alpine-Linux.zip package into a new “alpine_test” directory and ran:-

./luckfox-pico-SDK/tools/linux/Linux_Pack_Firmware/mk-update_pack.sh --chip-id rv1106 --image ./alpine_test/

[Partially abbreviated output follows, below]

[mk-update_pack.sh:info] image input dir: ./alpine_test/
[mk-update_pack.sh:info] partition file name: env.img
[mk-update_pack.sh:info] start to package update.img...
[mk-update_pack.sh:info] partitions:
env env.img
idblock idblock.img
uboot uboot.img
boot boot.img
rootfs rootfs.img
package-file package-file
bootloader download.bin

TOOL_PATH=luckfox-pico-SDK/tools/linux/Linux_Pack_Firmware
Android Firmware Package Tool v2.2
------ PACKAGE ------
Add file: ./alpine_test/env.img
env,Add file: ./alpine_test/env.img done,offset=0x800,size=0x40000,userspace=0x80,flash_address=0x00000000
...
...
package-file,Add file: ./alpine_test/package-file done,offset=0x1365800,size=0x83,userspace=0x1
Add file: ./alpine_test/download.bin
bootloader,Add file: ./alpine_test/download.bin done,offset=0x1366000,size=0x3e9c0,userspace=0x7e
Add CRC...
Make firmware OK!
------ OK ------
********rkImageMaker ver 2.2********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
[mk-update_pack.sh:info] Making -RK1106 update.img OK.

…and was rewarded with a nice, shiny new alpine_test/update.img file. Okay, now we’re more than halfway to our objective. The next part is a little bit scary, in that we have to overwrite the existing “busybox” image in NAND flash with our untested Alpine image, which could leave us with a semi-bricked Pico Pro. The saving grace here is that, should this happen and the Pico cannot boot from flash, it should automatically try to boot from the SD, so we do have a plan B.

Loading the image to NAND flash is now fairly simple, as we just need to follow the Wiki instructions for Linux Burning for Linux/MacOS (before doing this, you should already have added the UART2 header pins as outlined above and connected your serial-USB adapter). The basic procedure is to grab the command-line upgrade_tool for Linux from the link on the Wiki page, hold down the “BOOT” button on the Pico Pro and then press and release the “RESET” button (to force the board into download mode) and then use the command:-

upgrade_tool uf upgrade.img

…to start the actual update process.

Running Alpine Linux on the LuckFox Pico Pro

Probably the first thing to note about running Alpine Linux is that there is no RNDIS connection started on the USB port, so you must use the serial console to configure the board from this point, until you enable ssh logins over ethernet.

This Alpine 3.18 build from “walker2048” uses a default ethernet address of 192.168.50.59, so in all probability, you’ll want to log in on the serial console to modify /etc/network/interfaces to match your own LAN configuration. 

You don’t have to remember any pesky user-ID/password combinations, as “walker2048” has also configured an auto-login for “root” on the console. You might want to change this configuration by editing the /etc/inittab file to comment-out this line (just a quick word of caution here …before you begin this change, you need to ensure that you have a valid password set and tested for the root account):-

ttyFIQ0::respawn:/sbin/agetty --autologin root ttyFIQ0 vt100

…and replace it with the following:-

ttyFIQ0::respawn:/sbin/getty -L ttyFIQ0 115200 vt100

The two things to notice with this replacement are the obvious, missing “--autologin” and the not so obvious change from “agetty” to just plain old “getty“ (“agetty” is “advanced getty” and has the magic sauce included to create automatic logins, which plain old-fashioned getty doesn’t).

If everything went according to plan, you should now have a very usable Alpine distribution on your tiny LuckFox board and should be able to log in over the network and use the apk package manager to search for and install standard packages.


6 thoughts on “Getting started with the LuckFox Pico Pro [Part II]

  1. Hi, there

    I also just got myself my new Luckfox Pico Pro. It is cool to find this blog.

    I flashed the firmware without SD card. So basically, I rely on 256 MB NAND flash to run the board. I followed the instruction in the Luckfox wiki and they gave the instruction to connect to the board using SSH. I was able to connect to ssh root@172.32.0.93, but I failed when I tried to connect ssh pico@172.32.0.70. The latter ssh should connect me to Ubuntu. Do you think I was unable to connect to Ubuntu because I didn’t install the SD card version of the firmware?

    Also, from your post I notice you didn’t erase the firmware to install Alpine Linux? CMIIW

    Like

    • Hi Lukas,

       To answer your last question first — No, I didn’t explicitly erase the nand. The instructions on the Wiki were just to use “upgrade_tool -uf update.img” and it ran successfully; no need for the extra step.

       I didn’t actually try Ubuntu with this board (the Milk-V Duo which I’d been playing with previous to the LuckFox was much slower when running Ubuntu than with the smaller Alpine image, so this time I just went straight to Alpine).

       Does a ping to the 70 address work? Does a ping to the original, 93 address still work? The latter would indicate that your upgrade didn’t work and you’re still running the original “busybox” distro.

       In either case, connecting to the console pins (as outlined above) should give you a login.

       Best wishes,

            -John-

      Like

  2. Fcassia,

    If you’re looking for the smallest, then the “busybox” based distribution that the board ships with is pretty small …it’s not very useful, though.

    For a useful distribution with a working package manager and huge choice of up-to-date packages, it’s hard to beat Alpine (installed with the default system and a few added packages, my running Pro uses just 50MB of the flash and currently has an uptime of 50 days, running as a DNS server on my local network). With the default install of Alpine, you can also configure your Pro as an NFS or Samba client (to mount network disks hosted by other machines on your network) to give virtually unlimited disk space.

        -John-

    Like

    • Any information on the RTC battery type that you can share? I am eager to experiment with a mx1.25 cable and a CR2032 socket but I´m afraid of frying something. Can you measure a battery with a multimeter? any markings on the battery?. At least visually they look like the RTC battery on the Playstation 3…

      Like

  3. Thanks John. And very good idea about NFS. I often forget about NFS. It was Sun Microsystems which pushed it, and sadly now Oracle is not into that sort of thing

    Like

Leave a comment