Jump to content

[Armbian build PR] - add CAINIAO CNIoT-CORE initial support


Recommended Posts

Posted

How Has This Been Tested?

build the armbian.img, flash to eMMC/USB drive,then boot and use it

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings

Hardware

Cainiao Logistics Terminal A311D Edition, detachable into two parts: the main unit and the base.

overview

Main Unit

Amlogic A311D SoC, 2 GB DDR, 16 GB eMMC

No SD card slot, so the A311D can only load FIP from eMMC.

Gigabit Ethernet port and RTL8822CS WiFi/BT.

One USB Type-C port for power and data transfer in USB download mode. When the main unit is used with the base, it is unclear if this Type-C can function as a Host under Linux, as it is obstructed by the base, making it difficult to plug in devices for testing.

Base

The base comes in different models, but the software should be universal.

Equipped with a USB HUB, display (HDMI or VGA), and power supply (USB Type-C or DC).

Debug Points

Debug UART

debug-uart

eMMC Shorting Point

emmc-short

Armbian Peripheral Status

Component Status
GBE Working
WiFi Working
BT Working
PWM Fan Working
eMMC Working
USB Working
HDMI Display Working
HDMI Audio Working
Internal Speaker Not Working
Power Button Working
ADC Key Working
Side Lights? Not Working
Four Dots on Side Not Working (USB? SPI?)

Installing Armbian

The Amlogic USB Burning Tool uses a proprietary firmware format. Although the firmware extension is .img, it is not a disk image file.

There are tools available for unpacking/repacking it:

Amlogic binary only executable

hzyitc/AmlImg

7Ji/ampack

Repacking all system image .img files into USB flashing packages is not cost-effective.

You can pack an FIP with mainline U-Boot into a USB flashing package to restore the device to a state with mainline U-Boot. Mainline U-Boot includes drivers for Ethernet, USB, and eMMC, which is sufficient for many tasks.

An FIP with mainline U-Boot is available here.

Flashing Mainline U-Boot

Using dd Command

If the device has a working system like Android or Linux with root access, you can simply write fip-with-mainline-uboot.bin to the eMMC:

dd if=path-to-fip-with-mainline-uboot.bin of=/dev/mmcblk1 bs=512 seek=1

It is also recommended to flash the FIP to the eMMC boot area, as the A311D will try to load the FIP from the eMMC boot area if it cannot find it in the user area.

On Linux, you can:

# Check if write access to boot area is available
blockdev --getro /dev/mmcblk1boot0
blockdev --getro /dev/mmcblk1boot1

# Unlock write access to boot area
echo 0 | sudo tee /sys/block/mmcblk1boot0/force_ro
echo 0 | sudo tee /sys/block/mmcblk1boot1/force_ro

dd if=path-to-fip-with-mainline-uboot.bin of=/dev/mmcblk1boot0 bs=512 seek=1
dd if=path-to-fip-with-mainline-uboot.bin of=/dev/mmcblk1boot1 bs=512 seek=1

Using USB Download Mode

If you cannot gain root access to the existing system on the device, you can use the Amlogic USB Burning Tool with the prepared USB flashing package fip-with-mainline-uboot.burn.img to directly flash mainline U-Boot to the eMMC. See Flashing eMMC in USB Download Mode for the USB download process.

The Amlogic USB Burning Tool will write the FIP to the eMMC boot area.

Flashing Armbian Image

Flashing Armbian Image to USB Drive

If you frequently test different systems, considering the lifespan of eMMC and convenience, you may prefer booting from a USB drive. Simply flash the .img file to a USB drive, insert it into the device, and power on. The mainline U-Boot on the eMMC will automatically scan devices like eMMC, USB, and Ethernet in sequence to find a suitable boot environment, such as a U-Boot script, extlinux, or TFTP.

If the A311D still boots from eMMC, it means there is a bootable system on the eMMC. To force booting from USB, you need to destroy the system on the eMMC, such as by deleting the MBR partition table. Alternatively, in the U-Boot command line, enter setenv boot_targets usb0 && boot if you have a UART cable connected.

