source_id
int64 1
4.64M
| question
stringlengths 0
28.4k
| response
stringlengths 0
28.8k
| metadata
dict |
---|---|---|---|
42,735 | I am looking to document a hardware project my company is putting together. It consists of a Raspberry Pi prototype board and some basic circuitry. The tutorials on raspberrypi.org have very nice wiring diagrams; for example, the image below. I would like to generate similar-looking diagrams for my documentation. Does anybody know what software they use to generate these images and if I can use it for my own projects? | Assuming here you want to create similar images to what Raspberrypi.org provides (your question asks how the images are made, but you do not provide a reason why you want to know this): You can create similar diagrams using the Fritzing open source circuit design software, downloadable at http://fritzing.org/home/ . Output looks like this: You can then turn these circuits into PCB designs, and even order your PCB printed right from Fritzing itself. Outputs generated are compatible with what most PCB service need as inputs. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/42735",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/32585/"
]
} |
42,749 | Which Raspberry Pi OS images support ENC28J60 Ethernet adapter natively? If none, how can this be installed via the command line and on which OS image? | Assuming here you want to create similar images to what Raspberrypi.org provides (your question asks how the images are made, but you do not provide a reason why you want to know this): You can create similar diagrams using the Fritzing open source circuit design software, downloadable at http://fritzing.org/home/ . Output looks like this: You can then turn these circuits into PCB designs, and even order your PCB printed right from Fritzing itself. Outputs generated are compatible with what most PCB service need as inputs. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/42749",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/5424/"
]
} |
43,285 | I've seen the announcement of the new Raspberry 3 but didn't find any info regarding power consumption and heating. A 1.2 Ghz 64-bit CPU is great but does it draw a lot more power? Shall heat be an issue with small cases with the Rpi3? I've read that 2.5A are now needed but I've read contradictory infos on the subject: that 2.5A is only if you plan to run power-hungry USB devices. So how much more power does this draw and is it a concern at all? | There's a short piece that includes Pi 3 benchmarks over at the PiMoroni blog . All of the benchmarks below were carried out with just a USB keyboard
and mouse connected with power supplied from the official Raspberry Pi
Power Supply, with the exception of the WiFi dongle test in which the
USB WiFi dongle was also connected. The Pis were naked, i.e. not in a
Pibow, except for the onboard WiFi in Pibow test. ... The benchmark we used here was Sysbench, computing primes up to
20,000. This is a heavily CPU bound test and, as such, ideal for
comparing the [Pi Zero, Pi 2 and Pi 3] SoCs without side-effects from the memory or GPU. ... Current was measured with an inline USB current and voltage meter. The built-in Wireless LAN and Bluetooth and the more powerful
processor mean that the Raspberry Pi 3 draws about twice the current
of its predecessor when under heavy CPU load (750mA vs 360mA). Update ...and there's a second, similarly short, piece on Pi 3 benchmarks on the MagPi site : You can’t get extra performance without a few sacrifices. The Pi 3
draws the most power of the test group, but its extra performance
means it spends more time at idle. Those looking for maximum battery
life should look at the Model A+ or the Pi Zero as an alternative. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/43285",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/42135/"
]
} |
43,306 | I was wondering if the built-in Wi-Fi supports 5 GHz networks? Will it need an external antenna to be attached to work properly? | The network module is a a BCM43438. I'm having trouble finding a source I fully trust, but from a cursory view, it looks like it only supports 2.4 GHz. Since the Raspberry Pi foundation doesn't specify, it'd be normal to assume a lack of 5 GHz. An image on raspi.tv displays a very compact antenna. Reception with the default antenna may not be stellar, but we won't really know until it starts getting into reviewers' hands. Edit : As @EDP has pointed out, there appears to be only one Wi-Fi antenna. This further implies that there is only support for 2.4 GHz. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/43306",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/42258/"
]
} |
43,312 | Makezine's writeup on the Pi 3 this morning included a somewhat tantalising section: The other interesting thing on the back of the board, right next to
the wireless radio chip, is something that looks like an unpopulated
UFL antenna, labelled J13 on the silk screen. You can just seen the
board’s antenna in the image above on the flip side of the board
directly below the unpopulated contacts. While we’re not going to get any support from the Foundation — it
would break the terms of their FCC certification to document it — I’m
looking forward to the first hack to add a cantenna to the Raspberry
Pi either by desoldering the on-board antenna, or making use of those
unpopulated pads on the back of the board. Cheap long range Wi-Fi is
just a Pringle’s can away. Does it sound plausible that a long-range antenna might be connected to the J13 pads shown in the above image? Are similar kludges available on other small single-board computers, and if so what kind of performance might be expected? | Yes, it can be done, but beware of violating FCC. Details here: External antenna modifications for the Raspberry Pi 3 | {
"source": [
"https://raspberrypi.stackexchange.com/questions/43312",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/32756/"
]
} |
43,720 | Got a Pi 3 which will always use ethernet, so trying to figure out how to disable the WiFi such that it does not even turn on after a reboot. If I do an ifconfig I see the wlan0 device. I can do ifconfig wlan0 down but it will come back up again after a reboot. I tried commenting out anything about wlan0 (and wlan1 ) in /etc/network/interfaces but that has not made a difference. eth0 is not commented out so it can be used. | To completely disable the onboard WiFi from the firmware on the Pi3 / Pi4, add dtoverlay=disable-wifi in /boot/config.txt . This is documented here . Please be sure to use an up to date firmware, this feature was added in January 2017 . There is also an overlay for disabling onboard bluetooth : disable-bt .
If you want to disable both wifi and bluetooth, you need to add these 2 lines : dtoverlay=disable-wifi
dtoverlay=disable-bt NOTE : If you are using an old 'Pi3 only' firmware, you need to prefix the overlay name with pi3- . See this issue | {
"source": [
"https://raspberrypi.stackexchange.com/questions/43720",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/42752/"
]
} |
43,921 | In this page , the official RPi3 announcement states: You’ll need a recent NOOBS or Raspbian image from our downloads page. At launch, we are using the same 32-bit Raspbian userland that we use on other Raspberry Pi devices; over the next few months we will investigate whether there is value in moving to 64-bit mode. My question is, given that the processor is 64 bits, isn't it obvious that running the OS in 64 bits will be better in every way? What am I missing? | given that the processor is 64 bits, isn't it obvious that running the OS in 64 bits will be better in every way? No actually, it's not. In some ways, running a 64 bit operating system could deteriorate the Raspberry Pi's performance. Benefits of 64 bit : The two primary benefits of using a 64 bit processor/operating system is that the device can handle more than 4 GB of RAM, and natively handle integers larger than 2^32 without the need for a bignum library. At the time of writing the Raspberry Pi doesn't have more than 4 GB of RAM (Note: as of Aug. 2020, RPi 4 has from 2 to 8 GB of RAM). At a 1 GB of RAM, you've completely lost the first of the two primary benefits. As for the second benefit, what percentage of people are actually using enough giant numbers that it makes sense for the foundation to support a whole second operating system? As is, the RPi can use huge numbers through software methods, but it seems like if you're going to be consistently in that realm, you need to be using better hardware anyway. Problems with 64 bit : The ability to store a larger number isn't granted by magic. Rather, the size of memory objects needs to be increased. In C (and C++) this means changing an int to int64_t . This isn't done automatically, hence the comments about the foundation not wanting to maintain two branches. Additionally, many applications simply don't provide a benefit (for most users) when run in 64 bit mode. Notice that most web browsers, MS Office, and a whole host of other popular software is all still shipped and maintained in a 32 bit manner. Sure you can get your hands on an 64 bit release of MS Office, but it's rarely used. If the application/operating system is written to take advantage of a 64 bit architecture, your application is going to use more memory, simply because variables and pointers are taking up more space. Usually this is a relatively small trade off for machines that will benefit from the perks. In our case, we have very few perks, and very little RAM. Also of note : Just because you're running on a 64 bit machine, doesn't mean the application isn't running as 32 bit. Windows makes this very clear by having two different install paths, C:\Program Files and C:\Program Files (x86) . So, will the foundation likely provide 64 bit support? : We're back at the same point of, "Some people may see benefit, but most will not.". You'll certainly see other projects offering 64 bit builds, but unless the foundation gets a lot of undeserved (imo) flack, they probably won't and shouldn't (imo). Creating and maintaining a separate 64 bit branch isn't a small endeavor, and honestly, just doesn't seem worth it. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/43921",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/33176/"
]
} |
45,198 | I'm setting up a Raspberry Pi for the first time, and have been SSHing into it on a Mac on the same network like so: ssh [email protected] However on my Windows 10 box (also on the same network) this hostname does not resolve. I've tried ipconfig /flushdns , nslookup raspberrypi.local and similar commands to get my Windows machine to see the Raspberry Pi but to no avail. Since it's working on my Mac it doesn't seem like a router issue. What can I do to connect to my Pi by hostname on Windows? | How To Geek has a good article that covers this issue. In a nutshell .local domains are self-reported by each host (via Multicast DNS ), and other machines on the network have to listen for them. Windows comes with such a service ( LLMNR ) however it's non-standard and therefore doesn't work terribly well. Instead you should install Apple's Bonjour service ( install link ). Once Bonjour is installed you'll be able to connect to your Pi on Windows via .local hostnames. Modern Raspbian versions should come with Avahi to provide mDNS. If it's not working make sure avahi-daemon is installed and running on your Pi; if it's not run the following to install it: sudo apt-get install avahi-daemon | {
"source": [
"https://raspberrypi.stackexchange.com/questions/45198",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/44129/"
]
} |
45,570 | My Pi3 serial console produces rubbish and fails to respond to the keyboard. | This answer is still correct, and explains in more detail the nature of the changes, but most users of current Raspbian should just run sudo raspi-config Select Interfacing Options / Serial then specify if you want a Serial console (probably no) then if you want the Serial Port hardware enabled (probably yes). Then use /dev/serial0 in any code which accesses the Serial Port. The BCM2837 on the Raspberry Pi3 , Pi3B+, Pi3A+, PiZeroW has 2 UARTs (as did its predecessors), however to support the Bluetooth functionality the fully featured PL011 UART was moved from the header pins to the Bluetooth chip and the mini UART made available on header pins 8 & 10. (The BCM2711 on the Pi4 has additional UARTs, but the same 2 UARTs as BCM2837 are used for default serial on pins 8 & 10 and Bluetooth.) This has a number of consequences for users of the serial interface. The /dev/ttyAMA0 previously used to access the UART now connects to Bluetooth. The miniUART is now available on /dev/ttyS0 . In the latest operating system software there is a /dev/serial0 which selects the appropriate device so you can replace /dev/ttyAMA0 with /dev/serial0 and use the same software on the Pi3 and earlier models. Unfortunately there are a number of other consequences:- The mini UART is a secondary low throughput UART
intended to be used as a console.
The mini Uart has the following features:
• 7 or 8 bit operation.
• 1 start and 1 stop bit.
• No parities.
• Break generation.
• 8 symbols deep FIFOs for receive and transmit.
• SW controlled RTS, SW readable CTS.
• Auto flow control with programmable FIFO level.
• 16550 like registers.
• Baudrate derived from system clock. There is no support for parity and the throughput is limited, but the latter should not affect most uses. There is one killer feature "Baudrate derived from system clock" which makes the miniUART useless as the this clock can change dynamically e.g. if the system goes into reduced power or in low power mode. Modifying the /boot/config.txt removes this dependency by adding the following line at the end:- core_freq=250 This fixes the problem and appears to have little impact. The SPI clock frequency and ARM Timer are also dependent on the system clock. For some bizarre reason the default for Pi3 using the latest 4.4.9 kernel is to DISABLE UART. To enable it you need to change enable_uart=1 in /boot/config.txt . (This also fixes the core_freq so this is no longer necessary.) Finally if you don't use Bluetooth (or have undemanding uses) it is possible to swap the ports back in Device Tree. There is a miniuart-bt and disable-bt module which are described in /boot/overlays/README . | {
"source": [
"https://raspberrypi.stackexchange.com/questions/45570",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/8697/"
]
} |
45,914 | I'm seeing the login screen every time my pi boots up. At first it didn't need any password but after 3-4 boots, pi asks for a password. When I write the password displays the same screen again. I don't know what to do now :/ I'm using Raspbian on Raspberry Pi 3. Haven't installed tightvncserver as I saw other questions here. Screenshot of the screen below. I tried logging in from command line. I press Ctrl+Alt+F6 to get into command line and login from there. After login I write startx , the screen turns black, and then it's showing the error: xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error | It looks like your X server is working fine, but either your login manager or your desktop environment are failing to run properly (the former is supposed to ask for a password, then start the latter for you). How to investigate Since you can login via command line, you can easily access important log files which you should check for error messages. Login manager (I assume lightdm ) logs usually live in /var/log/lightdm/ , desktop environments should also keep their log somewhere in /var/log/ . Check man to find out. Also try starting your desktop environment manually from command line (e.g. if you use LXDE run startlxde ) and check the output for eventual error messages. How to fix Without knowing what exactly the problem is, here are some actions which might help: reset permissions on your home folder: sudo chown -R pi /home/pi . (Specifically, the .Xauthority file may have the incorrect permissions. In this case, you may only need sudo chown pi:pi .Xauthority to correct the issue.) reinstall your login manager and desktop environment. Use dpkg --purge to remove packages completely, including configuration files (you might want to back up files you have modified), then reinstall the packages back. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/45914",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/41986/"
]
} |
46,225 | Is there a way to adjust the brightness of the official touchscreen display? I couldn't find a definite answer. I'm running the latest release of Raspbian Jessie. | The driver for the screen provides an interface through /sys/ . To turn the screen on you can use the command: echo 0 > /sys/class/backlight/rpi_backlight/bl_power and to turn it off: echo 1 > /sys/class/backlight/rpi_backlight/bl_power the brightness can be adjusted using: echo n > /sys/class/backlight/rpi_backlight/brightness where n is some value between 0 and 255. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/46225",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/37834/"
]
} |
46,231 | How do I boot raspberry pi 3 with noobs installed on it. Steps I have done so far. Got NOOBS from the RPi downloads. Samsung EVO 64gb micoSDXC class 10 Formatted the SD card with SDformatter from SD association SD card File system exFAT Copied NOOBS from ZIP to the SD card Loaded SD card into raspberry pi connected 5v - my phones charger cable. connected to the monitor All i can see is blank screen Possible issues that may have happened. I connected my HDMI to a DVI monitor. I tested with my laptop it connects. The HDMI to DVI works when connected to my laptop. Could be fault on SD card format. | The driver for the screen provides an interface through /sys/ . To turn the screen on you can use the command: echo 0 > /sys/class/backlight/rpi_backlight/bl_power and to turn it off: echo 1 > /sys/class/backlight/rpi_backlight/bl_power the brightness can be adjusted using: echo n > /sys/class/backlight/rpi_backlight/brightness where n is some value between 0 and 255. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/46231",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/45393/"
]
} |
46,610 | Is it possible to add RAM to a Raspberry Pi? | No. There is no method by which RAM can be added to the Pi. See this discussion on the raspberrypi.org forums for more details, but basically the RAM and CPU are inextricably, inaccessibly connected. There is no physical method by which RAM could usefully be added, unless you want to start acid stripping the CPU chip, getting your microscope out and tracking down a micrometer scale soldering iron. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/46610",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/45786/"
]
} |
46,765 | I know for a long time that people should NOT put more than 3.3V on the GPIO pins. They also give out 3.3V when high. I did some research and it seems no one really bothered asking. Almost all of them talk about the maximum current. If I am supplying the Pi with 5V, why are the GPIO pins not 5V tolerant? Arduino pins more or less follow the input (or V CC ) voltage. If it's a 5V model, the pins use 5V. If it's a 3.3V model, it uses 3.3V. Anything above those would more or less fry it. I should probably ask Broadcom about this. | The ATMega chips specify Operating Voltage: ̶ 1.8 - 5.5V . If you read deeper the operating speed is dependent on voltage. They work at 3.3V but you have to limit the clock speed. The Arduino team presumably chose 5V because of the ready availability of systems which use this (a legacy of TTL ). The SOC used on Pi run on 3.3V (and also require a couple of lower voltages). These are orders of magnitude more complex than the ATMega and run at considerably higher speeds (~1GHz vs 16MHz). Like most complex systems running at lower voltage allows higher speed operation at lower power consumption (and thus heat). I suspect that the processor part and GPU run on the 1.8V and 1.2V supply and the 3.3V is for the peripherals. The SD Card also runs at 3.3V. The Pi (especially the later models) have complex power converters which supply the many voltages needed at high currents. The 5V is needed because this is the USB standard (and the ready availability of suitable power supplies). | {
"source": [
"https://raspberrypi.stackexchange.com/questions/46765",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/24224/"
]
} |
47,708 | I am looking for a way to configure the Raspberry Pi 3 as bluetooth speaker using Raspbian Jessie.
What I mean by as bluetooth speaker is use it to receive audio stream via bluetooth using A2DP and play it via speakers connected to the Raspberry Pi via the audio jack, the HDMI port or USB audio adapter. Different tutorials are available online but are quite outdated and most of them does not work anymore. | I have been on this project after while (to help my friend doing their paper for graduating) and find the online project doing just fine (although the pi processing the audio is quite lagging the pi, and voltage drop make it freeze as the only way to make it reboot is to unplugged the power cable). This is the step that I've been working on and it works on raspberry pi 3. 1. Download the required package This project depend on pulseaudio so grab it and installing by typing: sudo apt-get update && sudo apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2 bluez-tools udev i rather update the firmware of raspberry first before installing them because i have problem with rpi-bluetooth package so i do: sudo rpi-update and make it install and advance to next step. 2. Edit Configuration and applied it First add pi username to the group pulseaudio with sudo usermod -a -G lp pi create new config under /etc/bluetooth/audio.conf using text editor and add the following line [General]:
Enable=Source,Sink,Media,Socket edit file /etc/bluetooth/main.conf using your preferred text editor (I'm using nano). Set Bluetooth Class, Modify the following line to: Class = 0x00041C 0x000041C means that the rpi bluetooth support A2DP protocol. change /etc/pulse/daemon.conf add / modify (don't forget to check the code thoroughly before adding them), and change resample-method = trivial you can using any method you like, i personally using speex-float-3 for reference you can see this link start pulseaudio service with: pulseaudio -D we are going to use ragusa87 script to automate the bluetooth source to audio sink. First please add new configuration to udev init.d by editing file /etc/udev/rules.d/99-input.rules and add this to the file SUBSYSTEM="input", GROUP="input", MODE="0660"
KERNEL=="input[0-9]*", RUN+="/usr/lib/udev/bluetooth" add folder udev to /usr/lib by using mkdir sudo mkdir /usr/lib/udev && cd /usr/lib/udev and add this to the file bluetooth (credits ragusa87) #!/bin/bash
# This script is called by udev when you link a bluetooth device with your computer
# It's called to add or remove the device from pulseaudio
#
#
# Output to this file
LOGFILE="/var/log/bluetooth_dev"
# Name of the local sink in this computer
# You can get it by calling : pactl list short sinks
# AUDIOSINK="alsa_output.platform-bcm2835_AUD0.0.analog-stereo"
AUDIOSINK="alsa_output.0.analog-stereo.monitor"
# User used to execute pulseaudio, an active session must be open to avoid errors
USER="pi"
# Audio Output for raspberry-pi
# 0=auto, 1=headphones, 2=hdmi.
AUDIO_OUTPUT=1
# If on, this computer is not discovearable when an audio device is connected
# 0=off, 1=on
ENABLE_BT_DISCOVER=1
echo "For output see $LOGFILE"
## This function add the pulseaudio loopback interface from source to sink
## The source is set by the bluetooth mac address using XX_XX_XX_XX_XX_XX format.
## param: XX_XX_XX_XX_XX_XX
## return 0 on success
add_from_mac(){
if [ -z "$1" ] # zero params
then
echo "Mac not found" >> $LOGFILE
else
mac=$1 # Mac is parameter-1
# Setting source name
bluez_dev=bluez_source.$mac
echo "bluez source: $mac" >> $LOGFILE
# This script is called early, we just wait to be sure that pulseaudio discovered the device
sleep 1
# Very that the source is present
CONFIRM=`sudo -u pi pactl list short | grep $bluez_dev`
if [ ! -z "$CONFIRM" ]
then
echo "Adding the loopback interface: $bluez_dev" >> $LOGFILE
echo "sudo -u $USER pactl load-module module-loopback source=$bluez_dev sink=$AUDIOSINK rate=44100 adjust_time=0" >> $LOGFILE
# This command route audio from bluetooth source to the local sink..
# it's the main goal of this script
sudo -u $USER pactl load-module module-loopback source=$bluez_dev sink=$AUDIOSINK rate=44100 adjust_time=0 >> $LOGFILE
return $?
else
echo "Unable to find a bluetooth device compatible with pulsaudio using the following device: $bluez_dev" >> $LOGFILE
return -1
fi
fi
}
## This function set volume to maximum and choose the right output
## return 0 on success
volume_max(){
# Set the audio OUTPUT on raspberry pi
# amixer cset numid=3 <n>
# where n is 0=auto, 1=headphones, 2=hdmi.
amixer cset numid=3 $AUDIO_OUTPUT >> $LOGFILE
# Set volume level to 100 percent
amixer set Master 100% >> $LOGFILE
pacmd set-sink-volume 0 65537 >> $LOGFILE
return $?
}
## This function will detect the bluetooth mac address from input device and configure it.
## Lots of devices are seen as input devices. But Mac OS X is not detected as input
## return 0 on success
detect_mac_from_input(){
ERRORCODE=-1
echo "Detecting mac from input devices" >> $LOGFILE
for dev in $(find /sys/devices/virtual/input/ -name input*)
do
if [ -f "$dev/name" ]
then
mac=$(cat "$dev/name" | sed 's/:/_/g')
add_from_mac $mac
# Endfor if the command is successfull
ERRORCODE=$?
if [ $ERRORCODE -eq 0]; then
return 0
fi
fi
done
# Error
return $ERRORCODE
}
## This function will detect the bt mac address from dev-path and configure it.
## Devpath is set by udev on device link
## return 0 on success
detect_mac_from_devpath(){
ERRORCODE=-1
if [ ! -z "$DEVPATH" ]; then
echo "Detecting mac from DEVPATH" >> $LOGFILE
for dev in $(find /sys$DEVPATH -name address)
do
mac=$(cat "$dev" | sed 's/:/_/g')
add_from_mac $mac
# Endfor if the command is successfull
ERRORCODE=$?
if [ $ERRORCODE -eq 0]; then
return 0
fi
done
return $ERRORCODE;
else
echo "DEVPATH not set, wrong bluetooth device? " >> $LOGFILE
return -2
fi
return $ERRORCODE
}
## Detecting if an action is set
if [ -z "$ACTION" ]; then
echo "The script must be called from udev." >> $LOGFILE
exit -1;
fi
## Getting the action
ACTION=$(expr "$ACTION" : "\([a-zA-Z]\+\).*")
# Switch case
case "$ACTION" in
"add")
# Turn off bluetooth discovery before connecting existing BT device to audio
if [ $ENABLE_BT_DISCOVER -eq 1]; then
echo "Stet computer as hidden" >> $LOGFILE
hciconfig hci0 noscan
fi
# Turn volume to max
volume_max
# Detect BT Mac Address from input devices
detect_mac_from_input
OK=$?
# Detect BT Mac address from device path on a bluetooth event
if [ $OK != 0 ]; then
if [ "$SUBSYSTEM" == "bluetooth" ]; then
detect_mac_from_devpath
OK=$?
fi
fi
# Check if the add was successfull, otherwise display all available sources
if [ $OK != 0 ]; then
echo "Your bluetooth device is not detected !" >> $LOGFILE
echo "Available sources are:" >> $LOGFILE
sudo -u $USER pactl list short sources >> $LOGFILE
else
echo "Device successfully added " >> $LOGFILE
fi
;;
"remove")
# Turn on bluetooth discovery if device disconnects
if [ $ENABLE_BT_DISCOVER -eq 1]; then
echo "Set computer as visible" >> $LOGFILE
sudo hciconfig hci0 piscan
fi
echo "Removed" >> $LOGFILE
;;
#
*)
echo "Unsuported action $action" >> $LOGFILE
;;
esac
echo "--" >> $LOGFILE PLEASE NOTE that your AUDIOSINK might different from mine, check it before using pactl list short sinks make the script executable by inputting this code chmod 777 bluetooth plug in headset to test whether the audio jack working and test with aplay /usr/share/sounds/alsa/Front_Center.wav or you can set the default audio routing with sudo amixer cset numid=3 n where n could be: 0 = auto 1 = jack 2 = hdmi 3. Pair and Connect the audio go to terminal and type bluetoothctl . First activate bluetooth with power on and then agent on , set the default agent that you've been editing before with default-agent , and then set discoverable mode and pair mode on with discoverable on; pairable on . You should see raspberrypi bluetooth on your phone or laptop and you can pair it on the phone by clicking it and touch pair. On the terminal you type y. Back to the terminal, you connect to the phone by type connect xx:xx:xx:xx:xx:xx where xx:xx:xx:xx:xx:x x is you phone bluetooth mac address. and don't forget to trust with trust xx:xx:xx:xx:xx:xx where xx:xx:xx:xx:xx:xx is your phone bluetooth mac address And voila you have bluetooth amplifier (or whatever the name is) by using raspberry. 4. Conclusion after trying and experimenting, i found out the audio quality is low and i rather not using it as the raspberry will be freeze if you using it with the song being streaming to the raspberry. I advice to use UPNP speaker project by using gmediarenderer. The audio is superb and there's no delay and scatter sound and it can play lossless audio file (flac, wav, dll). This is the detailed how to setup it reference: jobpassion's tutorial ; ragusa's script ; related work ; | {
"source": [
"https://raspberrypi.stackexchange.com/questions/47708",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/31277/"
]
} |
48,050 | I need an old Raspbian release, precisely rpi_35_v3_jessie8_kernel_4_1_12.img . On the download page raspberrypi.org I can only find the latest release. Is there any way to get the old release mentioned above? | You can download the historical versions offered by the foundation here | {
"source": [
"https://raspberrypi.stackexchange.com/questions/48050",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/34176/"
]
} |
48,056 | I am trying to login to the raspberrypi as root user via winscp, but it only says "Access denied", same thing for trying to login directly as root on ssh. I have tried loging in as pi and doing sudo passwd root , which results in the console output passwd: Password changed successfully , however I still can't login as root | If you want to login as root using SSH or WinSCP you need to edit the config of SSHD, do this: Login, and edit this file: sudo nano /etc/ssh/sshd_config Find this line: PermitRootLogin without-password Edit: PermitRootLogin yes Close and save file reboot or restart sshd service using: /etc/init.d/ssh restart Set a root password if there isn't one already: sudo passwd root Now you can login as root , but I recommend you using strong password or ssh-keys | {
"source": [
"https://raspberrypi.stackexchange.com/questions/48056",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/47229/"
]
} |
48,307 | I have a pi running the latest release of raspbian and it's connected to the Internet using a wireless USB dongle. What I would like to do, is to share the pi's wifi connection so that any computer connected to the pi using a LAN cable would be able to receive the Internet. I had a look around the Internet but I can't seem to find anything of relevance. I'm familiar with this process on Windows and Mac OS X, but doing this on the pi has just got me stumped. EDIT: I don't know whether this helps anyone but I am connected to the Internet on my pi via wlan0, but I would like to share that Internet connection via eth0. | For Raspbian Jessie From this document : We will use dnsmasq package for this purpose because it is combined
DHCP and DNS server and also easy to configure. If you want something a little more 'heavyweight', you can use the isc-dhcp-server and bind9 packages for DHCP and DNS respectively,
but for our purposes, dnsmasq works just fine. sudo apt-get install dnsmasq We need to configure interfaces. We will assign a static IP address to eth0 which will be used as gateway. Open the interfaces file sudo nano /etc/network/interfaces Edit the eth0 section like this: allow-hotplug eth0
iface eth0 inet static
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255 Next, we will configure dnsmasq . The shipped dnsmasq config file
contains a lot of information on how to use it. So, I will advise to
move it and create a new one. sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf Paste the following into the new file interface=eth0 # Use interface eth0
listen-address=192.168.2.1 # listen on
# Bind to the interface to make sure we aren't sending things
# elsewhere
bind-interfaces
server=8.8.8.8 # Forward DNS requests to Google DNS
domain-needed # Don't forward short names
# Never forward addresses in the non-routed address spaces.
bogus-priv
# Assign IP addresses between 192.168.2.2 and 192.168.2.100 with a
# 12 hour lease time
dhcp-range=192.168.2.2,192.168.2.100,12h Edit the /etc/sysctl.conf file to enable packet forwarding sudo nano /etc/sysctl.conf Remove the # from the beginning of the line containing net.ipv4.ip_forward=1 This will enable packet forwarding on next
reboot. But if you want to try it right now without reboot then do
this. sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" We also need to share RPi’s internet connection with the devices
connected over Wi-Fi. We will configure a NAT between eth0 and wlan0 : sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT However, we need these rules to be applied every time we reboot the
Pi, so run sudo sh -c "iptables-save > /etc/iptables.ipv4.nat" to save the rules to the file /etc/iptables.ipv4.nat . Now we need to
run this after each reboot, so open the /etc/rc.local file with sudo nano /etc/rc.local and just above the line exit 0 , add the
following line: iptables-restore < /etc/iptables.ipv4.nat And that’s all! Now just Reboot your RPi and you will be able to
access Internet sudo reboot Updated for Raspbian Stretch Above configuration won't work in newer version of Raspbian. So, I have created a script for this which make it possible in less pain. Connect to WiFi network using this guide. Download the script from here . Place it at /home/pi/ Open up /etc/xdg/lxsession/LXDE-pi/autostart file sudo nano /etc/xdg/lxsession/LXDE-pi/autostart Add the last line : @lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
sudo bash /home/pi/wifi-to-eth-route.sh Make sure you have given full path to the file. And you're done. Now reboot to see the changes sudo reboot | {
"source": [
"https://raspberrypi.stackexchange.com/questions/48307",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/-1/"
]
} |
49,746 | I used the following command to install Iceweasel. sudo apt-get install iceweasel However, instead of Iceweasel, I get Firefox. Not that I'm complaining much, I love Firefox. If you click on Menu > Internet , there are 2 Firefox logos. One says Firefox ESR, and the other says Iceweasel > Firefox ESR. But I have no idea why it's doing this. Has Iceweasel been discontinued and Firefox linked to the Iceweasel install? | TL;DR: Iceweasel was rebranded back to Firefox in Feb '16. You can no longer install Iceweasel. Background Info Firefox is open source. This means that anyone can freely distribute and modify the source code. However, the laws surrounding the trademark 'Firefox' and the Firefox logo are slightly different. The trademark and logo may only be used with unmodified/official versions of the source code. (This is because Mozilla wants users to have a consistent experience when using 'Firefox') Debian (the Linux distro which Raspbian is based off) has a set of guidelines called the Debian Free Software Guidelines , which determines what software is allowed to be included in Debian. Because the restrictions placed on the logo and trademark were not compatible with the guidelines, the distribution of Firefox to be included in Debian had to be rebranded. After many debates etc, the name Iceweasel was born and Firefox was rebranded. However, in February 2016, Mozilla allowed Debian to use the Firefox trademark and logos in their distributions: Mozilla recognizes that patches applied to Iceweasel/Firefox don't
impact the quality of the product. [...] In case of derivatives of Debian, Firefox branding can be used as long
as the patches applied are in the same category as described above. Hence, Iceweasel was 'un-rebranded' back to Firefox. So why can't I install Iceweasel? Because Iceweasel has been rebranded to Firefox, the Iceweasel package has been discontinued, and instead Firefox is automatically installed. You can no longer install Iceweasel. Further reading Wikipedia article on Firefox Trademark laws Wikipedia article on Mozilla software rebranded by Debian Bug report for renaming Iceweasel to Firefox | {
"source": [
"https://raspberrypi.stackexchange.com/questions/49746",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/46678/"
]
} |
49,752 | I've been trying to setup my HL-L2300D printer. I downloaded the driver from Brother, hooked up the printer via USB, and everything looks like it should work. However, it doesn't print. Here is the system details Raspberry Pi 3 Model B Raspbian GNU/Linux 8 (jessie) CUPS 1.7.5 Brother HL-L2300D Brother Linux driver Everything looks like it should work. The HL-L2300D shows up on the USB port and CUPS website shows everything is good (even PDF printing with CUPS works). I would appreciate any help. | TL;DR: Iceweasel was rebranded back to Firefox in Feb '16. You can no longer install Iceweasel. Background Info Firefox is open source. This means that anyone can freely distribute and modify the source code. However, the laws surrounding the trademark 'Firefox' and the Firefox logo are slightly different. The trademark and logo may only be used with unmodified/official versions of the source code. (This is because Mozilla wants users to have a consistent experience when using 'Firefox') Debian (the Linux distro which Raspbian is based off) has a set of guidelines called the Debian Free Software Guidelines , which determines what software is allowed to be included in Debian. Because the restrictions placed on the logo and trademark were not compatible with the guidelines, the distribution of Firefox to be included in Debian had to be rebranded. After many debates etc, the name Iceweasel was born and Firefox was rebranded. However, in February 2016, Mozilla allowed Debian to use the Firefox trademark and logos in their distributions: Mozilla recognizes that patches applied to Iceweasel/Firefox don't
impact the quality of the product. [...] In case of derivatives of Debian, Firefox branding can be used as long
as the patches applied are in the same category as described above. Hence, Iceweasel was 'un-rebranded' back to Firefox. So why can't I install Iceweasel? Because Iceweasel has been rebranded to Firefox, the Iceweasel package has been discontinued, and instead Firefox is automatically installed. You can no longer install Iceweasel. Further reading Wikipedia article on Firefox Trademark laws Wikipedia article on Mozilla software rebranded by Debian Bug report for renaming Iceweasel to Firefox | {
"source": [
"https://raspberrypi.stackexchange.com/questions/49752",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/47957/"
]
} |
50,345 | Whenever I turn off my pi, I use sudo poweroff , which (in my understanding) is a safe way to stop all processes and shut down. Although sometimes when I'm using the Pi for embedded projects where I'm not always SSHing to the Pi, it often feels like it wastes time getting out my phone or a laptop and connecting to the Pi to power off. Some people I've talked to have said that they just whip the power lead out when they want to shut down, and that they've never noticed any problems with this. So what can go wrong with just unplugging the Pi? Should I start simply unplugging? Note: In this case I'm not too worried about data loss. I save regular backups and the only important data on this Pi is on my GitHub. | I don't make a habit of unplugging the pi in the sense of eschewing shutting them down properly except when I've lost networking on a headless pi, in which case I am usually too lazy to plug in a keyboard, etc. Generally I always check to make sure the green ACT light is not on at that point; for recent models (or firmware?) this will be off when the SD card isn't being accessed. Which is what you want to make sure of. Unless you are writing to it constantly, this should be simple enough; as long as there is a decent amount of headroom in free RAM (say 50-100+ MB, depending on context), then things that are prone to being re-used frequently but aren't actually loaded by a process at any given moment will be in cached in free memory and reloaded from there by the OS, not the real physical medium. This is how all contemporary general purpose operating systems operate. If the pi is making use of the SD card, here's what the risk is minimally : the filesystem on the card is out of sync with the in memory state. Normally, this is probably not a big problem; for starters, the filesystem journalling used by default on most pis might be a defense against it, as is the fsck which should be applied automatically at boot if the filesystem was not cleanly unmounted. I'll explain why I say "might" and not "is" shortly, because in this context I think it often might not . As far as I know, I've never ended up with filesystem corruption or data loss when pulling the plug, which I may have done a hundred or more times over the years. However, again, I don't do it habitually. If you do it several times a day you may eventually run into whatever the statistical risk level is, and there is a potentially nasty catch involved. Here's the PROBLEM: Recently it occurred to me that there is an issue with SD cards which OS/filesystem mechanisms may be powerless against, and which may explain why some people seem to have persistent problems with fs corruption, particularly those who get into yanking the cord regardless of system state -- e.g., recently someone here claimed to be running compute modules where corruption left the systems unbootable in ~1/40 such power cuts. In abstract terms, without taking the nature of SD cards into account , that should not happen even if the system is busy, because what is most likely to end up corrupted is non-critical stuff that's being written, not any system software that is effectively read-only and only gets altered during updates. It could happen if bits are being juggled around, and so the filesystem meta information which stores where various bits are is corrupted. Again, however, journalling and fsck should be capable of dealing with this, which does require the kernel to boot, but the kernel on the pi is on a separate boot partition which might as well be unmounted during use (except for when updating) because none of it is used after the system has booted. Meaning the information about the partition should be, effectively, incorruptible, even when it is left mounted. But... SD cards are a black box to the operating system. There is no way out of that. While there are specific drivers for SD card controllers that are part of the computer's hardware (on the pi, this is part of the SoC) there is no such thing as a driver for different, specific makes and models of card. And yet, they all have microcontrollers inside them that may operate in very different ways. 1. This is what makes the card a black box; it interacts with the operating system via a standardized SD protocol, and that is the last point of control the OS has. One of the things SD cards and other solid state media do which is different from traditional spinning disks is use opaque virtual addressing; they do not store information physically in the sequences the operating system perceives. This is mostly a good thing, or else we might really need different drivers for different brands of cards, etc., and it permits cards to (opaquely) implement wear leveling , which significantly prolongs their lifespan. Another thing they rely on is relatively large "erase blocks"; when data in a block needs to be changed, the entire block is erased and re-written. Filesystems also do this kind of thing as a matter of course, but note that is at a system software level, and problems resulting from this are exactly the kinds of problems journalling and fsck deal with. The crux of the more insurmountable problem is that the scale filesystems do that on is usually much smaller than the scale SD cards do it on. If it weren't, you'd end up wasting a good deal of storage space, because a filesystem block can only contain data from one file. If the block is 2 MB and there are only a few kB of data, the rest is wasted. So filesystem blocks tend to range from 1/2 KiB to 4 KiB. It is fairly obvious SD cards don't do that, and in fact, couldn't, because the controller in an SD card has no awareness of boundaries such as "file", "filesystem", or even "device partition". It just deals with the chunks of data the OS wants, via an opaque layer from inside a black box where anything could be happening on a physical level. One of the reasons it is obvious (aside from the premise cards "couldn't do that in the first place") is those blocks are frequently quite large, yet the cards seem to do a decent job of utilizing all space. An erase block may be several megabytes in size. What's more, the details are proprietary. While there may be mechanisms by which the OS can request the erase block size from the card, the card does not have to provide this, it can lie about it, and it would become absurd if the OS tried to leverage it. It follows from this that since: The SD card controller has no concept of what data "rightfully" belongs where in the sense of coherent filesystems and parititions, and, The SD card is a black box into which the OS cannot truly see, Then what is in a given 1 MB erase block, where a card contains several partitions using 4 KiB or smaller filesystem blocks, is bound to be arbitrary once the card has been used enough (and possibly even if it hasn't been used much at all). This is probably true even if you try to force the OS to use larger/corresponding block sizes; they will end up misaligned. So: If the power is cut while the SD card is in the middle of altering a block, that could result in the loss of a fairly large volume of arbitrary data that could be anything from the card. It could be information marked "read-only". It could be information from a partition which isn't even mounted , and, obviously enough, from the mostly unused boot partition. If that happens and the card doesn't have some kind of safeguard system of its own (which some may have, but I am sure most do not), then you could be looking at a FUBAR situation. Journalling will not protect against random MB size corruption which does not even recognize partition boundaries. Or fsck. Or, since the card's hardware is generally proprietary, could anything else except software produced by the card's manufacturer -- presuming that's plausible. I've never heard of such. This would make cards more complicated, more expensive, and more of a hassle to use. Which is not the goal. Put another way, SD cards are not intended to be used reliably this way . They are cheap and very handy but that is the result of a trade-off in the protocol: In general, there is no guarantee of data integrity for anything on the card if you arbitrarily kill the power to it. What can go wrong with just unplugging the Pi? Should I start simply unplugging? Note: In this case I'm not too worried about data loss. It will not physically harm the pi, no, just beware "data loss" could extend to "useless card" which needs to be completely reformatted. However, I'd say the chance of that if you are doing it with the green ACT light off are very low. This may be significant when considering why some specific makes/models of card clearly fair worse than others for some people. Unfortunately, while two cards which are labelled identically may be identical in terms of stated features (size, speed, etc.), manufacturers are not bound to making them truly 100% identical in terms of constituent parts. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/50345",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/42797/"
]
} |
51,052 | I'm attaching a fan to the RPi's original case. I wanted to use a laptop cpu fan. Should I suck the hot air from RPi? or blow cold air inside the case? Btw, there's a heatsink on the Soc and LAN & USB chip. | It doesn't matter. Either way you are moving air one place to the other. Cooling is about volume of air, not the direction of travel (in the sense of "push into" vs. "pull out of", ie. the direction the fan faces). In theory, pulling air out may create negative pressure inside the case which, in theory, may be advantageous to cooling, however, in reality this is not going to happen unless your fan is a jet engine, which will probably have very detrimental side effects on the case and things within. A more pragmatic concern on desktop cases is accumulation of dust inside because of all the moving air. However, by pushing the air in instead of out you can keep the interior clean by including a dust filter on the outside of the fan -- then you just have to vacuum the dust filter occasionally. Trying to use filters the other way around, unless you have some kind of special case, is impossible; if you are blowing air out you will end up sucking it in from some arbitrary crack, gap, or hole and dust will coat components in between there and the output fan. With a pi sized case dust accumulation won't add up to much hassle, of course. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/51052",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/49253/"
]
} |
51,410 | When doing an apt-get upgrade on my RPi 3, many lines of output show up like this: Adding 'diversion of /boot/bcm2708-rpi-b-plus.dtb to /usr/share/rpikernelhack/bcm2708-rpi-b-plus.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2708-rpi-b.dtb to /usr/share/rpikernelhack/bcm2708-rpi-b.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2708-rpi-cm.dtb to /usr/share/rpikernelhack/bcm2708-rpi-cm.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2709-rpi-2-b.dtb to /usr/share/rpikernelhack/bcm2709-rpi-2-b.dtb by rpikernelhack'
Adding 'diversion of /boot/bcm2710-rpi-3-b.dtb to /usr/share/rpikernelhack/bcm2710-rpi-3-b.dtb by rpikernelhack'
Adding 'diversion of /boot/kernel.img to /usr/share/rpikernelhack/kernel.img by rpikernelhack'
Adding 'diversion of /boot/kernel7.img to /usr/share/rpikernelhack/kernel7.img by rpikernelhack'
Adding 'diversion of /boot/COPYING.linux to /usr/share/rpikernelhack/COPYING.linux by rpikernelhack'
...
...
... I'm not very educated on Linux kernel features and this looks pretty specific to the RPi. My question is: What is all this? What is a 'diversion'? What do all these files (as a group) that are being referenced, actually do? What is 'rpikernelhack'? I did a little bit of googling and couldn't easily find anything interesting. I figure I'm not the only one who's curious about this so I hope this is an appropriate question! | "rpikernelhack" is a fake package name and a directory name used as part of a hack (in the sense of a dirty but expedient solution to a problem) to work around the fact that the Raspberry Pi foundation decided to make /boot a fat32 partition and dpkg does not get on well with fat32. I was the one who initially came up with the idea, though it was refined later by others. dpkg will install new files onto a fat32 partition (spewing some warnings along the way), but if it tries to update an existing file on a fat32 partition it will fail (iirc it tries to make a backup of the old file by creating a hardlink and fat32 doesn't support hardlinks). When people (including me) started trying to make deb packages of Pi kernels and firmware they ran into this problem, a package would install initially but trying to upgrade it would fail, ouch. My workaround was to (ab)use the "diversion" feature in dpkg. This feature was intended to allow files to be diverted so they could be replaced with either locally modified versions or versions from another package, but I was able to use it from the maintainer scripts in such a way that dpkg would perform its installation tasks on a Linux partition and then move the file to its final location at the end. Diversions require you to either specify a "package name" or "local". If you specify a package name then the diversion will affect files owned by all packages except the one you specify (the intent here is to allow a package to divert a file owned by another package and then install its own versions). I also needed a directory to divert the files to. Using the name of the kernel package being installed would have rendered the hack ineffective. Using "local" also seemed wrong, since that is supposed to be reserved for use by the local sysadmin. So I needed a fake package name that was unlikely to conflict with anything. I came up with "rpikernelhack", I also used this same string for the directory name. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/51410",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/33260/"
]
} |
51,615 | There are very many, often contradictory, claims about the power requirements and limitations of the Pi. What are the exact requirements? | Power requirements of the Pi Raspberry Pi Ltd. (Raspberry Pi Ltd.) has recommendations for various models which range from 700mA to 3.0A. These are quite generous, and all models will operate on a decent 1A supply - I can run all my Pi3/Pi3+/Pi4 with WiFi/keyboard/mouse/HDMI from an Apple 5W supply. Extra current may be required by USB peripherals and the recommended supplies make allowance for these. Power sources SHOULD provide 5±0.25V and often list a current rating. This is the MAXIMUM current that can be safely drawn without causing the output to drop below its rated voltage. (Of course, very many supplies do not actually meet their published ratings, including many sold by Pi retailers. I have tested a number of PSU (with a dummy load) and have yet to find one which actually delivers the rated voltage at the rated current, except for the Apple 5W iPad Power Adapter.) Many users worry that that they may "supply too much power" by using a higher rated supply. The Pi will only draw as much current as it requires and can not use more then 2.5A (Pi3) or 2A (Pi2/B+) as this is limited by a fuse, so there is no benefit in a higher rated supply. (Earlier models had a smaller polyfuse - probably 1.1A.) The newer Pi(3/2/B+) have a voltage monitor chip (APX803) which triggers at 4.63±0.07V . The Pi3B+, Pi3A+, Pi4B uses a MxL7704 PMIC chip to manage power, which has the same nominal trigger point. (MxL7704 Data Sheet says
Voltage rising >4.59 4.63 <4.7
Voltage falling >4.52 4.57 <4.65
.) This controls the Red Power LED . The MxL7704 PMIC Data states Input voltage range: 4.0V to 5.5V. If the Red Power LED is not illuminated this means the supply voltage is inadequate. (The newer Pi have a well engineered power circuit, and may continue to function even if the input voltage is below spec; the same may not be true of peripherals). The GUI had an rainbow indicator (replaced by a lightning bolt ) which comes up in the top right if the voltage is inadequate. This has a 3 second timer, and may display even if the LED appears to be lit. NOTE the Red Power LED on the Pi3B+, Pi3A+, Pi4B only functions if the SD Card/USB key has up to date firmware because it is controlled by software - it is meaningless otherwise. You should be wary of cheap USB supplies. Many of these have very poor voltage regulation. Many modern smartphones are designed to draw more current than the normal USB 500mA max. Phone manufacturers often supply higher current chargers, either by non-standard means or by adopting the new USB Charger spec, which permits higher currents, but permits voltage to drop to 3.6V. These are OK for charging smartphones, but NOT for voltage sensitive devices like the Pi. They may appear to work OK for a lightly loaded Pi, but may not if many peripherals are connected. NOTE If you are having problems (low voltage indicator, or peripherals which are unreliable) This does NOT mean you need a higher current/amp(sic) rating. It is extremely unlikely your supply cannot supply the current - it just cannot supply the required current while maintaining the required voltage. No matter how good your Power Supply if you use poor quality cables to connect to the Pi you will have problems. Many (the majority?) of μUSB cables are designed to carry data, and have very thin wiring. This makes the cables thin, light and inexpensive but they are unsuitable for power. To remain in spec there should be less than 0.25V drop which corresponds to loop resistance of 0.25Ω @ 1A. Cables designed for charging smartphones are probably the best bet, and always use the shortest possible cable. Unfortunately there appears to be no source of quality cables with guaranteed specifications (I have been forced to make my own). I have been unable to source Micro USB plugs in small quantities, but have found many sellers on eBay offering Micro USB 5 Pin Male Plug T Port Socket . You need to supply your own strain relief, but coupled with 23/.011mm speaker cable (suitable up to 1.5m) these provide a good connection. I couple with one of the 5V Switch Power Supply Driver Adapter For LED Strip to power several Pi. How much current can be drawn from the USB ports? The Pi(3/2/B+) USB Current are supplied through a Current-Limited Power Switch (AP2553?) (U13), although this is not shown on the published schematics. Maximum total USB peripheral current draw states the max USB current for Pi(2/B+ or later) is 1200mA. Earlier models claim 500mA. The default for 2/B+ is 600mA which can be doubled by setting max_usb_current=1 in /boot/config.txt . On recent Raspberry Pi OS this is set to 1200mA. The USB hub on the B models does not appear to be compliant to the USB specification and does not limit current. Individual ports can supply in excess of 500 mA independent of negotiation, subject to the overall maximum limit and adequate power supply. How much current can the 3.3V pin on the expansion header supply? The Pi 3.3V rail is widely assumed to provide 50mA, but this is not officially documented for recent Pi models. The original Pi has an on-board linear regulator which was limited, but the B+ and later have a switch mode regulator which can supply more. The regulator chip (which supplies both 3.3V and 1.8V) is rated at 1A.
The MxL7704 PMIC used in the Pi3B+, Pi3A+ and Pi4 is rated at 1.5A. Tests by a member indicate up to 800mA can be used - subject to an adequate power supply. Electrical Specifications of GPIO for best estimates of GPIO limits. How much current can the 5V pins supply? There is no simple answer to this. You can roughly calculate; min of polyfuse rating (2.5A for PI3) and power supply rating, less the current required by the Pi itself ( ~750mA for Pi3 , although this will increase for heavy use), less USB peripheral current, less Camera Module (~250mA if fitted), less HDMI port (~50mA), less Display (if fitted), less 3.3V current supplied to external devices (including GPIO). Can the Pi be powered through the expansion header? There are many good reasons to power through the expansion connector e.g using battery supply or powering multiple Pi from a single supply. There is no risk if you apply proper engineering practices. Indeed the Foundation Hats Master has recommendations and minimum requirements for such connection. "It is possible to power the Pi by supplying 5V through the GPIO (sic) header pins 2,4 and GND. The acceptable input voltage range is 5V ±5%. ⋯ Implement a duplicate power safety diode ⋯ supply 5V at a minimum of 1.3A ⋯ Under no circumstances should a power source be connected to the 3.3V pins." NOTE the Hats Master has been updated for newer models, and includes suggested circuitry. If you are using a Pi Zero the use of a power safety diode is probably superfluous, as the Zero does not have one, or indeed any protection circuitry. Technical details The release of the Pi3B+ has been followed by a description of its Power Circuitry which includes comments on earlier models. The PEN pin (next to RUN) on the J2 header is connected to the Global Enable on the power module. Pulling this low should reduce Pi current to a couple of mA. For those interested in understanding the Pi power configuration see the Raspberry Pi3 Schematic . Schematics for other models are available. This can be a little intimidating, even for those used to these kind of things. There is a rather more readable description of the Raspberry Pi B+ which is similar. The H5V supplies the HDMI power. A brief verbal description:- Power In from the μUSB connector goes through a polyfuse and an ideal diode to provide 5V which is the 5V rail on the expansion header and provides all power to the Pi including the following a dual step-down converter (PAM2306) which provide 3V3 and 1V8 via a MOSFET to 5V_CORE and a Step-Down Converter (RT8088A) which generates the VDD_CORE (nominal 1.2V). This was performed by the SOC in the original Pi. voltage monitor chip (APX803) Power Switch (RT9741) which produces H5V for HDMI NOTE On the B+ and Pi2 the "PWR" LED was connected to a GPIO pin as was the APX803 voltage monitor chip. This let the the Pi detect under-voltage OR control the LED. The MOSFET controlling the Pi3 "PWR" LED is directly connected to the APX803 (which is open drain) so will ALWAYS be off if the voltage is low, but if not it should be possible to pull it low (and turn the LED off) with a program . The latest Raspbian (using kernel 4.9) seems to have restored access to /sys/class/leds/led1 which can be used to control the PWR LED on the Pi3. Recent kernels support vcgencmd get_throttled bit0 indicates under-voltage | {
"source": [
"https://raspberrypi.stackexchange.com/questions/51615",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/8697/"
]
} |
53,127 | I am running Raspbian Jessie on Raspberry PI 2 Model B along with a touchscreen. I just noticed that whenever I use the touchscreen display, mouse pointer also follows my finger tips. I don't want that. I want to be able to permanently hide the mouse pointer whenever I am using the touchscreen and be able to get it back whenever I want the mouse pointer. I keep reading about unclutter program to hide the mouse pointer, but it doesn't totally hide the mouse pointer. As long as you don't touch the screen or move the mouse, the mouse pointer is hidden by the unclutter program, but when you do it shows the pointer. At least that's what I read. Any idea? | I simply added a nocursor option as follows in the file ( /etc/lightdm/lightdm.conf ) xserver-command = X -nocursor and it worked as it should. No cursor is displayed whatsoever. You can still put your finger on the touch screen and do what you normally do with your mouse pointer; Clicking and Dragging. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/53127",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/37947/"
]
} |
53,408 | I have followed the following tutorial ( http://mygeeks014.blogspot.nl/2015/01/audio-streaming-to-bluetooth-speaker.html ) to connect a Bluetooth speaker to my Raspberry Pi. Everything works as it's supposed to, but the speaker will not automatically reconnect when the Raspberry gets restarted or the speaker gets turned on/off. Right now I manually reconnect the speaker via the Raspbian GUI, but I wonder if there's a simple solution to reconnect the speaker via the CLI. I will then be able to write a simple CRON to reconnect the speaker if it's not connected yet. | Here is a very detail explanation: Den3243 Here is a command line solution: First, let's scan, pair, trust your device with
"bluetoothctl". To do that, run this at the
command line, your terminal: bluetoothctl -a You should get a different command prompt
like: [bluetooth] With your BT speaker on, type this: scan on In a few moments, you should see the BT
devices available. Next to the device will be
it's MAC address, like: 00:AA:22:BB:33. Now
type this: info <your mac address> Exclude the greater than and less than
characters. What your looking for is some
kind of previous association with your
BT speaker. You will know that there was
a previous association because bluetoothctl
will show information about your BT device.
Some of this information will be about the
device being paired and trusted. This is good. If bluetoothctl complains about
there is no device, then we need to set that
up at this moment. To do that, type this: pair <your mac address> You should see a success message about
your device pairing successfully. Now
let's trust our new BT device. Type this: trust <your mac address> Again, you should see a success message
about trusting. Let me pre-warn you. Your
BT device might connect then again it might
not. Never fear, we don't want it to connect.
Go ahead and let's exit "bluetoothctl".
To do that, type: quit Now you will be brought back to the
command line prompt. In a previous post
I suggested for you to create a scripts
directory in your home directory. If you
haven't, go ahead and do that now. Type
this at the command prompt: mkdir -p ~/scripts Press enter and now let's create our
autopair bash script. Type this: nano ~/scripts/autopair Enter this code into the script: #!/bin/bash
bluetoothctl << EOF
connect [enter your MAC add]
EOF Exclude the brackets! Now press CTRL + x at the same time, and
now press enter to save the script. We need
to make it executable. To do that, type this: chmod +x ~/scripts/autopair I'm assuming that you don't use external
analog speakers plug into the 3.5 mm
jack. If this is true, let's disable alsa.
To do that, let's edit a file in the /boot
directory called config.txt. To do that,
type this in your terminal: sudo nano /boot/config.txt Page down to the bottom of the file and
look for two lines that read: # Enable audio (loads snd_bcm2835)
dtparam=audio=on Place a (pound sign #) in front of
the line that reads: dtparam=audio=on To look like: #dtparam=audio=on Press CTRL + x and then press Enter
to save your file. I'm assuming you have pulseaudio installed?
If not, go ahead and run this command from
the command line: sudo apt-get update && sudo apt-get install pulseaudio -y This will get you a very important component to
making bluetooth work! Now let's edit our .bashrc
file in our home directory. Type this: nano ~/.bashrc Page down to the bottom and add this line: pulseaudio --start Press CTRL + x and now press Enter to save
your file. OK! We need to enter over into the Python
world. I have wrote a Python program that
will watch for the bluetooth device.
In short, it will activate the connection
between RPi and your bluetooth speaker,
once your bluetooth speaker is turned on.
And vice versa. Let's create a directory
called python in your home directory
To do that, type this: mkdir -p ~/python Now let's create the python program file.
To do that, type this: nano ~/python/on.py Inside that file, we need to copy and
paste the following: #!/usr/bin/python
#
# Monitor removal of bluetooth reciever
import os
import sys
import subprocess
import time
def blue_it():
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
while status == 0:
print("Bluetooth UP")
print(status)
time.sleep(15)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
else:
waiting()
def waiting():
subprocess.call('killall -9 pulseaudio', shell=True)
time.sleep(3)
subprocess.call('pulseaudio --start', shell=True)
time.sleep(2)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
while status == 2:
print("Bluetooth DOWN")
print(status)
subprocess.call('~/scripts/autopair', shell=True)
time.sleep(15)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
else:
blue_it()
blue_it() Now press CTRL + x and then press Enter to save
the Python program file. Now we need to make
this file executable. To do that, type this: chmod +x ~/python/on.py Finally, let's add this to our .bashrc script
in our home directory: nano ~/.bashrc Page down to the bottom of the file and add these
two lines: wait
~/python/on.py Now press CTRL + x and then press Enter to save.
Turn your bluetooth speaker on and reboot your
Raspberry Pi. Good Luck! -nitrolinux | {
"source": [
"https://raspberrypi.stackexchange.com/questions/53408",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/51824/"
]
} |
53,438 | I am trying to start a project with my rpi where I can send data from door sensors to the rpi wirelessly. I just cannot figure out the hardware that I would need to complete this. I am looking at wireless transmitters and receivers for the pi, am I on the right path? | Here is a very detail explanation: Den3243 Here is a command line solution: First, let's scan, pair, trust your device with
"bluetoothctl". To do that, run this at the
command line, your terminal: bluetoothctl -a You should get a different command prompt
like: [bluetooth] With your BT speaker on, type this: scan on In a few moments, you should see the BT
devices available. Next to the device will be
it's MAC address, like: 00:AA:22:BB:33. Now
type this: info <your mac address> Exclude the greater than and less than
characters. What your looking for is some
kind of previous association with your
BT speaker. You will know that there was
a previous association because bluetoothctl
will show information about your BT device.
Some of this information will be about the
device being paired and trusted. This is good. If bluetoothctl complains about
there is no device, then we need to set that
up at this moment. To do that, type this: pair <your mac address> You should see a success message about
your device pairing successfully. Now
let's trust our new BT device. Type this: trust <your mac address> Again, you should see a success message
about trusting. Let me pre-warn you. Your
BT device might connect then again it might
not. Never fear, we don't want it to connect.
Go ahead and let's exit "bluetoothctl".
To do that, type: quit Now you will be brought back to the
command line prompt. In a previous post
I suggested for you to create a scripts
directory in your home directory. If you
haven't, go ahead and do that now. Type
this at the command prompt: mkdir -p ~/scripts Press enter and now let's create our
autopair bash script. Type this: nano ~/scripts/autopair Enter this code into the script: #!/bin/bash
bluetoothctl << EOF
connect [enter your MAC add]
EOF Exclude the brackets! Now press CTRL + x at the same time, and
now press enter to save the script. We need
to make it executable. To do that, type this: chmod +x ~/scripts/autopair I'm assuming that you don't use external
analog speakers plug into the 3.5 mm
jack. If this is true, let's disable alsa.
To do that, let's edit a file in the /boot
directory called config.txt. To do that,
type this in your terminal: sudo nano /boot/config.txt Page down to the bottom of the file and
look for two lines that read: # Enable audio (loads snd_bcm2835)
dtparam=audio=on Place a (pound sign #) in front of
the line that reads: dtparam=audio=on To look like: #dtparam=audio=on Press CTRL + x and then press Enter
to save your file. I'm assuming you have pulseaudio installed?
If not, go ahead and run this command from
the command line: sudo apt-get update && sudo apt-get install pulseaudio -y This will get you a very important component to
making bluetooth work! Now let's edit our .bashrc
file in our home directory. Type this: nano ~/.bashrc Page down to the bottom and add this line: pulseaudio --start Press CTRL + x and now press Enter to save
your file. OK! We need to enter over into the Python
world. I have wrote a Python program that
will watch for the bluetooth device.
In short, it will activate the connection
between RPi and your bluetooth speaker,
once your bluetooth speaker is turned on.
And vice versa. Let's create a directory
called python in your home directory
To do that, type this: mkdir -p ~/python Now let's create the python program file.
To do that, type this: nano ~/python/on.py Inside that file, we need to copy and
paste the following: #!/usr/bin/python
#
# Monitor removal of bluetooth reciever
import os
import sys
import subprocess
import time
def blue_it():
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
while status == 0:
print("Bluetooth UP")
print(status)
time.sleep(15)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
else:
waiting()
def waiting():
subprocess.call('killall -9 pulseaudio', shell=True)
time.sleep(3)
subprocess.call('pulseaudio --start', shell=True)
time.sleep(2)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
while status == 2:
print("Bluetooth DOWN")
print(status)
subprocess.call('~/scripts/autopair', shell=True)
time.sleep(15)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
else:
blue_it()
blue_it() Now press CTRL + x and then press Enter to save
the Python program file. Now we need to make
this file executable. To do that, type this: chmod +x ~/python/on.py Finally, let's add this to our .bashrc script
in our home directory: nano ~/.bashrc Page down to the bottom of the file and add these
two lines: wait
~/python/on.py Now press CTRL + x and then press Enter to save.
Turn your bluetooth speaker on and reboot your
Raspberry Pi. Good Luck! -nitrolinux | {
"source": [
"https://raspberrypi.stackexchange.com/questions/53438",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/51861/"
]
} |
54,144 | I am connected to 2 Raspberry Pis via SSH. They are running the same OS (Raspbian in this case). How can I tell which one is Pi 1 and which one is Pi 2? I know how to identify the physical hardware (e.g. micro SD vs SD slot, yellow video output etc.) but I just don't know which IP address which one got via DHCP. | The Raspberry Pi 2 will give BCM270 9 hardware and ~1 GB of RAM like this: pi@raspberrypi:~ $ cat /proc/cpuinfo | grep Hardware
Hardware : BCM2709
pi@raspberrypi:~ $ cat /proc/meminfo | grep MemTotal
MemTotal: 947756 kB while the Pi 1 reports BCM270 8 hardware and definitely less than 1 GB: pi@raspberrypi:~ $ cat /proc/cpuinfo | grep Hardware
Hardware : BCM2708
pi@raspberrypi:~ $ cat /proc/meminfo | grep MemTotal
MemTotal: 445112 kB To know it in even more detail, use cat /proc/cpuinfo | grep Revision | awk '{print substr($0, length($0)-3, length($0))}' where the result can be one of the following: 0002: Pi B Rev 1.0, 256 MB
0003: Pi B Rev 1.0, 256 MB
0004: Pi B Rev 2.0, 256 MB
0005: Pi B Rev 2.0, 256 MB
0006: Pi B Rev 2.0, 256 MB
0007: Pi A
0008: Pi A
0009: Pi A
000d: Pi B Rev 2.0, 512 MB
000e: Pi B Rev 2.0, 512 MB
000f: Pi B Rev 2.0, 512 MB
0010: Pi B+
0012: Pi A+
0013: Pi B+
0015: Pi A+
0092: Pi Zero Rev 1.2
0093: Pi Zero Rev 1.3
1040: Pi 2B Rev 1.0
1041: Pi 2B Rev 1.1
2082: Pi 3B Rev 1.2 | {
"source": [
"https://raspberrypi.stackexchange.com/questions/54144",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/32351/"
]
} |
56,413 | I ran: sudo apt-get update
sudo apt-get install xrdp I wen't to Windows 10 remote desktop connection and connected to my Raspberry Pi 3: Then I entered default credentials credentials (pi/raspberry) and I got this log: The login was successful but "Problem Connecting"... not very informative I'd say. Anyone knows what to do with it? | One of my friends had the very same error which he resolved by following the steps on this page. Apparently there is a/are defect(s) which prevent xrdp working with the vncserver. However it works with tightvncserver Also the order of installation of tightvncserver and xrdp seems to be important. In summary remove the following packages : xrdp, vnc4server, tightvncserver sudo apt-get remove xrdp vnc4server tightvncserver install tightvncserver followed by xrdp sudo apt-get install tightvncserver sudo apt-get install xrdp | {
"source": [
"https://raspberrypi.stackexchange.com/questions/56413",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/43396/"
]
} |
56,621 | I'd like to build an in-house Raspberry Pi image based on Raspbian Lite which is already configured with the correct locale, timezone, etc. Unfortunately for me, current releases of Raspbian images automatically resize the file system, then reboot. I want to avoid the hassles of downsizing the filesystem by preventing the resize from ever occurring. How would I edit the image after burning such as to temporarily disable the automatic file system resize? Edited to clarify effects should be reversible; that is, I'll want my customized image to expand at first boot. | [Beware this may not reflect the current mechanism as it is some years old.] There is a two part mechanism which takes responsibility for this on Raspbian; likely the best idea is to take care of both parts if they are enabled. The first is that the original /boot/cmdline.txt includes this: init=/usr/lib/raspi-config/init_resize.sh Referring to a script with that path on the root partition, which will be used as the init process at boot. Without that bit, it would default to a value built into the kernel, /sbin/init , which on Raspbian is a symbolic link to /lib/systemd/systemd . By removing that portion of cmdline.txt , the system should then boot normally. What that script actually does is resize the partition on the SD card. This is a distinct process from resizing the filesystem in the partition, 1 which is what happens next. The way that happens is the system is immediately rebooted normally (that is, via systemd) and an init.d script is set to trigger early on, which should be removed from the second partition: /etc/init.d/resizefs_once And the symbolic link to it, which should also be removed: /etc/rc3.d/S01resizefs_once You can keep a copy for later use if you want, but raspi-config can create it again for you (it's embedded in the raspi-config shell script). If it actually runs, it deletes itself, so it will not happen again. What it also does is resize the filesystem in the newly resized partition. No harm should be done if just one or the other part happens; in the first case you end up with a filesystem that doesn't fill the enlarged partition, in the second nothing will happen, because the filesystem already fills the partition. If you later use raspi-config to enlarge the filesystem, it does the partition resize right away, then sets up the init script (as already mentioned). Editing cmdline.txt on the first partition is simple on any computer since it is a VFAT partition. Removing the init.d file requires a system that can access and edit ext4 filesystems. Both tasks can instead be done to the image file itself prior to burning the card; to mount and modify a Raspbian image on a GNU/Linux system, see here . There is a parallel Q&A for Windows . This is also reversible, but you'll need to put back both parts of the mechanism as just described, since the first one does not include automatically staging the second one. Although an error message from that script arguably confuses those terms by claiming it failed to resize the root filesystem , when what it really failed to do is resize the partition on which the root filesystem resides. Doing one does not automatically accomplish the other. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/56621",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/54372/"
]
} |
56,639 | I recently bought a RPi 3 but got a concern with its reliable operation in relation to the power source. A store near me has something like this but it has only two ports - http://www.amazon.in/Charger-iPhones-Samsung-Android-Devices/dp/B00MUSNG6K (5V 3.2A two USB ports) Can I reliably use this kind of adapter? Utilizing only one port for full 3A source. And for the cable, I got a spare cable lying around which came with a 5v 500ma adapter. Are they generally rated for high current sources? | [Beware this may not reflect the current mechanism as it is some years old.] There is a two part mechanism which takes responsibility for this on Raspbian; likely the best idea is to take care of both parts if they are enabled. The first is that the original /boot/cmdline.txt includes this: init=/usr/lib/raspi-config/init_resize.sh Referring to a script with that path on the root partition, which will be used as the init process at boot. Without that bit, it would default to a value built into the kernel, /sbin/init , which on Raspbian is a symbolic link to /lib/systemd/systemd . By removing that portion of cmdline.txt , the system should then boot normally. What that script actually does is resize the partition on the SD card. This is a distinct process from resizing the filesystem in the partition, 1 which is what happens next. The way that happens is the system is immediately rebooted normally (that is, via systemd) and an init.d script is set to trigger early on, which should be removed from the second partition: /etc/init.d/resizefs_once And the symbolic link to it, which should also be removed: /etc/rc3.d/S01resizefs_once You can keep a copy for later use if you want, but raspi-config can create it again for you (it's embedded in the raspi-config shell script). If it actually runs, it deletes itself, so it will not happen again. What it also does is resize the filesystem in the newly resized partition. No harm should be done if just one or the other part happens; in the first case you end up with a filesystem that doesn't fill the enlarged partition, in the second nothing will happen, because the filesystem already fills the partition. If you later use raspi-config to enlarge the filesystem, it does the partition resize right away, then sets up the init script (as already mentioned). Editing cmdline.txt on the first partition is simple on any computer since it is a VFAT partition. Removing the init.d file requires a system that can access and edit ext4 filesystems. Both tasks can instead be done to the image file itself prior to burning the card; to mount and modify a Raspbian image on a GNU/Linux system, see here . There is a parallel Q&A for Windows . This is also reversible, but you'll need to put back both parts of the mechanism as just described, since the first one does not include automatically staging the second one. Although an error message from that script arguably confuses those terms by claiming it failed to resize the root filesystem , when what it really failed to do is resize the partition on which the root filesystem resides. Doing one does not automatically accomplish the other. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/56639",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/55383/"
]
} |
57,963 | There is a lightning bolt icon flashing on the top right of my screen. What does it mean? Here's a picture: | That's the new undervoltage symbol. Your Pi's power supply is marginal or insufficient for its requirements. From the raspberrypi.org blog page : Finally on the subject of icons, in the past if your Pi was working
particularly hard, you might have noticed some yellow and red squares
appearing in the top-right corner of the screen, which were
indications of overtemperature or undervoltage. These have now been
replaced with some new symbols that make it a bit more obvious what’s
actually happening; there’s a lightning bolt for undervoltage, and a
thermometer for overtemperature. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/57963",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/11827/"
]
} |
58,303 | I have a project in mind that uses Raspberry Pi to develop a software. The final product will be modification of the Raspberry Pi circuit (get rid of any components that the project doesn't use) and add in some other circuits of mine. For the software parts, it will be running Raspbian OS with my application software. Is it legal to do that? I don't mind giving back if I can make a profit. | The answer to the question if something is legal or not, depends on the interpretation of laws in a particular jurisdiction. This answer should not be treated as a legal advice. It is based on published information by the relevant party. Raspberry Pi Foundation made a clear statement that answers your question in the Starting a business with a Raspberry Pi article: If [ ] you’re making a product which requires a Raspberry Pi to run, we don’t ask you to buy special permission or licences from us to use it. All we ask is that you include the words “Powered by Raspberry Pi” somewhere on your packaging. If your business is successful, we’d be very grateful if you could consider donating a small portion of your profits to the Raspberry Pi Foundation – but that’s all, and if you choose not to do that, that’s fine too. Regarding the use of the "Raspberry Pi" trademark / logo the guidelines are published on the Trademark Rules And Brand Guidelines page. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/58303",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/57371/"
]
} |
58,478 | I recently liberated an old model B from the loft, put NOOBS on an SD card, and installed the latest version of Raspbian on it. I booted it up, attempted to SSH to it from my Mac, but got: ssh: connect to host 192.168.1.248 port 22: Connection refused I got around this in the first instance by running sudo ssh restart , but now every time I boot up again, I have to restart the ssh service before I can ssh in again, which obviously isn't practical. Anything I can do to fix it more permanently? | Quoting the documentation : As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually. To enable SSH on machines through console: Enter sudo raspi-config in the terminal, first select Interfacing Options , then navigate to ssh , press Enter and select Enable or disable ssh server . To enable SSH for headless machines: For headless setup, SSH can be enabled by placing a file named ssh , without any extension, onto the boot partition of the SD card. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/58478",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/57629/"
]
} |
59,310 | I have a custom python app that I wanted to have started automatically on the RPi with the official touch screen. This used to work fine without a sleuth of boot messages appearing until the latest update in Jessie with the PIXEL desktop. My 'asplashscreen' script that I used to use now is littered with boot messages again. I dumped 'asplashscreen' and since Plymouth has finally been patched to work (after PIXEL release) I now have Plymouth showing a pretty boot screen, but the old methods of silencing the boot messages don't seem to work anymore. How can I remove ALL boot messages (including auto-login and kernel) messages? | Please note that removing the output of message can also hinder your ability to troubleshoot your system after. You may want to wait until you are in the finishing stages before applying these fixes. As of December 2016, a lot of the old methods seemed to have stopped working.
I created this question/answer post because it took me many hours to aggregate all the solutions. What I did to remove ALL the boot up text (even login messages): 1.) Change /boot/cmdline.txt sudo nano /boot/cmdline.txt Change the console from tty1 to console=tty3 Add this to the end of the line. 'loglevel=0' removes most of the messages from the boot. You can also use 'loglevel=3', but some boot messages may re-appear. quiet splash loglevel=0 logo.nologo vt.global_cursor_default=0 If you are going to use Plymouth add this: plymouth.ignore-serial-consoles 2.) Tell dmesg to be quiet sudo nano /etc/rc.local Add this before 'exit 0': #Suppress Kernel Messages
dmesg --console-off This should take care of most boot messages this far. #2 also took care of the 'watchdog watchdog0: watchdog did not stop!' message on shutdown for me. 3.) Change the auto login in systemd (Hides the login message when auto-login happens) sudo nano /etc/systemd/system/autologin\@.service Change your auto login ExecStart from: ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM To: ExecStart=-/sbin/agetty --skip-login --noclear --noissue --login-options "-f pi" %I $TERM Make sure to change 'pi' to the username you use! 4.) Change /etc/pam.d/login (removes the Kernel version from showing when you auto-login) sudo nano /etc/pam.d/login Change the line session optional pam_exec.so type=open_session stdout /bin/uname -snrvm To be session optional pam_exec.so type=open_session stdout 5.) Add .hushlogin touch ~/.hushlogin or Remove Message of the Day -MOTD (alternative to 5) sudo update-rc.d motd remove Now my boot just shows the Plymouth boot screen, and goes into my python GUI. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/59310",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/39416/"
]
} |
59,529 | My Pi is currently not responding to SSH, and the only HDMI monitor I have is a large TV several meters away. I've heard bad things about unplugging it, but do I have any other option? Currently running headless raspbian, maybe I could connect a keyboard and guess about commands? | Although it should be regarded as a last resort since it does increase the risk of filesystem corruption, unplugging the cord is usually okay if the green ACT light is not flashing intensely . By default the ACT led shows I/O activity on the SD card. If it is off, most likely the system is idle. This is not necessarily true, but killing a system that is busy with CPU intensive activity (and not I/O) is not inherently a problem anyway. The operating system does cache filesystem information in memory, meaning it can be out of sync with the actual storage on the SD card, but this should be dealt with at least every few seconds (you might sometimes be able to infer this pattern from the ACT led). So, if it appears idle after watching it for 5-10 seconds and you have no other choice, go ahead and unplug the power. Again, this doesn't guarantee anything and there are unfortunate scenarios whereby the system may get locked up and filesystem syncing doesn't occur properly, but in most cases you should be okay. I've probably had to pull the cord on a pi (or had power fail) over a hundred times this way and can't recall ever having grief because of it. Sometimes I will put the card in another machine and run e2fsck -f on the root filesystem, which is worthwhile. The OS will check the filesystem automatically on boot but it is possible for this check to fail (or not be done correctly) and go unnoticed. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/59529",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/58946/"
]
} |
59,532 | At first I do not want to do port forwarding to access my PI, what I want is that the PI would access a website where it would send the GPIO status and also will read the "new" values that must be set, based on data received from server. Ex. Pi would connect to www.mysite.com will post the GPIO status, this information would be displayed to user, also the user will set the GPIO's status that would be sent back to the Pi this must be almost instant or just 1-2 second delay between sending receiving data. POST pi GPIO status, GET GPIO status and set it. My question is if anyone has a good solution for this. I am using a shared hosting. Ok, I think the solution is to use long polling, just in case if anyone will ask this in the future. | Although it should be regarded as a last resort since it does increase the risk of filesystem corruption, unplugging the cord is usually okay if the green ACT light is not flashing intensely . By default the ACT led shows I/O activity on the SD card. If it is off, most likely the system is idle. This is not necessarily true, but killing a system that is busy with CPU intensive activity (and not I/O) is not inherently a problem anyway. The operating system does cache filesystem information in memory, meaning it can be out of sync with the actual storage on the SD card, but this should be dealt with at least every few seconds (you might sometimes be able to infer this pattern from the ACT led). So, if it appears idle after watching it for 5-10 seconds and you have no other choice, go ahead and unplug the power. Again, this doesn't guarantee anything and there are unfortunate scenarios whereby the system may get locked up and filesystem syncing doesn't occur properly, but in most cases you should be okay. I've probably had to pull the cord on a pi (or had power fail) over a hundred times this way and can't recall ever having grief because of it. Sometimes I will put the card in another machine and run e2fsck -f on the root filesystem, which is worthwhile. The OS will check the filesystem automatically on boot but it is possible for this check to fail (or not be done correctly) and go unnoticed. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/59532",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/58711/"
]
} |
59,605 | I'm trying to get remote screen access to my Raspberry Pi (running Raspbian) with a Mac OS X client. Here's what I've got: I ran 'raspbian-config' and used it to enable the VNC server. The desktop on the raspberry-pi shows that VNC server is
running. ps says it's vncserver-x11-core . The raspberry pi shows up as a shared screen on my Mac in the Finder. When I click the "Share Screen" button on the Mac, I get
a dialog with this error message: The software on the remote computer appears to be
incompatible with this version of Screen Sharing. My Mac is running 10.9 (Mavericks?), so it's a bit old... What are my options? Is there a config option on the Pi that I can tweak? That's my preferred approach. Failing that, will switching to tightvncserver help? It feels like a bit of overkill to update my Mac for this problem, but would it help? | Headless VncServer Configuration If you need to configure accessing the pi with osx's Screen, but only have headless access to the pi, you can use a vnc config file. Enable VNC: sudo systemctl enable vncserver-x11-serviced Generate the password you wish to use in screen with vncpasswd
-service sudo vncpasswd -service Create and edit the following file here:
/etc/vnc/config.d/common.custom Enter the following config: Authentication=VncAuth Restart the vnc service: sudo systemctl restart vncserver-x11-serviced Open Screen on your mac with the instructions below, and use the password you provided to vncpasswd. If you need to monitor the logs for vncserver, you can use journalctl: sudo journalctl -u vncserver-x11-serviced.service Other parameters you can use with VncServer configs are described here: https://www.realvnc.com/en/connect/docs/server-parameter-ref.html | {
"source": [
"https://raspberrypi.stackexchange.com/questions/59605",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/59046/"
]
} |
60,593 | How does the Pi know it being underpowered and to show the lighting bolt? As most of us know, if you use a bad power supply you get the lightning bolt telling you are underpowered. I noticed that when I run my Pi on battery, the last 15 minutes or so before the Pi starts to reboot, the lightning bolt starts appearing, and eventually stays there until the reboots, which makes sense because my battery voltage is dropping as it is drained. This got me thinking I could use this to make a program that turns the Pi off when it detects constant under-voltage. I know before this happened would be even better but I am not concerned about that. Is there a command for voltage like sudo vcgencmd measure_temp for temperature to know what the voltage is? If not how does the Pi know when it is being underpowered? EDIT : This is not a duplicate because the other question suggests you need external hardware. I am pointing out this is not strictly necessary. EDIT 2 : fixed typo in quoted command | If you want to do it with a shell script, here is a solution that works on Pi 1, 2 & 3 (not tested in zero). With the command: /opt/vc/bin/vcgencmd get_throttled If the answer is: throttled=0x0 You're good with the supplied voltage and SoC temperature. The bits on the returned number mean: Bit Hex value Meaning
0 1 Under-voltage detected
1 2 Arm frequency capped
2 4 Currently throttled
3 8 Soft temperature limit active
16 10000 Under-voltage has occurred
17 20000 Arm frequency capping has occurred
18 40000 Throttling has occurred
19 80000 Soft temperature limit has occurred A value of 0x50000 means 16 & 18 -- from the boot moment up to now Under-Voltage has ocurred at some point as well as Throrrling has occured. Reference: vcgencmd Documentation . | {
"source": [
"https://raspberrypi.stackexchange.com/questions/60593",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/29246/"
]
} |
61,699 | Is there a way of determining whether the current Raspberry Pi is either a 2 Model B and 3 with Raspbian Jessie Lite 8.0 ? This is because I have a particular bootstrap.sh written in Bash where it needs to set the attribute txpower for a Wi-Fi USB dongle (here, Raspberry Pi 2) using a Ralink RT5370 chipset driver. I set the Wireless attributes using iwconfig (which, I know is deprecated, but it currently gets the job done, so I am not changing it). Since, in Raspberry Pi 3 the internal Wi-Fi chipset is a bcm -based chipset which will not let the following command execute: iwconfig wlan0 mode ad-hoc channel 6 essid myadhoc txpower 0dBm With Raspberry Pi 3 the above mentioned command works just by removing dBm from the above mentioned command: iwconfig wlan0 mode ad-hoc channel 6 essid myadhoc txpower 0 I would like to add a check whether the Raspberry Pi model is 2 or 3 using Bash. Any hints? In case, someone wants to go through the bootstrap.sh : Bootstrapping for TWIN Notes I checked that dBm is not required , also in the case of the Raspberry Pi 2 with the Ralink chipset hence for non-ambiguity one can use the same command for both the Raspberry Pis viz. iwconfig wlan0 mode ad-hoc channel 6 essid myadhoc txpower 0 It is interesting to note that for external Wi-Fi USB dongles one needs to perform the following (for Raspberry Pi 2 ): ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc channel 6 essid myadhoc txpower 0
ifconfig wlan0 up while as for inbuilt Wi-Fi modules (Raspberry Pi 3) there is no need for ifconfig up and down . Just the straightforward iwconfig command works. | cat /proc/device-tree/model returns something like Raspberry Pi 3 Model B Rev 1.2 | {
"source": [
"https://raspberrypi.stackexchange.com/questions/61699",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/41423/"
]
} |
61,716 | Whenever I open up a page to my gmail account I get a yellow bar at the top of the browser with this message: This version of Chrome is no longer supported. Please upgrade to a supported browser . Dismiss When I click on the "supported browser" link in the message above Im directed to a general google Chrome support page which has nothing to do with the Chromium browser. When I try to update it the regular way I get the following: $ sudo apt-get install chromium-browser
[sudo] password for jmarbas:
Reading package lists...
Done Building dependency tree
Reading state information...
Done chromium-browser is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded. Why do I keep getting that message telling me to upgrade to the latest version if I am already at the latest available version? I'm seeing this on Raspbian Jessie 8.0 and Chromium browser version 51. EDIT(Feb 17, 2017): I am now getting the message that the chromium-browser is "kept back" when I try to upgrade, which means that very recenty after my question was posted, a package in the Raspbian repositories was added/modified and must now be installed. chromium-browser now depends on this new/modified package: $ sudo apt-get upgrade
[sudo] password for jmarbas:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
chromium-browser libgl1-mesa-dri pprompt rpi-chromium-mods sonic-pi xserver-xorg-input-all
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded. I never got this message before in all my test installations of Raspbian. When it says that chromium-browser is "kept back" it means that there is a package that has been add/modified to the repository that must be installed before the chromium-browser can be updated. So I retried my original command above to see if I can now update chromium-browser and it now works. As you can see below the package "libxcb-image0" is the package that was added/modified: $ sudo apt-get install chromium-browser
[sudo] password for jmarbas:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libxcb-image0
Suggested packages:
webaccounts-chromium-extension unity-chromium-extension adobe-flashplugin
The following NEW packages will be installed:
libxcb-image0
The following packages will be upgraded:
chromium-browser
1 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 56.1 MB of archives.
After this operation, 32.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] This question has been strangely resolved itself after I posted it.
I opened the browser and verified that it is now version 56. | cat /proc/device-tree/model returns something like Raspberry Pi 3 Model B Rev 1.2 | {
"source": [
"https://raspberrypi.stackexchange.com/questions/61716",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/47038/"
]
} |
61,723 | How to run fsck at boot when using Pi 3 and Raspberry Jessie? I have read some tutorial but they differ. I have run sudo touch /forcefsck but what else I have to do? I know that I should set FSCKFIX=yes but what is the correct file? Some say /lib/init/vars.sh others /etc/default/rcS . How can I verify that my settings are working? I have no visibility to screen. There is power outages so there is a high risk that file system gets corrupted. Edit: I tried two solution mentioned below. 1) By using sudo shutdown -rF now /var/log/boot.log says: [^[[32m OK ^[[0m] Started Load/Save Random Seed.
[^[[32m OK ^[[0m] Started Show Plymouth Boot Screen.
[ 3.679250] systemd-fsck[219]: fsck.fat 3.0.27 (2014-11-12)
[ 3.681320] systemd-fsck[219]: /dev/mmcblk0p1: 124 files, 2666/8057 clusters
[^[[32m OK ^[[0m] Started File System Check on /dev/mmcblk0p1.
Mounting /boot...
[^[[32m OK ^[[0m] Reached target Paths.
[^[[32m OK ^[[0m] Created slice system-systemd\x2drfkill.slice.
Starting Load/Save RF Kill Switch Status of rfkill0...
[^[[32m OK ^[[0m] Started Load/Save RF Kill Switch Status of rfkill0.
[^[[32m OK ^[[0m] Created slice system-ifup.slice.
[^[[32m OK ^[[0m] Mounted /boot.
[^[[32m OK ^[[0m] Reached target Local File Systems.
Starting Tell Plymouth To Write Out Runtime Data...
Starting Create Volatile Files and Directories...
Starting LSB: Raise network interfaces....
[^[[32m OK ^[[0m] Reached target Remote File Systems.
Starting Trigger Flushing of Journal to Persistent Storage...
Starting LSB: Prepare console...
Starting LSB: Switch to ondemand cpu governor (unless shift key is pressed)...
[^[[32m OK ^[[0m] Started Tell Plymouth To Write Out Runtime Data. 2) By using fsck.mode=force and fsck.repair=yes in /boot/cmdline.txt bootlog says: [^[[32m OK ^[[0m] Started Show Plymouth Boot Screen.
[^[[32m OK ^[[0m] Reached target Paths.
[^[[32m OK ^[[0m] Created slice system-systemd\x2drfkill.slice.
[^[[32m OK ^[[0m] Created slice system-ifup.slice.
[ 5.749367] systemd-fsck[112]: Pass 2: Checking directory structure
[ 8.673500] systemd-fsck[112]: Pass 3: Checking directory connectivity
[ 8.683831] systemd-fsck[112]: Pass 4: Checking reference counts
[ 9.318835] systemd-fsck[112]: Pass 5: Checking group summary information
[ 9.518754] systemd-fsck[112]: /dev/mmcblk0p2: 131321/956160 files (0.2% non-contiguous$
[^[[32m OK ^[[0m] Started File System Check on Root Device.
Starting File System Check on /dev/mmcblk0p1...
Starting Remount Root and Kernel File Systems...
[^[[32m OK ^[[0m] Started Remount Root and Kernel File Systems.
Starting Load/Save RF Kill Switch Status of rfkill0...
Starting Load/Save Random Seed...
[^[[32m OK ^[[0m] Reached target Local File Systems (Pre).
[ 9.639259] systemd-fsck[239]: fsck.fat 3.0.27 (2014-11-12)
[^[[32m OK ^[[0m] Started Load/Save RF Kill Switch Status of rfkill0.
[ 9.644216] systemd-fsck[239]: /dev/mmcblk0p1: 124 files, 2666/8057 clusters
[^[[32m OK ^[[0m] Started File System Check on /dev/mmcblk0p1.
[^[[32m OK ^[[0m] Started Load/Save Random Seed.
Mounting /boot...
[^[[32m OK ^[[0m] Mounted /boot. Why is the log file totally different in these two cases? | I have run sudo touch /forcefsck but what else I have to do? That's stuff that applies more to wheezy; jessie may (or may not) be backward compatible with it, but you might as well do it the new way: Add the following to /boot/cmdline.txt : fsck.mode=force Make sure that file remains all one line. Parameters should be separated with spaces. You'll probably notice fsck.repair=yes is already there; these are not the same thing. From man systemd-fsck (these are actually parameters that are passed on by the kernel to init , i.e., systemd): fsck.mode= One of "auto", "force", "skip". Controls the mode of operation. The default is "auto", and ensures that
file system checks are done when the file system checker deems them necessary. "force" unconditionally
results in full file system checks. "skip" skips any file system checks. fsck.repair= One of "preen", "yes", "no". Controls the mode of operation. The default is "preen", and will
automatically repair problems that can be safely fixed. "yes " will answer yes to all questions by fsck
and "no" will answer no to all questions. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/61723",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/59415/"
]
} |
62,933 | I bought the new Raspberry Pi W but I don't have right now an mini-HDMI adaptor (to connect it to a monitor) neither an Ethernet module to connect by SSH. Can I connect somehow by SSH through USB? How can I connect by SSH by WiFi without it being setup?
Will the WiFi automatically connect e.g to a wireless network without password? | That's a tough one. The WiFi won't automatically connect. So I would try the following: Image a micro SD card with the Raspbian OS image using Win32DiskImager. Manually configure your WiFi from another computer. In another computer running Linux (or PC with Live CD) you could edit the following file: /etc/wpa_supplicant/wpa_supplicant.conf And add the following where you enter your WiFi network SSID and password details: network={
ssid="SSID"
psk="password"
key_mgmt=WPA-PSK
} Enable SSH on the Pi from another computer. Create a file on the /boot partition named “ssh”. Put the SD card on your Pi and if everything works as I hope it would, you'll be able to see the Pi on your WiFi network using your router app and SSH into it. Good luck, hope it helps. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/62933",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/63263/"
]
} |
63,519 | For those who have the Pi Zero W with them, what is its power consumption in the following modes: No peripherals connected, WiFi And Bluetooth off Only WiFi turned on Only Bluetooth turned on Only camera connected and capturing I am aware of a previous question , but because it's older, that thread doesn't contain information about Pi Zero W and its specific features. | Based on the measurements made by RaspiTV , here are some estimates: 100 mA: No peripherals connected, WiFi And Bluetooth off 160 mA: Bluetooth turned on 170 mA: WiFi turned on 230 mA: Camera connected and capturing Overall, using WiFi and accounting for the 5V power adapter, you are only looking at 1.1 Watts. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/63519",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/63989/"
]
} |
68,002 | This code does not turn the led on and off. import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
for number in range(0,10):
GPIO.output(21,GPIO.LOW)
time.sleep(1)
GPIO.output(21,GPIO.HIGH)
GPIO.cleanup() but when I print out the number in the loop it does work: import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
for number in range(0,10):
GPIO.output(21,GPIO.LOW)
time.sleep(1)
GPIO.output(21,GPIO.HIGH)
print(number)
GPIO.cleanup() Any idea why that is? | Try to replace your print by a time.sleep(0.05) . You may occur this strange behavior as GPIO.output is switched too quickly from HIGH to LOW to be set/detected/seen.
Increase/reduce the sleep duration until the program works fine (increase) and fast enough (decrease). import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
for number in range(0,10):
GPIO.output(21,GPIO.LOW)
time.sleep(1)
GPIO.output(21,GPIO.HIGH)
time.sleep(0.05)
GPIO.cleanup() | {
"source": [
"https://raspberrypi.stackexchange.com/questions/68002",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/68278/"
]
} |
68,006 | I would like to run a script on start-up with my Raspberry Pi. I've followed some guides and the easiest method seems to be editing the rc.local file, which is what I did. So I opened up the rc.local file using: sudo nano /etc/rc.local Then, before the exit 0 line, on separate lines I added cd RPi_Cam_Web_Interface //just my 2 commands
./start.sh Saved the file using Ctrl+O, and rebooted. However my script doesn't run. I checked the file and my new commands are there. What could be wrong here? | Try to replace your print by a time.sleep(0.05) . You may occur this strange behavior as GPIO.output is switched too quickly from HIGH to LOW to be set/detected/seen.
Increase/reduce the sleep duration until the program works fine (increase) and fast enough (decrease). import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
for number in range(0,10):
GPIO.output(21,GPIO.LOW)
time.sleep(1)
GPIO.output(21,GPIO.HIGH)
time.sleep(0.05)
GPIO.cleanup() | {
"source": [
"https://raspberrypi.stackexchange.com/questions/68006",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/68283/"
]
} |
68,133 | I have a Raspberry Pi project that has three soil moisture sensors. I take a moisture sample every minute. After about a month I started to get bad readings. On further inspection I noticed that my soil moisture sensors were corroded to the point where they were giving false moisture readings (it completely corroded the metal contact away). It corroded all the sensors equally. Is soil moisture sensor corrosion normal? If so, how do you prevent this? Is it just a cheap sensor? What is recommended? The sensor I bought can be found here: Amazon - XCSOURCE 5pcs Soil Moisture Sensor And Automatic Watering System for Arduino TE215 . | If you think about what is happening you have a very hostile environment for electronics (moisture - sometimes large amounts, soil PH and electrical current induced electrolysis) The Hookup Guide for the SparkFun Soil Moisture Sensor includes the following: One commonly known issue with soil moisture senors is their short
lifespan when exposed to a moist environment. To combat this, we’ve
had the PCB coated in Gold Finishing (Electroless Nickel Immersion
Gold). Another way to extend the lifespan of your sensor is to only power it
when you take a reading. Using a digital pin set to HIGH on an
Arduino, for example, is an easy way to accomplish this. If you wish
to power the sensor with more than a digital pin on your
microcontroller can provide, you could always use a transistor. So yes this is normal, I can't speak to the longevity of the sparkfun sensor, but the extra lifetime afforded by the "Gold Finishing", may well be worth the extra cost for your use case. As others have stated powering the sensor only when taking a reading will also increase the lifetime of the sensor. I would also question the need to take a measurement every minute. Does your soil moisture really change significantly over that short a time period? I just saw this new method (covered in step 5) using graphite rods (pencils) to make long lasting probes. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/68133",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/68423/"
]
} |
68,148 | I formatted my SD card to install the Raspbian Jessie, using Etcher, but it gave me several errors, and after that my Mac, or Windows, laptop is not detecting the card at all. What can I do with it? | If you think about what is happening you have a very hostile environment for electronics (moisture - sometimes large amounts, soil PH and electrical current induced electrolysis) The Hookup Guide for the SparkFun Soil Moisture Sensor includes the following: One commonly known issue with soil moisture senors is their short
lifespan when exposed to a moist environment. To combat this, we’ve
had the PCB coated in Gold Finishing (Electroless Nickel Immersion
Gold). Another way to extend the lifespan of your sensor is to only power it
when you take a reading. Using a digital pin set to HIGH on an
Arduino, for example, is an easy way to accomplish this. If you wish
to power the sensor with more than a digital pin on your
microcontroller can provide, you could always use a transistor. So yes this is normal, I can't speak to the longevity of the sparkfun sensor, but the extra lifetime afforded by the "Gold Finishing", may well be worth the extra cost for your use case. As others have stated powering the sensor only when taking a reading will also increase the lifetime of the sensor. I would also question the need to take a measurement every minute. Does your soil moisture really change significantly over that short a time period? I just saw this new method (covered in step 5) using graphite rods (pencils) to make long lasting probes. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/68148",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/68431/"
]
} |
70,568 | In order to use pigpio Module in Python (remote GPIO for Raspberry Pi ), pigpiod has to be loaded to memory on each RPi. what is the right way to to it ? during Ubuntu's boot or a part of Python's script ? since It needs sudo pigpiod - how is it done (both Ubuntu and Python )? | sudo systemctl enable pigpiod will enable it to auto-start on boot. sudo systemctl start pigpiod will start it immediately (just a posh way of doing sudo pigpiod :) If you change your mind, sudo systemctl disable pigpiod will undo the start-up behaviour. Similarly, sudo systemctl stop pigpiod will have an immediate effect. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/70568",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/68038/"
]
} |
73,126 | The PIN mapping of the Raspberry 2B says: The red ones are 5V pins. Are these just used as 5V out pins when power is connected through Micro USB? Or is it also possible to power the Raspberry Pi via those pins, so that I can get rid of the Micro USB cable? Please note: I don't want to power peripherals from these pins, I want to power the Raspberry itself, i.e. I want to get rid of the micro USB power supply. | This pin is directly connected to the 5V net , meaning indeed it is possible to power through that pin. When under USB power, this net is supplied by USB power, but there is no reason you couldn't power it yourself, however, replicating some of the protection scheme is worthwhile to protect power supplies and prevent fires. In my opinion, modifying the board (replacing usb header) is riskier and more error-prone than using an external supply with adequate protection. However, the simplest solution is to make a cable from your power supply or connector of choice to micro-usb, because you may as well re-use the circuit they have there. Taking a look at the schematics we can see the GPIO pins are attached directly to 5V net What @Dr.Rabbit is referring to is a ressetable fuse that is used to protect from short circuit. This can be seen here as component F1 . The 5V net shows ups at the right of the schematic Note that the USB input is additionally protected from reverse power, it is a good idea to replicate both of these protection schemes in your set up. Keep in mind that these largely protect the operator and the power supply. If the polyfuse trips due to accidental short, the board is probably dead anyway, however if you are simply running too many loads then the polyfuse will protect the on board power supply and the wall-wart from continuous over-current. It is legitimate to use Diodes to OR power supplies and prevent reverse current . You just have to be sure to take into account the diode voltage drop or compensate for it in your schematic like what is done on the raspberry pi. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/73126",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/32351/"
]
} |
75,521 | I was wondering if there is a simple way to "turn on" all 100% of the CPU so that I can run processes faster (such as python calculations). 1) Is this possible? 2) Is there an easy way to revert back to normal? 3) Is there a way to use less CPU if desired? I'm thinking of a command line interaction like: pi@raspberry:~ $ sudo turnOnFourCores python run.py | By default, any computer will try to use all of its cores when it can. However, it can only achieve this when an application is multi-threaded. If it is not (i.e. a Python script that doesn't use the threading module), then it can only use at maximum, one core. This equates to 25% of the CPU on a four-core CPU. If you'd like to modify your script to use multiple cores, you can split your calculation into multiple parts, and multi-thread it as shown in the Python documentation . Update: As Anon answered , this will fail to work without working with Python's GIL (Global Interpreter Lock). This allows tasks to operate (seemingly) at the same time, but does not allow code to run across multiple cores. If you are using modules written in C (e.g. numpy), they can allow you to use multiple cores go around that limitation. Additionally, if that is not an option, Python offers multiprocessing , which allows you to run any task on multiple cores. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/75521",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/76601/"
]
} |
75,632 | I just installed a clean image of the latest Raspbian Stretch Lite. Specifically - 2017-09-07-raspbian-stretch-lite.img ifconfig shows that my wifi interface wlan0 is detected and up. eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:c6:dc:d4 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 2516 bytes 144456 (141.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2516 bytes 144456 (141.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.165 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::d4dd:c202:d337:c0de prefixlen 64 scopeid 0x20<link>
ether 00:24:a5:36:ed:49 txqueuelen 1000 (Ethernet)
RX packets 49461 bytes 49499638 (47.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 36499 bytes 4455517 (4.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 However, trying to use the ifdown or ifup commands says that the device does not exist. [pi:~] sudo ifdown wlan0
ifdown: unknown interface wlan0 Perhaps, ifup and ifdown will only work if /etc/network/interfaces is used to manage the networking devices, and that is apparently not the case in the raspbian stretch lite version dated 2017-09-07 | What does work instead of sudo ifup wlan0
sudo ifdown wlan0 is sudo ifconfig wlan0 up
sudo ifconfig wlan0 down | {
"source": [
"https://raspberrypi.stackexchange.com/questions/75632",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/30886/"
]
} |
77,240 | There are two new serious security flaws discovered, Spectre and Meltdown . Is the Raspberry Pi vulnerable for Spectre and/or Meltdown? | According to ARM themselves, the processor cores used in all models before the Pi 4 are not vulnerable . The majority of Arm processors are not impacted by any variation of this side-channel speculation mechanism. A definitive list of the small subset of Arm-designed processors that are susceptible can be found below. [see link for the table] The processor cores used by the older Pis are: Pi 1 and Zero (W) : ARM11 Pi 2 V1 : ARM Cortex-A7 Pi 2 V1.2 and Pi 3 : ARM Cortex-A53 None of the above cores are listed as vulnerable to any version of the attack (they are not listed at all, in fact, because there is no known vulnerability to these attacks). The Raspberry Pi 4 uses the Cortex-A72 , which is listed as vulnerable to variants 1, 2, 3a and 4. As stated in Is the Raspberry Pi 4 vulnerable to the Spectre exploits? , Raspbian contains software mitigations to these vulnerabilities, so the risk of exploitation should be low. Other operating systems may not contain appropriate mitigations, and while ARM say a hardware mitigation has been released for the Cortex-A72, it is unclear whether this has been applied to the Pi 4. Note that Variants 1 and 2 (CVE-2017-5753 and CVE-2017-5715) are known as Spectre , and Variants 3 (CVE-2017-5754) and 3a (a related attack investigated by ARM) are called Meltdown . Therefore, none of the Raspberry Pi devices before Pi 4 are believed to be vulnerable to either Spectre or Meltdown. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/77240",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/14994/"
]
} |
78,787 | Systemd's systemd-networkd can be used to replace the existing networking system on Raspbian. How does it work with Raspbian on a Raspberry Pi with two interfaces for ethernet and wlan? Can I also realize dynamic failover for them? | Tested on a Raspberry Pi 4B with Raspbian Buster Lite 2020-02-13 updated on 2020-04-11. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . It will not work with Raspbian Stretch ! Here you will find the last tested revision for Raspbian Stretch Lite . ♦ Abstract Using `systemd-networkd` instead of default `dhcpcd` is of course possible. But it is not meaningful in all cases. networkd is a small and lean service to configure network interfaces,
designed mostly for server use cases in a world with hotplugged and
virtualized networking. Its configuration is similar in spirit and
abstraction level to ifupdown, but you don't need any extra packages
to configure bridges, bonds, vlan etc. It is not very suitable for
managing WLANs yet; NetworkManager is still much more appropriate for
such Desktop use cases. [1] But for a raspi laying near by a TV or amplifier and doing its work 24/7 for streaming audio or video or for a camera etc., systemd-networkd is a good choice. But you have to do a complete switch. There is no way to mix up with networking and/or dhcpcd . Please also note that NetworkManager isn't supported by Raspbian out of the box. ♦ Step 1: Preparation For reference I use a fresh flashed SD Card from **Raspbian Buster Lite**. I will have attention to a headless installation only with ssh. If you are using this, double check typos or so otherwise you are lost with a broken connection. If you want a headless installation then look at SSH (Secure Shell) and follow section 3. Enable SSH on a headless Raspberry Pi (add file to SD card on another machine) . Disable the old stuff. Don't stop any service, only disable them! So it will take effect only on next boot. How to do it just follow to Use systemd-networkd for general networking , but only section ♦ Quick step and come back here. ♦ Step 2: Setup the wired ethernet interface (eth0) Create this file with your settings. You can just copy and paste this in one block to your command line beginning with `cat` and including both EOF (delimiter EOF will not get part of the file): pi@raspberrypi: ~$ sudo -Es # if not already done
root@raspberrypi: ~# cat >/etc/systemd/network/04-eth.network <<EOF
[Match]
Name=e*
[Network]
# to use static IP (with your settings) toggle commenting the next 8 lines.
#Address=192.168.50.60/24
#DNS=84.200.69.80 1.1.1.1
#[Route]
#Gateway=192.168.50.1
#Metric=10
DHCP=yes
[DHCP]
RouteMetric=10
EOF ♦ Step 3: Setup wlan interface (wlan0) Create this file with your settings: root@raspberrypi:~ # cat >/etc/systemd/network/08-wifi.network <<EOF
[Match]
Name=wl*
[Network]
# to use static IP (with your settings) toggle commenting the next 8 lines.
#Address=192.168.50.61/24
#DNS=84.200.69.80 1.1.1.1
#[Route]
#Gateway=192.168.50.1
#Metric=20
DHCP=yes
[DHCP]
RouteMetric=20
EOF Setup wpa_supplicant with this file and your settings for country= , ssid= and psk= and enable it: root@raspberrypi:~ # cat >/etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE
network={
ssid="TestNet"
psk="realyNotMyPassword"
key_mgmt=WPA-PSK
proto=RSN WPA
}
EOF
root@raspberrypi:~ # chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
root@raspberrypi:~ # systemctl disable wpa_supplicant.service
root@raspberrypi:~ # systemctl enable [email protected]
root@raspberrypi:~ # rfkill unblock 0
root@raspberrypi:~ # exit
root@raspberrypi:~ $ Reboot and good luck ;-) It is possible that the RasPi gets a new ip addresses so you may have to look at it for the next connection with ssh . ♦ Step 4: Bonding wired and wifi interface for failover You should have both interfaces setup and running as described above. It is no problem when both interfaces are up. The kernel will use the interface with the lowest **metric** first. Here the ethernet interface will be used first. But this has a great disadvantage. As you can see with `ip -4 -brief addr` each interface has it's own ip-address. If the kernel switches the interface because one is gone down it also uses its new source ip-address. This will break any established statefull TCP communication, e.g. ssh, streaming, login sessions and so on. You can use a new connection from the changed source ip address but the old connections are stuck. That isn't really what we want. The solution of this problem is bonding . We create an interim interface bond0 that does not change its settings. The wired and wifi interface will switch to bond0 . First disable the single ethernet and wifi network files: pi@raspberrypi:~ $ sudo -Es
root@raspberrypi:~ # cd /etc/systemd/network/
root@raspberrypi:~ # mv 04-eth.network 04-eth.network~
root@raspberrypi:~ # mv 08-wifi.network 08-wifi.network~ Then setup bonding with these four files: root@raspberrypi:~ # cat >/etc/systemd/network/02-bond0.netdev <<EOF
[NetDev]
# status: cat /proc/net/bonding/bond0
Name=bond0
Kind=bond
[Bond]
Mode=active-backup
# primary slave is defined in *eth.network
MIIMonitorSec=500ms
MinLinks=1
EOF
root@raspberrypi:~ # cat >/etc/systemd/network/12-bond0-add-eth.network <<EOF
[Match]
Name=e*
[Network]
Bond=bond0
PrimarySlave=yes
EOF
root@raspberrypi:~ # cat >/etc/systemd/network/16-bond0-add-wifi.network <<EOF
[Match]
Name=wl*
[Network]
Bond=bond0
EOF
root@raspberrypi:~ # cat >/etc/systemd/network/20-bond0-up.network <<EOF
[Match]
Name=bond0
[Network]
# to use static IP (with your settings) toggle commenting the next 4 lines.
DHCP=yes
#Address=192.168.50.60/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
EOF But this is not the whole story. systemd-networkd checks if all interfaces are up before proceeding with startup depending services. With bonding we have slave interfaces (eth0, wlan0) that never signal that they are up. Its only the bond interface that comes up if at least one of its slaves is connected. So the check will fail with errors and long waiting on bootup. To manage this you have to modifiy the systemd-networkd-wait-online.service . How to do it, please follow the instructions at A start job is running for wait for network to be configured If finished that, it's time to reboot. It is possible that the RasPi gets a new ip address so you may have to look at it for the next connection with ssh. Then you can check the bonding status: pi@raspberrypi:~ $ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 500
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: dc:a6:32:4c:08:1b
Slave queue ID: 0
Slave Interface: wlan0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 1
Permanent HW addr: dc:a6:32:4c:08:1c
Slave queue ID: 0 Test bonding: with the bonding status above you will see that the Currently Active Slave: will change and the MII Status: is down. If your are headless, don't down both interfaces together ;-) pi@raspberrypi:~ $ ip addr
pi@raspberrypi:~ $ sudo ip link set eth0 down
pi@raspberrypi:~ $ sudo ip link set eth0 up
pi@raspberrypi:~ $ sudo ip link set wlan0 down
pi@raspberrypi:~ $ sudo ip link set wlan0 up Be patient after setting wlan0 up. I may take some time to reconnect to the router and manage bonding. This time ssh will not response. For a more in-depth review of bonding you may have a look at Dynamic network failover prioritize wifi over ethernet . references: [1] /usr/share/doc/systemd/README.Debian.gz [2] man systemd.netdev [3] man systemd.network [4] https://wiki.debian.org/Bonding [5] https://www.kernel.org/doc/Documentation/networking/bonding.txt | {
"source": [
"https://raspberrypi.stackexchange.com/questions/78787",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/79866/"
]
} |
78,991 | I am trying to run a very small python script AFTER internet has been established. I am currently editing /etc/network/if-up.d/upstart by adding the following code directly under all_interfaces_up() : all_interfaces_up() {
python /path/to/script.py
# return true if all interfaces listed in /etc/network/interfaces as 'auto'
# are up. if no interfaces are found there, then "all [given] were up"
local prefix="$1" iface=""
for iface in $(get_auto_interfaces); do
# if cur interface does is not up, then all have not been brought up
[ -f "${prefix}${iface}" ] || return 1
done
return 0
} I know that the program "script.py" works, because I have tested it numerous times. I just need it to run AFTER internet connection has been established. I have tried the above code with and without the "python" preceding the path to script. I have also made sure that #!path/to/python was at the top of my .py file. Furthermore, I did chmod + x to make it executable. What am I missing? I have rebooted my Pi everytime I have tried something new and have run the code service networking restart to make sure the networking is restarted. Why isn't my script running after Internet connection has been established? | As @Milliways commented here is where the power of systemd comes to play. There is no need to wait that sequential processed commands are finished. systemd is working parallel (that is what it makes a bit unfamiliar). It can start services after other services are started. Because this "network-up thing" is a very common problem, we have a nice service for it named network-online.target . Now it is very simple to start your_script.py after network-online.target . Let's do it with my_script.sh as template. You can replace it with your_script.py . I use Raspbian Lite from debian stretch . Create my_script.sh and test it: pi ~$ cd
pi ~$ cat > my_script.sh <<EOF
#!/bin/bash
echo "hello world" >>/tmp/my_script.out
EOF
pi ~$ chmod u+x my_script.sh
pi ~$ ./my_script.sh
pi ~$ cat /tmp/my_script.out
hello world
pi ~$ Now create a new service for my_script.sh : pi ~$ sudo systemctl edit --force --full my_script.service Insert this statements with your settings, save them and quit the editor: [Unit]
Description=My Script Service
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi
ExecStart=/home/pi/my_script.sh
[Install]
WantedBy=multi-user.target Check the new service: pi ~$ systemctl status my_script.service
● my_script.service - My Script Service
Loaded: loaded (/etc/systemd/system/my_script.service; disabled; vendor preset: enabled)
Active: inactive (dead) Now we can enable and test our service: pi ~$ sudo systemctl enable my_script.service
pi ~$ sudo systemctl start my_script.service
pi ~$ sudo systemctl start my_script.service
pi ~$ cat /tmp/my_script.out
hello world
hello world
hello world
pi ~$ sudo systemctl reboot Login and check. /tmp directory was cleaned up on boot. pi ~$ cat /tmp/my_script.out
hello world
pi ~$ You can edit the unit-file and show it. After editing you must restart the service to take effect. pi ~$ sudo systemctl edit --full my_script.service
pi ~$ sudo systemctl restart my_script.service
pi ~$ systemctl cat my_script.service To check that all network devices are really up modify my_script.sh like this, reboot and look at /tmp/my_script.out : pi ~$ cat > my_script.sh <<EOF
#!/bin/bash
/bin/ip addr >/tmp/my_script.out
EOF
pi ~$ sudo systemctl reboot reference: [1] man systemd.unit | {
"source": [
"https://raspberrypi.stackexchange.com/questions/78991",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/80687/"
]
} |
80,193 | I have installed docker as described here raspberrypi.org/blog/docker-comes-to-raspberry-pi with curl -sSL https://get.docker.com | sh .
How do I uninstall it? | I had to use sudo apt remove docker-ce . The script at get.docker.com runs "$pkg_manager install -y -q docker-ce$pkg_version" so docker-ce is the package, not docker . | {
"source": [
"https://raspberrypi.stackexchange.com/questions/80193",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/81814/"
]
} |
80,208 | I am using Raspberry Pi 3 Model B for my project purpose. The Pi 3 works fine when it is powered through a 5V/2A charger and I am able to use the inbuilt Bluetooth and Wifi using it, but when I try to use the GPIO pins, I am not getting proper output voltage. For eg. when I use a multi meter to check the output voltage at 5V pin or 3.3v pin, the meter shows reading around 0.1V to 0.3 V. Is it due to the 5v/2a charger,which is not providing the required power? Or, is the problem with the Raspberry Pi board? Should I buy a 5V/2.5A charger as per the Pi3 specifications? | I had to use sudo apt remove docker-ce . The script at get.docker.com runs "$pkg_manager install -y -q docker-ce$pkg_version" so docker-ce is the package, not docker . | {
"source": [
"https://raspberrypi.stackexchange.com/questions/80208",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/82198/"
]
} |
83,374 | I would like update Node.js to the latest version and I need to choose between ARMv6 and ARMv7. From the package manager point of view this is an ARMv6 processor and dmesg tells it is CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7) so... probably ARMv7. Googling, I saw lot of people used ARMv7 without problem. But is it correct? | First: It's ARMv6. The Zero uses the original BCM2835 SoC used on the first generation of Pi's and all the other single core models, with a ARM1176JZF-S processor (although the Zero models have ones binned as 1000 Mhz instead of 700). All ARM11 cores use the ARMv6 instruction set architecture. Since those using ARMv7 or 8 are backward compatible with ARMv6, Raspbian has stuck with that. This is also the reason most of the distros used on the multicore models cannot be used on the Zero -- because they are ARMv7. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/83374",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/85471/"
]
} |
83,610 | I looked over various websites providing the pinout explanation, especially this . But I have trouble to figure them to the real rpi zero. I mean in the following image provides the pinout Information: But I cannot figure out on real rpi if the 5V and 3v3 pins are the ones located closer to sd card reader or not. In other words how I should place my RPi Zero against the image in order to figure out the pinout? Should the sdcard reader pointing towards left as I am looking it? (I use the sd card component as reference point in order to distinguish the pins more easily because rpizero has from one side the SD card reader and from the outher header the screen "slot") | In your image, the SD-card reader would be positioned to the left and the front side of the card would be facing the viewer. Here's a better image which can't be misinterpreted: | {
"source": [
"https://raspberrypi.stackexchange.com/questions/83610",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/85965/"
]
} |
84,810 | I have a stack of five Pis, each of which have a separate hostname and are on the same network. I need to physically identify each Pi from another Pi, perhaps by flashing the onboard LEDs in a recognisable manner. Any idea how I might do this from Bash ideally, and without wiring anything up? | On at least a Pi 3, you can turn the green (SD card activity) LED to be on constantly with the following command (as root): echo 1 > /sys/class/leds/led0/brightness Now that Pi will have the green LED on steady, which makes it very easy to identify and label. To put the LED back to its default state: echo 0 > /sys/class/leds/led0/brightness
echo mmc0 > /sys/class/leds/led0/trigger Iterate through all of your Pis this way until you've got them all addressed and labeled accordingly. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/84810",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/64367/"
]
} |
87,164 | What's the best approach for configuring the Time Zone non-interactively? Previously for hostname , I've used sudo raspi-config nonint do_hostname However, I am unable to locate the equivalent command for timezone ? | use timedatectl - for example sudo timedatectl set-timezone Australia/Sydney | {
"source": [
"https://raspberrypi.stackexchange.com/questions/87164",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/88244/"
]
} |
88,214 | I know how to do it the classic way as described for example by the official documentation at Wireless connectivity . But that needs many different components which must play together and each component must be configured its own way. These are networking (ifupdown) , dhcpcd , hostapd , dnsmasq and bridge-utils . Nowadays Raspbian Stretch has all needed components built in so it is not necessary to install additional software. This could simplify the setup a lot. Is it possible just to configure Raspbian to work as an wifi access point without installing additional software? | ━━━ Setting up an access point ━━━ We are talking about an access point together with an ethernet port eth0 . If you want an access point together with a wlan0 client connection to another wifi network (wlan repeater) then look at Access point as WiFi router/repeater, optional with bridge . It is possible to configure Raspbian Stretch as a wifi access point without installing additional software. All needed components are available: networking, DHCP server and bridging comes with systemd-networkd and wifi can be setup with wpa_supplicant . Connecting two interfaces eth0 and wlan0 can be done by routing or by bridging. Below first the setup for quick installation and then the details. First we have to switch over to systemd-networkd . Tested with Raspbian Buster Lite 2020-02-13 on a Raspberry Pi 4B updated at 2020-05-12. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . Here you can find the last tested revision for previous Raspbian versions . ♦ General setup Switch over to systemd-networkd Just follow to Use systemd-networkd for general networking . You can use section "♦ Quick Step" . Then come back here. Configure wpa_supplicant as access point To configure wpa_supplicant as access point create this file with your settings for country= , ssid= , psk= and maybe frequency= . You can just copy and paste this in one block to your command line beginning with cat and including both EOF (delimiter EOF will not get part of the file): rpi ~$ sudo -Es # if not already done
rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="RPiNet"
mode=2
frequency=2437
#key_mgmt=NONE # uncomment this for an open hotspot
# delete next 3 lines if key_mgmt=NONE
key_mgmt=WPA-PSK
proto=RSN WPA
psk="password"
}
EOF
rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
rpi ~# systemctl disable wpa_supplicant.service
rpi ~# systemctl enable [email protected]
rpi ~# rfkill unblock wlan Finished General setup. Go back. ♦ Setting up a stand alone access point Example for this setup: wifi
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0)
\ /
(dhcp) 192.168.4.1 Do "General setup" then create the following file to configure wlan0 . We only have the access point. There is no ethernet device configured. rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
MulticastDNS=yes
DHCPServer=yes
EOF If you want this then reboot. That's it. Otherwise go on, no need to reboot at this time. ♦ Setting up an access point and with eth0, without routing Example for this setup: |
wifi | wired wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
\ / | \ /
(dhcp) 192.168.4.1 | (dhcp) 192.168.50.1 Setup Do "Setting up a stand alone access point" then create the following file to configure eth0 . rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
DHCP=yes
EOF Reboot. That's it. Details Interface eth0 is connected with an ethernet cable to the internet router and gets it configuration by DHCP from the internet router. It is no problem to give it a static ip address with e.g. Address=192.168.50.2 instead of DHCP=yes . Without routing you cannot get into the internet with the mobile-phone. You can only get into it from the RPi itself to get updates or something like. ♦ Setting up an access point and with eth0, with NAT (recommended) Example for this setup: wifi wired wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
\ / \
(dhcp) 192.168.4.1 (dhcp) Setup Do "General setup" then create the following files to configure wlan0 and eth0 . If you have tried one of the previous setups then you can just overwrite the two files. Be sure that you use a different subnet for the access point than that from the router. The router in this example does not use subnet 192.168.4.0/24. If you need another subnet then just change the Address line, e.g. Address=192.168.5.1/24 . rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
MulticastDNS=yes
# IPMasquerade is doing NAT
IPMasquerade=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
DHCP=yes
EOF Reboot. That's it. Details If you have no access to the internet router you can fake it with NAT (network address translation) to tell it a lie that all packages are coming from your RasPi AP. But this is not clean routing and has limitations. Clients on the subnet of the router cannot connect to clients on the wifi. But in most cases this is not needed so this setup is recommended because it simplifies the setup. If you need to connect to the wifi clients from the router network then you have to use full routing as desribed in the next section. ♦ Setting up an access point and with eth0, with routing Example for this setup: wifi wired wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
\ / \ /
(dhcp) 192.168.4.1 192.168.50.2 192.168.50.1 Setup Do "General setup" then create the following files to configure wlan0 and eth0 . If you have tried one of the previous setups then you can just overwrite the two files. Be sure that you use different subnets for the access point and the router network. We have to use static ip addresses because we must use them as gateways. rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
MulticastDNS=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Address=192.168.50.2/24
Gateway=192.168.50.1
DNS=84.200.69.80 1.1.1.1
IPForward=yes
EOF Reboot. To get routing complete working you have to set a static route in your internet router so it can find the route for back coming packages over the RasPi to the clients connected by wifi to the access point. On most internet router you can set a static route but how to do that varies from model to model. It's up to you to find it out. For example your RasPi eth0 interface has the static ip address 192.168.50.2. Then on your router the gateway (next hop) is 192.168.50.2, destination network is 192.168.4.0/24 (or 192.168.4.0 netmask 255.255.255.0). That means for the internet router: "send all packages belonging to subnet 192.168.4.0/24 (destination network from AP) to the next router on my subnet, the RasPi AP 192.168.50.2 (gateway). It knows where to go on." That's it. ♦ Setting up an access point with a bridge Example for this setup: RPi
wifi ┌──────bridge──────┐ wired wan
mobile-phone <.~.~.~> │(wlan0) br0 (eth0)│ <-------> router <-----> INTERNET
\ | / DHCP-server
(dhcp (dhcp 192.168.50.1
from router) from router) If you have already an ethernet network with DHCP server and internet router and you want to expand it with a wifi access point but with the same ip addresses then you use a bridge. This is often used as an uplink to a router. Setup Do "General setup" then create the following three files to configure the network interfaces. If you have tried one of the previous setups then you can just delete all files in /etc/systemd/network/ except 99-default.link if present. The ip addresses are examples. You have to use your own. rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/02-br0.netdev <<EOF
[NetDev]
Name=br0
Kind=bridge
EOF
rpi ~# cat > /etc/systemd/network/04-br0_add-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Bridge=br0
EOF
rpi ~# cat > /etc/systemd/network/12-br0_up.network <<EOF
[Match]
Name=br0
[Network]
MulticastDNS=yes
DHCP=yes
# to use static IP uncomment these and comment DHCP=yes
#Address=192.168.50.60/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
EOF Now we have to tell wpa_supplicant to use a bridge. We do it by modifying its service with: rpi ~# systemctl edit [email protected] In the empty editor insert these statements, save them and quit the editor: [Service]
ExecStartPre=/sbin/iw dev %i set type __ap
ExecStartPre=/bin/ip link set %i master br0
ExecStart=
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I -bbr0
ExecStopPost=-/bin/ip link set %i nomaster
ExecStopPost=-/sbin/iw dev %i set type managed Reboot. That's it. Details We have to tell wpa_supplicant that its interface wlan0 is slave of a bridge. Otherwise it will reject client connects with "wrong password" means the key negotiation does not work. When we tell /sbin/wpa_supplicant with option -dbr0 to use a bridge for wlan0 then the interface must already be a member of the bridge. That's what we do with the drop in file (overlay) for the wpa_supplicant service. The empty statement ExecStart= deletes the old entry. Otherwise you have two lines ExecStart= and wpa_supplicant will start two times. The original ExecStart= you can view with systemctl cat [email protected] . Normally the router you are connected to with the ethernet cable has a DHCP server enabled. The bridge is also transparent for DHCP requests from the stations (devices connected to the access point) so you don't have to worry about configuration of its interfaces with ip addresses and options. The router will serve it. excursus: But if the router doesn't have a DHCP server, you can setup one on the RasPi. systemd-networkd has options to configure its built-in DHCP server but the problem is that systemd-networkd assumes it is running on the router itself and that's not true in this case. It will serve wrong options to the stations, in particular the router option. There is no way to configure it. So we have to install dnsmasq in this case that can be configured as needed. Install and configure it with (example, use your own ip addresses): rpi ~$ sudo -Es
rpi ~# apt install dnsmasq
rpi ~# systemctl stop dnsmasq
rpi ~# mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
rpi ~# cat > /etc/dnsmasq.conf <<EOF
interface=br0
dhcp-range=192.168.50.128,192.168.50.164,255.255.255.0,24h
dhcp-option=option:router,192.168.50.1
dhcp-option=option:dns-server,8.8.8.8,1.1.1.1
EOF
rpi ~# systemctl start dnsmasq
rpi ~# exit
rpi ~$ In this example are ip addresses 192.168.50.128 to 192.168.50.164 reserved to give to stations. For other static ip addresses use one outside this pool, also the ip address for the bridge itself. ♦ Optimizing When starting wpa_supplicant you mostly get this messages in the journal: wpa_supplicant[427]: random: Cannot read from /dev/random: Resource temporarily unavailable
wpa_supplicant[427]: random: Only 12/20 bytes of strong random data available from /dev/random
wpa_supplicant[427]: random: Not enough entropy pool available for secure operations
wpa_supplicant[427]: WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects It is not a big issue. wpa_supplicant needs random numbers to generate encrpyting keys. This is done a little bit slow so it has to wait. Fortunately the RasPi has a build in T rue R andom N umber G enerator (TRNG). We can use it and speed up getting random numbers by installing a piece of software (3) with: rpi ~$ sudo apt install rng-tools Update: Since Raspbian Stretch 2019-04-08 there is no need to install rng-tools . They are installed by default. ♦ Troubleshooting systemd-networkd Look at the status of a service: rpi ~$ systemctl status systemd-networkd.service
rpi ~$ systemctl status [email protected] Or even a bit more: rpi ~$ journalctl --boot --pager-end I found it helpful to follow the ongoing logging: rpi ~$ journalctl --boot --follow If you have made a drop in file you can look at the result: rpi ~$ systemctl cat [email protected] To check the runtime environment of a unit you can show it and for example look if there are two ExecStart= lines: rpi ~$ systemctl show [email protected] And if nothing others help you can enable the debug option from /sbin/wpa_supplicant with -d in a drop in file: rpi ~$ sudo systemctl edit [email protected]
ExecStart=
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I -bbr0 -d The output is in the journal. This way I have found the issue with the wrong key negotiation. wifi If you have setup the access point you should find it with a mobile phone. Showing the available networks, it is presented with name RPiNet and you can connect to it. On the RasPi you can also use the command: rpi ~$ sudo iw dev wlan0 info
phy#0
Interface wlan0
ifindex 3
wdev 0x2
addr b8:27:eb:06:e8:8b
ssid RPiNet
type AP
channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz As you can see it is type AP (access point) and it will also show you what channel it is using. A problem may be to translate a channel into frequency. The frequency must match a channel. You can look at (2) for a list of WLAN channels. For example to use channel 36 on the 5.1 GHz band you have to set frequency=5180 in /etc/wpa_supplicant\wpa_supplicant.conf . But you must be sure that your wifi supports the 5.1 GHz band. You can check with sudo iw phy . This will give you a bunch of information. It must also contain supported frequencies above 5000 MHz. If you only see frequencies of 24xx MHz then of course you can only use this. Another point could be random numbers. For encrypting keys for secured connections wpa_supplicant needs random numbers. Generating this is very slow on a Raspberry Pi. If it does not have enough entropy to generate encrypting keys wpa_supplicant will reject the authentication. You can look with cat /proc/sys/kernel/random/entropy_avail how many entropy is available. It should be >1000 to work quick enough. To speed up this, the rng-tools are installed by default. Look at the section Optimizing for further information. references: [1] Howto migrate from networking to systemd-networkd with dynamic failover [2] List of WLAN channels [3] Rng-tools | {
"source": [
"https://raspberrypi.stackexchange.com/questions/88214",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/79866/"
]
} |
88,217 | My RPi 3 will not boot even after I have looked at every possible trouble shooting technique I could find. I plug it into the power and all it does it turn on the red led. I had it working for some time, but now it refuses to turn on. I've now tried 3 different power sources and 3 different SD cards and all have ended in the same result of it not booting. It gave me this same problem when I first got it, but after the 3rd SD card it seemed to have worked itself out. The current power supply and SD card are from Adafruit, so I trust that they are of decent quality. Could this be a problem with the manufacturing of the RPi? I've refused to believe it is, but I don't know what else it could be. | ━━━ Setting up an access point ━━━ We are talking about an access point together with an ethernet port eth0 . If you want an access point together with a wlan0 client connection to another wifi network (wlan repeater) then look at Access point as WiFi router/repeater, optional with bridge . It is possible to configure Raspbian Stretch as a wifi access point without installing additional software. All needed components are available: networking, DHCP server and bridging comes with systemd-networkd and wifi can be setup with wpa_supplicant . Connecting two interfaces eth0 and wlan0 can be done by routing or by bridging. Below first the setup for quick installation and then the details. First we have to switch over to systemd-networkd . Tested with Raspbian Buster Lite 2020-02-13 on a Raspberry Pi 4B updated at 2020-05-12. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . Here you can find the last tested revision for previous Raspbian versions . ♦ General setup Switch over to systemd-networkd Just follow to Use systemd-networkd for general networking . You can use section "♦ Quick Step" . Then come back here. Configure wpa_supplicant as access point To configure wpa_supplicant as access point create this file with your settings for country= , ssid= , psk= and maybe frequency= . You can just copy and paste this in one block to your command line beginning with cat and including both EOF (delimiter EOF will not get part of the file): rpi ~$ sudo -Es # if not already done
rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="RPiNet"
mode=2
frequency=2437
#key_mgmt=NONE # uncomment this for an open hotspot
# delete next 3 lines if key_mgmt=NONE
key_mgmt=WPA-PSK
proto=RSN WPA
psk="password"
}
EOF
rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
rpi ~# systemctl disable wpa_supplicant.service
rpi ~# systemctl enable [email protected]
rpi ~# rfkill unblock wlan Finished General setup. Go back. ♦ Setting up a stand alone access point Example for this setup: wifi
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0)
\ /
(dhcp) 192.168.4.1 Do "General setup" then create the following file to configure wlan0 . We only have the access point. There is no ethernet device configured. rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
MulticastDNS=yes
DHCPServer=yes
EOF If you want this then reboot. That's it. Otherwise go on, no need to reboot at this time. ♦ Setting up an access point and with eth0, without routing Example for this setup: |
wifi | wired wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
\ / | \ /
(dhcp) 192.168.4.1 | (dhcp) 192.168.50.1 Setup Do "Setting up a stand alone access point" then create the following file to configure eth0 . rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
DHCP=yes
EOF Reboot. That's it. Details Interface eth0 is connected with an ethernet cable to the internet router and gets it configuration by DHCP from the internet router. It is no problem to give it a static ip address with e.g. Address=192.168.50.2 instead of DHCP=yes . Without routing you cannot get into the internet with the mobile-phone. You can only get into it from the RPi itself to get updates or something like. ♦ Setting up an access point and with eth0, with NAT (recommended) Example for this setup: wifi wired wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
\ / \
(dhcp) 192.168.4.1 (dhcp) Setup Do "General setup" then create the following files to configure wlan0 and eth0 . If you have tried one of the previous setups then you can just overwrite the two files. Be sure that you use a different subnet for the access point than that from the router. The router in this example does not use subnet 192.168.4.0/24. If you need another subnet then just change the Address line, e.g. Address=192.168.5.1/24 . rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
MulticastDNS=yes
# IPMasquerade is doing NAT
IPMasquerade=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
DHCP=yes
EOF Reboot. That's it. Details If you have no access to the internet router you can fake it with NAT (network address translation) to tell it a lie that all packages are coming from your RasPi AP. But this is not clean routing and has limitations. Clients on the subnet of the router cannot connect to clients on the wifi. But in most cases this is not needed so this setup is recommended because it simplifies the setup. If you need to connect to the wifi clients from the router network then you have to use full routing as desribed in the next section. ♦ Setting up an access point and with eth0, with routing Example for this setup: wifi wired wan
mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) <---------> router <---> INTERNET
\ / \ /
(dhcp) 192.168.4.1 192.168.50.2 192.168.50.1 Setup Do "General setup" then create the following files to configure wlan0 and eth0 . If you have tried one of the previous setups then you can just overwrite the two files. Be sure that you use different subnets for the access point and the router network. We have to use static ip addresses because we must use them as gateways. rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
MulticastDNS=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Address=192.168.50.2/24
Gateway=192.168.50.1
DNS=84.200.69.80 1.1.1.1
IPForward=yes
EOF Reboot. To get routing complete working you have to set a static route in your internet router so it can find the route for back coming packages over the RasPi to the clients connected by wifi to the access point. On most internet router you can set a static route but how to do that varies from model to model. It's up to you to find it out. For example your RasPi eth0 interface has the static ip address 192.168.50.2. Then on your router the gateway (next hop) is 192.168.50.2, destination network is 192.168.4.0/24 (or 192.168.4.0 netmask 255.255.255.0). That means for the internet router: "send all packages belonging to subnet 192.168.4.0/24 (destination network from AP) to the next router on my subnet, the RasPi AP 192.168.50.2 (gateway). It knows where to go on." That's it. ♦ Setting up an access point with a bridge Example for this setup: RPi
wifi ┌──────bridge──────┐ wired wan
mobile-phone <.~.~.~> │(wlan0) br0 (eth0)│ <-------> router <-----> INTERNET
\ | / DHCP-server
(dhcp (dhcp 192.168.50.1
from router) from router) If you have already an ethernet network with DHCP server and internet router and you want to expand it with a wifi access point but with the same ip addresses then you use a bridge. This is often used as an uplink to a router. Setup Do "General setup" then create the following three files to configure the network interfaces. If you have tried one of the previous setups then you can just delete all files in /etc/systemd/network/ except 99-default.link if present. The ip addresses are examples. You have to use your own. rpi ~$ sudo -Es # if not already executed before
rpi ~# cat > /etc/systemd/network/02-br0.netdev <<EOF
[NetDev]
Name=br0
Kind=bridge
EOF
rpi ~# cat > /etc/systemd/network/04-br0_add-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Bridge=br0
EOF
rpi ~# cat > /etc/systemd/network/12-br0_up.network <<EOF
[Match]
Name=br0
[Network]
MulticastDNS=yes
DHCP=yes
# to use static IP uncomment these and comment DHCP=yes
#Address=192.168.50.60/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
EOF Now we have to tell wpa_supplicant to use a bridge. We do it by modifying its service with: rpi ~# systemctl edit [email protected] In the empty editor insert these statements, save them and quit the editor: [Service]
ExecStartPre=/sbin/iw dev %i set type __ap
ExecStartPre=/bin/ip link set %i master br0
ExecStart=
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I -bbr0
ExecStopPost=-/bin/ip link set %i nomaster
ExecStopPost=-/sbin/iw dev %i set type managed Reboot. That's it. Details We have to tell wpa_supplicant that its interface wlan0 is slave of a bridge. Otherwise it will reject client connects with "wrong password" means the key negotiation does not work. When we tell /sbin/wpa_supplicant with option -dbr0 to use a bridge for wlan0 then the interface must already be a member of the bridge. That's what we do with the drop in file (overlay) for the wpa_supplicant service. The empty statement ExecStart= deletes the old entry. Otherwise you have two lines ExecStart= and wpa_supplicant will start two times. The original ExecStart= you can view with systemctl cat [email protected] . Normally the router you are connected to with the ethernet cable has a DHCP server enabled. The bridge is also transparent for DHCP requests from the stations (devices connected to the access point) so you don't have to worry about configuration of its interfaces with ip addresses and options. The router will serve it. excursus: But if the router doesn't have a DHCP server, you can setup one on the RasPi. systemd-networkd has options to configure its built-in DHCP server but the problem is that systemd-networkd assumes it is running on the router itself and that's not true in this case. It will serve wrong options to the stations, in particular the router option. There is no way to configure it. So we have to install dnsmasq in this case that can be configured as needed. Install and configure it with (example, use your own ip addresses): rpi ~$ sudo -Es
rpi ~# apt install dnsmasq
rpi ~# systemctl stop dnsmasq
rpi ~# mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
rpi ~# cat > /etc/dnsmasq.conf <<EOF
interface=br0
dhcp-range=192.168.50.128,192.168.50.164,255.255.255.0,24h
dhcp-option=option:router,192.168.50.1
dhcp-option=option:dns-server,8.8.8.8,1.1.1.1
EOF
rpi ~# systemctl start dnsmasq
rpi ~# exit
rpi ~$ In this example are ip addresses 192.168.50.128 to 192.168.50.164 reserved to give to stations. For other static ip addresses use one outside this pool, also the ip address for the bridge itself. ♦ Optimizing When starting wpa_supplicant you mostly get this messages in the journal: wpa_supplicant[427]: random: Cannot read from /dev/random: Resource temporarily unavailable
wpa_supplicant[427]: random: Only 12/20 bytes of strong random data available from /dev/random
wpa_supplicant[427]: random: Not enough entropy pool available for secure operations
wpa_supplicant[427]: WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects It is not a big issue. wpa_supplicant needs random numbers to generate encrpyting keys. This is done a little bit slow so it has to wait. Fortunately the RasPi has a build in T rue R andom N umber G enerator (TRNG). We can use it and speed up getting random numbers by installing a piece of software (3) with: rpi ~$ sudo apt install rng-tools Update: Since Raspbian Stretch 2019-04-08 there is no need to install rng-tools . They are installed by default. ♦ Troubleshooting systemd-networkd Look at the status of a service: rpi ~$ systemctl status systemd-networkd.service
rpi ~$ systemctl status [email protected] Or even a bit more: rpi ~$ journalctl --boot --pager-end I found it helpful to follow the ongoing logging: rpi ~$ journalctl --boot --follow If you have made a drop in file you can look at the result: rpi ~$ systemctl cat [email protected] To check the runtime environment of a unit you can show it and for example look if there are two ExecStart= lines: rpi ~$ systemctl show [email protected] And if nothing others help you can enable the debug option from /sbin/wpa_supplicant with -d in a drop in file: rpi ~$ sudo systemctl edit [email protected]
ExecStart=
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I -bbr0 -d The output is in the journal. This way I have found the issue with the wrong key negotiation. wifi If you have setup the access point you should find it with a mobile phone. Showing the available networks, it is presented with name RPiNet and you can connect to it. On the RasPi you can also use the command: rpi ~$ sudo iw dev wlan0 info
phy#0
Interface wlan0
ifindex 3
wdev 0x2
addr b8:27:eb:06:e8:8b
ssid RPiNet
type AP
channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz As you can see it is type AP (access point) and it will also show you what channel it is using. A problem may be to translate a channel into frequency. The frequency must match a channel. You can look at (2) for a list of WLAN channels. For example to use channel 36 on the 5.1 GHz band you have to set frequency=5180 in /etc/wpa_supplicant\wpa_supplicant.conf . But you must be sure that your wifi supports the 5.1 GHz band. You can check with sudo iw phy . This will give you a bunch of information. It must also contain supported frequencies above 5000 MHz. If you only see frequencies of 24xx MHz then of course you can only use this. Another point could be random numbers. For encrypting keys for secured connections wpa_supplicant needs random numbers. Generating this is very slow on a Raspberry Pi. If it does not have enough entropy to generate encrypting keys wpa_supplicant will reject the authentication. You can look with cat /proc/sys/kernel/random/entropy_avail how many entropy is available. It should be >1000 to work quick enough. To speed up this, the rng-tools are installed by default. Look at the section Optimizing for further information. references: [1] Howto migrate from networking to systemd-networkd with dynamic failover [2] List of WLAN channels [3] Rng-tools | {
"source": [
"https://raspberrypi.stackexchange.com/questions/88217",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/90819/"
]
} |
88,954 | I want to bridge the wifi interface with the ethernet interface on a Raspberry Pi so any device on the ethernet port becomes a member of the wifi network. Usually this is done by a bridge (OSI layer 2) but on wifi you need WDS (wireless distribution system) with 4addr to do it. Unfortunately WDS isn't supported by the wifi on board chip of a Raspberry Pi so we have to workaround it with proxy arp . Bridging Network Connections with Proxy ARP shows how to do it on a Debian system. But it uses old style networking that isn't supported out of the box by Raspbian . How can I make proxy arp available on a Raspberry Pi with Raspbian? | Proxy arp is a way to build a pseudo bridge that is working on OSI layer 3 but it behaves like a real layer 2 bridge. So it is a good way to workaround the lack of WDS support on Raspberry Pi.
There are mainly two methods to use it. You can use a subnet overlapping with the main local network. This is only a configuration issue and does not need additional helper programs. This makes it more stable and less error prone. But it requires some more know how about subnets to configure it and to understand how it works. And it has some restrictions in using ip address ranges, but this doesn't matter in most cases. You will see. There are also helper programs available that makes usage of ip address ranges more flexible but it is more sensible with correct configuration and stability. If ip address ranges doesn't matter I would prefer the subnetting method. ############################################################################# PROXY ARP WITH SUBNETTING (recommended) Example Setup ┌─proxy arp─┐ UPLINK
wired V ║ V wifi wan
laptop <────────────> (eth0)RPi(wlan0) <~.~.~.~.> hotspot <---> INTERNET
\ ╱ ║ ╲
(dhcp from 192.168.50.241 ║ (dhcp from hotspot)
RPi) ║
║
subnet: 192.168.50.240/28 ║ 192.168.50.0/24 As you can see, we have two subnets: the main subnet (local WiFi network): 192.168.50.0/24
ip addresses: 192.168.50.1 to 192.168.50.254 = 254 ip addresses
broadcast address: 192.168.50.255
the wired subnet: 192.168.50.240/28
ip addresses: 192.168.50.241 to 152.168.50.254 = 14 ip addresses
broadcast address: 192.168.50.255 Have in mind that you cannot use the first network address and the last broadcast address of each subnet. For details on subnets look at Wikipedia - Subnetwork . For proxy arp it is important that the smaller wired subnet is a subset of the main subnet and that it fits to the correct boundaries of possible subnets in the main subnet. I have set it to the end of the main subnet. With this example we can address 14 devices on the wired subnet. If you need more or less simply use a bigger or smaller wired subnet. To calculate the subnet I use this IP Calculator but there are some others. Use your own favorite one. So we have this overlapping: 0 |240 255
main subnet: |N------------------------------------------------B|
wired subnet: |N---------B| Here you can see that a device on the main subnet can also broadcast for ip addresses 241 to 254. If you ensure - and that is important - that there are no devices on the main subnet having these addresses, the RasPi can use proxy arp to reply to the broadcast for an ip address instead of the device on the wired subnet, which isn't direct addressable from the main subnet. The RasPi works as proxy for the arp request. Please note that this has nothing to do with routing using ip addresses. It only works with mac addresses. That is also the reason why this only works on local area networks with one main subnet (broadcast domain). Again, you must ensure that there are no devices on the main subnet using the ip addresses from the wired subnet. If using a DHCP server you must exclude this ip range from its address pool. Now with this background information let's configure the RasPi. To simplify things I will use systemd-networkd . Tested with Raspberry Pi OS (32-bit) Lite 2020-05-27 on a Raspberry Pi 4B updated at 2020-08-19. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . Switch over to systemd-networkd Just follow to Use systemd-networkd for general networking . You can use section ♦ Quick Step . Then come back here. Configure the WiFi client connection Create this file for wpa_supplicant with your settings for country= , ssid= and psk= : rpi ~$ sudo -Es # if not already done
rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=DE
ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="TestNet"
psk="testingPassword"
}
EOF
rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
rpi ~# systemctl disable wpa_supplicant.service
rpi ~# systemctl enable [email protected]
rpi ~# rfkill unblock 0 We have to enable promiscuous mode on wlan0 to see broadcasts on both subnets. Edit the wpa_supplicant.service with: rpi ~# sudo systemctl edit [email protected] In the empty editor insert these statements, save them and quit the editor: [Service]
ExecStartPre=/sbin/ip link set %i promisc on
ExecStopPost=/sbin/ip link set %i promisc off Configure interfaces Create these two files. rpi ~# cat > /etc/systemd/network/04-wired.network <<EOF
[Match]
Name=e*
[Network]
# Have attention to the bit mask at the end of the address
Address=192.168.50.241/28
# or just the smallest possible subnet with 2 ip addresses
#Address=192.168.50.253/30
# or the half of the main subnet with 126 ip addresses
#Address=192.168.50.129/25
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF rpi ~# cat > /etc/systemd/network/08-wifi.network <<EOF
[Match]
Name=wl*
[Network]
DHCP=yes
IPForward=ipv4
IPv4ProxyARP=yes
EOF Reboot. That's it. ############################################################################# PROXY ARP WITH HELPER PROGRAMS In general I followed the tutorial (2) . Have a look at it for the background. Example Setup ┌─proxy arp─┐ UPLINK
wired V V wifi wan
laptop <─────────> (eth0)RPi(wlan0) <~.~.~.~.> hotspot <---> INTERNET
\ \
(dhcp from hotspot) (dhcp from hotspot) I will present two setups. One that is only static but simpler. It is configured one time on startup and does not respect changes on its interfaces. You have to reboot then. It is good for static use cases, for example to connect a printer. The other setup is a bit more complex but it will monitor connection changes on its interfaces. It is usable on mobile RasPis that will connect to different WiFi networks and wired connections on the fly. Tested with Raspbian Buster Lite 2019-09-26 on a Raspberry Pi 4B updated at 2020-02-05.
Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . Here you can find the last tested revision for previous Raspbian versions . ♦ Static configuration of proxy arp First do ♦ General Setup (look at the end). Then follow this setup. parprouted runs as a daemon but has no systemd unit installed. So we will make it and enable also promiscous mode: rpi ~# systemctl edit --full --force parprouted.service In the empty editor insert these statements, save them and quit the editor: [Unit]
Description=proxy arp routing service
Documentation=https://raspberrypi.stackexchange.com/q/88954/79866
[Service]
Type=forking
PIDFile=/run/parprouted.pid
# Restart until wlan0 gained carrier
Restart=on-failure
RestartSec=5
TimeoutStartSec=30
ExecStartPre=/lib/systemd/systemd-networkd-wait-online --interface=wlan0 --timeout=6 --quiet
ExecStartPre=/bin/echo 'systemd-networkd-wait-online: wlan0 is online'
# clone the dhcp-allocated IP to eth0 so dhcp-helper will relay for the correct subnet
ExecStartPre=/bin/bash -c '/sbin/ip addr add $(/sbin/ip -4 -br addr show wlan0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0'
ExecStartPre=/sbin/ip link set dev eth0 up
ExecStartPre=/sbin/ip link set wlan0 promisc on
# v minus sign
ExecStart=-/usr/sbin/parprouted eth0 wlan0
ExecStopPost=/sbin/ip link set wlan0 promisc off
ExecStopPost=/sbin/ip link set dev eth0 down
ExecStopPost=/bin/bash -c '/sbin/ip addr del $(/sbin/ip -4 -br addr show eth0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0'
[Install]
[email protected] Enable the service: rpi ~# systemctl enable parprouted.service Reboot. That's it. ♦ Dynamic configuration of proxy arp with monitoring interfaces Because we will monitor the state of the inerfaces wlan0 and eth0 we have to use a program that will report changes. For this I have made the ifplug.service . So first Make ifplugd available again since Raspbian Stretch . If you have tested the ifplug.service and it works, then do ♦ General Setup . After that configure the eth0 interface with this file: rpi ~# cat > /etc/systemd/network/04-eth.network <<EOF
[Match]
Name=eth0
EOF As action file for the ifplug.service use this /etc/ifplugs/ifplugs.action script: #!/bin/bash
# redirect all output into a logfile for debug
#exec 1>> /tmp/ifplug-debug.log 2>&1
INTERFACE="$1"
EVENT="$2"
IPADDR=''
get_ipaddr () {
if [ "$EVENT" = "down" ]; then
IPADDR=$(/sbin/ip -4 -br addr show $INTERFACE | /bin/grep -Po "\d+\.\d+\.\d+\.\d+")
return 0
fi
# check 10 times with 1 sec delay if ip address is available
for ((i=10; i>0; i--)); do
IPADDR=$(/sbin/ip -4 -br addr show $INTERFACE | /bin/grep -Po "\d+\.\d+\.\d+\.\d+")
[ $? -eq 0 ] && break
/bin/sleep 1
done
}
case "$INTERFACE" in
eth0)
case "$EVENT" in
up)
# clone ip address from wlan0 and start parprouted
IPADDR=$(/sbin/ip -4 -br addr show wlan0 | /bin/grep -Po "\d+\.\d+\.\d+\.\d+")
if [ -n "$IPADDR" ]; then
/sbin/ip addr add $IPADDR/32 dev eth0
/usr/sbin/parprouted eth0 wlan0
fi
;;
down)
# stop parprouted
/usr/bin/killall -q parprouted
/sbin/ip -4 addr flush dev eth0
;;
*)
>&2 echo empty or undefined event for "$INTERFACE": \""$EVENT"\"
exit 1
;;
esac
;;
wlan0)
case "$EVENT" in
up)
# clone ip address from wlan0 and start parprouted
get_ipaddr
if [ -n "$IPADDR" ]; then
/sbin/ip addr add $IPADDR/32 dev eth0
/sbin/ip link set wlan0 promisc on
/usr/sbin/parprouted eth0 wlan0
fi
;;
down)
# stop parprouted
/usr/bin/killall -q parprouted
/sbin/ip link set wlan0 promisc off
/sbin/ip -4 addr flush dev eth0
;;
*)
>&2 echo empty or undefined event for "$INTERFACE": \""$EVENT"\"
exit 1
;;
esac
;;
*)
>&2 echo empty or unknown interface: \""$INTERFACE"\"
exit 1
;;
esac Reboot. That's it. You can follow actions with: rpi ~$ journalctl --follow | grep "ifplugd\|parprouted" ♦ General Setup Install helpers and setup systemd-networkd I will use systemd-networkd for reasons so first we have to switch over to it.
For detailed information look at (1) . Here only in short. Execute these commands: # install helpers
rpi ~$ sudo -Es
rpi ~# apt install parprouted dhcp-helper
rpi ~# systemctl stop dhcp-helper
rpi ~# systemctl enable dhcp-helper
# deinstall classic networking
rpi ~# apt --autoremove purge ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common
rpi ~# rm -r /etc/network /etc/dhcp
# setup systemd-resolved
rpi ~# apt --autoremove purge avahi-daemon
rpi ~# apt install libnss-resolve
rpi ~# systemctl enable systemd-resolved.service
rpi ~# ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
# enable systemd-networkd
rpi ~# systemctl enable systemd-networkd.service Configure wpa_supplicant To configure wpa_supplicant create this file with your settings for country= , ssid= and psk= . You can just copy and paste this in one block to your command line beginning with cat and including EOF (delimiter EOF will not get part of the file): rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE
network={
ssid="TestNet"
key_mgmt=WPA-PSK
proto=RSN WPA
psk="verySecretPassword"
}
EOF
rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
rpi ~# systemctl disable wpa_supplicant.service
rpi ~# systemctl enable [email protected] To configure the wlan0 interface create this file: rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
IPForward=yes
DHCP=yes
# for a static ip address comment DHCP=yes
# and uncomment next 3 lines with your settings
#Address=192.168.50.2/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
EOF Setup helpers We have installed dhcp-helper , a proxy to get ip addresses from the wifi network, and parprouted that manages proxy arp . Enable DHCP relay in /etc/default/dhcp-helper : # relay dhcp requests as broadcast to wlan0
DHCPHELPER_OPTS="-b wlan0" End of General Setup. Go back. references: [1] Howto migrate from networking to systemd-networkd with dynamic failover [2] Bridging Network Connections with Proxy ARP [3] ProxyARP Subnetting HOWTO | {
"source": [
"https://raspberrypi.stackexchange.com/questions/88954",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/79866/"
]
} |
89,803 | I need a wireless access point that is bridged with the wired ethernet port and that is connected to another wifi internet router with a client connection as uplink. All devices connected to the RasPi either by wifi or by wired ethernet should have access to the internet and should be able to connect to each other. How can I achieve this with a Raspberry Pi? | We are talking about an access point together with a wireless client connection on interface wlan0 to another wifi network (wlan repeater) or an internet router. If you want an access point together with an ethernet interface eth0 for a wired uplink to a switch or an internet router then look at Setting up a Raspberry Pi as an access point - the easy way . Tested on a Raspberry Pi 4B with Raspberry Pi OS (32-bit) with desktop 2020-08-20 updated on 2020-09-01. Raspberry Pi OS (32-bit) with desktop 2020-05-27 updated on 2020-06-11. Raspbian Buster Lite 2020-02-13 updated on 2020-03-03. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . Here you will find the last tested revision for Raspbian Stretch Lite . IMPORTANT UPDATE on 2020-09-02: I have found that the image versions of the Raspberry Pi OS come with an unstable firmware for the built-in WiFi device. For further information look at my bug report at WiFi firmware brcmfmac crashes when using virtual AP interface . The last stable is firmware-brcm80211_20190114-1+rpt4_all.deb comming with image Raspbian Buster Lite 2020-02-13 . So we have to downgrade the WiFi firmware to this stable version as long as the bug isn't fixed. After flashing the Raspberry Pi OS image with update/full-upgrade, follow this to do downgrade: rpi ~$ wget http://archive.raspberrypi.org/debian/pool/main/f/firmware-nonfree/firmware-brcm80211_20190114-1+rpt4_all.deb
rpi ~$ sudo dpkg --purge firmware-brcm80211
rpi ~$ sudo dpkg --install firmware-brcm80211_20190114-1+rpt4_all.deb
rpi ~$ sudo apt-mark hold firmware-brcm80211
rpi ~$ sudo systemctl reboot The Raspberry Pi is able to work as a wireless hotspot and simultaneously connect to another hotspot as a client. But the wifi device on the RasPi has a general limitation. The client connection cannot be bridged because lack of WDS (wireless distribution system) that is needed for bridging on the wireless. For further information look at Raspberry Pi WiFi to Ethernet Bridge for a server? . So we can only use routing for the wifi client connection to the internet router. But the wifi hotspot and the wired ethernet port can be bridged so all devices on wifi and the wired port can have the same broadcast domain on its common subnet. I assume that you already have a connection to the internet. All commands can simply be copied and pasted to the command line of the RasPi. The blocks with EOF you can select from cat incl. the last EOF and paste it to the RasPis command line. With Enter it will be copied to a file without the delimiter EOF. We will first setup a wifi repeater so if anyone only needs this he can stop setup at this point and use it. For those who need a bridged ethernet port with the wifi access point can continue with setting it up. I use systemd-networkd for reasons. For the impatient first only the Setup. ♦ Setup wifi repeater Example for this setup: wifi wifi uplink wan
mobile-phone <~.~.~.~.~> (ap@wlan0)RPi(wlan0) <.~.~.~.~.> router <───> INTERNET
╲ ╱ ╲
(dhcp 192.168.4.1 (dhcp
from RPi) from router) Step 1: setup systemd-networkd Just follow to Use systemd-networkd for general networking . You can use section "♦ Quick Step" . Then come back here. Step 2: install hostapd for the access point rpi ~$ sudo -Es # if not already done
rpi ~# apt install hostapd Create this file with your settings for ssid= , country_code= and wpa_passphrase= . As channel= select the same channel wpa_supplicant with wlan0 will connect to your internet router. ATTENTION! This is a restriction from the hardware. hostapd will always set the channel to the same value than from the client connection, no matter what you set here. If you need different channels then you have to use an additional USB/WiFi dongle. rpi ~# cat > /etc/hostapd/hostapd.conf <<EOF
driver=nl80211
ssid=RPiNet
country_code=DE
hw_mode=g
channel=1
auth_algs=1
wpa=2
wpa_passphrase=verySecretPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
rpi ~# chmod 600 /etc/hostapd/hostapd.conf Create a service for the accesspoint with hostapd: rpi ~# systemctl edit --force --full [email protected] In the empty editor insert these statements, save them and quit the editor: [Unit]
Description=accesspoint with hostapd (interface-specific version)
Wants=wpa_supplicant@%i.service
[Service]
ExecStartPre=/sbin/iw dev %i interface add ap@%i type __ap
ExecStart=/usr/sbin/hostapd -i ap@%i /etc/hostapd/hostapd.conf
ExecStopPost=-/sbin/iw dev ap@%i del
[Install]
WantedBy=sys-subsystem-net-devices-%i.device Enable the service: rpi ~# systemctl enable [email protected]
rpi ~# rfkill unblock wlan Step 3: setup wpa_supplicant for client connection Create this file with your settings for country= , ssid= and psk= and enable it: rpi ~# cat >/etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="TestNet"
psk="realyNotMyPassword"
key_mgmt=WPA-PSK # see ref (4)
}
EOF
rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
rpi ~# systemctl disable wpa_supplicant.service Extend wpa_supplicant with: rpi ~# systemctl edit [email protected] In the empty editor insert these statements. Save it and quit the editor: [Unit]
BindsTo=accesspoint@%i.service
After=accesspoint@%i.service Step 4: setup static interfaces Create these files: rpi ~# cat > /etc/systemd/network/08-wifi.network <<EOF
[Match]
Name=wl*
[Network]
LLMNR=no
MulticastDNS=yes
# If you need a static ip address, then toggle commenting next four lines (example)
DHCP=yes
#Address=192.168.50.60/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
EOF For those who want a bridge, do not need the next file and must continue with Setup bridge . rpi ~# cat > /etc/systemd/network/12-ap.network <<EOF
[Match]
Name=ap@*
[Network]
LLMNR=no
MulticastDNS=yes
IPMasquerade=yes
Address=192.168.4.1/24
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF Setup a wifi repeater without bridge is finished. You must Reboot. ♦ Setup bridge Setup wifi repeater as described above. Example for this setup: (dhcp
from RPi) bridge
╱ wifi ┌──────┐
mobile-phone <~.~.~.~.> │(ap@) │ wifi uplink wan
│ br0│RPi(wlan0) <.~.~.~.~.> router <───> INTERNET
laptop <────────> |(eth0)│╲ ╲
╲ wired └──────┘╱ (dhcp
(dhcp 192.168.4.1 from router)
from RPi) Step 5: configure hostapd for a bridge Add a line bridge=br0 to /etc/hostapd/hostapd.conf with: rpi ~# echo 'bridge=br0' >> /etc/hostapd/hostapd.conf Step 6: setup wpa_supplicant for a bridge Extend wpa_supplicant with: rpi ~# systemctl edit [email protected] In the editor append lines so it looks like the following. Have attention to the minus sign after equal =- on some statements. Save it and quit the editor: [Unit]
BindsTo=accesspoint@%i.service
After=accesspoint@%i.service
[Service]
ExecStartPost=/lib/systemd/systemd-networkd-wait-online --interface=%i --timeout=60 --quiet
ExecStartPost=/bin/ip link set ap@%i up
ExecStopPost=-/bin/ip link set ap@%i up Please note that ExecStopPost=-/bin/ip link set ap@%i up is not a typo. On stopping wpa_supplicant, interface ap@wlan0 must be set up again. Step 7: setup static interfaces For a bridge ap@wlan is dynamically created. So create these files: rpi ~# cat > /etc/systemd/network/02-br0.netdev <<EOF
[NetDev]
Name=br0
Kind=bridge
EOF
rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Bridge=br0
EOF
rpi ~# cat > /etc/systemd/network/16-br0_up.network <<EOF
[Match]
Name=br0
[Network]
IPMasquerade=yes
Address=192.168.4.1/24
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF Reboot. That's it. ♦ Details General One problem is that we want to use the same device for a wifi client and for an access point. This must be supported by the wifi hardware. We can check this with rpi ~$ sudo iw list | grep -A4 "valid interface combinations:"
valid interface combinations:
* #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
total <= 3, #channels <= 2
* #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
total <= 4, #channels <= 1 The important part is #{ managed } <= 1, #{ AP } <= 1, but you can also see that this is only possible on one channel . I've found that we have to setup this in sequence, otherwise, it won't work. If other applications bind to the wifi port it cannot be set. create a virtual interface ap@wlan0 for the access point start access point daemon hostapd using interface ap@wlan0 start wpa_supplicant for wifi client using interface wlan0 This order restricts the whole setup. It isn't possible to start hostapd when wpa_supplicant is running. You must first stop wpa_supplicant and then start hostapd and wpa_supplicant in this order. This is due to the WiFi driver brcmfmac . Another quirk is that wpa_supplicant disables the interface ap@wlan0 when it is managed, no matter if it starts or stops. So even after a start from wpa_supplicant , we have to enable ap@wlan0 again. Here are mainly four components involved: virtual interface ap@wlan0 , hostapd , wpa_supplicant , and setup the bridge. hostapd (Step 2) This is the normal setup you will find all over the web. Please set the channel to the same value then wlan0 is connected to the wifi from your router. It is the restriction from the hardware and may avoid confusion with channel settings. hostapd will always set the channel to the same value than from the client connection, no matter what you set here. Please use a passphrase that is long enough, I would say at least with 8 characters. It was told that 4 characters are too small and hostapd will refuse to accept connections. You will not find the access point RPiNet on your mobile phone (thanks to @Leo ). We do not need to unmask the hostapd.service as described at /usr/share/doc/hostapd/README.Debian because we create our own [email protected] for hostapd. In this service the interface ap@wlan0 is created before starting hostapd . This is respected to the starting order. Because ap@wlan0 is bound to wlan0 it gets the same mac address. You may consider to give it a unique mac address but that's not a good idea. On the network is only seen the mac address from wlan0 . If you give ap@wlan0 its own mac address then it is not seen on the network for arp requests and the IP address for connections to ap@wlan0 is not found and gets stuck. You have to set ap@wlan0 to promiscuous mode to get it to work then. After stopped hostapd then ap@wlan0 is also deleted so it can be created again on the next start of hostapd . wpa_supplicant (Step 3) Setting up wpa_supplicant for wlan0 we do as usual. You may consider to disable p2p with p2p_disabled=1 in /etc/wpa_supplicant/wpa_supplicant-wlan0.conf to avoid to get the unneeded confusing P2P-device seen with iw dev . Don't do that in this configuration with a virtual AP interface (e.g. ap@wlan0). It confuses wpa_supplicant and it will immediately disconnect from the uplink router when it has just connected to it. It endless connect and disconnect. Its extended unit is to strictly bind wpa_supplicant to hostapd so it will start and stop with it in the right order. We do it because running wpa_supplicant without hostapd is very complicated and may result in a total crash of the brcmfmac wifi driver, I have seen that on my tests. Setup static interfaces (Step 4) Here we define interface wlan0 and the virtual interface ap@wlan0 we need for a wifi repeater. For wlan0 we get an IP address by DHCP from the internet router. Optional you can set a static IP address, but then you also have to define all other settings like gateway and DNS server because you don't get them anymore from the DHCP server. Interface ap@wlan0 needs a static IP address because it is the access point and the source of the DHCP server for the wifi network. There is no need that clients, connected to the internet router, must also connect to clients on the access point. So we can use NAT (IPMasquerade=yes) that simplifies setup a lot. Then we don't have to configure static routes and it is not needed to configure wlan0 with static values (IP address, gateway, DNS server, etc.). hostapd for bridge (Step 5) We have setup hostapd in Step 2. Now we only need to append bridge=br0 to its configuration so that it will dynamically manage to add ap@wlan0 to the bridge. wpa_supplicant for bridge (Step 6) When wpa_supplicant is started it also brings up interface wlan0 . Every time it is managed, no matter if it started or stopped, it will stop ap@wlan0 because it is not a real interface and depends directly on wlan0 . The ap interface can only start when wlan0 "Gained carrier" and the link becomes ready (3) . This will happen some or more seconds after wpa_supplicant has started. There is a helper program systemd-networkd-wait-online that can do this synchronous. We use it with a timeout of 60 seconds. If your network connection takes longer than 60 seconds to get up, then you should increase the timeout accordingly. With journalctl -b -e you can check if Starting Bring up wifi interface ap@wlan0... and Started Bring up wifi interface ap@wlan0. covers wlan0: Gained carrier . This is very important because otherwise, the bridge will not work correctly with undefined behavior. You can check the helpers options with /lib/systemd/systemd-networkd-wait-online --help . After stopped wpa_supplicant (bring wlan0 down) ap@wlan0 must be brought up again so it can continue running for the access point. define static interfaces for bridge (Step 7) These files define the bridge. ap@wlan0 will dynamically be added by hostapd . eth0 and ap@wlan0 are slaves of the bridge and don't need an IP address. The bridge br0 itself also does not need an IP address but here it has a static IP address because we need it for the DHCP server bound to br0 so the DHCP server is available on the subnet of the bridge ( interfaces eth0, ap@wlan0). Conclusion Update 2020-07-22: Bassline Soup has made some interesting tests that may help to troubleshoot the setup. You are now able to start, stop and restart hostapd and wpa_supplicant . You should see the access point, here RPiNet , in your mobile phone and should get an IP address to connect to the access point. You should also get an IP address from the same subnet if you connect a laptop with a cable to the ethernet port and you can ping the mobile phone. With this setup you have the following dependencies with starting and stopping: hostapd │ wpa_supplicant wpa_supplicant │ hostapd
───────────┼────────────────────────────────────┼──────────
starting │ starts starting │ starts
stopping │ stops stopping │ ----
restarting │ restarts restarting │ starts This is because of the strict order of starting (see section General ). You cannot run wpa_supplicant without hostapd but you can run hostapd without wpa_supplicant by starting hostapd and then stop wpa_supplicant . If communication stops for some reason (e.g. delay to small or something else) it is mostly enough to kick ap@wlan0 with /bin/ip link set ap@wlan0 up . references: [1] Howto migrate from networking to systemd-networkd with dynamic failover [2] man systemd.unit [3] systemd-networkd wireless bridging - need to wait for carrier [4] Setup WiFi on Pi 3 B+ | {
"source": [
"https://raspberrypi.stackexchange.com/questions/89803",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/79866/"
]
} |
92,736 | My router uses DHCP, and whenever I reformat my raspberry pi, even when using a different microSD card, it always has the same LAN ip. I'm not quite sure how IPs are assigned, but I assume the device has a unique id on the network which my router recognises? | Your Raspberry Pi has a unique ID, called a MAC address, actually two to be precise. Each network adapter has one of those. So the Wi-Fi adapter has one unique ID and the Ethernet adapter does. And this is why your Raspberry Pi gets the same IP. For your router it's not important what you are doing with the device exactly. It just recognizes the MAC and provides the same IP as before. Edit: As Beege pointed out, the IP can still change as the 'D' in DHCP stands for dynamic. But if your device gets the same IP as before via DHCP its because of the MAC that's recognized. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/92736",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/-1/"
]
} |
94,877 | When navigating the file system of my USB drive in the terminal, some weird things happen that didn't used to happen on my Raspberry Pi B+. I'm not quite sure how to articulate this, so I'll just show what is I open the command line and navigate to my USB drive with cd /media/pi/MYUSB/ I use cd to enter a folder of the USB drive with cd /myFolder/myOtherFolder I navigate backwards to myFolder with cd .. I try to navigate again to myOtherFolder with cd /myOtherFolder . However, this raises the bash error bash: cd: /myOtherFolder: no such file or directory I have no idea what or why this is happening, but I used to be able to do this without the error message. Sometimes I have power outages that cause the Raspberry Pi to shut off with the USB drive in it, so I have "ghost USB drives" like the ones described in Ghost USB drives left behind when power is cycled off and on . | You put a leading / to your path names! That's the root directory, meaning what you write next is an absolute path.
Your /myFolder/myOtherFolder is not on your USB if it's mounted inside /media/pi/MYUSB/ anyway. But you can use cd myOtherFolder in the case you're asking. I suggest reading some basic tutorial about Linux's (or Unix) file handling, filesystems, and such. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/94877",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/99628/"
]
} |
96,606 | Q How can I make iw wlan0 set power_save off permanent for stretch? What's the proper way to do it? Edit I'm using an r-Pi 1 Mod. B with an Edimax wifi dongle and Raspian stretch. | Power save mode was an issue years ago on older versions of Raspbian. But it is fixed for a long time. Now it is disabled by default with the WiFi driver brcmfmac . You will find it if you grep the journal for the driver: rpi ~$ journalctl | grep brcmfmac:
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: F1 signature read @0x18000000=0x15264345
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Feb 27 2018 03:15:32 version 7.45.154 (r684107 CY) FWID 01-4fbe0b04
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: brcmf_c_preinit_dcmds: CLM version = API: 12.2 Data: 9.10.105 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2018-03-09 18:56:28
Apr 17 09:01:27 raspberrypi kernel: brcmfmac: power management disabled As you see, it is power management disabled . So there is no need to worry about it. You don't need to disable it again. Update after getting information about used hardware: If you do not have an on-board WiFi and using an USB/WiFi dongle then you will not find brcmfmac because there is another driver loaded for the dongle. To execute programs on boot up you can use a systemd Unit file. I will give you here a bit more comfortable example for switching off or on power_save. Create a Unit file with: rpi ~$ sudo systemctl --full --force edit [email protected] In the empty editor insert these statements, save them and quit the editor: [Unit]
Description=Set WiFi power save %i
After=sys-subsystem-net-devices-wlan0.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/iw dev wlan0 set power_save %i
[Install]
WantedBy=sys-subsystem-net-devices-wlan0.device Now enable just what you want on boot up: rpi ~$ sudo systemctl disable [email protected]
rpi ~$ sudo systemctl enable [email protected]
# or
rpi ~$ sudo systemctl disable [email protected]
rpi ~$ sudo systemctl enable [email protected] | {
"source": [
"https://raspberrypi.stackexchange.com/questions/96606",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/22174/"
]
} |
96,624 | Hello I'm new in python and raspberry, today I try to run a script take in ' https://www.rhydolabz.com/wiki/?p=18639#comment-47045 '
But I don't have a valid data in my status code.
The code : #Code pour reconnaissance GPS :
import serial
import time
from decimal import *
from subprocess import call
def find(str, ch):
for i, ltr in enumerate(str):
if ltr == ch:
yield i
# initialisation des commandes AT
port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=1)
print('test')
port.write('AT\n'.encode('utf8')); #on fait repartir le système à 0
rcv = port.read(100)
print(rcv)
print('fin test')
time.sleep(.1)
port.write('AT+CGNSPWR=1\n'.encode('utf8')) # on allume le GPS
rcv = port.read(100)
print(rcv)
time.sleep(.1)
port.write('AT+CGNSIPR=115200\n'.encode('utf8')) # baud rate de UART2
rcv = port.read(100)
print(rcv)
time.sleep(.1)
port.write('AT+CGNSTST=1\n'.encode('utf8')) #on envoie les donées à l'UART
rcv = port.read(100)
print(rcv)
time.sleep(.1)
port.write('AT+CGNSINF\n'.encode('utf8')) #transphorme les infos GPS
rcv = port.read(200) # en phrases NMEA
print(rcv)
time.sleep(.1)
ck=1
while ck==1:
print("test 2")
fd = port.read(200)
print(fd) #envoie les données GPS à l'UART
time.sleep(.5)
if '$GNRMC'.encode('utf8') in fd:
print("test 3") #on relève la lattitude et longitude
ps=fd.find('$GNRMC'.encode('utf8'))
print(ps)
dif=len(fd)-ps
print(dif)
if dif > 50 :
print("test 4")
data=fd[ps:(ps+50)]
print(data)
ds=data.find('A'.encode('utf8')) #on regarde juste si le GPS marche bien.
if ds > 0 and ds < 20:
print("test 5")
p=list(find(data, ","))
lat=data[(p[2]+1):p[3]]
lon=data[(p[4]+1):p[5]]
#calcul des données du GPS
s1=lat[2:len(lat)]
s1=Decimal(s1)
s1=s1/60
s11=int(lat[0:2])
s1 = s11+s1
s2=lon[3:len(lon)]
s2=Decimal(s2)
s2=s2/60
s22=int(lon[0:3])
s2 = s22+s2
print(s1)
print(s2) the probleme is on the line : ds=data.find('A'.encode('utf8')) #on regarde juste si le GPS marche bien.
if ds > 0 and ds < 20: I don't have any 'A' !!! I just have a "V" for "data is void". I can give you some words of my shell : test
b'AT\r\nOK\r\n$GNGGA,022839.094,,,,,0,0,,,M,,M,,*59\r\n$GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n$GLGSA,A,1,,,,,,,,,,,,,'
fin test
b',,*02\r\n$GPGSV,1,1,00*79\r\n$GLGSV,1,1,00*65\r\n$GNRMC,022839.094,V,,,,,0.00,0.00,060180,,,N*53\r\n$GNVTG,0'
b'.00,T,,M,0.00,N,0.00,K,N*2C\r\nAT+CGNSPWR=1\r\nOK\r\nAT+CGNSIPR=115200\r\nOK\r\n$GNGGA,022840.094,,,,,0,0,,,M,'
b',M,,*57\r\n$GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n$GLGSA,A,1,,,,,,,,,,,,,,,*02\r\n$GPGSV,1,1,00*79\r\n$GLGSV,1,1,00'
b'*65\r\n$GNRMC,022840.094,V,,,,,0.00,0.00,060180,,,N*5D\r\n$GNVTG,0.00,T,,M,0.00,N,0.00,K,N*2C\r\nAT+CGNSTST=1\r\nOK\r\nAT+CGNSINF\r\n+CGNSINF: 0,,,,,,,,,,,,,,,,,,,,\r\n\r\nOK\r\n$GNGGA,022841.094,,,,,0,0,,,M,,M,,*56\r\n$'
test 2
b'GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n$GLGSA,A,1,,,,,,,,,,,,,,,*02\r\n$GPGSV,1,1,00*79\r\n$GLGSV,1,1,00*65\r\n$GNRMC,022841.094,V,,,,,0.00,0.00,060180,,,N*5C\r\n$GNVTG,0.00,T,,M,0.00,N,0.00,K,N*2C\r\n$GNGGA,022842.094,,'
test 3
95
105
test 4
b'$GNRMC,022841.094,V,,,,,0.00,0.00,060180,,,N*5C\r\n$' The problem is from this line : test 4
b'$GNRMC,022841.094,V,,,,,0.00,0.00,060180,,,N*5C\r\n$' Have you got an idee for what can I do ? Thank you !! | Power save mode was an issue years ago on older versions of Raspbian. But it is fixed for a long time. Now it is disabled by default with the WiFi driver brcmfmac . You will find it if you grep the journal for the driver: rpi ~$ journalctl | grep brcmfmac:
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: F1 signature read @0x18000000=0x15264345
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Feb 27 2018 03:15:32 version 7.45.154 (r684107 CY) FWID 01-4fbe0b04
Apr 14 22:13:28 raspberrypi kernel: brcmfmac: brcmf_c_preinit_dcmds: CLM version = API: 12.2 Data: 9.10.105 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2018-03-09 18:56:28
Apr 17 09:01:27 raspberrypi kernel: brcmfmac: power management disabled As you see, it is power management disabled . So there is no need to worry about it. You don't need to disable it again. Update after getting information about used hardware: If you do not have an on-board WiFi and using an USB/WiFi dongle then you will not find brcmfmac because there is another driver loaded for the dongle. To execute programs on boot up you can use a systemd Unit file. I will give you here a bit more comfortable example for switching off or on power_save. Create a Unit file with: rpi ~$ sudo systemctl --full --force edit [email protected] In the empty editor insert these statements, save them and quit the editor: [Unit]
Description=Set WiFi power save %i
After=sys-subsystem-net-devices-wlan0.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/iw dev wlan0 set power_save %i
[Install]
WantedBy=sys-subsystem-net-devices-wlan0.device Now enable just what you want on boot up: rpi ~$ sudo systemctl disable [email protected]
rpi ~$ sudo systemctl enable [email protected]
# or
rpi ~$ sudo systemctl disable [email protected]
rpi ~$ sudo systemctl enable [email protected] | {
"source": [
"https://raspberrypi.stackexchange.com/questions/96624",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/101590/"
]
} |
100,543 | How to disable WiFi in Raspberry Pi4, possibly keeping the chip powered off. | Raspbian is managing hardware with overlays. In /boot/overlays/README you will find: Name: pi3-disable-wifi
Info: Disable Pi3 onboard WiFi
Load: dtoverlay=pi3-disable-wifi
Params: <None> I suggest you just add dtoverlay=pi3-disable-wifi to /boot/config.txt to disable wifi. I have tested it with a Raspberry Pi 4B. It is also valid for Pi4. When disabled you will not get a WiFi interface wlan0 as you can check with ip -br addr . UPDATE: @JeffAtwood noted in his comment They renamed it to disable-wifi so you can use that, pi3-disable-wifi was kept as a synonym for compatibility. Same thing with disabling bluetooth. 2019-10-25: seems everything is documented now in /boot/overlays/README . | {
"source": [
"https://raspberrypi.stackexchange.com/questions/100543",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/10728/"
]
} |
100,926 | Looking for a 64-bit version of Linux for the Raspberry Pi 4. I'm aware that support under Ubuntu Mate is in the works, apparently Ubuntu Server works but it limited to using 1 GB of RAM. Are there any other options that are working now? | As of September 2019, the following 64-bit operating systems run on a Raspberry Pi 4: Gentoo Raspbian with 64-bit kernel (32-bit userland) Manjaro (Arch) The above list is by no means exhaustive because there have been many one-off 64-bit experiments ("Hey, it boots") starting shortly after Pi 4's release. After all, the procedure for tweaking an existing distro into a 64-bit Pi 4 compatible one has not changed. Just like with a Pi 3 or Pi 2 v1.2, copying over the kernel and kernel modules from a working system will usually result in a configuration that boots * . In terms of quality and support, the situation with Raspberry Pi 4, Buster, kernel 4.19+, and 64-bit is better than it had been with Pi 3B+ and Stretch. This time it is actually possible to access the SoC camera in Fake KMS mode. Gentoo has been listed first for its active userbase and it was the first to provide fixes for accessing 4 GB of memory and V3D acceleration. Note that for distros without an arm64 userland (e.g. Raspbian + 64-bit kernel), additional steps are necessary to run 64-bit programs. This can be done via static compilation, containers (LXC, systemd-nspawn), or chroot. The last option has proven to be the most straightforward: sudo apt install -y debootstrap schroot
cat << EOF | sudo tee /etc/schroot/chroot.d/pi64
[pi64]
description=V3D arm64 testing
type=directory
directory=/srv/chroot/pi64
users=pi
root-groups=root
profile=desktop
personality=linux
preserve-environment=true
EOF
sudo debootstrap --arch arm64 buster /srv/chroot/pi64
sudo schroot -c pi64 -- apt install -y mesa-utils sudo
schroot -c pi64 Then continue to install more arm64 programs or run them inside the chroot: (pi64)pi@raspberrypi:~ $ glxgears * One pitfall specific to Pi 4 is that fake KMS with VC6 requires a very recent build of Mesa, so an initial workaround is to edit config.txt to switch to legacy mode. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/100926",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/52762/"
]
} |
101,842 | I formatted my SD card to fat32 using GParted and copied all the files from the official NOOBS Lite download: https://www.raspberrypi.org/downloads/noobs/ . I unzipped using unzip command on the terminal. When I turn on the rainbow appears and the Pi gets stuck there. Red LED is on, green turned off after a few seconds. Don't know if I did something wrong or my card is broken. Appreciate your help. | I connected it to the other HDMI port and the image appeared, it was actually booting but showing the rainbow through that port. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/101842",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/107320/"
]
} |
101,861 | I can not connect to a (probably hidden) wireless network with my RPi4. My wpa_supplicant.conf: ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE
network={
ssid="NAME"
scan_ssid=1
key_mgmt=WPA-EAP
etc..
} Hovering over the wireless icon in the taskbar states wlan0: Not associated .
Clicking on it says No wireless interfaces found . I have tried some stuff I found like adding lines like auto wlan0 in /etc/interfaces or /etc/dhcpcd.conf but none of that helped. Apart from this hidden network, there should also be some visible and unprotected public networks to connect to, but I don't see them either. This is a fresh install of Buster. EDIT: I tinkered a little, and now it seems to be "half" connected??
I have no internet, but iwconfig says: wlan0 IEEE 802.11 ESSID:"NAME"
Mode: Managed Frequency=5.26 Ghz Access Point: B4:5D....
Bit Rate=12 Mb/s Tx-Power=31 dBm
... ifconfig says: wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether dc:a6:.... txqueuelen 1000 (Ethernet)
RX packets 198 bytes 85074 (83.0 KiB)
RX errors 0 ... output of ip addr is: 3: wlan0 <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether dc:a6:... brd ff:ff:ff:ff:ff:ff EDIT2:
The suggested wpa config for the network is: network={
ssid="NAME"
key_mgmt=WPA-EAP
pairwise=CCMP TKIP
group=CCMP TKIP
eap=TTLS
phase2="auth=PAP"
anonymous_identity="[email protected]"
identity="[email protected]"
password="password"
ca_cert="/etc/ssl/certs/T-TeleSec_GlobalRoot_Class_2.pem"
altsubject_match="DNS:radius-wlan.name.edu"
} The only things I did differently is using a passkey generated using wpa_passphrase and adding scan_ssid=1 | I connected it to the other HDMI port and the image appeared, it was actually booting but showing the rainbow through that port. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/101861",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/74746/"
]
} |
105,016 | I have a Raspberry Pi 3 B+ board and I am trying to connect it both to a local wireless hotspot and another machine via cable. I am not connected to the Internet on any of the devices and all data transfer is local. My question is that do wireless and wired connections affect each other? is their bandwidths seperated or using one, will slow down the other? | As noted by other answers, the physical mediums are of course separate and do not affect each other. However, it is a valid question whether they share a common bus in the Raspberry Pi 3 hardware. Infamously, the wired network chip is on the same USB controller as the USB ports, causing bandwidth to be shared with any USB drives connected. (Image source: shabaz on Element14 forums ) As visible in the block diagram, the 802.11n wireless network chip in the upper left has its own dedicated SDIO bus to the processor. The bandwidth available is thus fully independent of the wired network controller on the right side. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/105016",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/110600/"
]
} |
107,368 | I am trying to understand the Raspbian file system better. I opened properties on the Raspberry Pi's "Wastebasket" hoping to find out where it is located in the file system and I found trash:/// . Can anyone explain this, please?
I expected to find some folder off of root e.g. /some-dir/trash . System info: Raspberry Pi 4B OS: Raspbian Buster | The folder trash can is in /home/pi/.local/share/Trash/ . In this folder, there are two folders, files and info . /home/pi/.local/share/Trash/files/
/home/pi/.local/share/Trash/info/ Source | {
"source": [
"https://raspberrypi.stackexchange.com/questions/107368",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/113550/"
]
} |
107,410 | For an alarm with wired sensors and home automation purposes, I want to use a compute module 3 (for its eMMC reliability) but I have an issue ; I need a LAN connection. In one of your answers Eliette suggest to use an enc28j60 module but I already own a WIZ850io and prefer this module. Does the driver exist ? Is it possible to add "dtoverlay=w5500" in
the config.txt ? | The folder trash can is in /home/pi/.local/share/Trash/ . In this folder, there are two folders, files and info . /home/pi/.local/share/Trash/files/
/home/pi/.local/share/Trash/info/ Source | {
"source": [
"https://raspberrypi.stackexchange.com/questions/107410",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/113570/"
]
} |
107,424 | So I downloaded the OS on the SD card and I want to make sure that the system works? I just started my raspberry adventure, and I'm completely new to this. I also tried to connect my Raspberry by Network cable to my computer but at VNC It says that it can't show the image. | The folder trash can is in /home/pi/.local/share/Trash/ . In this folder, there are two folders, files and info . /home/pi/.local/share/Trash/files/
/home/pi/.local/share/Trash/info/ Source | {
"source": [
"https://raspberrypi.stackexchange.com/questions/107424",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/113617/"
]
} |
108,592 | systemd-networkd can be used to replace the existing networking system on Raspbian. How can I use it for general purposes for networking like DHCP server, name resolution, link-local addresses, mDNS and so on? | Tested on a Raspberry Pi 4B with Raspbian Buster Lite 2020-02-13 updated on 2020-05-05. For reference I use a fresh flashed SD Card with the tested version. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot . Here you will find the last tested revision for Raspbian Stretch Lite . ♦ Abstract Using systemd-networkd instead of default dhcpcd it is not meaningful in all cases. networkd is a small and lean service to configure network interfaces,
designed mostly for server use cases in a world with hotplugged and
virtualized networking. Its configuration is similar in spirit and
abstraction level to ifupdown, but you don't need any extra packages
to configure bridges, bonds, vlan etc. It is not very suitable for
managing WLANs yet; NetworkManager is still much more appropriate for
such Desktop use cases. (5) But for a RasPi laying near by a TV or amplifier and doing its work 24/7 for streaming audio or video or for a camera etc., systemd-networkd is a good choice. But you have to do a complete switch. There is no way to mix up with Debian networking and/or dhcpcd . For this tutorial I assume you have setup an installation from the image with a network connection either wired (works out of the box) or using a wireless connection so you can connect to it with ssh but haven't done any further configuration. ♦ Quick Step Those who have already read the details and know how it works and only want to quick enable systemd-networkd will just do this here. But don't forget to configure the network interfaces with files in /etc/systemd/network/ . Please read at least the "♦ Abstract" section above and make a backup of your running system if you modify it! # deinstall classic networking
pi@raspberrypi:~ $ sudo -Es # if not already done
root@raspberrypi:~ # systemctl daemon-reload
root@raspberrypi:~ # systemctl disable --now ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
root@raspberrypi:~ # apt --autoremove purge ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
root@raspberrypi:~ # rm -r /etc/network /etc/dhcp
# setup/enable systemd-resolved and systemd-networkd
root@raspberrypi:~ # systemctl disable --now avahi-daemon libnss-mdns
root@raspberrypi:~ # apt --autoremove purge avahi-daemon
root@raspberrypi:~ # apt install libnss-resolve
root@raspberrypi:~ # ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
root@raspberrypi:~ # apt-mark hold avahi-daemon dhcpcd dhcpcd5 ifupdown isc-dhcp-client isc-dhcp-common libnss-mdns openresolv raspberrypi-net-mods rsyslog
root@raspberrypi:~ # systemctl enable systemd-networkd.service systemd-resolved.service
root@raspberrypi:~ # exit
pi@raspberrypi:~ $ Return to your setup. ♦ Create interface file for a wired connection I will have attention to a headless installation only with ssh . If you are also headless, double check typos or so otherwise you are lost with a broken connection. Deinstalling services does not effect the current network connection as long as you don't restart or reboot the network. So only do it if you are sure to have finished all needed configuration to have a working network. First enable systemd-networkd by following section "♦ Quick Step" . Then come back here. If you are connected wired then create this interface file but with only one option enabled (uncommented). Most common is to use DHCP. pi@raspberrypi:~ $ sudo -Es # if not already done
root@raspberrypi:~ # cat > /etc/systemd/network/04-wired.network <<EOF
[Match]
Name=e*
[Network]
## Uncomment only one option block
# Option: using a DHCP server and multicast DNS
LLMNR=no
LinkLocalAddressing=no
MulticastDNS=yes
DHCP=ipv4
# Option: using link-local ip addresses and multicast DNS
#LLMNR=no
#LinkLocalAddressing=yes
#MulticastDNS=yes
# Option: using static ip address and multicast DNS
# (example, use your settings)
#Address=192.168.50.60/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
#MulticastDNS=yes
EOF Reboot. If you connect using the ip address it is possible that this has also changed so you have to search for the new ip address. ♦ Create interface file for a WiFi connection I will have attention to a headless installation only with ssh . If you are also headless, double check typos or so otherwise you are lost with a broken connection. Deinstalling services does not effect the current network connection as long as you don't restart or reboot the network. So only do it if you are sure to have finished all needed configuration to have a working network. First enable systemd-networkd by following section ♦ Quick Step . Then come back here. Create this file for wpa_supplicant with your settings for country= , ssid= and psk= : pi@raspberrypi:~ $ sudo -Es # if not already done
root@raspberrypi:~ # cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=DE
ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
update_config=1
p2p_disabled=1
network={
ssid="TestNet"
psk="testingPassword"
}
EOF
root@raspberrypi: ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
root@raspberrypi: ~# systemctl disable wpa_supplicant.service
root@raspberrypi: ~# systemctl enable [email protected]
root@raspberrypi: ~# rfkill unblock wlan Create an interface file with only one option enabled (uncommented). Most common is to use DHCP. root@raspberrypi:~ # cat > /etc/systemd/network/08-wifi.network <<EOF
[Match]
Name=wl*
[Network]
## Uncomment only one option block
# Option: using a DHCP server and multicast DNS
LLMNR=no
LinkLocalAddressing=no
MulticastDNS=yes
DHCP=ipv4
# Option: using link-local ip addresses and multicast DNS
#LLMNR=no
#LinkLocalAddressing=yes
#MulticastDNS=yes
# Option: using static ip address and multicast DNS
# (example, use your settings)
#Address=192.168.50.61/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
#MulticastDNS=yes
EOF Reboot. If you connect using the ip address it is possible that this has also changed so you have to search for the new ip address. ♦ Details to enable systemd-networkd This is a detailed setup that you also have in short in section "♦ Quick Step" . To simplify commands we will work as root: pi@raspberrypi:~ $ sudo -Es # if not already done Deinstall classic Debian networking that is managed with file /etc/network/interfaces and deinstall default Raspbian dhcpcd network management. root@raspberrypi:~ # apt --autoremove purge ifupdown
root@raspberrypi:~ # rm -r /etc/network
root@raspberrypi:~ # apt --autoremove purge dhcpcd5
root@raspberrypi:~ # apt --autoremove purge isc-dhcp-client isc-dhcp-common
root@raspberrypi:~ # rm -r /etc/dhcp
root@raspberrypi:~ # apt --autoremove purge rsyslog We will set this programs to hold so they are not authomatically installed with other programs later and conflict with systemd-networkd. root@raspberrypi:~ # apt-mark hold ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog raspberrypi-net-mods openresolv And enable systemd-networkd: root@raspberrypi:~ # systemctl enable systemd-networkd.service ♦ Details to enable systemd-resolved This is a detailed setup that you also have in short in section "♦ Quick Step" . An important part of systemd networking is its network name resolution. systemd-resolved provides name services by Domain Name System (DNS) (including DNSSEC and DNS over TLS ), Multicast DNS (mDNS) and Link-Local Multicast Name Resolution (LLMNR) . (1) systemd-resolved provides this to local applications via a D-Bus interface, the resolve NSS service ( libnss-resolve ), and a local DNS stub listener on 127.0.0.53 (1) , (2) . For all three software interfaces there are also traditional services installed which may conflict with systemd-resolved. On my tests I have seen problems in the order of name resolution: long response time depending on the amount of DNS server to use, queries for the .local domain going to DNS server, no responses to local host names if the internet connection was down and so on. So I will deinstall not needed services instead of only disable them. This should ensure that entries in common used static config files like /etc/nsswitch.conf will also cleaned up. At first please follow section ♦ Details to enable systemd-networkd . Then enable systemd-resolved and configure its three interfaces: pi@raspberrypi:~ $ sudo -Es # if not already done
root@raspberrypi:~ # systemctl enable systemd-resolved.service Check D-Bus software interface I haven't found any conflicting issues. The D-Bus should be installed by default and running. Check with: root@raspberrypi:~ # systemctl status dbus.service Configure NSS software interface There is the avahi service together with the mdns service definitely conflicting, so we have to deinstall them. This will also clean up /etc/nsswitch.conf : root@raspberrypi:~ # apt --autoremove purge avahi-daemon
root@raspberrypi:~ # apt-mark hold avahi-daemon Now install the systemd-resolved software interface: root@raspberrypi:~ # apt install libnss-resolve For troubleshooting you may have a look at /etc/nsswitch.conf . It should contain a line like this: hosts: files resolve [!UNAVAIL=return] dns Configure DNS stub listener interface Here we have to symlink /etc/resolv.conf to the stub listener: root@raspberrypi:~ # ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf Don't Reboot! Before doing that you must have created an interface file for a wired or WiFi connection. Check name resolution Now you can check the status of name resolution. Depending on your settings it could look similar to this with a wireless connection: pi@raspberrypi:~ $ resolvectl status
Global
LLMNR setting: yes
MulticastDNS setting: yes
DNSOverTLS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: yes
--- snip ---
Link 3 (wlan0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
DefaultRoute setting: yes
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: yes
Current DNS Server: 84.200.69.80
DNS Servers: 84.200.69.80
1.1.1.1
Link 2 (eth0)
Current Scopes: none
DefaultRoute setting: no
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: yes ♦ Quirks and troubleshooting Problem with DNSSEC It should be said that there is a known bug. If you get error messages like: DNSSEC validation failed for question google.com IN A: no-signature then you hit Sporadic "DNSSEC validation failed" — "no-signature" #12388 . You can workaround this with adding option DNSSEC=no to /etc/systemd/resolved.conf and reboot to disable DNS record signing. DNS-name domain search trouble According to a comment from @lbt there was a bug with the name search option given by the DHCP server. This option completes not full qualified DNS names. For example if you rpi ~$ ping harley
PING harley.home.hoeft-online.de (192.168.30.121) 56(84) bytes of data.
64 bytes from harley.home.hoeft-online.de (192.168.30.121): icmp_seq=1 ttl=64 time=0.932 ms
--- snip --- the domain search will complete the DNS name harley to harley.home.hoeft-online.de to get the ip address, where the domain home.hoeft-online.de is given by the DHCP-server (received together with the dynamic ip address). According to https://superuser.com/questions/1490670/does-systemd-networkd-systemd-resolved-add-search-domains-specified-in-dhcp there was a problem which was fixed with systemd v243. I have noticed that there was a problem with older systemd versions but was able to find a solution, because I have full access to my own powerful isc-dhcp-server. Here are the settings on a test client to get domain search working as you can see with the ping above: rpi ~$ systemd --version
systemd 241 (241)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
rpi ~$ cat /etc/systemd/network/04-wired.network
[Match]
Name=e*
[Network]
LLMNR=no
MulticastDNS=yes
LinkLocalAddressing=no
DHCP=ipv4
[DHCP]
UseDomains=true
rpi ~$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 37 2020-12-18 16:52 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf
rpi ~$ cat /etc/resolv.conf
--- snip ---
nameserver 127.0.0.53
options edns0
search home.hoeft-online.de The search line is received from the DHCP server. The essential is the setting on the ISC DHDP-server. Here the subnet setting from its /etc/dhcp/dhcpd.conf : # My settings
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.65 192.168.30.126;
option routers 192.168.30.1;
option domain-name "home.hoeft-online.de";
# option domain-search "home.hoeft-online.de";
} As you can see there are two options available. option domain-search doesn't work but I successful use option domain-name . The only restriction is, that you can only give one domain name. It is not possible to search for e.g. home.hoeft-online.de and hoeft-online.de . references: (1) - archlinux - systemd-resolved (2) - freedesktop - systemd-resolved — Network Name Resolution manager (3) - freedesktop - What is D-Bus? (4) - archlinux - Domain name resolution (5) - /usr/share/doc/systemd/README.Debian | {
"source": [
"https://raspberrypi.stackexchange.com/questions/108592",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/79866/"
]
} |
111,425 | To keep myself entertained during the COVID-19 pandemic, I've bought a Raspberry Pi. I thought that it would be possible to program it from my laptop over SSH using an Ethernet connection, but I've just discovered that this requires me to know the IP address of the Raspberry Pi. Without a keyboard/mouse to plug into it, I can't set up the Raspberry Pi's Wi-Fi and/or check its IP address (as far as I'm aware) using a monitor. Without an SD card reader, I cannot follow a tutorial such as this for headless setup. Can anyone think of a way around this? The Raspberry Pi already has an SD card in it with the Raspbian operating system installed on it. | Welcome to the world of Pi - you will get many hours of fun from them once you are up and running. First check with your supplier to see if the version of the operating system they put on the card had ssh enabled - most suppliers do not do this though. If not: Try ping raspberry.local - it may find it. Check your router to see if you have a new device Look at a ping program for your computer or 'phone / tablet - I use one called fing Once you have the IP address you need to load and use PUTTY on a PC or ssh from the terminal of a Linux or Mac computer. ssh [email protected] where x.x.x.x is the IP address of the Pi from above. Sorry I do not use PUTTY but plenty of guides on the internet :-) If that does not work then unfortunately without a SD card reader/writer you are stuck as you do not have ssh enabled - as a bare minimum you need to be able to add a file call ssh to the /boot partition of the SD card then you can access it via ssh [email protected] from a Mac, Linux or an up to date Windows PC. You can get low cost USB to SD card adapters - that will take a few more days of waiting though. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/111425",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/118549/"
]
} |
114,462 | I am running a haarcascade based face detection and face recognition on Raspberry Pi 4 . The CPU temperature rises to 83-84C. So I have installed a heat sink and 5v pi fan. After installing this, I have noticed that temperature is always below 70c. But 5v pi fan is making too much noise so I have disconnected it from 5v and running it using 3.3v. Now fan is not running at full speed and is a bit slow. Due to which the temperature remains 74-76*c. I do not want to run fan using 5v as its making too much noise. Is running it on 3.3v fine. Is 74-76C a normal temperature for raspberry pi.? | What temperature range is normal or... how hot is too hot? My Pi 4B's with a decent heat management system (I've used several varieties) will typically run in the mid to upper 30°C's to the low-mid 40°C's when either idle or under typical/normal workloads (not pegging the CPU cores). Anything under 50°C is great! It is possible to stay in this temperature range without fans (more on that shortly). The Raspberry Pi does have some self-protection against over-heating. Specifically it will reduce its clock speed so it can run cooler. The drawback is that it's not doing computations as quickly. The throttling temperature is controlled via firmware and will throttle at 80°C (But a firmware update could change that. So this value may not be the same in the future.) Fan Noise You can think of Raspberry Pi cooling in a few ways and... whether or not the Pi is in a case, the case type and venting, will also impact these. You could run a stock Raspberry Pi with nothing added to help with cooling. You could use a passive heat management strategy involving a heat-sink, but no active cooling system (no fans, no water pump, etc.) You could use an active cooling system such as a fan, but but no heat sink. You could use both a heat-sink system and an active cooling fan. There are lots of variations on fans. Many are always-on and at just one speed. There are fan solutions that only kick on when the temperature reaches some threshold. There are also multi-speed fans. There is also a variety of quality among fans. I've been disappointed with several fans that initially seem to be fine... only to start hearing excessive fan noise a few days later (the bearings are already have problems). Noctua brand is known for their high quality and they are one of the least noisy fans. They do cost a bit more. A cheap fan might be in the range of $4-8 US Dollars. A similarly sized Noctua brand fan would probably be more like $14. Be aware that they make these in 12v and 5v versions and you want the 5v version for a Raspberry Pi and likely the version that does not use the PWM (Pulse Wave Modulation -- which they use to control speed so this is a variable speed fan. But Noctua expects a 5v PWM and I think the Pi uses a 3.3v PWM and I'm not sure that can reliably control the fan without problems. So I chose to get the basic single-speed (non-PWM) 5v fan. This brand is unlikely to be excessively noisy nor start to make the buzzing sounds of a failed bearings (at least not any time soon). Passive Cooling Not all passive cooling systems are equal. The basic idea is to install a tiny heat-sink (fins) using some thermal tape. These provide only moderate cooling help and usually don't do an adequate job without also adding a fan. Recently (a few weeks ago), I purchased an Argon One Pi 4B case for my Pi (Argon40.com). This is an interesting case because it also has a small board that attaches to the side of the Pi and routes ALL connectors to the rear (power, HDMI, and audio are all routed to the rear next to the USB and Ethernet ports) and also supplies a power switch. The case includes a variable speed fan and software to determine when to activate the fan and the power level. Their 'default' values are no fan below 55°C. At 55°C they activate 10% fan. At 60°C they boost to 55% fan. At 65°C they go all the way to 100% fan. But the entire upper case body is an aluminum alloy casting and they have solid posts that hang down from above and touch the CPU (System on a Chip) via supplied thermal tape. When I put my Pi 4B in that case... the temperatures (the Pi was previously in a case with basic heat-sinks and a fan) that were previously in the mid-40's... dropped to the upper 30's. When I apply typical workloads I sometimes see it go into the low 40's. If I apply synthetic loads to send all 4 cores to 100%... I have managed to get the Pi to about 46°C. I once managed to run it hard enough and long enough to finally see it hit 51°C. I have never managed to get it any hotter than this ... no matter how hard I try. Keep in mind... this case doesn't bother to turn on the fan until the temps reach 55°C. This means I have ... never once ... had the fan turn on in all these weeks of trying. I would say it has outstanding passive thermal management. (The case will feel warm). This case is a bit on the pricy side ($25 is more than the cost of most Raspberry Pi 4 cases) but it has several nice features and, in my opinion, it's worth it. The same company Makes a more compact case uses the same passive thermal management (at $15 USD). That case does not have an option for any cooling fan. But when I noticed how exceptionally well their other case is able to dump the heat, I'm starting to think that the their cheaper case would have been more than adequate (I have not tested one, but I'm thinking I will because I own several Raspberry Pi 4B's.) Full disclosure: This is testing in my home office, which is located in the basement of my home. Since hot air rises, the basement is naturally the coolest room in the house. It tends to be around 22-23°C (the upstairs is much warmer). So I suspect if I tested the Pi upstairs I might be able to get it warm enough to kick on the fan at the lowest speed. I have looked at a few other passive thermal cases... where the entire case body (top and bottom) is all heat-sink. These cases are not expensive ($10-15 USD) I would not use the "official" case for the Raspberry Pi 4B. The case is basically sealed with no way vent any warm air. | {
"source": [
"https://raspberrypi.stackexchange.com/questions/114462",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/70471/"
]
} |
116,118 | I recently updated my Raspberry Pi with sudo apt update and sudo apt full-upgrade to the system. Even if Python 3.8 is out, when I run python3 in terminal, it shows me version 3.7, instead of 3.8. Why is this the case? | Why? Just because it takes a while for distributions to integrate new versions. Here's what I did to install Python 3.8.5 on my rpi: sudo apt-get install -y build-essential tk-dev libncurses5-dev \
libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev \
libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev
version=3.8.5
wget https://www.python.org/ftp/python/$version/Python-$version.tgz
tar zxf Python-$version.tgz
cd Python-$version
./configure --enable-optimizations
make -j4
sudo make altinstall Installs Python into /usr/local/bin | {
"source": [
"https://raspberrypi.stackexchange.com/questions/116118",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/119768/"
]
} |
4 | I took a basic 40-hr Reverse Engineering course a few summers ago. While teaching us to use IDAPro, the instructor demonstrated, rather quickly and without explaining much, how to label certain variables in the ASM as members of a structure, basically equivalent to a good old fashioned struct in C/C++, and treat them as such wherever they are seen in the rest of the code. This seems rather useful to me. What he did not cover, however, was how to identify a structure. How do you know when a group of variables does in fact constitute a structure and not just a set of related variables? How can you be sure that the author used a struct (or something similar) there? | There are very common patterns that you will find in code that denote structure usage. Dereferencing offsets: If you have a pointer which is dereferenced at some non-zero offset, you are probably dealing with a structure. Look for patterns like: mov eax, [ebp-8] ; Load a local variable into eax
mov ecx, [eax+8] ; **Dereference a dword at eax+8** In this example, we have a variable that contains a pointer, but we care about the contents of memory at some specific offset ahead of the pointer. This is exactly how structures are used: We get a pointer to the structure, and then dereference the pointer plus some offset to access a specific member. In C, the syntax for this is: pMyStruct->member_at_offset_8 . Side note : Do not confuse dereferencing at the offset of some variable with dereferencing at offsets of the stack pointer or the frame pointer ( esp or ebp ). Of course, you could think of the local variables and function arguments as being one large structure, but in C, they are not explicitly defined as such. More subtle pointer offsets: You don't actually need to dereference anything to detect a structure member. For example: mov eax, [ebp-8] ; Load a local variable into eax
push 30h ; num = 30h
push aSampleString ; src = "Sample String"
add eax, 0Ch
push eax ; dst = eax + 0xC
call strncpy In this example, we are copying up to 0x30 characters from some source string to eax + 0xC (see strncpy ). This tells us that eax probably points to a structure with a string buffer (of at least 0x30 bytes) at offset 0xC. For example, the structure may look something like: struct _MYSTRUCT
{
DWORD a; // +0x0
DWORD b; // +0x4
DWORD c; // +0x8
CHAR d[0x30]; // +0xC
...
} In which case, the sample code would look like: strncpy(&pMyStruct->d, "Sample String", sizeof(pMyStruct->d)); Side note: It is possible (though unlikely) that we could be copying to a large string buffer at offset +0xC, but you would be able to determine this through context. If, say, offset +0x8 were an integer, for example, then it's definitely a struct. But if we copied a string of fixed length 0xC to address eax then copied another string to address eax+0xC , it's probably one giant string. All reads / all writes: Let's say you have a struct ( not a pointer to a struct) as a local variable your stack. Most of the time, IDA doesn't know the difference between a struct on the stack or a bunch of individual local variables. But a huge tip-off that you're dealing with a structure is if you only ever read from a variable without writing to it, or (less so) if you only write to a variable without reading from it. Here's an example of each: lea eax, [ebp+var_58] ; Load THE ADDRESS of a local variable into eax
push eax
call some_function
mov eax, [ebp+var_54] ; Let's say we've never touched var_54 before...
test eax, eax ; ...But we're checking its value!
jz somewhere
... In this example, we're reading from var_54 without ever writing anything to it (within this function). This probably means that it is a member of a structure which was accessed from some other function call. In this example, it's implied that var_58 might be the start of that structure, since its address is pushed as the argument to some_function . You can verify this by following the logic of some_function and checking if its argument is ever dereferenced (and modified) at offset +0x4. Of course, this doesn't necessarily have to happen in some_function -- it could happen in one of its child functions, or one of its child functions, etc. A similar example exists for writing: xor eax, eax
mov [ebp+var_28], eax ; Let's say this is the *only* time var_28 is touched
lea eax, [ebp+var_30]
push eax
call some_other_function
... When you see local variables being set and then never referenced again, you can't just forget about them, because they could very likely be members of a structure which is passed on to another function. This example implies that a structure (which starts at var_30 ) is written to at offset +0x8 before the address of that structure is passed to some_other_function . Both of these examples in C might look like: some_function(&myStruct);
if (myStruct.member_at_offset_4) ... and myStruct.member_at_offset_8 = 0;
some_other_function(&myStruct); Side note: Although each of these examples used local variables, the same logic applies to globals. Documented functions that expect structures: This one's probably obvious, and IDA will handle this for you almost all of the time, but an easy way to know when you have a structure in your code is if you call a documented function that expects a certain structure. For example, CreateProcessW expects a pointer to a STARTUPINFOW structure. This one shouldn't require an example. How do I know if these patterns actually indicate structure usage? One final point I want to make is that in all of these cases, yes, technically, the author of the program could written their code without the use of structures. They also could have written their code by defining every function as __declspec(naked) with a large __asm inline. You'd never be able to tell. But arguably, it doesn't matter. If there are logical groups of values that are stored contiguously in memory and passed from function to function, it is still meaningful to annotate them as structures. Almost all of the time, this is how the author wrote their code anyway. If you need me to elaborate on anything, let me know. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/4",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/63/"
]
} |
11 | When I am looking at the machine code of an application, are there hints and patterns I can discern from the generated machine code which would indicate which compiler (and possibly version) was used to generate it? Does knowing the compiler used to generate an application help me to more effectively reverse engineer back from the generated object to what the source code might have been, and if it does help, how so? | There is some academic research in this area, the keywords you want are 'toolchain provenance'. There was a pretty good paper by Nate Rosenblum on this topic , it's been a while since I read this paper but you can use many techniques to establish this information. I think some use machine learning and others can use a big pile of heuristics or axioms about compiler behavior. Establishing this is of limited utility IMO. It could be useful in an adversarial situation where you're trying to get intelligence about a malware group or threat actor, but also keep in mind that this kind of information can be obfuscated or destroyed. One potential use of this information would be to establish that some binary software was compiled using some companies SDK that included a compiler with signature information unique to that company. Establishing the tool chain provenance can help you make a case that someone who bought your SDK is in violation of a license or contract, say by producing malware. An example of behavior differences is parameter writing. There are two ways to place a value onto the stack, one using 'push' and another using mov with an address based in esp as the destination operand. So one compiler can do this: push eax
push ebx And another can do this: mov [esp+foo], eax
mov [esp+foo+4], ebx And they do. Generally, MSVC does the first example and GCC does the second example, at least in some very limited testing/observation just now... | {
"source": [
"https://reverseengineering.stackexchange.com/questions/11",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/93/"
]
} |
23 | I've recently managed to isolate and archive a few files that managed to wreak havoc on one of my client's systems. So I was wondering what software and techniques make the best sandbox for isolating the code and digging into it to find out how it works. Usually, up to this point in time I would just fire up a new VMWare or QEMU instance and dig away, but I am well aware that some well-written malware can break out of a VM relatively easily. So I am looking for techniques (Like using a VM with a different emulated CPU architecture for example.) and software (Maybe a sandbox suite of the sorts?) to mitigate the possibility of the code I am working on "breaking out". What techniques do you recommend? What software do you recommend? | The title mentions "sandbox" but VMWare or QEMU is usually not called that, so the question seems to be more about "how do I analyze it without a danger of infection?" There are three broad categories of tools and approaches you could take here. 1. User-mode sandboxes A user-mode sandbox basically runs the sample being investigated but intercepts all or at least the most critical APIs that access the host OS, neutralizes them and modifies the results to fool the software into thinking it's running all alone. One of the most popular such tools seems to be Sandboxie , but there exist others such as PyBox . Usually can be detected by the malware pretty easily and there's always a danger that an unemulated API will let the code to run amok. 2. Virtual machines and emulators These go a bit deeper and try to emulate not only APIs but execution of the actual code. As well, usually you need to run a full OS inside the emulator and can't use the host OS as is (could be an advantage or disadvantage depending on your goals). These can be further subdivided in three categories by approach used for emulation: a) virtualization These include VMWare, VirtualBox and VirtualPC. They use virtualization features of the recent processors to run most of the code natively and only emulate memory or hardware accesses. This makes them fast but in theory can lead to code escaping the VM in case of implementation bugs. b) dynamic translation This approach is used by QEMU. It translates each basic block into a sequence of native CPU's instructions and executes that. This approach allows it to reasonably fast emulate many different architectures, however the timing may differ quite a lot from the original. I don't think I've heard of any VM escaping bugs but it's possible to detect it. c) full emulation This is used by Bochs. It fully emulates each separate instruction one by one, as they're being executed. This makes it somewhat slower than other solutions but allows it to achieve almost perfect emulation of even the most low-level details. It's also probably the safest regarding to VM escaping bugs. There were some implementation bugs that could be used to detect it but I think most of them have been fixed. 3. Static analysis The best way to avoid the break out is to not run the code at all! Also, static analysis allows you to look at the complete code of the binary and see all of it, even the code paths which are not taken by running it and you sidestep all runtime checks and detections. Unfortunately, static analysis can be hampered by packing or obfuscation used in the malware. So it's often necessary to combine several approaches. I'm not a professional analyst, but I do dabble in some malware analysis. My workflow usually goes like this: Open sample in IDA. if it looks packed or encrypted, use Bochs debugger to emulate its execution and let it unpack itself. When it's finished (usually it's obvious), I take a memory snapshot, stop debugging, and continue analysis statically. If the unpacked code contains another embedded file (pretty common situation), saved it into a separate file and go to step 1 | {
"source": [
"https://reverseengineering.stackexchange.com/questions/23",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/115/"
]
} |
34 | Let's say I have a .jar file and wrap it into a .exe using any number of free utilities out there, like JSmooth . Would it be possible to tell, given just the .exe, if it was generated using one such utility from a .jar file? | I did a quick test with JSmooth and it simply places the whole .jar file in a resource. You can easily see this by opening a JSmooth executable with Resource Hacker as the following screen shot shows (I used sun's deploy.jar from the java lib folder): For other utilities it might be different but you could use a tool like binwalk to look for the jar/zip signature inside the exe. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/34",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/151/"
]
} |
42 | The Android java code is compiled into Dalvik byte code, which is quite readable. I wonder, is it possible in theory and in practice to write a decompilation software for Dalvik byte code? | It's not only possible but has been done already, and not just once. Here's three I know about, and there may be more. Kivlad by Cody Brocious http://www.matasano.com/research/kivlad/ DAD by Zost (Androguard project): http://code.google.com/p/androguard/wiki/Decompiler JEB by Nicolas Falliere (commercial) http://www.android-decompiler.com/ Then there are all the Java decompilers that can be used after using dex2jar or Dare on the Dalvik binary. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/42",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/35/"
]
} |
47 | Is it possible to create an object file using gcc that cannot be reverse engineered to its source code ? | AFAIK that is not possible. There are other things you can keep in mind however: Use of the GCC optimization flags will help make the code look much less readable to a human. When you compile with the highest level of optimization gcc -O3 the compiler will move things around such that the "flow" might not be at all what you expect. You can also use the flag -static which will force gcc to take small functions and make them inline. This will embed them into your code instead of showing as function calls.. it will make them harder to distinguish. One thing to keep in mind is too it's important to get rid of any unneeded symbols. Gcc offers -fvisibility=hidden and -fvisibility-inlines-hidden to help with this. You can also pass the -s flag to gcc to strip symbols away. I think that's about all you can do with gcc to help prevent reverse engineering. Additionally you can use code obfuscation, but there are issues there as well unless you implement it yourself, if you use a readily available method or tool to prevent reverse engineering, there is probably already a tool to counter it. Keep in mind that the final executable will have information in it as well such as what version of gcc it was compiled with. This too can be removed with the strip command. If I have an executable ( myprog ) I can run objdump on it to check some information: mike@mike-VirtualBox:~/C$ objdump --full-contents --section=.comment myprog | head
myprog: file format elf64-x86-64
Contents of section .comment:
0000 4743433a 20285562 756e7475 2f4c696e GCC: (Ubuntu/Lin
0010 61726f20 342e362e 332d3175 62756e74 aro 4.6.3-1ubunt
0020 75352920 342e362e 3300 u5) 4.6.3. Oops, you can see what version/compiler I used. Well, we can fix that: mike@mike-VirtualBox:~/C$ strip -R .comment -R .note myprog
mike@mike-VirtualBox:~/C$ objdump --full-contents --section=.comment myprog | head
objdump:
section '.comment' mentioned in a -j option, but not found in any input file
myprog: file format elf64-x86-64 There are other portions you can strip as well, such as .note.ABI-tag but you do lose portability | {
"source": [
"https://reverseengineering.stackexchange.com/questions/47",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/189/"
]
} |
60 | Is it legal to reverse engineer certain features of a closed source application and then integrate those features into a closed or open source application that may be either a commercial or non-commercial application ? Brownie points for an answer covering the situation in India. | In the United States The short answer is no for the purposes you've stated in your question, but keep reading to see exactly what is allowed. Also worth reading are the two links included herein. In the U.S., Section 103(f) of the Digital Millennium Copyright Act (DMCA) ( 17 USC § 1201 (f) - Reverse Engineering) specifically states that it is legal to reverse engineer and circumvent the protection to achieve interoperability between computer programs (such as information transfer between applications). Interoperability is defined in paragraph 4 of Section 103(f). It is also often lawful to reverse-engineer an artifact or process as long as it is obtained legitimately. If the software is patented, it doesn't necessarily need to be reverse-engineered, as patents require a public disclosure of invention. It should be mentioned that, just because a piece of software is patented, that does not mean the entire thing is patented; there may be parts that remain undisclosed. Also of note is that in the U.S. most End-User License Agreements (EULAs) specifically prohibit reverse-engineering. Courts have found such contractual prohibitions to override the copyright law which expressly permits it ( Bowers v. Baystate Technologies , 320 F.3d 1317 (Fed. Cir. 2003) ). In other words, for your purposes, it sounds like it would be illegal to integrate features from a reverse-engineered program into another program for commercial or non-commercial use. If you were trying to enable interoperability (again, see Section 103(f), noted above), that would be different. In India From what I can find, the direct reverse engineering of software, in whole or in part, for use in your own software for commercial use, is protected under copyright. The protected reasons for reverse engineering are similar to those in the United States. According to the article Trade Secret, Contract and Reverse Engineering (also note end note 5), the copyright act broadly protects actions (including reverse engineering) for the following purposes: Obtaining information essential for achieving interoperability of an independently created computer program with other programs if such information is not otherwise readily available. Determining the ideas and principles underlying any element of the program for which the computer program was supplied. Making copies or adaptations of a legally obtained copy of the computer program for non-commercial, personal use. Additionally, due to section 23 of the Indian Contract Act, which handles all contracts including License Agreements, a contract is declared void if it goes against public policy. Section 52 of the Copyright Act declares public policy concerning reverse engineering, which is that it is permitted in a limited way. A contract (or EULA), prohibiting reverse engineering in software to the extent permitted by the Copyright Act, may not stand in a court of law. Section 52, subsections (aa) through (ad) of the Copyright Act explain these protected acts (see Indian Copyright Act 1957 , page 33, along with section 18 of these revisions from 2012 ). Another source (though possibly a bit outdated) is Software Patent and Copyright Laws in India (a paper) with its footnotes. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/60",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/189/"
]
} |
72 | I find that more and more often binaries are being packed with exe protectors such as upx, aspack etc. I tried to follow a few tutorials on how to unpack them but the examples are often quite easy while my targets are not. I am looking for good resources and any hints/tips on how to unpack targets. | Unpacking a generic wrapping packer or cryptor usually involves the following steps: 1. Trace the code, possibly evading or bypassing anti-debugging checks. This is not difficult with simple packers but might be tricky with the more advanced ones. They may employ timing checks ( rdtsc ), exception-based control transfer, using debug registers for calculations etc. Using a VM or an emulator here usually helps against most of them. 2. Find the original entry point (OEP) There are many ways to do this. Sometimes the jump to OEP is obvious when it follows a chunk of looping code and there's nothing reasonable-looking after it. Or you may recognize the code at OEP if you're familiar with the entrypoints produced by different compilers. A couple other tricks: if the packer saves the original registers before unpacking, set a hardware breakpoint on their location in the stack - this way you'll break right when they're restored before jumping to OEP. if during tracing you can identify memory where the unpacked code is being written, set a page execution breakpoint on that memory range - it will trigger after the jump. IDA allows you to set such a breakpoint, and I think OllyDbg too. set breakpoints on common APIs used by startup code, e.g. GetCommandLine or GetVersionEx . This won't get you the exact OEP, but you can usually go back the callstack and find it more or less easily. 3. Dump the unpacked code If you're using IDA, you don't actually need to dump the file into a separate file - it's enough to take a memory snapshot that would copy the bytes from memory to the database so you can analyze them later. One thing to keep in mind here is that if the packer used dynamically allocated memory, you need to mark it as "loader" so it gets included in the snapshot. More here . 4. Restore imports I'm not very familiar how it's done in Olly or other debugger, but AFAIK you need to use a tool like ImpREC on your dump and a copy of the process in memory. It's somewhat simpler (IMO) in IDA. You just need to find the import table and rename the pointers according to the functions they are currently pointing to (this should be done while debugger is active). You can use either renimp.idc script or UUNP "manual reconstruct feature" (see here ). For finding import table there are two tricks I sometimes use: follow some calls in the startup code at OEP to find external APIs and this should lead you to the import table. Usually the start and the end of the table is obvious. during unpacking, set a breakpoint on GetProcAddress and see where the results are written. This however won't work with packers that use manual import resultion using the export directory. Putting a read BP on kernel32's export table might help here. 5. Clean up This is optional but it may be useful to remove the remains of the packer code that would only distract you. In IDA, you should also apply a compiler FLIRT signature if you recognize the compiler used. 6. Making an unpacked executable I don't do this step as I rarely need to run the unpacked file but in general you usually need to fix up the PE header so that offsets to the section's code in file match those in the dump. Now, there are many variations and tricks not covered by the above steps. For example, some packers don't fully resolve imports initially but put jumps to stubs that resolve import on first call and then patch it so it goes directly to the target next time. Then there is "stolen code" approach which makes it harder to find and recover OEP. Sometimes the packer runs a copy of itself and debugs it, so that you can't attach your own debugger to it (this can be solved by using emulator or a debugger that doesn't use debugging APIs like Intel PIN). Still, the outlined steps can cover quite a lot of what's out there. I will conclude with the video that Elias made showing the process of unpacking the Lighty Compressor: https://www.hex-rays.com/video/bochs_video_2.html | {
"source": [
"https://reverseengineering.stackexchange.com/questions/72",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/99/"
]
} |
77 | Are there any tools available to take an already compiled .dll or .exe file that you know was compiled from C# or Visual Basic and obtain the original source code from it? | ILSpy is a great open-source decompiler. ILSpy Features Assembly browsing IL Disassembly Support C# 5.0 "async" Decompilation to C# Supports lambdas and 'yield return' Shows XML documentation Decompilation to VB Saving of resources Save decompiled assembly as .csproj Search for types/methods/properties (substring) Hyperlink-based type/method/property navigation Base/Derived types navigation Navigation history BAML to XAML decompiler Save Assembly as C# Project Find usage of field/method Extensible via plugins (MEF) Assembly Lists | {
"source": [
"https://reverseengineering.stackexchange.com/questions/77",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/151/"
]
} |
85 | Let's assume I have a device with an FPGA on it, and I managed to extract the bitstream from its flash. How would I go about recovering its behavior? One simple case is if it implements a soft processor - in that case there should be firmware for that processor somewhere and I can just disassemble that. But what if it's just a bunch of IP blocks and some additional logic? | While FPGA makers don't just throw their formats out there, there is extensive documentation at a low level. Xilinx devices are a good example. To reverse engineer the bit stream you might generate test cases that implement simple logic and see how those translate to the bit stream, then move on to designs that exercise different portions of the chip. At the basic level, you would want to know how a CLB is controlled then the IOBs and interconnects. the CLBs are the logic the IOBs the are connected to the pins and interconnects link up the CLBs and IOBs. This document should give you a lot of insight into how FPGAs are implemented and how you might go about reverse engineering the bit streams. Do note that newer FPGAs are moving to 6-input luts rather than 4-input as was common. Just keep in mind that the bit stream isn't software - it is a hardware configuration image. So, it's actually very similar to how ENIAC must have been programmed - rewiring circuits and flipping switches to program it - except in this case you are setting up routes with interconnects and logic in the CLBs. Also the guy behind the Ben NanoNote is writing a fpga-toolchain which I am following avidly. Since a secondary to my SparcStation collecting hobby is reimplementing sun4m, a SparcStation architecture, in FPGA. After all who wouldn't want to be able to configure an FPGA from an FPGA with your own processor design on it. Update: It's worth noting that IceStorm (mostly ice40 chips) and NextPNR (Multi targeted at ice40/ECP5/Xilinx Series 7) are the current state of the art reverse engineered FPGA toolchains. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/85",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/60/"
]
} |
98 | I have a binary on a Linux (Kernel 2.6) which I can execute, but can't read (chmod 0711). Therefore no static analysis is possible. user1: $ ls -l bin
-r-s--x--- user2 user1 bin
user1: $ file bin
setuid executable, regular file, no read permission I'm looking for different dynamic techniques to gather as much information as possible. For example strace works with this executable. UPDATE : I was able to resolve the issue. See answer. Thank you all <3 this new reverseengineering community rocks! | I initially thought you wouldn't be able to dump the program, but it turns out that you can — see the second section of this answer. Running the program Most of the usual methods won't work because the executable is setuid. If you start the program normally, it runs with elevated privileges (euid ≠ ruid), and most debugging facilities are reserved to root. For example, anything that relies on attaching to the program with ptrace is reserved to root. This includes just about anything you could do in a debugger. Linux lets you dump the memory of a running process (with ptrace or through /proc/$pid/maps and /proc/$pid/mem ), but that too is disabled for a setuid executable. You can run strace ./bin , and see what system calls the program makes. However, this runs the program without any extra privileges. It may well stop early and complain that it can't read a file, or that it isn't running as the right user. You can see statistics like CPU usage, IO usage, network usage, memory usage, etc. in /proc/$pid : files like status , sched and net/netstat are world-readable (whether the program is actually started with extra privileges or not, the setuid restrictions apply). The one interesting thing I see is the program's network connections. The really juicy stuff, like memory contents ( mem ) and even open files ( fd ) is disabled either way. Preloading a library with LD_PRELOAD or running the program with a different LD_LIBRARY_PATH is also disabled either way. Nor will you get a core dump. So what works? You can see open network connections, maybe one of them will give you a clue or will be spoofable. You can try to figure out what files the program accesses by modifying them when you can, or by running the program from another directory (try making a symbolic link). If you have access to a chroot jail on the machine, try running the program from there. If you can run a virtual machine which implements shared folders (e.g. VMware or VirtualBox), see if you can access the program from there. This is all about subverting the security of the system: the permissions are designed to hinder you in your task. An advanced technique is to observe the program under heavy load and try to deduce what it does from the time it takes. Pollute the disk caches and see what files become quickly accessible. See how the swap usage varies depending on what the program does (so you get an idea of how many different pages are in its working set, not just how much total memory it's using). A lot of trial and error will be required. When you know the code and are trying to obtain the data, this is a well-known side channel attack. When you don't know the code, I expect it to be very difficult to obtain useful information this way. Dumping the memory contents I initially thought you couldn't dump the memory of the program because of the setuid bit (which usually wouldn't be a problem because you'd just copy the executable, but here this isn't possible because the executable is not readable). This turns out to be wrong. If you attach to the program with ptrace before calling execve (like running strace ./bin does), you do have access to ptrace in all its glory, including PTRACE_PEEKDATA and PTRACE_PEEKEXEC . That doesn't run the program setuid, so it may behave differently, but the code and static data loaded into memory are the same either way. Kudos to samuirai for pointing this out. Here's an overview of how you can dump the program's memory: Fork, and call ptrace(PTRACE_TRACEME, ...) in the child then execute the program ( execl("./bin", "./bin", NULL) ). In the parent, call waitpid to wait for the child to return from execve . Figure out the address at which the code is loaded. The value of the IP register (obtained through PTRACE_GETREGS ) should give a clue, and you can look for file format headers. Read the child's memory word by word ( PTRACE_PEEKTEXT , PTRACE_PEEKDATA ). Reconstruct the file format (e.g. make an ELF binary from text and data sections) if needed. Dump out the data into a file. Kill the child — it won't even get to execute anything. Dougall pointed out a working proof-of-concept tool for ELF executables: xocopy . | {
"source": [
"https://reverseengineering.stackexchange.com/questions/98",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/145/"
]
} |
125 | I have an Arduino Uno Rev3. I would like to extract and find out what code is burned on the ROM of the micro-controller board. How do I extract the code from the board? How do I figure out the original source code that went into the hex file? | I'll answer this in two parts, #1 is relatively easy, #2 impossible to the level which I'm assuming you want. 1. Extracting the hex code from the Uno: While the specifics will depend on the revision of the Uno that you have, you'll want to use avrdude ( available for linux, bundled with the OS X Arduino software ) and a command similar to the following that would extract the information from an ATmega168: avrdude -F -v -pm168 -cstk500v1 -P/dev/ttyUSB0 -b19200 -D -Uflash:r:program.bin:r Look at the avrdude documentation to match the part parameter -p specific to your device (or post them and we can go from there). Since it appears that you have the Uno Rev3 , that board has an ATmega328 ( -pm328 ). The programmer "communicates using the original STK500 protocol" thus the communication protocol flag -c should be -cstk500v1 the command you would need (assuming the Uno is connected to /dev/ttyUSB0) follows: avrdude -F -v -pm328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -D -Uflash:r:program.bin:r Next up your second question. 2. Converting Hex code to original source: Sorry, but that's not possible. While you can get some hex to c "decompilers" the gibberish returned, while functionally correct, will not be human readable (some commercial ones, like Hex-Rays, might give you some level of human-readability). With that said, you're best bet would be a hex to assembly translator/converter - which will still only give you a better picture of what's happening, but will still be (by definition) very low level. All variable names, comments etc would be stripped and you're still going to be left with not knowing the original source program contents - just the compiled result. Since you're dealing with an Atmel device you could try to use the avr specific gcc toolchain avr-gcc . Specifically, you'll need avr-objdump using the needed MCU type flag -m atmega328 (avr5) architecture ( Full List of Available Architectures, MCU types ) avr-objdump -s -m atmega328 program.hex > program.dump It is also possible, depending on your configuration, that providing the architecture type itself (avr5) would be sufficient: avr-objdump -s -m avr5 program.hex > program.dump | {
"source": [
"https://reverseengineering.stackexchange.com/questions/125",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/189/"
]
} |
160 | Having recently watched/read a presentation given by Dave Kennedy at DEF CON 20 [PDF] , I'd like to know how to decompile a Python script compiled with PyInstaller . In his presentation, he is creating a basic reverse shell script in Python, and converts it to an EXE with PyInstaller. My question is how do you take a PyInstaller created EXE and either completely, or generally, retrieve the logic/source code from the original Python script(s)? | extract EXE's appended data (block starting with PYZ, until the end of the file) extract wanted files with PyInstaller's archive viewer decompyle .PYCs - I personally recommend Uncompyle2 for that. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/160",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/161/"
]
} |
175 | I've seen this referenced in a couple of other questions on this site. But what's a FLIRT signature in IDA Pro? And when would I create my own for use? | FLIRT stands for Fast Library Identification and Recognition Technology . Peter explained the basics, but here's a white paper about how it's implemented: https://www.hex-rays.com/products/ida/tech/flirt/in_depth.shtml To address those issues, we created a database of all the functions
from all libraries we wanted to recognize. IDA now checks, at each
byte of the program being disassembled, whether this byte can mark the
start of a standard library function. The information required by the recognition algorithm is kept in a
signature file. Each function is represented by a pattern. Patterns
are first 32 bytes of a function where all variant bytes are marked. It's somewhat old (from IDA 3.6) but the basics still apply. To create your own signatures, you'll need FLAIR tools, which can be downloaded separately. (FLAIR means Fast Library Acquisition for Identification and Recognition) The IDA Pro book has a chapter on FLIRT and using FLAIR tools. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/175",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/270/"
]
} |
185 | I want to add some functionality to an existing binary file. The binary file was created using gcc . Do I need to decompile the binary first, even though I sufficiently understand the functioning of the program ? How should I go about adding the necessary code ? Do I need any tools to be able to do this ? | There are several broad ways in which you could do this. Dynamic instrumentation Tools such as PIN , Valgrind , or DynamoRIO allow you to dynamically change the behavior of a program. For instance, you can add calls to new functions at particular addresses, intercept library calls and change them, and much more. The downside is that dynamic instrumentation often has high overhead. Static instrumentation You can also try to statically modify the program to add the desired behavior. One challenge is that you often need to muck around with the executable file format. Some tools, such as elfsh from the ERESI project exist for this, but I have found them buggy and difficult to use. Another strategy for static instrumentation is to "recompile". You can do this by decompiling the program, modifying the source code, and recompiling. In theory, you could also use a tool like BAP to lift the program to IL, modify it, and then re-compile it using LLVM. However, the current version is probably not mature enough for this. Dynamic loading You can use LD_PRELOAD to override functions that are going to be dynamically linked. This is a nice option when you want to change the behavior of a library function. Naturally, it does not work on statically linked binaries, or for static functions. Binary patching You can often make simple changes to a binary using a hex-editor. For instance, if there is a function call or branch you would like to skip, you can often replace it with nop instructions. If you need to add a large amount of new code, you will probably need to use something like elfsh from the ERESI project to help you resize the binary. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/185",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/189/"
]
} |
206 | It seems that a popular use of software reverse engineering skills is to reverse malicious code in an effort to build better protection for users. The bottleneck here for people aspiring to break into the security industry through this path seems to be easy access to new malicious code samples to practice on and build heuristics for. Are there any good resources for a person unaffiliated with any organization to download malware in bulk to run analysis on? | There's a number of interesting resources you can get malware from The premier Malware sample dump Contagio KernelMode.info (Focuses on Win32 and novel rootkit techniques) DamageLab.org (People occassionally will post their unpacked executables here, which differ from 'in the wild' executables they are seeking to drop on victim's computers, but interesting none the less, many many rips of more well known techniques and software ranging from TDL to Zeus can be found at sites like this) The multitude of malware dump sites such as MalwareBlacklist As qbi kindly pointed out, Malware.lu (You have to register for the samples) In addition to these, you can always live dangerously and click on shady affiliate marketing ads or find various signatures for the multitude of " BEPs" (Browser Exploit Packs) that malware authors frequently use to get installs and analyze the payload to try to find what they are trying to download and exec. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/206",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/270/"
]
} |
250 | I see this instruction in the beginning of several Windows programs.
It's copying a register to itself, so basically, this acts as a nop .
What's the purpose of this instruction? | Raymond Chen (Microsoft) has a blog post discussing this in detail: https://devblogs.microsoft.com/oldnewthing/20110921-00/?p=9583 In short, it's a compile time addition applied in order to support run time hot patching, so the function can have the first two bytes overwritten with a JMP instruction to redirect execution to another piece of code. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/250",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/35/"
]
} |
252 | I have an executable file and I would like to figure out which programming language was the source code written in. The first step would be to use a disassembler. What should be done after that ? Also, I read that determining which libraries are used during runtime would be a good indicator of the programming language being used. How should I determine which libraries are used ? | Raymond Chen (Microsoft) has a blog post discussing this in detail: https://devblogs.microsoft.com/oldnewthing/20110921-00/?p=9583 In short, it's a compile time addition applied in order to support run time hot patching, so the function can have the first two bytes overwritten with a JMP instruction to redirect execution to another piece of code. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/252",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/189/"
]
} |
265 | Can someone give a list of websites with good (and free) reverse engineering training exercises ? | The organisation OpenSecurityTraining offers free training materials under creative commons type licenses. Many of the training's are videos , while others are slide decks and related class materials (scripts, malware samples and so on). The course-ware comes under 3 categories and features the following items (Which I have edited to include the RE related material): Beginner: Introductory Intel x86 : Architecture, Assembly, Applications, & Alliteration Introduction to ARM The Life of Binaries Malware Dynamic Analysis Introduction to Trusted Computing Intermediate: Intermediate Intel x86 : Architecture, Assembly, Applications, & Alliteration Introduction to Software Exploits Exploits 2: Exploitation in the Windows Environment Advanced: Rootkits: What they are, and how to find them Introduction to Reverse Engineering Software Reverse Engineering Malware Advanced x86: Virtualization with Intel VT-x Disclosure: I am not associated with OpenSecurityTraining in any way and have only worked through a small portion of their total offerings. Seems like a great resource though. | {
"source": [
"https://reverseengineering.stackexchange.com/questions/265",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/53/"
]
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.