amanharitsh123 / sugarizer-school-box

Sugarizer School Box GSoC '18
Apache License 2.0
2 stars 6 forks source link

Wifi Hotspot #6

Closed amanharitsh123 closed 6 years ago

amanharitsh123 commented 6 years ago

Made the necessary changes to start wifi ap at boot .

  1. Issue #8 Exists only in the first run of the image . after a reboot it disappears and wifi hotspot works perfectly .
  2. Issue #9 After a reboot it almost take a minute for iptables to load . Hence ethernet bridging works after 1-2 min of starting hotspot.
  3. So , Everything works fine after the first successful run of 1 hour.
quozl commented 6 years ago

Thanks, reviewed.

da6eb3e,

70138dc,

Hope that helps! Let me know if you have any questions.

amanharitsh123 commented 6 years ago

da6eb3e

70138dc,

Authentication Problem still exists , Do you have any suggestions to fix this ?

quozl commented 6 years ago

Yes, there are many tutorials, often using heuristic rather than analytical techniques. You are using now a recent systemd and the documentation for it should be considered rather than tutorials that were intended for older releases. It is best to do the minimum necessary, rather than add steps that are not tested. Result will be efficient and quick.

Diagnose the authentication problem further. Access the system using local keyboard and display, or serial port, or ethernet, and check the network interface configuration for the wireless device. Check the logs written to by the rc.local. Try repeating the ap command by hand. My guess is that something in the network management facility you've used may not have been tested with the most recent systemd packages from Debian.

amanharitsh123 commented 6 years ago

@quozl I have made some interesting observations

quozl commented 6 years ago

Interesting, thanks.

Issue #8 Exists only in the first run of the image . after a reboot it disappears and wifi hotspot works perfectly .

As you have both docker initialisation and install of your network management facility happening at the same time; they are probably competing for the same CPU and memory resources, slowing each other down.

it almost take a minute for iptables to load . Hence ethernet bridging works after 1-2 min of starting hotspot.

It should not take that long. An average iptables loading should take no more than a few milliseconds. You could diagnose further; add timestamps to your logs, find which command is causing the delay.

Is another reason to use the absolute minimum of commands. Many of the services are restarted without justification; many services know to re-read configuration files or detect network interface transitions.

amanharitsh123 commented 6 years ago

@quozl I think that the reason behind the delay is the access speed of my SD card . I am using a class 4 8GB sd card. After every boot, docker containers boots up .I think they cause some decent amount of load on SD card . Hence , network setup experiences delay .

quozl commented 6 years ago

Certainly the SD card can become a point of contention in any attempt to do simultaneous operations; which is why doing unnecessary operations (such as stopping and starting network services) should be avoided. You can monitor /proc/diskstats to measure the length of the request queue at intervals during boot. Class 4 only refers to write request speed, and has to do with the program running on the CPU of the microSD card and the Flash cell array beyond it. Do your best to avoid writes; avoid unnecessary operations, and use a tmpfs for any file that does not need to be saved. While the FTL is doing a write to the array, it cannot do a read, so a read is queued.

quozl commented 6 years ago

Reviewed to 20c906a. "keep the Rpi running for an hour" may be frustratingly inexact. It will depend on internet speed, microSD card class, and how new the microSD card is (they get slower as they age).

You're targeting Raspberry Pi 3, aren't you? If so, you can provide a limited user interface to indicate progress of the docker setup on the two built-in LEDs.

There's a green LED and a red LED. These can be changed from their default purpose to some other purpose. For example on a Raspberry Pi 3 to be used in complete darkness, my rc.local ends with;

# turn off the lights
echo default-on > /sys/class/leds/led0/trigger
echo default-on > /sys/class/leds/led1/trigger

echo oneshot > /sys/class/leds/led0/trigger
echo oneshot > /sys/class/leds/led1/trigger

You can cat the trigger file to find the options, and read the kernel documentation for the LED class driver for more details on the option formats. You can communicate state using different blink rates;

You should experiment to find something appropriate.

Hope that helps!

amanharitsh123 commented 6 years ago

@quozl Thanks a lot for such a great idea to use LEDs. I would like to inform you that , rpi image is not using internet for anything. All the docker packages and images are already added in the image , docker will only load those images and will make containers.

quozl commented 6 years ago

Oh! Why not make docker load those images and make containers before writing to the final image?

amanharitsh123 commented 6 years ago

@quozl I was having trouble executing them in chroot environment :\

quozl commented 6 years ago

Best to resolve that trouble. qemu should be used to execute not only in the chroot, but in a processor environment that matches the installed binaries.

amanharitsh123 commented 6 years ago

This https://github.com/drtyhlpr/rpi23-gen-image script has a parameter to add a directory which can contain scripts that should be run inside chroot . I think that will work , what do you think?

quozl commented 6 years ago

I'm not trying it for you. You should experiment. :grin: Yes, you can add custom scripts, as you have already done. Read and understand the existing scripts. bootstrap.d/11-apt.sh for example installs packages in the context of both chroot and qemu.

If there was a way to make a .deb file with what you need, then the debian/postinst script could do everything needed during 11-apt.sh.

amanharitsh123 commented 6 years ago

Thanks a lot for the suggestions :) .

On Tue, Jun 12, 2018, 2:12 PM James Cameron notifications@github.com wrote:

I'm not trying it for you. You should experiment. 😁 Yes, you can add custom scripts, as you have already done. Read and understand the existing scripts. bootstrap.d/11-apt.sh for example installs packages in the context of both chroot and qemu.

If there was a way to make a .deb file with what you need, then the debian/postinst script could do everything needed during 11-apt.sh.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amanharitsh123/sugarizer-school-box/pull/6#issuecomment-396513218, or mute the thread https://github.com/notifications/unsubscribe-auth/ARKnBKOJ0hGQT-x-JZr9rT2SeKXEAbqzks5t738OgaJpZM4UhmWP .

amanharitsh123 commented 6 years ago

@quozl I think making the led to blink to show docker install progress is unnecessary as during the docker load , the green led is running almost continuously because there is heavy load on sdcard. We can mention this in the readme , For ex. Reboot the Rpi after green light turns off.

quozl commented 6 years ago

Your 5a9d701 removed the ap command after the ifconfig. Perhaps you didn't intend that.

Your 5a9d701 shows a need for configuration variables, so that the SSID and passphrase can be set in one place rather than having to be changed in two places.

Your 0b0fbac does delete all lines containing bash in rc.local. Perhaps you didn't intend that.

It is difficult to keep track of the transitions with "self-modifying code", and this is another justification for using filesystem markers instead, for example;

#!/bin/bash -e
[ -e /var/lib/sugarizer-school-box-setup-done ] && exit 0
# ... do the setup steps ...
touch /var/lib/sugarizer-school-box-setup-done
exit 0

Paraphrasing; only do the setup steps if the marker file is missing, then create the empty marker file. On next reboot, the conditional statement will be true and an early exit taken. This also means that if the device loses power or fails during the setup steps, they should be repeated next time.

That said, it is best to work toward completing all setup steps before writing the image.

amanharitsh123 commented 6 years ago

@quozl I have added script for status led and I am experimenting on optimization part. PS: Till now the image works , shall I merge this PR?

quozl commented 6 years ago

Reviewed to 287dd34.

Merge whenever you like.

amanharitsh123 commented 6 years ago

Everything seems to work perfectly now , Merging the PR.