How to configure the Atmel AVRISP MKii to work with Arduino IDE

Hello all, since I’ve been helped by so many knowledgeable and generous people here, I wanted to give back a little on what I’ve learned.  After two days of searching literally hundreds of forums, blogs and spec sheets, I was finally able to get my Atmel AVRISP MKii to work with the Arduino IDE and upload sketches to my breadboarded Mega 328P IC.  I found many threads with tips on doing this and that, but none had all the missing pieces nor helped walk a newcomer through all the little adjustments that had to be made in order to make this happen (at least for a newbie like myself).

So here goes;  For this particular tutorial, I’m using a breadboarded Mega328P with the Atmel AVRISP MKii with Arduino IDE 0023 on a Windows 7 machine. If anyone spots an error, please let me know.

1.  DO NOT install the Atmel AVR Studio software suite.  It installs the “Jungo USB” driver which is not compatible with AVRdude (which the Arduino IDE uses).  You can either use one of the other, not both at the same time.

If by chance you had already installed AVR Studio and the Jungo Drivers, don’t worry, I’ll show you how to replace it further down.

2.  Download the LibUSB-Win32 driver and extract it somewhere temporary.  It can be found at www.libusb.org, however, for some reason my machine did not like this version, so I found another version that appeared to be tailored specifically for the AVRISP MKii here: http://mightyohm.com/blog/2010/09/avrisp-mkii-libusb-drivers-for-windows-7-vista-x64/

3.  Now if you haven’t installed the Jungo USB drivers, then you can simply plug in your AVRISP MKii, but when it asks whether you wish to install the drivers for it automatically or manually, choose MANUAL. If your did like mine and went ahead automatically and installed the stinkin Jungo USB drivers anyway, then you’ll need to do the follow:

How to replace the Jungo USB drivers:
A. Go into your Device Manager and expand the tree under “Jungo”.  If you see “AVRISP mkII” there, then you’ll need to replace that driver with the LibUSB-Win32 driver. Right-Click and select “Update Driver Software” and then choose “Browse my computer for driver software”.  Then simply navigate to where you extracted your LibUSB-Win32 drivers and let it do it’s thing. If it refuses to replace it or says that Windows deems the current driver the latest, then you’ll need to find a better/newer copy of the LibUSB driver.  You can also try uninstalling the Jungo driver first, but my smartass PC kept reinstalling it automatically everytime I plugged the AVRISP MKii back in—regardless of me manually clicking cancel!

4. If the LibUSB-Win32 driver installed correctly, the AVRISP MKii should now appear under “LibUSB-Win32 Devices” instead of the Jungo tree. This is important to make sure of because the Arduino IDE will NOT work with it as long as it appears under Jungo.

5. Now, to get the Mega328p to work with IDE 0023, you’ll need to edit the /hardware/boards.txt << within your Arduino install folder and add the following to the very bottom:

###############################################

atmega328bb.name=AVRISP mkII w/ ATmega328
atmega328bb.upload.using=arduino:avrispmkii
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=standard

###############################################

Keep in mind the above is for the Mega328P (the “P” being the “Pico” version of the chip). You’ll need to make some minor adjustments for the non-pico version).

6. Now locate /lib/preferences.txt file and find the line “upload.using=bootloader” and replace it with, “upload.using=avrispmkii” (we’re just replacing the bootloader with the avrispmkii)

7. DONE! You’re now ready to begin using your new AVRISP MKii!!! When you first open up the Arduino IDE (I’m using 0023) go to Tools > Boards > and you’ll see a new entry for “AVRSIP MKII w/ ATMega328” > choose this one if you’re that’s the chip you’re using like I am.  After that, I’d suggest you try out a simple sketch like the Blink LED in the examples folder and make sure it all works.

Some closing tips. If you’re hooking up the MKii to your breadboard, be sure you have the cable’s pinouts correctly.  I found so much confusing and contradictory pinout information for the AVRISP MKii on the web it was rediculous. It all comes down to locating PIN 1 — which is always located on the side of the ribbon with the stripe. Now since two pinholes line up with the ribbon stripe, look carefully for a triangle symbol. The triangle will point you to PIN 1, and thereafter you can make out the orientation of all the other pins.

I really hope this helps out other people and saves you all the headaches I had to go through to get this thing working. I swear at one point I was ready to hang the MKii on a post outside and put a bullet through it!

Source: How to configure the Atmel AVRISP MKii to work with Arduino IDE

