Skip to content

Instantly share code, notes, and snippets.

@liquidx
Last active April 29, 2024 20:19
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save liquidx/fd1002ec870a7c13f04a0b8a44744246 to your computer and use it in GitHub Desktop.
Save liquidx/fd1002ec870a7c13f04a0b8a44744246 to your computer and use it in GitHub Desktop.
Reflashing a TechNexion PICO-PI-IMX7

By: Alastair Tse @liquidx

Updated: 2021-12-05

This is a guide for installing Linux on a Technexion NXP IMX7 board. This is a board that was part of the Android Things Starter Kit (now discontinued).

There are some dead ends in this guide where I got to a point where I failed. I'm documenting this so that it can help anyone else who is trying the same thing.

Before starting, there are a few useful sources of information:

Hardware

There are two USB ports on this device. I found that the USB-C port is the one that exposes the serial port which you can use to flash the device. There is no SD Card slot on this board, so the storage is using eMMC.

Serial Downloader Mode

See https://developer.technexion.com/docs/pico-evaluation-kit-boot-mode-settings for information on how to set the jumps.

You need to set the jumpers to the to Serial reset.
-** **-
-** **-


To reset back to booting off eMMC the jumpers should be
**- -**
**- **-

Flashing Tools

Most of the tutorials online seem to mention an FTP server, but you can get the same files from their HTTP server: https://download.technexion.com/development_resources/development_tools/installer/

The flashing software is called UUU. It is open source, so you can compile it from source here: https://github.com/NXPmicro/mfgtools

In order to flash the IMX7 using these tools, you need a Secondary Program Loader and a UBoot image. These can be found by downloading imx-mfg-uuu-tool.zip from the following site: https://download.technexion.com/development_resources/development_tools/installer/

Flashing from a Mac.

Summary: I was not able to get this to work flashing from a MacBook Pro. I got all the tools working, but UUU would not be able to issue FastBoot commands to over the serial interface.

Building UUU

Follow the instructions on the mfgtools repo.

In short:

# Install libusb, libbz2, zlib.
$ brew install openssl libusb zlib libbz2 libzip

# Install HEAD checkout of libusb (>1.0.4) because there is an issue with
# other Kernel extensions not releasing the USB device.
# See:  https://github.com/NXPmicro/mfgtools/issues/246
$ brew install --head libusb

# Clone mfgtools
git clone https://github.com/NXPmicro/mfgtools.git
cmake -DOPENSSL_ROOT_DIR=$(brew --prefix)/opt/openssl . && make

# Run the binary (test by trying to list the USB devices)
$ mfgtools/uuu/uuu -lsusb

Using the pre-built Mac binary (alternative)

Alternatively, you can also avoid building the binary by using the prebuilt Mac binary at: https://github.com/NXPmicro/mfgtools/releases/tag/uuu_1.4.165

This mac binary is compiled against a vanilla homebrew setup (libraries in /usr/local/opt).

Problems with this on a Mac

If you get a "Failure Claim Interface" when running UUU, it means it was unable to access the USB device. You'll have to use the libusb HEAD which includes a workaround for Mac.

Afterwards, if you can get it to work, you'll find that it infinitely loops at the SPL stage. I was not able to get it to manually run the FastBoot commands:

$ uuu -s
> FB: getvar 
...

Flashing from Linux

Building UUU on Linux

Follow the instructions on the mfgtools repo to build for Linux. If you are running Linux on a 64-bit processor, you can use the prebuilt binaries from .

Flashing the Image

Three things are needed to flash the IMX7, the Secondary Program Loader (SPL), the UBoot image (UBOOT) and the image itself.

Getting the image.

The model of the board in the Android Things starter kit is PICO-PI-IMX7. Since this board doesn't have an SD card slot, I think the right image will be the eMMC images:

https://download.technexion.com/demo_software/PICO/IMX7/pico-imx7-emmc/

There are two images that should work:

pico-imx7_pico-pi_yocto-3.0-qt5_qca9377_lcd-800..> 29-Apr-2021 09:01           332467921
pico-imx7d_pi_ubuntu-20.04-xfce_QCA9377_5-lcd-8..> 03-Feb-2021 09:01           739894001

The first one pico-imx7_pico-pi_yocto-3.0-qt5 is a Yocto (custom Debian) build. It does not have any of the propietery firmwares that allow it to work with the onboard Broadcom wireless chip. It unpacks to a 2GB image on the eMMC. However, that is a little weird because the eMMC is actually 4GB.

The second one pico-imx7d_pi_ubuntu-20.04-xfce_QCA9377_5 is the Ubuntu build. I've not been able to get this working because of the size of this image.

Flashing using the auto script.

The instructions on the Technexion site refer to this command:

sudo uuu/linux64/uuu -b emmc_imx7_img imx7/imx7-SPL imx7/imx7-u-boot.img fsl-image-qt5-validation-imx-pico-imx7.sdcard

emmc_imx7_img is a prebuilt command that is available if you use the prebuilt uuu from Technexion. If you built UUU from source, you may not have it. You will need to use the autoscript (which seems to be the exact same commands.) The Technexion repository refers to this as the "multiboard" commands.

For the multiboard commands, it recommends that you move the appropriate SPL and UBOOT and image into the directory you will execute the script named as follows:

_SPL
_UBOOT
_rootfs.sdcard

So then the command would be:

cd ${dir_with_spl_uboot_image_files}
sudo mfgtools/uuu/uuu -b imx-mfg-uuu-tool/multiboard/emmc_imx7_img.auto 

You can also execute this by adding the file locations as paramters to avoid having to rename them:

sudo mfgtools/uuu/uuu \
 -b imx-mfg-uuu-tool/multiboard/emmc_imx7_img.auto \
 imx-mfg-uuu-tool/imx7/pico-imx7/imx7-SPL \
 imx-mfg-uuu-tool/imx7/pico-imx7/imx7-u-boot.img \
 ../fsl-image-qt5-validation-imx-pico-imx7-20210429040519.rootfs.wic

Note that UUU will be able to decompress the bz2, so there's no need to decompress it. If the host (flasher) machine doesn't have enough memory, it may fail to flash the image. I've found that if I unpack it rather than relying on uuu to unpack it, it will have a higher success rate.

If you are running this from a 32-bit machine, and the image file is larger than 2GB, it will likely fail with an error fail open file because UUU tries to load the size into an int. This happens with the ubuntu image that is available.

Note that .wic and .sdcard are the same file type (and presumably .img).

Flashing from VirtualBox

I tried to flash this from a VirtualBox Linux guest running on a Mac host. That doesn't work, even though the USB device is exposed, the USB emulation/passthrough seem to introduce enough errors that the flashing process doesn't work.

Booting up

Once flashing is completed, switch the jumpers back to the eMMC boot mode so it boots off of the image that was just flashed.

The USB-C port will now only be used to supply power. You will not see the device when using lsusb from the USB-C port.

The micro-USB port will show up as a serial device, plugging into a Linux machine, it should show up as /dev/ttyUSB0 which you can connect to using screen /dev/ttyUSB0 115200. When you plug this in, the LEDs next to the micro-USB port will flash a little. This is the activity light for the micro-USB. If you start typing in the console, the light should start flashing.

Problems

  • If the lights next to the USB-C power keep on flashing, then there's something wrong with the power supply to the power. This seems to happen for me when I plug into a port that supplies too little power or too much power (PD). I was able to power this off a well supplied Raspberry PI 2, but when plugging straight into other device.
  • When not enough power is supplied, it looks like the board is dead.
  • The partition flashed in the yocto image is smaller than the available eMMC size. To expand to the whole eMMC size, you can do a live partition resize.

References

https://github.com/TechNexion/u-boot-tn-imx/wiki/Use-mfgtool-%22uuu%22-to-flash-eMMC https://github.com/NXPmicro/mfgtools/wiki nxp-imx/mfgtools#246

@alhafoudh
Copy link

Thank you! It worked

@artemcarabash
Copy link

Thanks, also worked for me, with some corrections, spend a half day to find a image that works on my imx7 :/
just in case if somebody also want to fix their NXP and flash ubuntu/android on it from your mac you can contact me, will try to help :)

@carlossg
Copy link

carlossg commented Feb 21, 2023

thanks, I was able to flash from linux Ubuntu 22 pico-imx7_pico-pi_ubuntu-22.04_qca9377_lcd-800x480_20221221.zip however I cannot get wifi working, looks like drivers are not in there

@maciekmp
Copy link

maciekmp commented Oct 9, 2023

I can cofirm that it works, tested on windows 11 with newest yocto image with command bellow

uuu/windows64/uuu.exe -b imx-mfg-uuu-tool/multiboard/emmc_imx7_img.auto  imx-mfg-uuu-tool/imx7/pico-imx7/imx7-SPL imx-mfg-uuu-tool/imx7/pico-imx7/imx7-u-boot.img pico-imx7_pico-pi_yocto-4.0-qt6_qca9377_lcd-800x480_20230905/pico-imx7_pico-pi_yocto-4.0-qt6_qca9377_lcd-800x480_20230905.wic.bz2

@carlossg
Copy link

carlossg commented Oct 9, 2023

I can cofirm that it works, tested on windows 11 with newest yocto image with command bellow

@maciekmp you can confirm that wifi works?

@maciekmp
Copy link

If I am right it is not working, checking by running ipconfig -a - no wlan0 interface was available.
Googling that I found this https://github.com/TechNexion/tn-imx-yocto-manifest maybe some image with drivers need to be prepared.

@yougotborked
Copy link

This worked for me with the latest xfce ubuntu 22.04, no wifi detected though

.\uuu\windows64\uuu.exe -b emmc_imx7_img .\imx7\pico-imx7\imx7-SPL .\imx7\pico-imx7\imx7-u-boot.img .\imx7\pico-imx7\pico-imx7_pi_ubuntu-22.04-xfce-desktop_lcd_20231018\pico-imx7_pi_ubuntu-22.04-xfce-desktop_lcd_20231018

@carlossg
Copy link

the other issue besides wifi is that iptables kernel module doesn't work either

$ sudo iptables -L
iptables v1.8.7 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment