avrdude error on atmega1281 - avr

I have atmega1281 and AD-USBISP V03.6
I have compile problem write on flash
problem is
sudo avrdude -p m1281 -P /dev/ttyUSB0 -c stk500v2 -U flash:w:test.hex:i
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0xffffff (retrying)
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0xffffff (retrying)
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0xffffff
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
first problem that I guessed is stk500v2_ReceiveMessage(): timeout but I don't know how to solve this problem.
How to solve this problem and write test.hex on flash of avr ?

You can select programmer type with -c option, for USBISP use -c usbasb. So try the following
sudo avrdude -p m1281 -P /dev/ttyUSB0 -c usbasb -U flash:w:test.hex:i
If it fails, add another option -B 10 to set the clock
sudo avrdude -p m1281 -P /dev/ttyUSB0 -B 10 -c usbasb -U flash:w:test.hex:i
Read more information here

Related

SNMP: No such object available on this agent at this OID

I am trying to monitor the state of a UPS (NetVision), using the provided mib file.
So, upsBatteryStatus should be .1.3.6.1.2.1.33.1.2.1.0
snmpwalk -c COMMUNITY -v1 192.168.1.10 .1.3.6.1.2.1.33.1.2.1.0
iso.3.6.1.2.1.33.1.2.1.0 = INTEGER: 2
And here comes the tricky part:
snmptranslate -Of SOCOMECUPS-MIB::upsBatteryStatus
.iso.org.dod.internet.private.enterprises.socomecSicon.software.network.netvision.upsObjects.upsBattery.upsBatteryStatus
snmptranslate -On SOCOMECUPS-MIB::upsBatteryStatus
.1.3.6.1.4.1.4555.1.1.1.1.2.1
Its different from .1.3.6.1.2.1.33.1.2.1.0 , and it doesnt respond with a value.
check_snmp -H 192.168.1.10 -C COMMUNITY -o upsBatteryStatus -w 1 -c #3:7 -m /var/lib/mibs/ietf/NetVision-nv6-unix.mib -l "Battery Status: "
External command error: Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: SOCOMECUPS-MIB::upsBatteryStatus
Any ideas why it isnt recongnizes as upsBatteryStatus ?
There seem to be 2 objects with the object name upsBatteryStatus in 2 different MIBs: http://www.oidview.com/mibs/4555/SOCOMECUPS-MIB.html and https://www.rfc-editor.org/rfc/rfc1628 . That explains the different OIDs. Nothing wrong with that. The OID is the true identifier of an object, the name is just for us humans.
As far as the error, I don't know what check_snmp does, so cannot say anything about that. But, have you tried this command?
snmpwalk -c COMMUNITY -v1 192.168.1.10 .1.3.6.1.4.1.4555.1.1.1.1.2.1
Helpful commands:
snmptranslate -Tp -m /usr/share/mibs/ietf/NetVision-nv6-unix.mib
and:
"upsBatteryStatus" "1.3.6.1.2.1.33.1.2.1"
| | |
| | +--upsBattery(2)
| | | |
| | | +-- -R-- EnumVal upsBatteryStatus(1)
| | | | Values: unknown(1), batteryNormal(2), batteryLow(3), batteryDepleted(4)
Nagios check_snmp command that reported the correct value is:
/usr/local/nagios/libexec/check_snmp -H 192.168.1.10 -C COMMUNITY -m /var/lib/mibs/ietf/NetVision-nv6-unix.mib -o upsBatteryStatus -w #0:1 -c #3:7 -l "Battery Status: "
SNMP OK - Battery Status: 2 | 'Battery Status: '=2;1;7;
Thank you for help.

Adjust ulimit [open file handle limit] on Mac OS X Sierra to run GATK tools

I'm trying to run the VariantsToBinaryPed tool from GATK3, but it seems that my system's 'open file handle limit' is too small for it to successfully run.
I've tried increasing the limit using ulimit, as shown below, but the command still fails.
The GATK command:
> java -jar GenomeAnalysisTK.jar \
-T VariantsToBinaryPed \
-R Homo_sapiens_assembly38.fasta \
-V ~/vcf/snp.indel.recal.splitMA_norm.vcf.bgz\
-m ~/03_IdentityCheck/KING/targeted_seq_ped_clean.fam\
-bed output.bed\
-bim output.bim\
-fam output.fam\
--minGenotypeQuality 0
Returns this error:
ERROR MESSAGE: An error occurred because there were too many files
open concurrently; your system's open file handle limit is probably too small.
See the unix ulimit command to adjust this limit or
ask your system administrator for help.
Following the advice given here, I ran:
echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
sudo ulimit -n 65536 65536
and added this line to my .bash_profile and sourced it:
ulimit -n 65536 65536
So that now, when I run ulimit -n, I get:
65536
However, I still get the same error from GATK:
ERROR MESSAGE: An error occurred because there were too many files
open concurrently; your system's open file handle limit is probably too small.
See the unix ulimit command to adjust this limit or
ask your system administrator for help.
Is there anything else I can do to avoid this error?

writing shell ssh script for uploading compiled sketch on multiple arduino yun in network

I work with a couple of arduino yuns and want to write a script to upload sketches on multiple of them. Let's assume I have a compiled arduino program:sketch.hex.
Now I'd like to upload this file via LAN. For a single device it works like this.
Copying the sketch onto the device. (password required)
scp sketch.hex root#yun1.local:/tmp/sketch.hex
Opening an ssh session with the device. (password required)
ssh root#yun1.local
And then load the program onto the Atmega with the following 2 commands.
merge-sketch-with-bootloader.lua /tmp/sketch.hex
run-avrdude /tmp/sketch.hex
Now my question would be, how to do this for multiple arduinos (yun1,yun2,...,yunN) without entering actually ssh-ing into each single device in order to run the bottom 2 commands.
Hope the question is not too confusing and thanks a lot in advance.
Update: could figure it out myself. Here is the code in case someone needs it.
#!/bin/sh
# globalUpload.sh
#
#
# Created by maggu on 21/02/16.
#
clear
FILENAME="valve_adjusting.hex"
SSHPASS="doghunter"
SSHCOMMAND="ssh -p 22 -T -o StrictHostKeyChecking=no -o BatchMode=no"
PREFIX="root#linino"
PREFIXO="linino"
SUFFIX=".local"
YUNS=8
for i in `seq 1 $YUNS`
do
SSHACCOUNT=$PREFIX$i$SUFFIX
ssh-keygen -R $PREFIXO$i$SUFFIX
sshpass -p "doghunter" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sketch.hex $SSHACCOUNT:/tmp/sketch.hex
sshpass -p $SSHPASS $SSHCOMMAND $SSHACCOUNT << EOF_run_commands
merge-sketch-with-bootloader.lua /tmp/sketch.hex
run-avrdude /tmp/sketch.hex
EOF_run_commands
done
#!/bin/sh
# globalUpload.sh
#
#
# Created by maggu on 21/02/16.
#
clear
FILENAME="valve_adjusting.hex"
SSHPASS="doghunter"
SSHCOMMAND="ssh -p 22 -T -o StrictHostKeyChecking=no -o BatchMode=no"
PREFIX="root#linino"
PREFIXO="linino"
SUFFIX=".local"
YUNS=8
for i in `seq 1 $YUNS`
do
SSHACCOUNT=$PREFIX$i$SUFFIX
ssh-keygen -R $PREFIXO$i$SUFFIX
sshpass -p "doghunter" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sketch.hex $SSHACCOUNT:/tmp/sketch.hex
sshpass -p $SSHPASS $SSHCOMMAND $SSHACCOUNT << EOF_run_commands
merge-sketch-with-bootloader.lua /tmp/sketch.hex
run-avrdude /tmp/sketch.hex
EOF_run_commands
done

OSX equivalent of piping sound to linux's aplay

