Enable CONFIG_USB_MUSB_GADGET
and CONFIG_USB_MUSB_PIO_ONLY
(DMA not supported currently).
There is a bug that without CONFIG_USB_ETHER
option u-boot will not load musb gadget driver and gadgets like UMS and fastboot will show this error:
=> ums 0 0
UMS: LUN 0, dev 0, hwpart 0, sector 0x0, count 0x1dacc00
Controller uninitialized
g_dnl_register: failed!, error: -6
g_dnl_register failed
=>
Full defconfig should look somehting like this
CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_NR_DRAM_BANKS=1
CONFIG_SPL=y
CONFIG_MACH_SUN8I_H3=y
CONFIG_DRAM_CLK=408
CONFIG_MMC_SUNXI_SLOT_EXTRA=2
# CONFIG_VIDEO_DE2 is not set
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
CONFIG_USE_PREBOOT=y
CONFIG_CONSOLE_MUX=y
CONFIG_CMD_USB_MASS_STORAGE=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-nanopi-neo"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
# CONFIG_USB_FUNCTION_FASTBOOT is not set
CONFIG_SUN8I_EMAC=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_MUSB_GADGET=y
CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
CONFIG_USB_GADGET_VBUS_DRAW=500
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_USB_ETH_CDC=y
boot with
sunxi-fel uboot u-boot-sunxi-with-spl.bin write 0x43100000 uboot.env
bt -b 115200 -c fixed -t abs -f "$DEV-%Y%m%d-%H%M%S.log" /dev/$DEV
uboot.env should lok something like this
#=uEnv
bootcmd=fastboot usb 0
https://github.com/artizirk/u-boot/commit/e3899d21d58719ebad5d190f55a349384dd3ac93
Write GPT partition layout in partitions
var to disk with
fastboot oem format
and then flash spl with this
fastboot flash loader1 spl/sunxi-spl.bin
and u-boot with this
fastboot flash loader2 u-boot.bin
A Pretty cool little router thingy
CPU | Model: Rockchip RK3328 Number of Cores: Quad-Core Cortex-A53 Frequency: 4 x Cortex-A53 Up to 1.3GHz |
Memory | RAM: 1GB DDR4 |
Storage | MicroSD Slot: MicroSD x1 for external storage up to 128GB |
Connectivity | Ethernet: Gbps Ethernet x1 USB 3.0 to Gbps Ethernet x1 |
USB | USB 2.0 Host x1: USB Type A USB-Micro x1: Power input(5V/2A) and Slave |
Pin-header | Serial Debug Port x1: 2.54mm pitch 3pin-header(3.3V TTL) |
LED | SYS LED(Red) x1 WAN LED(Green) x1 LAN LED(Green) x1 |
Button | User button x1 |
Working Temperature | 0℃ to 80℃ |
usb ethernet stability fix https://github.com/armbian/build/pull/3763/commits/d52b67ffeeebc89f49159accb953f1ecf9352e74
r8152 will hang randomly, adding snps,xhci-trb-ent-quirk;
to usbdrd3: usb@ff600000
in device tree seems to fix it
Update: No it doesnt fix it, the realtek USB Ethernet IC is just BAD and will crash and drop packets often. Just pretend it does not exist!!! My workaround was to just connect a managed switch to the onboard eth port and do some VLAN magic to seperate WAN and LAN into different virtual interfaces
Start and Size columns are in in LBA sectors. 1 LBA == 512 Bytes.
Name | Start | Size | Image | Puprpose |
---|---|---|---|---|
loader1 | 64 | 7104 | idbloader.bin |
preloader / ram init |
loader2 | 16384 | 8192 | uboot.img |
U-Boot main binary |
trust | 24576 | 8192 | trust.bin |
ATF binary |
boot | 32768 | 229376 | EFI ESP | fat32 or ext4 filesystem |
rootfs | - | - | - | main linux root filesystem |
boot
partiton must be LegacyBIOSBootable, contain filesystem readable by U-Boot and contain a boot.cmd
script that is run on boot.
By default first-lba is at 2048 (1MB) but we need to force it to start just behind GPT structures at 64.
#!/bin/bash
sfdisk --force --output +Name "${1}" <<EOF
label: gpt
first-lba: 64
start=64 size=7104 name="loader1" type=8DA63339-0007-60C0-C436-083AC8230908 attrs="RequiredPartition"
start=16384 size=8192 name="loader2" type=8DA63339-0007-60C0-C436-083AC8230908 attrs="RequiredPartition"
start=24576 size=8192 name="trust" type=8DA63339-0007-60C0-C436-083AC8230908 attrs="RequiredPartition"
start=32768 size=229376 name="boot" type=BC13C2FF-59E6-4262-A352-B275FD6F7172 attrs="RequiredPartition LegacyBIOSBootable"
name="rootfs" type=B921B045-1DF0-41C3-AF44-4C6F280D3FAE
EOF
git clone --depth 1 https://github.com/ARM-software/arm-trusted-firmware.git
cd arm-trusted-firmware
make realclean
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3328
cd ..
Compilation failed with aarch64-linux-gnu-gcc (GCC) 12.2.0
so i used aarch64-none-elf-gcc (Arm GNU Toolchain 11.3.Rel1) 11.3.1 20220712
instead and that worked
git clone --depth 1 https://source.denx.de/u-boot/u-boot.git
cd u-boot
make nanopi-r2s-rk3328_defconfig
export BL31=../arm-trusted-firmware/build/rk3328/release/bl31/bl31.elf
make CROSS_COMPILE=aarch64-linux-gnu- -j16
sudo dd if=u-boot-rockchip.bin of=/dev/sdX1 seek=64
First create a partition table
#!/bin/bash
sfdisk --force --output +Name "${1}" <<EOF
label: gpt
first-lba: 64
start=64 size=16M name="u-boot" type=8DA63339-0007-60C0-C436-083AC8230908 attrs="RequiredPartition"
size=1G name="boot" type=BC13C2FF-59E6-4262-A352-B275FD6F7172 attrs="RequiredPartition LegacyBIOSBootable"
name="rootfs" type=B921B045-1DF0-41C3-AF44-4C6F280D3FAE
EOF
then format them
sudo mkfs.ext4 /dev/sdX2 -L BOOT
sudo mkfs.btrfs /dev/sdX3 -L ROOT --data single --metadata single
Setup filesystems before unpacking arch linux arm rootfs
mkdir root
mount /dev/sdX3 root
cd root
btrfs subvolume create @
cd ..
umount root
mount -o noatime,compress-force=zstd,user_subvol_rm_allowed,subvol=@ /dev/sdX3 root
mkdir root/boot
mount /dev/sdX2 root/boot
When using Armbian 5.6.11-dev kernel, haveged
daemon fails to start. Fix seems to be to add --data=16
to /etc/default/haveged
startup arguments.
Put everything in a target folder
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 \
INSTALL_PATH=../linux-imx-install/boot \
INSTALL_DTBS_PATH=../linux-imx-install/boot/dtbs \
INSTALL_MOD_PATH=../linux-imx-install/usr \
INSTALL_HDR_PATH=../linux-imx-install/usr \
zinstall modules_install dtbs_install headers_install -j32
# MAC address (use spaces instead of colons)
setenv macaddr da 19 c8 7a 6d f4
setenv uuid 85d806a6-f85d-7b40-a303-8664d8be5264
setenv bootargs console=ttyS2,1500000 root=PARTUUID=${uuid} rootflags=subvol=@ rw rootwait earlycon=uart8250,mmio32,0xff130000
setenv fdtfile rockchip/rk3328-nanopi-r2s.dtb
setenv devtype mmc
setenv devnum 1
setenv bootpart 2
if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /Image; then
if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /dtbs/${fdtfile}; then
fdt addr ${fdt_addr_r}
fdt resize
fdt set /ethernet@ff540000 local-mac-address "[${macaddr}]"
if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /initramfs-linux.img; then
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
else
booti ${kernel_addr_r} - ${fdt_addr_r};
fi;
fi;
fi
mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.txt boot.scr
Since v2024.01
there is a scripts/gen_compile_commands.py
that can be used to generate Compilation Database file. It's a compile_commands.json
file that contains all files with all of its flags and include paths. That is enough for CLion (or other IDE's/Language Servers) to index all relevant files and provide accurate code navigation.
./scripts/gen_compile_commands.py
gen_compile_commands.py
has to be re-run after configuration changes.