Error Message while programming using avrdude and Codeblock - codeblocks

I was setting up codeblock for AVR. I am able to compile and build. But while buring using avrdude, I see lot of stderr messages. Can anyone tell what could be the reason? The program however gets written correctly to the controller.
My post build configuration in code block is
avr-objcopy -O ihex -j .text -j .data $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex
Below is the Error Details:
Launching tool 'Serial Programmer': C:\Atmega\programmers\avrdude.exe -C"C:\Atmega\programmers\avrdude.conf" -pm328p -carduino -PCOM2 -b115200 -Uflash:w:EmbeddedProject2.elf.hex (in C:\Atmega\Projects\Codeblock Projects\EmbeddedProject2\bin\Debug)
stderr>
stderr> avrdude.exe: AVR device initialized and ready to accept instructions
stderr>
stderr> Reading | ################################################## | 100% 0.00s
stderr>
stderr> avrdude.exe: Device signature = 0x1e950f
stderr> avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
stderr> To disable this feature, specify the -D option.
stderr> avrdude.exe: erasing chip
stderr> avrdude.exe: reading input file "EmbeddedProject2.elf.hex"
stderr> avrdude.exe: input file EmbeddedProject2.elf.hex auto detected as Intel Hex
stderr> avrdude.exe: writing flash (11674 bytes):
stderr>
stderr> Writing |
stderr> ##
stderr> ##
stderr> #
stderr> ##
stderr> ###
stderr> #
stderr> ##
stderr> ###
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> ##
stderr> ##
stderr> #
stderr> ##
stderr> #
stderr> ##
stderr> ###
stderr> ###
stderr> ###
stderr> ##
stderr> #
stderr> ##
stderr> #
stderr> ## | 100% 1.90s
stderr>
stderr> avrdude.exe: 11674 bytes of flash written
stderr> avrdude.exe: verifying flash memory against EmbeddedProject2.elf.hex:
stderr> avrdude.exe: load data flash data from input file EmbeddedProject2.elf.hex:
stderr> avrdude.exe: input file EmbeddedProject2.elf.hex auto detected as Intel Hex
stderr> avrdude.exe: input file EmbeddedProject2.elf.hex contains 11674 bytes
stderr> avrdude.exe: reading on-chip flash data:
stderr>
stderr> Reading | ##
stderr> #
stderr> #
stderr> ####
stderr> ###
stderr> ##
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> ##
stderr> #
stderr> ##
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> #
stderr> ##
stderr> #
stderr> #
stderr> #
stderr> #
stderr> ### | 100% 1.51s
stderr>
stderr> avrdude.exe: verifying ...
stderr> avrdude.exe: 11674 bytes of flash verified
stderr>
stderr> avrdude.exe done. Thank you.
stderr>
Tool execution terminated with status 0

You're seeing output in stderr because avrdude outputs to stderr. If you want to suppress non-error output then pass -qq to avrdude.

Related

No key available with this passphrase luks bash