Flashing Armbian Image to eMMC

Method 1

This method requires a USB drive and network access for the device.

First, flash the Armbian system image to a USB drive and boot the device from it. Then, transfer the system image to be installed to the USB drive via the network, and use the dd command to flash it to the eMMC:

dd if=path-to-your-os-img of=/dev/mmcblk1 status=progress

Alternatively, use a trick to avoid transferring the system image to the USB drive.

On the Armbian system booted from the USB drive, install Netcat and run:

nc -l -p 1234 > /dev/mmcblk1

On a Linux PC, install Netcat and run:

nc -w 3 your-cainiao-cniot-core-ip 1234 < path-to-your-os-img

Netcat has two variants: GNU and OpenBSD. If you have GNU Netcat installed on the PC, the command should be:

nc -w 3 -c your-cainiao-cniot-core-ip 1234 < path-to-your-os-img

To install OpenBSD Netcat:

# ArchLinux
sudo pacman -S openbsd-netcat
# Ubuntu/Debian
apt install netcat-openbsd

To install GNU Netcat:

# ArchLinux
sudo pacman -S gnu-netcat
# Ubuntu/Debian
sudo apt install netcat-traditional

Method 2

This method requires connecting the device's UART to a PC and ensuring both the device and PC are on the same LAN via Ethernet.

First, place the system image to be installed on the Linux PC and rename it, e.g., armbian.img.

Split the image on the Linux PC, as the device's memory cannot hold the entire image at once:

split -b 512M armbian.img armbian.img.
# Assume armbian.img is split into armbian.img.aa, armbian.img.ab, armbian.img.ac; note the filenames.

Set up a TFTP server on the PC.

Windows users can use Tftpd64.

On Linux, use a similar tool like puhitaku/tftp-now. Download the binary from Releases, install it to PATH, and run sudo tftp-now serve -root dir-to-armbian.img.aX.

When powering on the device, press the spacebar in the UART session to enter the U-Boot command line.

Configure the device's network:

setenv ipaddr 172.24.0.241
setenv netmask 255.255.252.0
setenv gatewayip 172.24.0.1
setenv serverip 172.24.0.248

The IP 172.24.0.248 is the PC's IP.

Set the RAM address for temporarily storing the image:

setenv loadaddr 0x20000000

Start downloading the image from the PC's TFTP server and write it to the eMMC:

setenv mmcscript 'setenv files "armbian.img.aa armbian.img.ab armbian.img.ac"; setenv offset 0x0; for file in ${files}; do tftpboot ${loadaddr} ${file}; setexpr nblk ${filesize} / 0x200; mmc write ${loadaddr} ${offset} ${nblk}; setexpr offset ${offset} + ${nblk}; done'
mmc dev 1 && run mmcscript

Finally, reboot the device.

Flashing eMMC in USB Download Mode

The USB Type-C port on the main unit is the USB download port.

Shorting the eMMC shorting point and powering on will put the device into USB download mode.

Alternatively, while the device is running, you can erase the header of the eMMC user/boot area and reboot to enter USB download mode. Example commands:

# Under Linux
sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1MiB count=4 status=progress

echo 0 | sudo tee /sys/block/mmcblk1boot0/force_ro
echo 0 | sudo tee /sys/block/mmcblk1boot1/force_ro

sudo dd if=/dev/zero of=/dev/mmcblk1boot0 bs=1MiB count=4 status=progress
sudo dd if=/dev/zero of=/dev/mmcblk1boot1 bs=1MiB count=4 status=progress

# Under U-Boot command line
mmc dev 1
mmc erase 0 8192
mmc partconf 1 1 1 1
mmc erase 0 8192
mmc partconf 1 1 2 2
mmc erase 0 8192

Finally, use Amlogic USB Burning Tool v2.x.x to flash the image.

View the full article

×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines