NixOS on ARM/LS1046A

From NixOS Wiki

U-boot

Cross-compiling


nix-shell --cores 0 '<nixpkgs>' --arg crossSystem '(import <nixpkgs> {}).lib.systems.examples.aarch64-multiplatform' -A ubootQemuAarch64
git clone git://git.denx.de/u-boot.git
cd u-boot
git checkout v2018.03 
# find available defconfigs and pick one
ls configs/ | grep ls1046

make CROSS_COMPILE=aarch64-unknown-linux-gnu- ls1046ardb_sdcard_defconfig
make CROSS_COMPILE=aarch64-unknown-linux-gnu-

Switching QSPI flash banks in u-boot

cpld reset # switch to bank0 (default boot)
cpld reset altbank # switch to bank4 (reset to boot from alternative bank)
cpld reset sd # reset to boot from SD card

Flashing u-boot to QSPI flash

tftp <uboot_image_addr> <uboot_file_name>.bin
# use alternative bank
sf probe 0:1 
sf erase 100000 +$filesize
sf write <uboot_image_addr> 100000 $filesize
# boot from altbank
cpld reset altbank

It is also possible to use sf probe 0:0 to flash current bank.

Flashing u-boot to flash

Replace /dev/sdX with correct device:

dd if=u-boot-with-spl-pbl-sd.bin of=/dev/sdX bs=512 seek=8