Skip to content
Open
106 changes: 106 additions & 0 deletions nit6sx/debimage-nit6sx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{{- $image := or .image "debian-nit6sx.img" -}}

architecture: armhf

actions:
- action: download
description: Download pre-built nit6sx u-boot binary
url: http://linode.boundarydevices.com/u-boot-images/u-boot.nitrogen6sx
name: bootloader

- action: debootstrap
suite: buster
components:
- main
mirror: https://deb.debian.org/debian
variant: minbase

- action: apt
description: Install extra packages
packages:
- sudo
- openssh-server
- adduser
- systemd-sysv
- linux-image-armmp
- u-boot-imx
- wget

- action: run
description: Set up user
chroot: true
script: scripts/setup-user.sh

- action: run
description: Add hostname
chroot: true
command: echo nit6sx > /etc/hostname

- action: overlay
source: overlays/networkd

- action: run
chroot: true
script: scripts/setup-networking.sh

- action: run
chroot: true
command: echo console=ttymxc0,115200 > /etc/kernel/cmdline

# Make dtb easy to find (normally flash-kernel does this for us)
- action: run
chroot: true
command: ln -rsf /usr/lib/linux-image-*-armmp/imx6sx-nitrogen6sx.dtb /boot/dtb

- action: run
description: Generate boot-loader script
script: scripts/gen-bootscript.sh

- action: image-partition
imagename: {{ $image }}
imagesize: 1GB
partitiontype: msdos
mountpoints:
- mountpoint: /
partition: root
partitions:
- name: root
fs: ext4
start: 1MB
end: 100%
flags: [ boot ]

- action: filesystem-deploy
description: Deploying filesystem onto image

# The nitrogen6sx support is not yet in upstream u-boot, see:
# https://github.com/boundarydevices/u-boot-imx6/tree/boundary-v2018.07
# (note: must be done after partition table writing or will be wiped!)

- action: raw
description: Write u-boot binary to raw image load addr
origin: bootloader
source: .
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See go-debos/debos#77 (downloaded is a file which should be used directly, not an archive.)

offset: 1024
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note to self: This could also be written as {{ sector 2 }}.)


#- action: raw
# description: Write u-boot SPL
# origin: filesystem
# source: /usr/lib/u-boot/nitrogen6sx/SPL
# offset: 1024 # bs=1k seek=1

#- action: raw
# description: Write u-boot full version
# origin: filesystem
# source: /usr/lib/u-boot/nitrogen6sx/u-boot.img
# offset: 70656 # bs=1k seek=69

- action: run
description: Create block map file
postprocess: true
command: bmaptool create {{ $image }} > {{ $image }}.bmap

- action: run
description: Compressing final image
postprocess: true
command: gzip -f {{ $image }}
6 changes: 6 additions & 0 deletions nit6sx/overlays/networkd/etc/systemd/network/wired.network
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Match]
Name=e*

[Network]
DHCP=yes

28 changes: 28 additions & 0 deletions nit6sx/scripts/gen-bootscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
# Puts below info in a script and generate boot.scr
# This script assumes it's executed from 'artifact directory' (/scratch)

cat << 'EOF' > bootscr.txt
# debos nit6sx boot script
# loadaddr=0x82000000
env exists ramdiskaddr || setenv ramdiskaddr 84000000
# fdt_addr=83000000
# console=ttymxc0
# baudrate=115200


setenv prepbootargs 'if test -n "${console}"; then setenv bootargs "${bootargs} console=${console}" ; fi ; setenv bootargs ${bootargs} cma=256M ; setenv bootargs ${bootargs} root=LABEL=root'
#setenv bootargs ${bootargs} quiet

setenv loadkernel 'load mmc 0 ${loadaddr} /vmlinuz'
setenv loadfdt 'load mmc 0 ${fdt_addr} /boot/dtb'
setenv loadrd 'load mmc 0 ${ramdiskaddr} /initrd.img && setenv rdsize $filesize'
setenv loadall 'run loadkernel; run loadfdt; run loadrd'

setenv bootmmc 'mmc dev 0; run prepbootargs; run loadall; bootz ${loadaddr} ${ramdiskaddr}:${rdsize} ${fdt_addr}'

run bootmmc

EOF

mkimage -A arm -T script -C none -n "Debos Nitrogen6SoloX script" -d bootscr.txt $ROOTDIR/boot/boot.scr
6 changes: 6 additions & 0 deletions nit6sx/scripts/replace-u-boot-rpi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e
wget http://ftp.us.debian.org/debian/pool/main/u/u-boot/u-boot-rpi_2018.09+dfsg-1_arm64.deb
dpkg -i u-boot-rpi_2018.09+dfsg-1_arm64.deb
rm u-boot-rpi_2018.09+dfsg-1_arm64.deb
10 changes: 10 additions & 0 deletions nit6sx/scripts/setup-networking.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

# Network management
systemctl enable systemd-networkd
# DNS resolving
systemctl enable systemd-resolved
# NTP client
systemctl enable systemd-timesyncd
8 changes: 8 additions & 0 deletions nit6sx/scripts/setup-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

adduser --gecos user \
--disabled-password \
--shell /bin/bash \
user
adduser user sudo
echo "user:user" | chpasswd