I am trying to remote configure my host with a script.
However it fail when doing cryptsetup luksOpen
here is my function:
# used to encrypt the volume
# $1 the ssh connect
# $2 the partition
# $3 the password
# $4 the LUKSName
encrypt(){
ssh $1 << EOF
sudo -s
# convert the partition to the LUKS format
echo "About to init luks on partition: cryptsetup luksFormat $2 with [YES, $3, $3]"
(
echo YES
echo $3
echo $3
) | cryptsetup -v luksFormat $2
sleep 3
echo "About to mount and format: cryptsetup luksOpen $2 $4 with [$3]"
(
echo $3
) | cryptsetup -v luksOpen $2 $4
# Create an EXT4 file system on the LUKS logical volume
mkfs.ext4 /dev/mapper/$4
# optional create the luks.key
echo $3 > /root/luks.key
echo "About to create the luksKey: cryptsetup luksAddKey $2 /root/luks.key with [$3]"
(
echo $3
) | cryptsetup luksAddKey $2 /root/luks.key
# enter the new volume in /etc/fstab
echo "/dev/mapper/$4 /$4 ext4 defaults 1 2" >> /etc/fstab
# create the mount point
mkdir /$4
#mount the luks volume
mount /$4
EOF
}
So my logs are correct for the luksFormat but fail with luksOpen
About to init luks on partition: cryptsetup luksFormat /dev/sdb1 with [YES, pwd, pwd]
Command successful.
About to mount and format: cryptsetup luksOpen /dev/sdb1 mongo_data with [pwd]
No key available with this passphrase.
Command failed with code 1: No key available with this passphrase.
When I do it manually it is working.
Here is debug traces:
# cryptsetup 1.6.6 processing "cryptsetup --debug luksOpen /dev/sdb1 mongo_data"
# Running command open.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating crypt device /dev/sdb1 context.
# Trying to open and read device /dev/sdb1.
# Initialising device-mapper backend library.
# Trying to load LUKS1 crypt type from device /dev/sdb1.
# Crypto backend (gcrypt 1.6.5) initialized.
# Detected kernel Linux 4.4.0-81-generic x86_64.
# Reading LUKS header of size 1024 from device /dev/sdb1
# Key length 32, device size 20969472 sectors, header size 2050 sectors.
# Timeout set to 0 miliseconds.
# Password retry count set to 3.
# Password verification disabled.
# Iteration time set to 1000 miliseconds.
# Activating volume mongo_data [keyslot -1] using [none] passphrase.
# dm version OF [16384] (*1)
# dm versions OF [16384] (*1)
# Detected dm-crypt version 1.14.1, dm-ioctl version 4.34.0.
# Device-mapper backend running with UDEV support enabled.
# dm status mongo_data OF [16384] (*1)
# STDIN descriptor passphrase entry requested.
# Trying to open key slot 0 [ACTIVE_LAST].
# Reading key slot 0 area.
# Using userspace crypto wrapper to access keyslot area.
# Trying to open key slot 1 [INACTIVE].mke2fs 1.42.13 (17-May-2015)
# Trying to open key slot 2 [INACTIVE].The file /dev/mapper/mongo_data does not exist and no size was specified.
# Trying to open key slot 3 [INACTIVE].
# Trying to open key slot 4 [INACTIVE].
# Trying to open key slot 5 [INACTIVE].
# Trying to open key slot 6 [INACTIVE].
# Trying to open key slot 7 [INACTIVE].
# STDIN descriptor passphrase entry requested.
# Nothing read on input.
# Releasing crypt device /dev/sdb1 context.
# Releasing device-mapper backend.
# Unlocking memory.
It seems that Nothing read on input means that it did not get my password...
Do you maybe have an idea?
Regards
The password for your encrypted container is YES... cryptsetup luksFormat does not carry out the dialogue when standard input is not a terminal; it just reads one line and uses that as the password.

Unattended generation of an ECDSA key using gpg2

Short question
How do I specify an elliptic curve in a gpg2 v2.1.11 parameter file?
Long question
I have successfully used the following bash script to generate an RSA key using gpg2 v2.1.11:
#!/bin/bash
PUBRING_FILE=$(mktemp /tmp/pub.XXXXXX)
CONFIG_FILE=$(mktemp /tmp/config.XXXXXX)
cat >$CONFIG_FILE <<EOF
Key-Type: DSA
Key-Length: 1024
Subkey-Type: RSA
Subkey-Length: 2048
Name-Real: Name
Name-Comment: Comment
Name-Email: Email
Expire-Date: 0
Passphrase: abc
%pubring $PUBRING_FILE
EOF
gpg2 --quiet --batch --expert --full-gen-key $CONFIG_FILE
I want to use the same script to generate an ECDSA key. However, when I replace
Subkey-Type: RSA
Subkey-Length: 2048
with
Subkey-Type: ECDSA
Subkey-Length: 256
I get the following error
gpg: key generation failed: Unknown elliptic curve
My configuration file clearly omits the curve, but how can I include it? I.e., how do I specify an elliptic curve in a gpg2 v2.1.11 parameter file?
gpg2 does not know which EC curve you want to use. To fix this, you need to use the Key-Curve option. In your example you should remove the Subkey-Length: 2048 line and add a new Subkey-Curve: [...] option.
Example using the NIST P-256 curve:
cat >$CONFIG_FILE <<EOF
Key-Type: DSA
Key-Length: 1024
Subkey-Type: ECDSA
Subkey-Curve: nistp256
Name-Real: Name
Name-Comment: Comment
Name-Email: Email
Expire-Date: 0
Passphrase: abc
%pubring $PUBRING_FILE
EOF

avrdude error on atmega1281

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

Unattended GPG command script hangs at GPG command