How to configure the Atmel AVRISP MKii to work with Arduino IDE was last modified: July 13th, 2017 by Jovan Stosic

JTAG Debugging

I am very excited to finally see the Due in the wild. I am eagerly looking for its soulmate, the JTAG debugger. What are our options for debugging 96kb of code? Can we use low-cost debuggers like the LPC-LINKs or are Atmel’s programmers like the JTAGICE II our only choice?

Source: JTAG Debugging

JTAG Debugging was last modified: July 13th, 2017 by Jovan Stosic

AWS Secure Provisioning

The Zero Touch for AWS IoT Secure Provisioning Platform for AWS IoT offers the industry’s first end-to-end security solution for Internet of Things (IoT) devices that connect to the Amazon Web Services’ (AWS) cloud. The product was developed jointly with AWS and will help IoT devices complying quickly and easily with AWS’s mutual authentication IoT security model. Then new security model states that a device must use mutual authentication with a remote server to be authorized on the AWS cloud. Adding Microchip’s pre-configured ECC508 device and software kit to a system is now the simplest and most secure solution available to connect to the AWS IoT service.

In the Internet of Things (IoT) space, security is by far the greatest challenge that designers need to overcome. Microchip’s Zero Touch Secure Provisioning Platform for AWS IoT offers the industry’s first end-to-end security solution for IoT devices that connect to the Amazon Web Services (AWS) cloud. This platform was developed jointly with AWS to help designers to quickly and easily develop IoT devices that are in compliance with the new AWS security. This new state security mods states that a device must use mutual authentication with a remote server to be authorized on the AWS cloud. Incorporating Microchip’s preconfigured ECC508 secure crypto device and software kit into your system provides you with the simplest and most secure method to connect your design to the AWS IoT service.

All cloud-connected devices need a unique and protected identity that can be securely authenticated. There two main challenges to achieving this goal: providing a secure authentication method and managing the private keys in a large-scale production environment. The AWS-ECC508 meets these challenges by complying with AWS IoT just-in-time registration. While one-way authentication has commonly been used to secure systems, AWS IoT now offers mutual authentication between devices and the remote server. The AWS-ECC508 is an easy, flexible and cost-effective solution for adding this new, mutual authentication process to your device design. Simply solder the tamper-resistant AWS-ECC508 on your board and connect it to the host microcontroller (MCU) over I2C. The AWS-ECC508 is preconfigured to be automatically recognized by the AWS IoT service. All information is contained in a small, easy-to-deploy crypto companion device that is agnostic to surrounding hardware. This solution has been fully evaluated by AWS to comply with all of its security requirements.

Since the AWS-ECC508 generates unique device keys internally, it eliminates the need the need for IoT product developers to externally generate and securely manage databases of unique device keys amongst various custodians in their manufacturing and supply chains. This can be a costly, complex and risky procedure, involving the installation of Hardware Secure Modules (HSM) and frequent audits to assure trust. The AWS-ECC508 eliminates these costs and the complexity of assuring that secret information is kept secure during the manufacturing process.

The AWS Zero Touch Secure Provisioning Platform provides all that is needed in every stage of the life cycle of an AWS connected product development:

  1. AT88CKECC-AWS-XSTK complete starter kit for demonstration, evaluation and development.
  2. AWS IoT pre-configured ATECC508A-xxxAW-x for prototyping and pre-production pilots. The pre-configuration includes extensions for the product developer to experiment with choices of a Certificate Root, from self-signed to using third party Certificate Authorities (CA).
  3. A custom CPN AWS-ready ATECC508A fitted with internally generated unique keys chained to customer chosen certificate root and having signer certificates pre-registered to customers AWS account. The customer just needs to assemble the custom AWS-ECC508 device into the IoT product.

Source: AWS Secure Provisioning

AWS Secure Provisioning was last modified: July 13th, 2017 by Jovan Stosic

Service-oriented architecture

A service-oriented architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. The basic principles of service oriented architecture are independent of vendors, products and technologies.[1] A service is a discrete unit of functionality that can be accessed remotely and acted upon and updated independently, such as retrieving a credit card statement online.

A service has four properties according to one of many definitions of SOA:[2]

  1. It logically represents a business activity with a specified outcome.
  2. It is self-contained.
  3. It is a black box for its consumers.
  4. It may consist of other underlying services.[3]

Different services can be used in conjunction to provide the functionality of a large software application.[4] So far, the definition could be a definition of modular programming in the 1970s. Service-oriented architecture is less about how to modularize an application, and more about how to compose an application by integration of distributed, separately-maintained and deployed software components. It is enabled by technologies and standards that make it easier for components to communicate and cooperate over a network, especially an IP network.

Source: Service-oriented architecture – Wikipedia

Service-oriented architecture was last modified: September 25th, 2017 by Jovan Stosic

EEPROM

Hi there, I wanted to know if the EEPROM has default values of 0, or of they are set to null.

If i wanted to initialize a value to the EEPROM, and increment it each time the arduino powers on, where would i place my initial
EEPROM.write(0,value);

would it be in the setup();?

basically ill be doing something within the loop like this

value = EEPROM.read(0);
value++;
EEPROM.write(0,value);

Source: EEPROM

EEPROM was last modified: July 13th, 2017 by Jovan Stosic

How To Set Up Master Slave Replication in MySQL | DigitalOcean

About MySQL replication

MySQL replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database. This can helpful for many reasons including facilating a backup for the data,a way to analyze it without using the main database, or simply as a means to scale out.

This tutorial will cover a very simple example of mysql replication—one master will send information to a single slave. For the process to work you will need two IP addresses: one of the master server and and one of the slave.

This tutorial will use the following IP addresses:

12.34.56.789- Master Database

12.23.34.456- Slave Database

Setup

This article assumes that you have user with sudo privileges and have MySQL installed. If you do not have mysql, you can install it with this command:

sudo apt-get install mysql-server mysql-client

Step One—Configure the Master Database

Open up the mysql configuration file on the master server.

sudo nano /etc/mysql/my.cnf

Once inside that file, we need to make a few changes.

The first step is to find the section that looks like this, binding the server to the local host:

bind-address            = 127.0.0.1

Replace the standard IP address with the IP address of server.

bind-address            = 12.34.56.789

The next configuration change refers to the server-id, located in the [mysqld] section. You can choose any number for this spot (it may just be easier to start with 1), but the number must be unique and cannot match any other server-id in your replication group. I’m going to go ahead and call this one 1.

Make sure this line is uncommented.

server-id               = 1

Move on to the log_bin line. This is where the real details of the replication are kept. The slave is going to copy all of the changes that are registered in the log. For this step we simply need to uncomment the line that refers to log_bin:

log_bin                 = /var/log/mysql/mysql-bin.log

Finally, we need to designate the database that will be replicated on the slave server. You can include more than one database by repeating this line for all of the databases you will need.

binlog_do_db            = newdatabase

After you make all of the changes, go ahead and save and exit out of the configuration file.

Refresh MySQL.

sudo service mysql restart

The next steps will take place in the MySQL shell, itself.

Open up the MySQL shell.

mysql -u root -p

We need to grant privileges to the slave. You can use this line to name your slave and set up their password. The command should be in this format:

GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'password';

Follow up with:

FLUSH PRIVILEGES;

The next part is a bit finicky. To accomplish the task you will need to open a new window or tab in addition to the one that you are already using a few steps down the line.

In your current tab switch to “newdatabase”.

USE newdatabase;

Following that, lock the database to prevent any new changes:

FLUSH TABLES WITH READ LOCK;

Then type in:

SHOW MASTER STATUS;

You will see a table that should look something like this:

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      107 | newdatabase  |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

This is the position from which the slave database will start replicating. Record these numbers, they will come in useful later.

If you make any new changes in the same window, the database will automatically unlock. For this reason, you should open the new tab or window and continue with the next steps there.

Proceeding the with the database still locked, export your database using mysqldump in the new window (make sure you are typing this command in the bash shell, not in MySQL).

mysqldump -u root -p --opt newdatabase > newdatabase.sql

Now, returning to your your original window, unlock the databases (making them writeable again). Finish up by exiting the shell.

UNLOCK TABLES;
QUIT;

Now you are all done with the configuration of the the master database.

Step Two—Configure the Slave Database

Once you have configured the master database. You can put it aside for a while, and we will now begin to configure the slave database.

Log into your slave server, open up the MySQL shell and create the new database that you will be replicating from the master (then exit):

CREATE DATABASE newdatabase;
EXIT;

Import the database that you previously exported from the master database.

mysql -u root -p newdatabase < /path/to/newdatabase.sql

Now we need to configure the slave configuration in the same way as we did the master:

