-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
add CAINIAO CNIoT-CORE initial support #8208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new board configuration file for the "CAINIAO CNIoT-CORE" device was introduced, detailing board-specific settings and custom build functions for handling firmware integration and tooling. This includes fetching vendor firmware, building a required host tool ( Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (4)
config/sources/families/meson-g12b.conf (1)
27-29
: Redundant noop branch can be droppedThe new branch exactly mirrors the preceding VIM3 branch – a simple do-nothing (
:
) – which is fine, but not strictly necessary.
Removing it would shorten the if-chain without changing behaviour because the board already implementspost_uboot_custom_postprocess
in its own file.config/boards/cainiao-cniot-core.conf (3)
8-8
: Black-listingsimpledrm
hides a working fallback consoleDisabling
simpledrm
avoids Panfrost conflicts but also removes the early framebuffer that’s handy for debugging.
An alternative is to leave the module enabled and passvideo=efifb:off
ordrm.debug=0
on the kernel cmdline when Panfrost is loaded.
Consider whether losing the boot logo / early console is acceptable.
13-13
:ASOUND_STATE
points to a different board
ASOUND_STATE="asound.state.khadas-vim3"
may work accidentally but makes the intent unclear and risks mismatched mixer-routing.
Provide a dedicated state file (even if identical) to make future maintenance obvious.
33-45
: Installation step should useinstall(1)
and honor$DESTDIR
Copying the binary with
cp
hard-codes/usr/local/bin
. Useinstall -m 0755
and the build framework’s destination directory instead:- mkdir -p /usr/local/bin/ - cp gxlimg /usr/local/bin + install -Dm0755 gxlimg "${HOST_INSTALL_DIR:-/usr/local}/bin/gxlimg"This also preserves permissions and works under sudo-less container builds.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
patch/kernel/archive/meson64-6.12/dt/meson-g12b-a311d-cainiao-cniot-core.dts
is excluded by!patch/**
patch/kernel/archive/meson64-6.14/dt/meson-g12b-a311d-cainiao-cniot-core.dts
is excluded by!patch/**
patch/u-boot/v2025.04/board_cainiao-cniot-core/add-board-cainiao-cniot-core.patch
is excluded by!patch/**
📒 Files selected for processing (4)
config/boards/cainiao-cniot-core.conf
(1 hunks)config/kernel/linux-meson64-current.config
(1 hunks)config/kernel/linux-meson64-edge.config
(1 hunks)config/sources/families/meson-g12b.conf
(1 hunks)
🔇 Additional comments (3)
config/kernel/linux-meson64-edge.config (1)
3722-3722
: Enable CONFIG_PWM_GPIO as a loadable module
This change mirrors the update inlinux-meson64-current.config
and makes the PWM_GPIO driver available at runtime without a full rebuild. It’s consistent with the existingCONFIG_PWM=y
selection above and should satisfy the new board’s PWM requirements.config/kernel/linux-meson64-current.config (1)
3717-3722
: PWM-GPIO enabled only as module – verify boot-time requirements
CONFIG_PWM_GPIO=m
will defer driver availability until after the root FS is mounted.
If the board needs PWM (e.g. fan, back-light) very early in the boot sequence consider compiling it in (=y
) instead of a module. Otherwise the change looks good.config/boards/cainiao-cniot-core.conf (1)
58-60
: Missing existence check beforemv
mv u-boot.bin raw-u-boot.bin
assumes the file is in the current working directory.
To avoid hard-to-diagnose build failures:[[ -f u-boot.bin ]] || { echo "u-boot.bin not found"; exit 1; } mv u-boot.bin raw-u-boot.bin
Who is (re)selling this product? Tried to find it but it seems a proprietary tool for the Cainiao logistics company. When not a commercial product there is little point in having it as a board in Armbian/build. |
This device is indeed not a product directly aimed at ordinary consumers, but on a famous online second-hand market in China, some merchants are selling it, with prices ranging from $14 to $30. Most people buy it to use as an Android TV Box. |
6bc91d0
to
6e6e585
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (2)
config/boards/cainiao-cniot-core.csc (2)
4-4
: Fill inBOARD_MAINTAINER
to avoid “orphan” board definitionsLeaving the maintainer field empty makes it hard for others to know who to ping when this board definition breaks in the future.
Please add at least a GitHub handle or email so issues can be routed quickly.
33-45
: Race-proof rebuild guard forgxlimg
git rev-parse @
fails if the repo has no commits (e.g. interrupted clone).- The current logic rebuilds when
/usr/local/bin/gxlimg
is missing, but never checks whether that binary actually matches the recorded commit.A safer pattern:
current_sha=$(git rev-parse HEAD) installed_sha=$(cat /usr/local/bin/.gxlimg_commit 2>/dev/null || echo "none") if [[ $current_sha != "$installed_sha" ]]; then … cp gxlimg /usr/local/bin echo "$current_sha" >/usr/local/bin/.gxlimg_commit fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
patch/kernel/archive/meson64-6.12/dt/meson-g12b-a311d-cainiao-cniot-core.dts
is excluded by!patch/**
patch/kernel/archive/meson64-6.12/meson-g12b-pinctrl-Add-missing-pinmux-for-pwm.patch
is excluded by!patch/**
patch/kernel/archive/meson64-6.14/dt/meson-g12b-a311d-cainiao-cniot-core.dts
is excluded by!patch/**
patch/kernel/archive/meson64-6.14/meson-g12b-pinctrl-Add-missing-pinmux-for-pwm.patch
is excluded by!patch/**
patch/u-boot/v2025.04/board_cainiao-cniot-core/add-board-cainiao-cniot-core.patch
is excluded by!patch/**
📒 Files selected for processing (2)
config/boards/cainiao-cniot-core.csc
(1 hunks)config/sources/families/meson-g12b.conf
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- config/sources/families/meson-g12b.conf
Hey! I don't mind merging this, but please check if any of AI suggested changes are valuable. There is also one merge conflict. |
6e6e585
to
0bd2d87
Compare
I am very happy that it can be merged into the mainline source code, and I will modify my PR as much as possible to meet the requirements. |
I have submitted a PR to the gxlimg repository about gxlimg incorrectly returning a non-zero value. We can wait for the author of gxlimg to merge it. Then I modified PR again to remove the temporary changes to the gxlimg source code. There may be errors in gxlimg's handling of bl3x. If I have free time later, I would like to study [angerman/meson64-tools] and try port its bl3x processing code to gxlimg. So this PR can only use amlogic binary only executable for the time being. |
… four contacts on the side of the host
0bd2d87
to
8103f79
Compare
Hi, this PR is ready to be merged. Compared to the last time:
|
How Has This Been Tested?
build the armbian.img, flash to eMMC/USB drive,then boot and use it
Checklist:
Hardware
Cainiao Logistics Terminal A311D Edition, detachable into two parts: the main unit and the base.
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
eMMC Shorting Point
Armbian Peripheral Status
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:
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:
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.
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.
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:
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:
On a Linux PC, install Netcat and run:
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:
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:
The IP 172.24.0.248 is the PC's IP.
Set the RAM address for temporarily storing the image:
Start downloading the image from the PC's TFTP server and write it to the eMMC:
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:
Finally, use Amlogic USB Burning Tool v2.x.x to flash the image.