File tree Expand file tree Collapse file tree 4 files changed +71
-4
lines changed Expand file tree Collapse file tree 4 files changed +71
-4
lines changed Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ callPackage ,
4+ } :
5+ rec {
6+ reform-flash-uboot =
7+ lib . mapAttrs ( name : config : callPackage ./reform-flash-uboot.nix { inherit config ; } )
8+ {
9+ reform2-rk3588-dsi = {
10+ warn = true ;
11+ mmc = "mmcblk0" ;
12+ mmcBoot0 = false ;
13+ ubootOffset = 32768 ;
14+ flashbinOffset = 0 ;
15+ image = "${ ubootImage . reform2-rk3588-dsi } /rk3588-mnt-reform2-dsi-flash.bin" ;
16+ } ;
17+ } ;
18+
19+ uboot . reform2-rk3588-dsi = callPackage ../rk3588/uboot.nix { } ;
20+ ubootImage . reform2-rk3588-dsi = callPackage ../rk3588/uboot-image.nix {
21+ uboot = uboot . reform2-rk3588-dsi ;
22+ } ;
23+ }
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ writeShellApplication ,
4+ config ,
5+ } :
6+ let
7+ dev = "/dev/" + config . mmc + lib . optionalString config . mmcBoot0 "boot0" ;
8+ in
9+ writeShellApplication {
10+ name = "reform-flash-uboot" ;
11+ text = ''
12+ if [ "$(id -u)" -ne 0 ]; then
13+ echo "reform-flash-uboot has to be run as root / using sudo."
14+ exit 1
15+ fi
16+ ''
17+ + lib . optionalString config . warn ''
18+ echo "W: Flashing u-boot to eMMC on $(cat /proc/device-tree/model) is not without risk." >&2
19+ echo "W: If you flash the wrong u-boot or if the flashing process goes wrong, it is" >&2
20+ echo "W: possible to soft-brick your board. Restoring it might need some extra hardware." >&2
21+ echo "W: Please only proceed if you are sure that the benefits outweigh the risks for you." >&2
22+ printf "Are you sure you want to proceed? [y/N] "
23+ read -r response
24+
25+ if [ "$response" != "y" ]; then
26+ echo "Exiting."
27+ exit
28+ fi
29+ ''
30+ + ''
31+ echo "Writing ${ config . image } to ${ dev } " >&2
32+ ''
33+ + lib . optionalString config . mmcBoot0 ''
34+ echo 0 >"/sys/class/block/${ config . mmc } boot0/force_ro"
35+ ''
36+ + ''
37+ dd if='${ config . image } ' of='${ dev } ' bs=512 seek='${
38+ builtins . toString ( config . ubootOffset / 512 )
39+ } ' skip='${ builtins . toString ( config . flashbinOffset / 512 ) } '
40+ ''
41+ + lib . optionalString config . mmcBoot0 ''
42+ echo 1 >"/sys/class/block/${ config . mmc } boot0/force_ro"
43+ '' ;
44+ }
Original file line number Diff line number Diff line change 4444 storeContents = config . installerImage . storeContents ;
4545 comp = config . installerImage . squashfsCompression ;
4646 } ;
47- uboot = pkgs . callPackage ./uboot.nix { } ;
48- firmware = pkgs . callPackage ./firmware.nix { inherit uboot ; } ;
47+ packages = pkgs . callPackage ../pkgs { } ;
48+ ubootImage = packages . ubootImage . reform2-rk3588-dsi ;
4949 content = pkgs . callPackage (
5050 {
5151 stdenv ,
215215 eval $(partx $img -o START,SECTORS --nr 1 --pairs)
216216 dd conv=notrunc if=${ content } of=$img seek=$START count=$SECTORS
217217
218- dd conv=notrunc if=${ firmware } /rk3588-mnt-reform2-dsi-flash.bin of=$img seek=64
218+ dd conv=notrunc if=${ ubootImage } /rk3588-mnt-reform2-dsi-flash.bin of=$img seek=64
219219
220220 if test -n "$compressImage"; then
221221 zstd -T$NIX_BUILD_CORES --rm $img
Original file line number Diff line number Diff line change 44 fetchFromGitHub ,
55} :
66# script from https://source.mnt.re/reform/reform-rk3588-uboot/-/blob/28289e36cd1cb90b302780e83b014250c880c4ec/build.sh
7- runCommand "mnt-reform-firmware -rk3855${ uboot . variant } " { } ''
7+ runCommand "mnt-reform-uboot-image -rk3855${ uboot . variant } " { } ''
88 mkdir $out
99 cp ${ uboot } /idbloader.img $out/rk3588-mnt-reform2${ uboot . variant } -flash.bin
1010 dd if=${ uboot } /u-boot.itb of=$out/rk3588-mnt-reform${ uboot . variant } -flash.bin seek=16320
You can’t perform that action at this time.
0 commit comments