I want to create an auto GnuPG key generation script for one person atm who, although they run ubuntu, does not feel comfortable using the CLI. In addition, someone else manages their computer, keeping it up to date and in good running order, so they do not have root/sudo access either. And I would really like to try and avoid doing as much as possible with instructions over the phone... been there too many times to know what a PITA that can be!
So I whipped up this script borrowing heavily from an example I found on the gnupg.org forums (I think?). But it does not seem to do anything once the gpg --gen-key --batch command is run no matter how much mouse activity is generated in 3 or 4 minutes. All the echo statements btw are just a temporary means to indicate script progress, which isn't very far atm.
#!/bin/bash
# First run give your server some work, otherwise gpg won't be able to generator random bytes.
#sudo rngd -r /dev/urandom
#no sudo so:
echo -e "\nYou need to begin moving your mouse continuously and in random patterns for as long as it takes to generate a new key. This could take a minute or two, so be patient and just keep moving the mouse.\n"
echo -e "\ngpg --gen-key --batch\n"
gpg --batch --gen-key
%echo Generating a default key
Key-Type: default
Key-Length: 2048
Subkey-Type: default
Name-Real: Firstname Lastname
Name-Comment: No comment
Name-Email: user#domain.com
Expire-Date: 0
Passphrase: abcde
%pubring foo.pub
%secring foo.sec
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
# kill the rngd task.
#sudo service rng-tools stop
echo -e "\ngpg -k\n"
gpg -k
# get key id for newly created passkey
echo -e "\nkId=$(gpg -k Firstname|grep pub|sed -r 's/^pub[ ]*2048R\/([A-Z0-9]{8,})[ ]*.*$/\1/')\n" #; echo "\$kId: ${kId}"
kId=$(gpg -k Firstname|grep pub|sed -r 's/^pub[ ]*2048R\/([A-Z0-9]{8,})[ ]*.*$/\1/') ; echo -e "\n\$kId: ${kId}\n"
# set key as the default key (if desired) by entering this line in your ~/.bashrc
echo -e "\nexport GPGKEY=$kId\n"
export GPGKEY="$kId"
# restart the gpg-agent and source your .bashrc again
echo -e "\nkillall -q gpg-agent\n"
killall -q gpg-agent
eval $(gpg-agent --daemon)
source ~/.bashrc
#create revocation cert
echo -e "\ngpg --output revoke.asc --gen-revoke $GPGKEY\n"
gpg --output revoke.asc --gen-revoke $GPGKEY
# send public key to keyserver
echo -e "\ngpg --send-keys --keyserver keyserver.ubuntu.com $GPGKEY\n"
#gpg --send-keys --keyserver keyserver.ubuntu.com $GPGKEY
I wonder if anyone can see any obvious problems or omissions feeding 'gpg' required key details?
I get the same thing even if I run the script with the sudo rngd -r /dev/random command that I need to bypass for the intended user (no sudo access).
So I guess the prob is in the key params I want to pass to gpg, but I have cross referenced them with the man page and can't seem to find what the problem might be. It is funny though that gpg does not return the error.
With batch key generation, GnuPG expects the creation commands in a file, compare with the GnuPG manual page on batch key generation.
cat <<EOT >batch-cmds
%echo Generating a default key
Key-Type: default
Key-Length: 2048
Subkey-Type: default
Name-Real: Firstname Lastname
Name-Comment: No comment
Name-Email: user#domain.com
Expire-Date: 0
Passphrase: abcde
%pubring foo.pub
%secring foo.sec
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOT
gpg --batch --gen-key batch-cmds
Consider the security implications of storing the passwords in a file on the hard disk. I'm not sure if you can also pipe the contents directly into GnuPG instead of storing them to a file. Try something like this:
gpg --batch --gen-key <<EOT
%echo Generating a default key
Key-Type: default
Key-Length: 2048
Subkey-Type: default
Name-Real: Firstname Lastname
Name-Comment: No comment
Name-Email: user#domain.com
Expire-Date: 0
Passphrase: abcde
%pubring foo.pub
%secring foo.sec
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOT

How to connect to wifi in bash?

I'd like to make a simple bash script to connect to known wifi networks.
Thus far I have...
#!/bin/bash
NETWORK_ID=${1:myintranet}
WIRELESS_KEY=${2:""}
WIRELESS_DEVICE=${3:wlan0}
if [ ! -n "$WIRELESS_KEY" ]; then
read -s -p "Enter Password: " WIRELESS_KEY
fi
#ifconfig wlan0
iwconfig wlan0 essid $NETWORK_ID key s:$WIRELESS_KEY
dhclient wlan0
I enter the plain text password for the network when requested and it fails with the error
iwconfig: unknown command "s:myPassword"
But I can't find any reason why it should be expecting a command and not translating the key to hex.
This is working fine for me for WEP wifi. Don't forget to name the script with .sh extension.
#!/bin/bash
NETWORK_ID=${1:myintranet}
WIRELESS_KEY=${2:xxx}
WIRELESS_DEVICE=${3:wlan0}
if [ -z "$WIRELESS_KEY" ]; then
read -s -p "Enter Password: " WIRELESS_KEY
fi
#ifconfig wlan0
iwconfig wlan0 essid $NETWORK_ID key s:$WIRELESS_KEY
dhclient wlan0
For WPA wifi, it may not work. Consider using wpa_supplicant or configure it using wicd (wicd-gtk)

Resources