On Ubuntu I am able to use aplay to play sound generated live from a script by piping the output of my script to aplay's stdin :
./generate_sound.py | aplay -r 2000 -c2 -f MU_LAW
cat sample.wav | aplay
Is there a way to do the same from terminal in OSX? I think afplay doesn't support this ...
Maybe someone knows another OSX command line sound player that would do the trick?
I had high hopes for redirection/piping, but afplay /dev/stdin <<< $(generate_sound.py) failed for all the formats I tried. Sadly afplay doesn't let you specify the format, and so it tries instead to sniff it which probably involves seeking which doesn't work with pipes.
I think you'd better find another command line player. sox seems like a good candidate. And! It's installable via homebrew: brew install sox and you can pipe data to it like so:
cat whatever.raw | play -t raw -e floating-point -b 32 -c 2 -r 44100 -
To Listen to an FM station on a mac
rtl_fm -f 95.3e6 -M wbfm -s 200000 -r 48000 – | aplay -r 48k -f S16_LE
To record for 10s
export AUDIOSAMPLERATE=48000
export SAMPLERATE=200000
export FREQ="127.2m"
rtl_fm -f $FREQ -M am -s $SAMPLERATE -r $AUDIOSAMPLERATE | sox -r $AUDIOSAMPLERATE -t raw -e s -b 16 -c 1 -V1 - FILENAME.wav&
sleep 10
killall rtl_fm

Why isn't my Arch Linux fully automated installer working?

