Can i control volume on Raspberry Pi from Java ? (3.5 Jack) - raspberry-pi

I'm using Raspbian.
I found PI4J library to control GPIO's. Now i want to control the sound (make it squeak) on 3.5 Jack. Is there a library or commands for this ?

What are you running? (Raspbian, XBMC, Arch...)
I don't know of any libraries that could do this for you, but you can always resort to the following... assuming you're using Rasbian.
Use Java to make the following system calls with 'exec':
amixer -c 0 set PCM 2dB+ // Volume up.
amixer -c 0 set PCM 2dB- // Volume down.
Hope this helps!
EDIT: As for your new question, you can try the following:
Toolkit.getDefaultToolkit().beep();

Related

Bare metal Raspberry Pi 2: Generating an SD card image for QEMU emulation

I've recently been getting into bare metal development for the Raspberry Pi 2, and having some success. Admittedly I've hesitated to buy an actual physical device until I feel I can do something useful with it, for the time being I've been emulating the device using qemu 2.11.0.
So far I've developed multicore capabilities for my kernel, as well as simple Serial I/O, but I feel I'd like to get much further before working with a physical device.
My issue right now is that I'm trying to learn how to place my kernel onto an SD card image and boot qemu-system-arm from that SD card image, so I can properly emulate a kernel loaded from the raspberry pi 2 bootloader.
I've gotten as far as grabbing the SD card contents from https://github.com/raspberrypi/firmware ... aster/boot, and using the following script to create the image and load my kernel into it. I've seen that people have figured out how to load Raspbian from an emulated SD card, so I figure I can do the same.
#!/bin/bash
OUTPUT_IMG=os.img
OUTPUT_IMG_SIZE=40
TEMP_MOUNT_DIR="$(mktemp -d)"
# the SD card boot partition contents are in this folder...
OUTPUT_IMG_CONTENTS_DIR="./sd"
OS_DIR="${HOME}/os"
OS_BINARY="${OS_DIR}/kernel.bin"
dd if=/dev/null of=${OUTPUT_IMG} bs=1M seek=${OUTPUT_IMG_SIZE}
mkfs.fat -F 32 ${OUTPUT_IMG}
sudo mount -t vfat -o loop ${OUTPUT_IMG} ${TEMP_MOUNT_DIR}
make -C ${OS_DIR} clean
make -C ${OS_DIR}
sudo cp -r ${OUTPUT_IMG_CONTENTS_DIR} ${TEMP_MOUNT_DIR}
sudo cp ${OS_BINARY} "${TEMP_MOUNT_DIR}/kernel.img"
The only issue is that qemu doesn't seem to boot from this image using the following command:
qemu-system-arm -machine raspi2 -serial file:serial.log -sd ./dev/os.img
I've tried a few different combinations, but to no avail.
I can see from hooking GDB that the kernel is simply not booting from this card image. Loading the kernel directly into qemu with the -kernel argument works otherwise perfectly.
I was wondering if anyone here had any insight on how to accomplish this!
Any help here would be greatly appreciated!
Your command won't work because you haven't passed QEMU either a guest BIOS or a guest kernel to run. The QEMU arm boards aren't like the x86 PC machine, which always automatically runs a guest BIOS image. If you want to run a BIOS (probably UEFI?) you need to find a suitable BIOS blob and pass it to QEMU with the -bios argument. Then QEMU will run the BIOS code, which will hopefully include SD card drivers to load the kernel and so on off the SD card.
Just using -kernel is much simpler...
After doing a bit of reading and searching online, as well as a bit of help from other contributors such as Peter Maydell with his answer above, I think I've answered my own question. Unless I'm mistaken qemu-system-arm does not fully emulate the Raspberry Pi boot process, and instead just loads the kernel specified with the -kernel argument by loading the binary into the guest system's memory and jumping to the entry point. It doesn't look like any additional hardware bootloading is emualted for -M raspi2 unfortunately.
Can ARM qemu system emulator boot from card image without kernel param?
This question is similar and contains some more useful details on this issue, relating to qemu-system-arm as a whole..

how to get beaglebone black wifi with buildroot

