into build_dir/files/etc/config/wireless and build_dir/files/etc/uci-defaults/wireless, but after flashing the SD card with the official RPi imager, my RPi didn't boot up with the Wi-Fi enabled. Did I miss something?
FYI, I replaced wpad-basic-wolfssl with wpad-openssl, not sure if this is still needed, but I did it anyway.
There are several problems with that file. The best way to do this is to set up wifi once on a device of the same model, make sure it works then copy the /etc/config/wireless to the ROM. You don't need to add or change /etc/uci-defaults/wireless.
If there is no Ethernet in your PC you can configure any old router as a dumb AP and connect it to the PI Ethernet, then connect the PC to the AP wifi. Serial and local keyboard/screen access is also possible.
you need to put the files in openwrt/files/etc/config/wireless if you build from source or openwrt-imagebuilder-19.07.7-ramips-mt76x8.Linux-x86_64/files/etc/config/wireless and specify this folder on the command line as said here https://openwrt.org/docs/guide-user/additional-software/imagebuilder#custom_files if you use the image builder (the image builder folder I used is an example, choose the folder you have extracted the image builder in)
Create the "files" folder if it does not exist (it usually does not exist).
build_dir is a folder with temporary build binaries, it is not the right place for the "files" folder
Your script works but placing it in package\base-files\files\etc\uci-defaults is a hack, next time you update sources git will complain, next time you make clean it will be deleted.
Best to place it in openwrt/files/etc/uci-defaults if you build from source or openwrt-imagebuilder-19.07.7-ramips-mt76x8.Linux-x86_64/files/etc/uci-defaults and specify this folder in the command line as said here https://openwrt.org/docs/guide-user/additional-software/imagebuilder#custom_files if you use image builder (folder name is an example, use the folder you have extracted image builder in)