Page 1 of 1

Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-06-11 5:39
by spiritdude
Hi, I'm new here.

I'm currently writing a guide how to get LuckFox Pico Pro/Max 128MB and 256MB boards configured using Linux as host.

The wiki.luckfox.com is OK and useful, but I think it misses crucial information how the board actually boots.

Here my preliminary understanding:
  • ROM: there is a boot code within the chip which cannot be changed
  • eMMC: 256MB SPI NAND FLASH which is booted first aka "firmware", it may contain also an entire lightweight Linux, or just a relay code to boot from the optional SD Card (when I checked the boot process pre-kernel launching, it looked like first SD card is checked and then goes to the eMMC back)
  • optional SD Card: it can be 1GB-32GB in size, and contain a Linux system of your choice
When you run `./build.sh lunch` you need to think if you want to build a system for eMMC alone, or eMMC and SD card, unfortunately the menu does not give any indication that you need to switch to MS-Windows to follow-up with SD card option.

Be aware: you cannot write unto the SD card with the `upgrade_tool`, you need a MS-Windows system & SocToolKit.exe as of 2024/06. So, even though you are given the option with SDK running under Linux to choose eMMC and SD card, you cannot install update.img unto the SD card within Linux yet.

We need a Linux host solution to configure LuckFox boards - essentially replacing SocToolKit.exe
Update: there is a Linux version (unlike Wiki indicates at 2024/06/19): https://github.com/LuckfoxTECH/luckfox- ... SocToolKit

So, this thread shall operate to gather the information.
Update: the issue has been resolved, see below.

Configure eMMC (256MB) aka Firmware + Lightweight Linux
Use `upgrade_tool` as described in https://wiki.luckfox.com/Luckfox-Pico/L ... Burn-Image
for now choose eMMC option to build the system

Configure SD Card (any size) Heavyweight Linux
See a reply lower for the solution using blkenvflash script


FAQ:
  • "Definition of partition in the firmware is larger than flash" error: you were trying to put Heavyweight Linux into the tiny 256MB eMMC - you have chosen the wrong system to `./build.sh` and the resulting `update.img` actually belongs to the SD card (& eMMC), not only the eMMC which the `upgrade_tool` writes to. Solution: redo `./build.sh lunch` and choose eMMC only option (the numbering changes due updates of the SDK)

Re: Pico Pro/Max with Linux Host

Posted: 2024-06-11 5:51
by spiritdude
A quick solution could be:
  • we use `upgrade_tool` to write to eMMC (256MB), which would require a change of the .env.txt, so only those *.img are written which belong to the eMMC
  • we use a dedicated script to write to the SD card while connected to the host (not yet inserted into the board)
I started to code a small script which takes .env.txt and and looks at the *.img (it doesn't write anything yet):
% blkenvflash /dev/sdc
mmcblk1: env.img size:32,768/32K (offset:0/0B) imgsize:32,768 (32K)
mmcblk1: idblock.img size:524,288/512K (offset:32,768/32K) imgsize:182,272 (178K)
mmcblk1: uboot.img size:262,144/256K (offset:0/0B) imgsize:262,144 (256K)
mmcblk1: boot.img size:33,554,432/32M (offset:0/0B) imgsize:2,903,552 (2,903,552B)
mmcblk1: oem.img size:536,870,912/512M (offset:0/0B) imgsize:45,555,712 (44,488K)
mmcblk1: userdata.img size:268,435,456/256M (offset:0/0B) imgsize:9,999,360 (9,765K)
mmcblk1: rootfs.img size:6,442,450,944/6G (offset:0/0B) imgsize:1,094,365,184 (1,068,716K)
mmcblk0: idblock.img size:524,288/512K (offset:32,768/32K) imgsize:182,272 (178K)
mmcblk0: uboot.img size:4,194,304/4M (offset:0/0B) imgsize:262,144 (256K)
this is the Ubuntu with 6G rootfs.img.

Questions:
  • can I write the mmcblk1/*.img with `dd` in one go (concat the involved *.img) or do we need to fdisk/sfdisk to partition the SD card first, and then individually `dd` the *.img to the SD card?
  • is there anything else on the SD card beside the mmclbk1/*.img?

Re: Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-06-18 10:42
by spiritdude
I developed the solution based on the feedback I received at https://github.com/LuckfoxTECH/luckfox-pico/issues/129 - there also link to the script is posted.

Re: Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-06-19 4:42
by spiritdude
Also, for clarification, there is a SocToolKit for Linux at https://github.com/LuckfoxTECH/luckfox- ... SocToolKit

As SocToolKit didn't work for me, I did this blkenvflash script which allows to write to the SD card direct on the Linux Host: https://gist.github.com/Spiritdude/da36 ... 0a8b9f972f

Re: Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-06-19 5:52
by Crocodile
Thank you for sharing.

Re: Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-07-27 13:02
by ssoportal
To use Pico Pro/Max with a Linux host for flashing or upgrading via SD card, follow these steps: SSO ID Login

1. Download Tools: Obtain `SocToolKit` or `upgrade_tool` for Linux from the official source or repository.

2. Prepare SD Card:
- Format the SD card to FAT32.
- Copy the firmware image or upgrade files to the SD card.

3. Connect Devices:
- Insert the SD card into the Pico Pro/Max device.
- Connect the device to your Linux host using the appropriate interface (USB/Serial).

4. Run Tool:
- Open a terminal on your Linux host.
- Use `SocToolKit` or `upgrade_tool` commands to interact with the device.
- Replace `firmware.img` with your firmware file and ensure the correct tool syntax.

5. Monitor Progress: Follow the terminal output for progress and any error messages.

6. Completion: Once the process is complete, remove the SD card and reboot the Pico Pro/Max to apply the changes.

Re: Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-08-13 3:08
by kornpow
Thanks a lot for the information about the linux version of SocToolKit!

However I am getting an error running it on my Ubuntu 23.04 machine
```
$ ./SocToolKit
QSocketNotifier: Can only be used with threads started with QThread

(SocToolKit:50620): GLib-GIO-ERROR **: 20:59:34.487: Settings schema 'org.gnome.settings-daemon.plugins.xsettings' does not contain a key named 'antialiasing'
Trace/breakpoint trap (core dumped)
```

Being able to develop for this board without windows would be amazing! Also, you work trying to get around windows/soctoolkit altogether is also great, because SocToolKit is super buggy.

Re: Pico Pro/Max with Linux Host (SocToolKit/upgrade_tool for Linux with SD card support)

Posted: 2024-10-22 23:16
by kornpow
spiritdude wrote: 2024-06-19 4:42 Also, for clarification, there is a SocToolKit for Linux at https://github.com/LuckfoxTECH/luckfox- ... SocToolKit

As SocToolKit didn't work for me, I did this blkenvflash script which allows to write to the SD card direct on the Linux Host: https://gist.github.com/Spiritdude/da36 ... 0a8b9f972f
Thanks for this tool link! I missed it the first time coming around to this thread! blkenvflash worked for me on my Mac.

Hopefully this get me going on my project finally. The mental context switching to use windows computer, or my painfully slow Parallels install made developing for this board terrible.