#!/bin/sh
python -c '
import struct, zlib, os, sys
p = "/sys/class/block/nand/size"
if not os.path.exists(p):
print "Error"
sys.exit(1)
with open(p, "r") as f:
t = int(f.read().strip())
L = [("bootloader", 2048, 32768), ("env", 34816, 4096), ("rootfs", 38912, t - 36864)]
e = ""
for idx, (n, st, sz) in enumerate(L):
if idx == 0:
l1 = struct.pack("<BBB5sII", 0, 0, 3, "\x00" * 5, st, 0)
else:
l1 = struct.pack("<QII", 0, st, 0)
e += l1 + struct.pack("<I4sQ", sz, "DISK", 0) + n.ljust(16, "\x00") + "\x00" * 16
b = (struct.pack("<II8s", 0, 0x100, "softw311") + e).ljust(1024, "\x00")
out = ""
for i in range(4):
c = b[:17] + struct.pack("B", i) + b[18:]
out += struct.pack("<I", zlib.crc32(c[4:]) & 0xffffffff) + c[4:]
with open("nand_part.bin", "wb") as f:
f.write(out)
print "Done"
'
dd if=nand_part.bin of=/dev/nand bs=1k count=4
sleep 1
sync
sleep 1
sync
sleep 1
blockdev --rereadpt /dev/nand
sleep 2
blockdev --rereadpt /dev/nand
sleep 2
blockdev --rereadpt /dev/nand
sleep 2
umount /dev/nandc
mkfs.ext4 /dev/nandc
tune2fs -o journal_data_writeback /dev/nandc
tune2fs -O ^has_journal /dev/nandc
e2fsck -f /dev/nandc
mkdir /mnt/nandroot
mount /dev/nandc /mnt/nandroot
tar --exclude=/proc/* \
--exclude=/sys/* \
--exclude=/dev/* \
--exclude=/tmp/* \
--exclude=/run/* \
--exclude=/mnt/* \
--exclude=/media/* \
--exclude=/var/log/* \
--exclude=/var/tmp/* \
-cf - / | (cd /mnt/nandroot && tar -xf -)
cat << 'EOF' > /mnt/nandroot/etc/fstab
/dev/nandc / ext4 defaults,noatime,nodiratime,commit=60 0 1
tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=64M 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755,size=32M 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777,size=32M 0 0
EOF
umount /mnt/nandroot
rmdir /mnt/nandroot
mkdir -p /mnt/sdboot
mount /dev/mmcblk0p1 /mnt/sdboot
mkdir -p /mnt/nandboot
mount /dev/nanda /mnt/nandboot
cp /mnt/sdboot/uImage /mnt/nandboot/
cp /mnt/sdboot/script.bin /mnt/nandboot/
umount /mnt/sdboot
rmdir /mnt/sdboot
umount /mnt/nandboot
rmdir /mnt/nandboot
cat << 'EOF' > u-boot.txt
baudrate=115200
bootdelay=1
console=ttyS0,115200
loglevel=8
machid=102a
nand_root=/dev/nandc
init=/sbin/init
setargs=setenv bootargs console=${console} root=${nand_root} rootwait init=${init} loglevel=${loglevel}
boot_normal=fatload nand 0:0 0x44000000 uImage; bootm 0x44000000
bootcmd=run setargs boot_normal
EOF
python -c "
import zlib, struct
with open('u-boot.txt', 'r') as f:
lines = [line.strip() for line in f if line.strip()]
data = '\x00'.join(lines) + '\x00'
target_size = 131072 - 4
data = data.ljust(target_size, '\x00')
crc = zlib.crc32(data) & 0xffffffff
header = struct.pack('<I', crc)
with open('env.bin', 'wb') as f:
f.write(header + data)
print('env.bin reafy! filesize:', len(header + data))
"
sudo dd if=env.bin of=/dev/nandb bs=1k
sync
rm env.bin u-boot.txt
echo "All done! Now power off the board, remove SD card and next time it will boot Linux from NAND!"
I spent about two nights trying to program the iCE40HX1K-EVB using my RPi 4 with no success, checking connections, switching pins on the RPi.

Quote from: Roman on June 06, 2026, 08:09:08 PMCould you tell which revisions of the board you have?
Quote from: mossroy on May 14, 2026, 10:36:02 PMI've described a different procedure to install Debian 13 on my A64-OLinuXino-2Ge8G-IND boards: https://blog.mossroy.fr/2026/05/14/debian-13-sur-a64-olinuxino-2ge8g-ind/ (it's written in French).
Quote from: Roman on May 10, 2026, 09:05:36 PMNow it boots as expected untill "Starting kernel ..."
[ 2.836347] gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 2.847404] sun50i-a64-r-pinctrl 1f02c00.pinctrl: initialized sunXi PIO driver
[ 2.856795] sun50i-a64-r-pinctrl 1f02c00.pinctrl: supply vcc-pl not found, using dummy regulator
[ 2.866685] sunxi-rsb 1f03400.rsb: RSB running at 4000000 Hz
[ 2.877472] gpio gpiochip1: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 2.891691] sun50i-a64-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 2.900359] dw-apb-uart 1c28000.serial: Error applying setting, reverse things back
[ 2.909301] dw-apb-uart 1c28000.serial: Error applying setting, reverse things back
[ 2.981557] clk: Disabling unused clocks#!/bin/sh
apt-get install rsync
apt-get clean
apt-get autoclean
umount /dev/nandi
mkfs.ext4 /dev/nandi
tune2fs -o journal_data_writeback /dev/nandi
tune2fs -O ^has_journal /dev/nandi
e2fsck -f /dev/nandi
umount /dev/nandd
mkfs.ext4 /dev/nandd
tune2fs -o journal_data_writeback /dev/nandd
tune2fs -O ^has_journal /dev/nandd
e2fsck -f /dev/nandd
umount /dev/nande
mkfs.ext4 /dev/nande
tune2fs -o journal_data_writeback /dev/nande
tune2fs -O ^has_journal /dev/nande
e2fsck -f /dev/nande
umount /dev/nandh
mkfs.ext4 /dev/nandh
tune2fs -o journal_data_writeback /dev/nandh
tune2fs -O ^has_journal /dev/nandh
e2fsck -f /dev/nandh
mkdir /mnt/nandroot
mount /dev/nandi /mnt/nandroot
rsync -aAXHv \
--exclude=/proc \
--exclude=/home \
--exclude=/sys \
--exclude=/dev \
--exclude=/tmp \
--exclude=/run \
--exclude=/mnt \
--exclude=/media \
/ /mnt/nandroot
mkdir /mnt/nandroot/dev /mnt/nandroot/proc /mnt/nandroot/sys /mnt/nandroot/tmp /mnt/nandroot/run /mnt/nandroot/mnt /mnt/nandroot/media /mnt/nandroot/home
rm -rf /mnt/nandroot/var/log/*
rm -rf /mnt/nandroot/var/tmp/*
mkdir -p /mnt/nandroot/mnt/storage
mkdir -p /mnt/nandroot/mnt/backup
cat << 'EOF' > /mnt/nandroot/etc/fstab
/dev/nandi / ext4 defaults,noatime,nodiratime,commit=60 0 1
/dev/nande /home ext4 defaults,noatime,nodiratime,commit=60 0 2
/dev/nandh /mnt/storage ext4 defaults,noatime,nodiratime,commit=60 0 2
/dev/nandd /mnt/backup ext4 defaults,noatime,nodiratime,commit=60 0 2
tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=64M 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755,size=32M 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777,size=32M 0 0
EOF
umount /mnt/nandroot
rmdir /mnt/nandroot
mkdir /mnt/new_home
mount /dev/nande /mnt/new_home
rsync -aHAXx /home/ /mnt/new_home/
umount /mnt/new_home
rmdir /mnt/new_home
mkdir -p /mnt/sdboot
mount -t vfat /dev/mmcblk0p1 /mnt/sdboot
dd if=/mnt/sdboot/uImage of=/dev/nandc bs=1M
dd if=/mnt/sdboot/script.bin of=/dev/nandf bs=1k
sync
umount /mnt/sdboot
rmdir /mnt/sdboot
cat << 'EOF' > u-boot.txt
baudrate=115200
bootdelay=1
console=ttyS0,115200
loglevel=8
machid=102a
nand_root=/dev/nandi
init=/sbin/init
setargs=setenv bootargs console=${console} root=${nand_root} rootwait init=${init} loglevel=${loglevel}
boot_normal=nand read 0x44000000 0x1300000 0x500000; nand read 0x43000000 0x33300000 0x20000; bootm 0x44000000
bootcmd=run setargs boot_normal
EOF
python -c "
import zlib, struct
with open('u-boot.txt', 'r') as f:
lines = [line.strip() for line in f if line.strip()]
data = '\x00'.join(lines) + '\x00'
target_size = 131072 - 4
data = data.ljust(target_size, '\x00')
crc = zlib.crc32(data) & 0xffffffff
header = struct.pack('<I', crc)
with open('env.bin', 'wb') as f:
f.write(header + data)
print('env.bin reafy! filesize:', len(header + data))
"
sudo dd if=env.bin of=/dev/nandb bs=1k
sync
rm env.bin u-boot.txt
echo "All done! Now power off the board, remove SD card and next time it will boot Linux from NAND!"