I've been working on a simple fully-automated installer for ArchLinux recently.
I started with a basic three-partition system; that made a bootable system.
I added LVM and several more logical partitions; that worked also.
I'm now trying to add LUKS encryption; that isn't working.
I want to have LUKS inside of LVM for more flexibility. For a BIOS system with a single disk, that should look something like this:
Raw Partitions
+-----------+------+-------+-----------+
| Partition | Name | Size | Flags |
+-----------+------+-------+-----------+
| /dev/sda1 | grub | 2MB | bios_grub |
| /dev/sda2 | boot | 200MB | boot |
| /dev/sda3 | lvm | | lvm |
+-----------+------+-------+-----------+
LVM Partitions
+-------------+--------------+-------+------+
| LVM Device | LUKS Device | Name | Size |
+-------------+--------------+-------+------+
| LvmDvc-root | LuksDvc-root | root | 2GB |
| LvmDvc-home | LuksDvc-home | home | 2GB |
| LvmDvc-var | LuksDvc-var | var | 1G |
| LvmDvc-usr | LuksDvc-usr | usr | 1G |
| LvmDvc-swap | LuksDvc-swap | swap | 4G |
+-------------+--------------+-------+------+
LvmDvc-root is decrypted to LuksDvc-root using a passphrase.
All other LVM devices are decrypted using keys stored in /etc/ctyptkeys.
Partitions are mounted as:
/dev/mapper/LuksDvc-root -> /
/dev/sda2 -> /boot
/dev/mapper/LuksDvc-home -> /home
/dev/mapper/LuksDvc-var -> /var
/dev/mapper/LuksDvc-usr -> /usr
From what I can tell, disk partitioning and system install work just fine. I receive a slew of errors about lvmetad not being loaded during grub configuration, but the documentation in Arch's wiki indicates this is a non-issue (https://wiki.archlinux.org/index.php/GRUB#UEFI_systems_2). I also receive these same errors in the previous version of my script (using LVM, but not LUKS), and it produces a bootable system. So I don't think this error message indicates a problem.
When I boot the system, I get through GRUB just fine. I am presented with a dialogue to decrypt the root partition:
A password is required to access the LuksDvc-root volume:
Enter passphrase for /dev/mapper/LvmDvc-root:
I enter the passphrase used during installation, and receive this message:
No key available with this passphrase.
I'm using a very simple passphrase for testing (asdfasdf), so I doubt I'm messing it up. I can decrypt and mount the whole system from the live installer without incident, I just can't make it happen at boot.
I'm not sure what information would be most helpful for solving this. Here is the script I use to install the system:
#!/usr/bin/env bash
set -ex -o pipefail -o nounset
# Raw Partitioning
parted --script --align optimal -- /dev/sda mklabel gpt
parted --script --align optimal -- /dev/sda mkpart primary 2 4
parted --script --align optimal -- /dev/sda name 1 bios_grub
parted --script --align optimal -- /dev/sda set 1 bios_grub on
parted --script --align optimal -- /dev/sda mkpart primary 4 204
parted --script --align optimal -- /dev/sda name 2 boot
parted --script --align optimal -- /dev/sda set 2 boot on
parted --script --align optimal -- /dev/sda mkpart primary 204 -1
parted --script --align optimal -- /dev/sda name 3 lvm
parted --script --align optimal -- /dev/sda set 3 lvm on
# LVM Partitioning
pvcreate -ff --yes /dev/sda3
vgcreate LvmDvc /dev/sda3
lvcreate --zero y --wipesignatures y --name root --size 2G LvmDvc
lvcreate --zero y --wipesignatures y --name home --size 2G LvmDvc
lvcreate --zero y --wipesignatures y --name var --size 1G LvmDvc
lvcreate --zero y --wipesignatures y --name usr --size 1G LvmDvc
lvcreate --zero y --wipesignatures y --name swap --size 4G LvmDvc
# Root Partition
echo asdfasdf | cryptsetup -q --key-file - luksFormat /dev/mapper/LvmDvc-root
echo asdfasdf | cryptsetup -q --key-file - luksOpen /dev/mapper/LvmDvc-root LuksDvc-root
mkfs.ext4 -q /dev/mapper/LuksDvc-root
mkdir -p /mnt/archbox
mount /dev/mapper/LuksDvc-root /mnt/archbox
# Boot Partition
mkfs.ext4 -q /dev/sda2
# Encrypted Partitions
mkdir -p /mnt/archbox/etc/cryptkeys
chmod 400 /mnt/archbox/etc/cryptkeys
dd if=/dev/random of=/mnt/archbox/etc/cryptkeys/home bs=512 count=4 iflag=fullblock
chmod 400 /mnt/archbox/etc/cryptkeys/home
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/home luksFormat /dev/mapper/LvmDvc-home
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/home luksOpen /dev/mapper/LvmDvc-home LuksDvc-home
mkfs.ext4 -q /dev/mapper/LuksDvc-home
dd if=/dev/random of=/mnt/archbox/etc/cryptkeys/var bs=512 count=4 iflag=fullblock
chmod 400 /mnt/archbox/etc/cryptkeys/var
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/var luksFormat /dev/mapper/LvmDvc-var
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/var luksOpen /dev/mapper/LvmDvc-var LuksDvc-var
mkfs.ext4 -q /dev/mapper/LuksDvc-var
dd if=/dev/random of=/mnt/archbox/etc/cryptkeys/usr bs=512 count=4 iflag=fullblock
chmod 400 /mnt/archbox/etc/cryptkeys/usr
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/usr luksFormat /dev/mapper/LvmDvc-usr
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/usr luksOpen /dev/mapper/LvmDvc-usr LuksDvc-usr
mkfs.ext4 -q /dev/mapper/LuksDvc-usr
dd if=/dev/random of=/mnt/archbox/etc/cryptkeys/swap bs=512 count=4 iflag=fullblock
chmod 400 /mnt/archbox/etc/cryptkeys/swap
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/swap luksFormat /dev/mapper/LvmDvc-swap
cryptsetup -q --key-file /mnt/archbox/etc/cryptkeys/swap luksOpen /dev/mapper/LvmDvc-swap LuksDvc-swap
mkswap /dev/mapper/LuksDvc-swap
# Mount
mkdir -p /mnt/archbox/boot
mount /dev/sda2 /mnt/archbox/boot
mkdir -p /mnt/archbox/home
mount /dev/mapper/LuksDvc-home /mnt/archbox/home
mkdir -p /mnt/archbox/var
mount /dev/mapper/LuksDvc-var /mnt/archbox/var
mkdir -p /mnt/archbox/usr
mount /dev/mapper/LuksDvc-usr /mnt/archbox/usr
swapon /dev/mapper/LuksDvc-swap
# Packages
mkdir -p ./cache-dir
rm -f /mnt/archbox/var/lib/pacman/db.lck
pacstrap /mnt/archbox --cachedir ./cache-dir base grub
# Root password
echo "root:asdfasdf" | chpasswd --root /mnt/archbox
# FSTab
genfstab -U -p /mnt/archbox >> /mnt/archbox/etc/fstab
# CryptTab
echo "" > /mnt/archbox/etc/crypttab
echo "home /dev/mapper/LvmDvc-home /mnt/archbox/etc/cryptkeys/home" >> /mnt/archbox/etc/crypttab
echo "usr /dev/mapper/LvmDvc-usr /mnt/archbox/etc/cryptkeys/usr" >> /mnt/archbox/etc/crypttab
echo "var /dev/mapper/LvmDvc-var /mnt/archbox/etc/cryptkeys/var" >> /mnt/archbox/etc/crypttab
echo "swap /dev/mapper/LvmDvc-swap /mnt/archbox/etc/cryptkeys/swap" >> /mnt/archbox/etc/crypttab
# Ramdisk
file=/mnt/archbox/etc/mkinitcpio.conf
search="^\s*MODULES=.*$"
replace="MODULES=\\\"virtio virtio_blk virtio_pci virtio_net\\\""
grep -q "$search" "$file" && sed -i "s#$search#$replace#" "$file" || echo "$replace" >> "$file"
search="^\s*HOOKS=.*$"
replace="HOOKS=\\\"base udev autodetect modconf block keymap encrypt lvm2 filesystems keyboard shutdown fsck usr\\\""
grep -q "$search" "$file" && sed -i "s#$search#$replace#" "$file" || echo "$replace" >> "$file"
arch-chroot /mnt/archbox mkinitcpio -p linux
# Bootloader
arch-chroot /mnt/archbox grub-install --target=i386-pc --recheck /dev/sda
file=/mnt/archbox/etc/default/grub
search="^\s*GRUB_CMDLINE_LINUX=.*$"
replace="GRUB_CMDLINE_LINUX=\\\"init=/usr/lib/systemd/systemd cryptdevice=/dev/mapper/LvmDvc-root:LuksDvc-root root=/dev/mapper/LuksDvc-root quiet\\\""
grep -q "$search" "$file" && sed -i "s#$search#$replace#" "$file" || echo "$replace" >> "$file"
search="^\s*GRUB_DISABLE_LINUX_UUID=.*$"
replace="GRUB_DISABLE_LINUX_UUID=true"
grep -q "$search" "$file" && sed -i "s#$search#$replace#" "$file" || echo "$replace" >> "$file"
arch-chroot /mnt/archbox grub-mkconfig -o /boot/grub/grub.cfg
Does anything stick out as blatantly wrong? What should I be doing differently? Can I provide additional/specific information?
tl;dr - Install script seems to work, but I can't decrypt the system at boot. Halp!
I found the main problem: formatting the root LUKS volume should be done with a password, not a key file. Taking out the option --key-file - on the formatting and opening for the root volume fixes the problem I was seeing.
There are some other issues, in the script, but I'll come back after I've tried and failed to fix them.
appreciate any updates of your script; I'm currently testing it. Note, in the above script, the isolated '-' is a syntax error:
echo asdfasdf | cryptsetup -q --key-file - luksFormat /dev/mapper/LvmDvc-root
echo asdfasdf | cryptsetup -q --key-file - luksOpen /dev/mapper/LvmDvc-root LuksDvc-root
after taking out '--key-file' as you suggested, the two lines should be:
echo asdfasdf | cryptsetup -q luksFormat /dev/mapper/LvmDvc-root
echo asdfasdf | cryptsetup -q luksOpen /dev/mapper/LvmDvc-root LuksDvc-root
after this changing the script did run through with the warnings you mentioned. when booting the disk generated by the script, root volume password and then
dev/mapper/Lucks-Dvc-root: clean, ...
ERROR: device '' not found. Skipping fsck.
mount: wrong fs type, bad option, bad superblock ,
missing code page or helper program, ... try dmesg | tail
ERROR: root device mounted success..., but /usr/lib/systemd/systemd does not exist.
Bailing out...
sh: cant access tty: job control turned off
[rootfs /]#
when searching for this error, found:
"Looks like that script doesn't install systemd-sysvcompat, which provides the /sbin/init symlink to /usr/lib/systemd/systemd. You might want to file a bug report and/or use pacstrap in the future."
-- https://bbs.archlinux.org/viewtopic.php?id=146712
(post by WorMzy 2013-02-06 15:11:34)
What about using LVM on top of LUKS instead of the other way around used in your script?
I used the following instructions on a number of machines and it worked just fine: http://is.gd/OoDx1d

Resources