This is a raspberry pi image creation automation project for cnc.js setup on Rpi with 64 bits
using HashiCorp packer, using an upgraded version of the popular https://github.com/mkaczanowski/packer-builder-arm plugin
(see https://gitub.com/brederle/packer-plugin-armflash)
Please submit bugs and wishes under https://github.com/brederle/packer-image-cncjs/issues.
The repo contains a pre-configured .devcontainer with the required packer tooling and the
packer-plugin-armflash plugin preconfigured. To use the DevContainer:
-
Install the Microsoft-supported VSCode devcontainer extension
-
Load the repo folder wth VSCode
-
Push STRG+SHIFT+P > Dev Containers: Rebuild and Reopen in Container
Eventually, a terminal opens up where packer can directly be started as described below.
Without setting any variables, a universal image is build.
packer build .
Neither wifi nor ssh key access is configured by default, make the corresponding settings when
uploading cncpi-pi-arm64.img via Raspberry Pi imager.
For a custom image build, configure your (private) parameters under .private.
You can copy and extend the .template files:
-
authorized_keysthe well-known ssh configuration for key access
For security reasons, ssh is using contemporary elliptic crypto methods and prefers elliptic keys. -
settings.pkrvars.hclthe well-known ssh configuration for key access
For security reasons, ssh is using contemporary elliptic crypto methods and prefers elliptic keys.
Look at raspios.vars.pkr.hcl and IMG.vars.pkr.hcl for the documentation of the different setting
parameters and their defaults.
Run packer with:
packer build -var-file=".private/settings.pkrvars.hcl" .
|
Warning
|
Please avoid to check in credential and other private setting in public repos! |
diskutl list
sudo diskutil unmountDisk /dev/diskX
sudo dd if=./lowrider3-cncjs-raspi-arm64.img of=/dev/rdiskX bs=4Mwhere /dev/diskX is the disk with the size of your eMMC listed in the first step.
Note: Using rdisk and bs=4M optimized flashing speed.
export PACKER-LOG=1
You can already set the variable globally in devcontainer.json to run it as default.
Before flashing the image, you can review the image content by mounting the partitions:
export IMG_LOOP=$(losetup --find --partscan --show lowrider3-cncjs-raspi-arm64.img)
mount -o discard ${IMG_LOOP}p2 /media/img
mount -o discard ${IMG_LOOP}p1 /media/img/boot/firmware
With:
* /dev/loopXp1: boot partition (new bookworm layout)
* /dev/loopXp2: workload partition
To remove the environnment:
umount ${IMG_LOOP}p1
umount ${IMG_LOOP}p2
losetup --detach ${IMG_LOOP}