Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Software | WiFi Hotspot: Set country code during installation #5407

Closed
matteocarnelos opened this issue Apr 5, 2022 · 5 comments
Closed
Labels
Enhancement 💨 Solution available 🥂 Definite solution has been done
Milestone

Comments

@matteocarnelos
Copy link

Creating a bug report/issue

Required Information

  • DietPi version
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=3
G_DIETPI_VERSION_RC=1
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
  • Distro version | bullseye 1
  • Kernel version | Linux DietPi 5.15.32-v7+ #1538 SMP Thu Mar 31 19:38:48 BST 2022 armv7l GNU/Linux
  • SBC model | RPi 3 Model B+ (armv7l)
  • Power supply used | 5V 3A
  • SD card used | SanDisk Ultra

Additional Information (if applicable)

  • Software title | WiFi Hotspot
  • Was the software title installed freshly or updated/migrated? Freshly installed using DietPi-Automation
  • Can this issue be replicated on a fresh installation of DietPi? Yes

Steps to reproduce

  1. Perform a fresh install of the latest DietPi, setting the following in the dietpi.txt file:
AUTO_SETUP_AUTOMATED=1
AUTO_SETUP_INSTALL_SOFTWARE_ID=60

Expected behaviour

  • After the install, the wifi country code should be set accordingly to AUTO_SETUP_NET_WIFI_COUNTRY_CODE in dietpi.txt

Actual behaviour

  • The wifi country code is not set

Extra details

Issue probably due to the fact that, since the wifi adapter is disabled during first boot, the country code is not applied, as said by @MichaIng in this forum post:

The country code is applied automatically on first boot and applied to /etc/default/crda to be loaded on every next boot via udev rules, as fast as the WiFi device is attached/found by the kernel, but indeed only when WiFi is enabled dietpi.txt wise. Actually it makes sense to do that regardless whether WiFi is enabled or not, so that the correct country code is applied as fast as any WiFi adapter is enabled.

As said, a possible fix is to set the wifi country code regardless wether WiFi is enabled or not.

Thanks for the help!

@MichaIng
Copy link
Owner

MichaIng commented Apr 5, 2022

Many thanks for your report.

How do you know that the country code is not set correctly? Did you check iw reg get?

The dietpi-config/dietpi.txt option sets it via CRDA, but since the forum post I found out that with modern kernel it is set automatically without CRDA, i.e. CRDA is actually obsolete nowadays and has hence been removed for Debian Bookworm (next stable) already: https://packages.debian.org/crda

I can basically verify this on my RPis and x86 systems with Bullseye, where changing the country code via CRDA to something that does not match my country does not survive a reboot, it is set automatically correctly.

When connecting via WiFi to an access point, this all makes sense since the AP can pass the country code. But when using the adapter as hotspot, I don't know how the kernel should know which country code is the correct one. Basically I need to read into this topic and run some tests.

@matteocarnelos
Copy link
Author

matteocarnelos commented Apr 6, 2022

How do you know that the country code is not set correctly? Did you check iw reg get?

After the install, if I go to dietpi-config > Network Options: Adapters > WiFi the country code is not set:

Screen Shot 2022-04-06 at 01 58 23

And here's the output of iw reg get:

global
country 00: DFS-UNSET
	(2402 - 2472 @ 40), (6, 20), (N/A)
	(2457 - 2482 @ 20), (6, 20), (N/A), AUTO-BW, PASSIVE-SCAN
	(2474 - 2494 @ 20), (6, 20), (N/A), NO-OFDM, PASSIVE-SCAN
	(5170 - 5250 @ 80), (6, 20), (N/A), AUTO-BW, PASSIVE-SCAN
	(5250 - 5330 @ 80), (6, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
	(5490 - 5730 @ 160), (6, 20), (0 ms), DFS, PASSIVE-SCAN
	(5735 - 5835 @ 80), (6, 20), (N/A), PASSIVE-SCAN
	(57240 - 63720 @ 2160), (N/A, 0), (N/A)

phy#0
country 99: DFS-UNSET
	(2402 - 2482 @ 40), (6, 20), (N/A)
	(2474 - 2494 @ 20), (6, 20), (N/A)
	(5140 - 5360 @ 160), (6, 20), (N/A)
	(5460 - 5860 @ 160), (6, 20), (N/A)

It seems that without connecting to any AP (the wifi interface is used for the hotspot only and the ethernet one is used for the internet access) the country code does not get set.

@MichaIng
Copy link
Owner

MichaIng commented Apr 6, 2022

Probably CRDA is even messing with the auto-selection. At least worth to give a shot:

apt purge crda
reboot
# after reboot
iw reg get

If it remains true that it needs to be set for the hotspot:

apt install crda
dietpi-config

Then configure it there.

What we should then do is applying the country code during WiFi hotspot installation. So as before, it is skipped during first boot if WiFi is not enabled (as Internet facing adapter), but it is applied when WiFi hotspot is installed during first run installs, including automated installs.

@matteocarnelos
Copy link
Author

matteocarnelos commented Apr 6, 2022

Unfortunately, after purging CRDA and rebooting, the country code was still not set. So yes, I think we should set it during WiFi Hotspot installation.

As a temporary workaround I put the following in Automation_Custom_Script.sh:

# Set WiFi Country Code
/boot/dietpi/func/dietpi-set_hardware wificountrycode "$(sed -n '/^[[:blank:]]*AUTO_SETUP_NET_WIFI_COUNTRY_CODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)"

@MichaIng MichaIng added this to the v8.4 milestone Apr 14, 2022
@MichaIng MichaIng changed the title DietPi-Automation | WiFi Hotspot installation does not set the wifi country code DietPi-Software | WiFi Hotspot: Set country code during installation Apr 14, 2022
MichaIng added a commit that referenced this issue Apr 22, 2022
- DietPi-Software | WiFi Hotspot: Resolved an issue where the WiFi country code was not applied when the WiFi Hotspot was installed via automated first run setup. Many thanks to @matteocarnelos for reporting this issue: #5407
@MichaIng MichaIng added Solution available 🥂 Definite solution has been done and removed Investigating 🤔 labels Apr 22, 2022
@MichaIng
Copy link
Owner

Solved with: c864974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 💨 Solution available 🥂 Definite solution has been done
Projects
None yet
Development

No branches or pull requests

2 participants