sudo nano /etc/mysql/my.cnf

We have to make sure that we have a few things set up in this configuration. The first is the server-id. This number, as mentioned before needs to be unique. Since it is set on the default (still 1), be sure to change it’s something different.

server-id               = 2

Following that, make sure that your have the following three criteria appropriately filled out:

relay-log               = /var/log/mysql/mysql-relay-bin.log
log_bin                 = /var/log/mysql/mysql-bin.log
binlog_do_db            = newdatabase

You will need to add in the relay-log line: it is not there by default. Once you have made all of the necessary changes, save and exit out of the slave configuration file.

Restart MySQL once again:

sudo service mysql restart

The next step is to enable the replication from within the MySQL shell.

Open up the the MySQL shell once again and type in the following details, replacing the values to match your information:

CHANGE MASTER TO MASTER_HOST='12.34.56.789',MASTER_USER='slave_user', MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=  107;

This command accomplishes several things at the same time:

  1. It designates the current server as the slave of our master server.
  2. It provides the server the correct login credentials
  3. Last of all, it lets the slave server know where to start replicating from; the master log file and log position come from the numbers we wrote down previously.

With that—you have configured a master and slave server.

Activate the slave server:

START SLAVE;

You be able to see the details of the slave replication by typing in this command. The \G rearranges the text to make it more readable.

SHOW SLAVE STATUS\G

If there is an issue in connecting, you can try starting slave with a command to skip over it:

SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; SLAVE START;

All done.

Source: How To Set Up Master Slave Replication in MySQL | DigitalOcean

How To Set Up Master Slave Replication in MySQL | DigitalOcean was last modified: July 13th, 2017 by Jovan Stosic

How to detect and configure an output with xrandr? – Ask Ubuntu

I have a DELL U2410 monitor connected to a Compaq 100B desktop equipped with an integrated AMD/ATI graphics card (AMD E-350). The installed O/S is Ubuntu 10.04 LTS.

The computer is connected to the monitor via the DVI connection.

The problem is that I cannot set the desktop resolution to the native 1920×1200. The maximum allowed resolution is 1600×1200.

Doing some research I found about the xrandr utility. Unfortunately, when trying to use it I cannot configure it to the required resolution. First, it does not report the output name (which supposed to be DVI-0), saying default instead. Without it I cannot use the --fb option.

The EDID utility seems to identify the monitor well. Here’s the output from get-edid:

Source: How to detect and configure an output with xrandr? – Ask Ubuntu

How to detect and configure an output with xrandr? – Ask Ubuntu was last modified: July 13th, 2017 by Jovan Stosic

server – Turn off monitor using command line – Ask Ubuntu

I am runnning Ubuntu Server on my laptop. There is really no reason for the screen to be on. I have been trying to use this command to turn the screen off:

sleep 1 && xset dpms force off

The problem is I get the following error

unable to open display "".

Any idea what is going on / what is wrong? Any other suggestions for how to do this?

Source: server – Turn off monitor using command line – Ask Ubuntu

server – Turn off monitor using command line – Ask Ubuntu was last modified: July 13th, 2017 by Jovan Stosic

This is how to disable capacitive buttons &a… | Samsung Galaxy Tab Pro 12.2, 10.1, 8.4

In another thread, I nonchalantly posted that I was able to disable the capacitive buttons on my 8.4 and enable on-screen softkey menu buttons. This, surprisingly, has garnered a lot of PMs and requests for how I was able to achieve this, so I’ve decided to write up a quick guide on how I was able to do it.

Source: This is how to disable capacitive buttons &a… | Samsung Galaxy Tab Pro 12.2, 10.1, 8.4

This is how to disable capacitive buttons &a… | Samsung Galaxy Tab Pro 12.2, 10.1, 8.4 was last modified: July 13th, 2017 by Jovan Stosic

arduino – How to switch to normal wifi mode to access-point mode ESP8266 – Stack Overflow

I am using ESP8266-12 wifi module for accessing my home wifi network to control lights. For uploading new firmware(OTA: Over the Air) update, I want to use ESP8266’s hotspot AccessPoint because after changing the password of my wifi network, I will not able to do that.

Source: arduino – How to switch to normal wifi mode to access-point mode ESP8266 – Stack Overflow

arduino – How to switch to normal wifi mode to access-point mode ESP8266 – Stack Overflow was last modified: July 13th, 2017 by Jovan Stosic