I am trying to build beaglebone black wifi with buildroot but it seems that there are several configuration , for u-boot and kernel.
What is the right def config , am335-evm or omap3-beagle for BBB wireless?
What is the right kernel and def config for BBB wireless?
U-boot should be the target image format u-boot.bin or u-boot.img?
Does anyone has a git repo of a working beaglebone black ( wireless or not) working?
What are the minimum uEnv.txt settings to get u-boot start working?
Thanks!
You can use beaglebone_defconfig configuration file:
make beaglebone_defconfig
It enables support for multiple am335x boards like BBB, am335x-evm etc. This BR configuration provides U-Boot and U-Boot's internal scripts would read the board ID and load corresponding device tree blob. At the end of the build process you'll get a SD card image, that you can directly burn onto your SD card.
The only things missing are WiLink firmware and wpa_supplicant. Just select following packages in BR's menuconfig:
BR2_PACKAGE_WILINK_BT_FIRMWARE
BR2_PACKAGE_WPA_SUPPLICANT
Ok, so it does work, but i was waited to see on the HDMI the login.
After I connected UART using this post:
https://codechief.wordpress.com/2013/11/11/beaglebone-black-serial-debug-connection/ ( but i did replace tx and rx)
Pressed the S2 button i do see the linux prompt.

Raspberry Pi 3 OpenWrt

I have a trouble build OpenWrt with SD card.
I download the source, git://github.openwrt.org/openwrt.git and run "make menuconfig", set target "brcm27xx", "brcm2710", "Raspberry Pi 3 Model B".
And finish the configuration, build success.
Using "sudo dd if=openwrt....img of=/dev/sdb bs=2M", I create SD card.
When I boot Raspberry Pi 3 with creating SD card, the Kernel message with error.
run "mount"
/dev/root/ type ext4 ro(read-only) file system.
What is the problem!! Because of this I can not do anything...
Please Help me...
I have been using dd for a while now and it is both very powerful and very unforgiving, in the sense that your console will suggest the writing of the image is concluded but in actuality it has not. My images constantly failed for much the same reason as yours so now use my alternative command line, see below....
sudo dd if=openwrt....img of=/dev/sdb bs=2M
Here is my suggestion
sudo dd if=openwrt....img of=/dev/sdb bs=4096 conv=sync,notrunc status=progress; sudo sync
the last command may be unnecessary as sync is defined within dd command line. remember all of the above is one a line command not two wrap is ok I hope this helps you
This question is almost a year old and people might come across this in the future.
To run OpenWRT/LEDE on Raspberry Pi, you need to flash an image on a microSD. You may download the images through this link(Just search for the particular RPi Model): https://openwrt.org/toh/views/toh_fwdownload
Then from personal experience, I use Etcher to flash the image on the microSD. You may download it through this link: https://etcher.io/
Hope this helps someone out there. :)

What are the differences between all -device configurations available for configure Qt5

I follow this tutorial : https://wiki.qt.io/RaspberryPi2EGLFS#Step_by_step in order to compile Qt5.7 for Raspberry pi3.
I have succeeded to compile and start examples but after further investigations I found others device configuration in this directory :
ls -l qt5/qtbase/mkspecs/devices/
It contains :
...
linux-rasp-pi2-g++
linux-rasp-pi-g++
linux-rpi3-g++
linux-rpi3-vc4-g++
...
I'm not sure what is the best device option I have to set for the ./configure for Raspberry Pi3, someone can explain the differences between all these configurations?
If you are working with Raspberry Pi 3, you should use linux-rpi3-g++ or linux-rpi3-vc4-g++.
linux-rpi3-vc4-g++ should be used if you want to enable hardware acceleration. VC stands for Video Core. You have more information about Video Core IV in the wikipedia. I think it's worth it to try this configuration.
linux-rasp-pi-g++ is the configuration for the first model and linux-rasp-pi2-g++ for the Raspberry Pi 2.

Is it possible to boot the Raspberry Pi in Secure Mode?

I am currently developing a small OS on my Raspberry Pi, that I install by replacing the kernel.img file on the /boot partition of my SD card. By the time my code is run, the CPU is already in Normal Mode, so I can't have access to the Secure world / Trustzone area.
Is it possible to modify the boot process of the Raspberry to be able to start executing my code in Secure mode ?
Best,
V.
In fact you don't have to do anything but stop being stupid like me.
As explained here:
https://raspberrypi.stackexchange.com/questions/14953/is-it-possible-to-boot-the-raspberry-pi-in-secure-mode
When the NS bit of the SCR register is 0, it means that you are in Secure Mode, which is the case at boot on my Raspberry. I had the meaning of this bit backwards, sorry !