# Raspberry PI, pre-populate wpa_supplicant.conf and SSH?



## forrie (Dec 25, 2021)

I have a newer Raspberry PI (arm7) that I would like to test FreeBSD on.   In Raspbian, you can mount the installation image and create the wpa_supplicant.conf and enable SSH before installing.   Basically, a headless, non-interactive install -- which requires a bunch of defaults set.  I imagine there is an equivalent possibility with FreeBSD?


----------



## Phishfry (Dec 25, 2021)

On FreeBSD you would mount the image in a memorydisk and edit your preferences.




__





						mdconfig(8)
					






					www.freebsd.org


----------



## covacat (Dec 25, 2021)

download and unpack the img.xz
mdconfig -t vnode file.img
mount /dev/md0s2a /mnt
hack /mnt/etc/rc.conf /mnt/etc/wpa_supplicant.conf
/mnt/boot/loader.conf /mnt/etc/sshd_config
you probably need an usb dongle for wifi


----------



## Alain De Vos (Dec 25, 2021)

I use an USB-SDCard dongle.
Then i simply mount the ufs partition on the sdcard, ie on my PC,

```
mount /dev/da5s2a /mnt/PI
```
Then i just edit the files in /mnt/PI/etc/
To backup the contents of the SDCard i use:

```
clone -v 1 -s /mnt/PI /destination
```
PS: I reformated the /dev/da2sa2 ufs partition with a little tuning :

```
newfs -E -L rootfs -O 2 -U -b 65536 -f 8192 -n -e 65536 -g 65536 -h 1024 /dev/da5s2a
tunefs -p /dev/da5s2a
```

I have not tested wifi on the Raspberry PI4. But if detection should fail you can use a very cheap wifi USB-dongle.


----------



## eternal_noob (Dec 25, 2021)

Didn't know WiFi works on Pis. The wiki suggests it doesn't.


			arm/Raspberry Pi - FreeBSD Wiki


----------



## Alain De Vos (Dec 25, 2021)

It seems it uses a closed source firmware. Eg in Debian,


			Debian -- Details of package firmware-brcm80211 in sid


----------



## covacat (Dec 25, 2021)

Phishfry said:


> With the newer GENERIC Arm images that are not board dependant do you need to manually create the uboot partition and copy appropriate uboot port into the fat partition?
> How is uboot working with the newer platform generic ARM images?


the rpib which i use for the pi zero has everything needed to boot on it (in the dos partition)
the ufs part is generic
earlier versions of uboot without efi were booting considerably faster


----------



## covacat (Dec 25, 2021)

off topic for other pi users
can you boot/get to single user mode ?
somehow on the pi zero there is no console for userland until getty spawns
so you can't see /etc/rc* messages on screen
kernel messages ARE displayed just nothing from /etc/rc
also boot -s does not work


----------



## Phishfry (Dec 26, 2021)

covacat said:


> boot -s does not work


what if you set it as a /boot/loader.conf flag?

From /boot/defaults/loader.conf
#boot_single=""        # -s: Start system in single-user mode


----------



## covacat (Dec 26, 2021)

the syntax works, it's just not usable when reaching single user as i have no console input/output


----------



## Phishfry (Dec 26, 2021)

I was just noticing that none of the uboot stuff is logged. It comes early so dmesg doesn't catch it.

```
Consoles: EFI console 
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/arm EFI loader, Revision 1.1

   Command line arguments: l
   Image base: 0x9cdd9000
   EFI version: 2.80
   EFI Firmware: Das U-Boot (rev 8217.4096)
   Console: comconsole (0)
   Load Path: /efi\boot\bootarm.efi
   Load Device: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,0x01,0,0x81f,0x18fa8)
Trying ESP: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,0x01,0,0x81f,0x18fa8)
Setting currdev to disk0p1:
Trying: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,0x01,0,0x197c7,0x5e6821)
Setting currdev to disk0p2:
Loading /boot/defaults/loader.conf
Loading /boot/defaults/loader.conf
Loading /boot/device.hints
Loading /boot/loader.conf
Loading /boot/loader.conf.local
```


----------



## Alain De Vos (Dec 26, 2021)

There is also a file called "cmdline" in the dos partition of the rapberry OS distro. I don't know what it's good for.
And calling "init 1" on freebsd, makes the system just hang.


----------



## eternal_noob (Dec 26, 2021)

Alain De Vos said:


> There is also a file called "cmdline" in the dos partition of the rapberry OS distro. I don't know what it's good for.


You can pass options to the kernel with it.
See https://github.com/raspberrypi/linux/blob/rpi-4.0.y/Documentation/kernel-parameters.txt


----------

