Atmel AVR Studio 6 using Arduino Uno (ATmega328p) and FreeRTOS - avr

Hey there all,
I want to begin working with freeRTOS using my Arduino Uno which uses the ATmega328p on Atmel AVR Studio 6.
I am working on windows 7.
I went into this tutorial:
http://www.jayconsystems.com/tutorial/atmerpt1/
which describes how to install and prepare the Atmel AVR Studio 6 to work with ATmega328p.
I failed to understand what should I do in step 5A , which tells to do the following:
Go to Tools -> External Tools...
Create the new tool with these settings:
Title: Serial Program
Command: C:\arduino-1.0.1\hardware\tools\avr\bin\avrdude.exe
(Change that to match your arduino installation folder and locate avrdude.exe)
-CC:\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf -patmega328p -carduino -P\.\COM3 -b57600 -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i // *
NOTE: I do have the avrdude.exe installed on my computer at this location:
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe
So my questions are:
1) On the line * , what does -CC mean, does it needs to be within the arguments or the initial directory (within the External Tools dialog box)?
2) As it is mentioned , the path to the avrdude.conf (indeed in my case) goes through the X86 folder , so how does the line I need to enter there should be (cause it is mentioned there something about double quotes)?
3) After I will solve all of these problems how/where/does AVR Studio 6 has a "simple generic template" project to get started with freeRTOS ?
I ran into this tutorial (which uses different board) , can I "follow" it although I am using another board (my ATmega328p)?
Thanks allot in advance,
Guy.

1) -C is an option to the avrdude executable to specify the configuration file. The second C is part of the filename: C:\.
2) If the path to the configuration file has a space in the name, then it will get messed up when passed as an option to avrdude.exe. (The path will end with the space, and the rest will be junk that causes the command to fail.)
To get around spaces in a string, surround the string with quotes.
-C"C:\a directory with spaces\a filename with spaces in it.conf"
3) is beyond the scope of Stack Overflow (recommending a tool or resource.)

Related

How can I specify a minimum compute capability to the mexcuda compiler to compile a mexfunction?

I have a CUDA project in a .cu file that I would like to compile to a .mex file using mexcuda. Because my code makes use of the 64-bit floating point atomic operation atomicAdd(double *, double), which is only supposed for GPU devices of compute capability 6.0 or higher, I need to specify this as a flag when I am compiling.
In my standard IDE, this works fine, but when compiling with mexcuda, this is not working as I would like. In this post on MathWorks, it was suggested to use the following command (edited from the comment by Joss Knight):
mexcuda('-v', 'mexGPUExample.cu', 'NVCCFLAGS=-gencode=arch=compute_60,code=sm_60')
but when I use this command on my file, the verbose option spits out the following line last:
Building with 'NVIDIA CUDA Compiler'.
nvcc -c --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -
gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -
gencode=arch=compute_60,code=sm_60 -
gencode=arch=compute_70,code=\"sm_70,compute_70\"
(and so on), which signals to me that the specified flag was not passed to the nvcc properly. And indeed, compilation fails with the following error:
C:/path/mexGPUExample.cu(35): error: no instance of overloaded function "atomicAdd" matches
the argument list. Argument types are: (double *, double)
The only other post I could find on this topic was this post on SO, but it is almost three years old and seemed to me more like a workaround - one which I do not understand even after some research, otherwise I would have tried it - rather than a true solution to the problem.
Is there a setting I missed, or can this simply not be done without a workaround?
I was able to work my way around this problem after some messing around with the standard xml-files in the MatLab folder. The following steps allowed me to compile using -mexcuda:
-1) Go to the folder C:\Program Files\MATLAB\-version-\toolbox\distcomp\gpu\extern\src\mex\win64, which contains xml-files for different versions of msvcpp;
-2) Make a backup of the file that corresponds to the version you are using. In my case, I made a copy of the file nvcc_msvcpp2017 and named it nvcc_msvcpp2017_old, to always have the original.
-3) Open nvcc_msvcppYEAR with notepad, and scroll to the following block of lines:
COMPILER="nvcc"
COMPFLAGS="--compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD $ARCHFLAGS"
ARCHFLAGS="-gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\" $NVCC_FLAGS"
COMPDEFINES="--compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,$MATLABMEX"
MATLABMEX="/DMATLAB_MEX_FILE"
OPTIMFLAGS="--compiler-options=/O2,/Oy-,/DNDEBUG"
INCLUDE="-I"$MATLABROOT\extern\include" -I"$MATLABROOT\simulink\include""
DEBUGFLAGS="--compiler-options=/Z7"
-4) Remove the architectures that will not allow your code to compile, i.e. all the architecture flags below 60 in my case:
ARCHFLAGS="-gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\" $NVCC_FLAGS"
-5) I was able to compile using mexcuda after this. You do not need to specify any architecture flags in the mexcuda call.
-6) (optional) I suppose you want to revert this change after you are done with the project that required you to make this change, if you want to ensure maximum portability of the code you will compile after this.
Note: you will need administrator permission to make these changes.

arduino.h: 48:17: fatal error: sam.h: No such file or directory

I am trying to compile a simple new project ('hello') for the Arduino M0 Pro. I have created a new project in visual studio 2015 (using vMicro).
But I get the error:
hello.ino: In file included from
arduino.h: 48:17: fatal error: sam.h: No such file or directory
#include "sam.h"
compilation terminated
Through the Arduino IDE - board manager I have installed the cores for Arduino SAM Boards and SAMD Boards. Currently it is on Arduino IDE: v1.6.18, SAM: v1.6.11 and SAMD: v1.6.15 (the newest version at time of writing).
The strange thing is that I do see that the project has included this file, as it is shown in the file tree of External Dependencies, see screenshot.
file tree showing sam.h
I have also checked the include paths in the 'hello.vcxproj' file. I have cut out the list below:
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\..\..\..\Program Files (x86)\Arduino\libraries
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.10\libraries
$(ProjectDir)..\libraries
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.10\cores\arduino
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.10\cores\arduino\avr
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.10\cores\arduino\USB
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.10\variants\arduino_mzero
$(ProjectDir)..\hello
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS-Atmel\1.0.0\CMSIS\Device\ATMEL\
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\arm-none-eabi
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\bits
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\sys
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.10\system
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\avr
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\hardware\samd\usb
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\lib\gcc\arm-none-eabi\4.8.3\include
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\Device\ATMEL\samd21\include
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\include
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\Device\ATMEL\samd21\include\component
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\Device\ATMEL\samd21\include\instance
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\Device\ATMEL\samd21\include\pio
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.5.0\Device\ATMEL\samd21\include\component
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS-Atmel\1.0.0\CMSIS\Device\ATMEL\samd21\include
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\CMSIS\include
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\CMSIS-Atmel\1.0.0\CMSIS\Device\ATMEL\samd21\include\component
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\CMSIS-Atmel\1.0.0\CMSIS\Device\ATMEL\samd21\include\instance
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\CMSIS-Atmel\1.0.0\CMSIS\Device\ATMEL\samd21\include\pio
$(ProjectDir)..\..\..\AppData\Local\arduino15\packages\arduino\tools\CMSIS\CMSIS-Atmel\1.0.0\CMSIS\Device\ATMEL\samd21\include\component
%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Even when I just open a completely new project in the Arduino IDE and try to compile it for Arduino M0, I get the exact same error!
I am stuck at this point. I've tried, as suggested at some other websites, de-installing SAM, de-installing SAMD, changing versions of either, but no luck.
In my case the specific solution was to delete the C:\Users[username]\AppData\Local\Arduino15 folder and reinstall the board packages I needed through the Arduino IDE Boards Manager.
Note this will not impact any libraries or other changes you have made in the IDE.

Trouble Creating and Executing an Intel SGX Enclave

I'm very new to SGX and wanted to start with something simple. Fortunately, I found this very basic tutorial. Unfortunately, as simple as it is, I can't get it to work. The code executes, but there are errors in the output.
[sgx_create_enclavew ..\urts\win\urts.cpp:195] Couldn't open file with CreateFile()
error 0x200f, failed to create enclave.
Buffertests:
Buffer before change: Hello World!
Buffer after change: Hello World!
Stringtests:
Returned Secret:
Saved Secret: My secret string
Load Secret:
Integertests:
secretIntValue first load: 0
saved a 1337 to the enclave.
secretIntValue second load after 1337 was saved: 0
error, failed to destroy enclave.
image of output
the tutorial says:
If you get the error SGX couldn't find the enclave file. The solution is to move the enclave_test_save.signed.dll into the same folder where the app_test_save.exe is located.
which I've tried, but it didn't solve the problem.
when I try to create the enclave using:
sgx_create_enclave(ENCLAVE_FILE, SGX_DEBUG_FLAG, &token, &updated, &eid, NULL);
it returns: SGX_ERROR_ENCLAVE_FILE_ACCESS
could the problem be a result of using a different version of Visual Studio? (The tutorial uses VS 2012, while I'm using VS 2015)
Did you run the application through command prompt or from IDE?
If you are using IDE, You need to change the debugging properties to $(OutDir) from $(ProjecttDir) under Project Properties->Configuration Properties->Debugging->Working Directory.(Both Enclave and Application) Select the Intel(R) SGX Debugger.
Disclaimer: I had the same error although under a different setting (Ubuntu, eclipse) so I am not sure to what extent this will help.
Before initialize_enclave() is called (which in turn calls sgx_create_enclave()), a chdir(absolutePath) command needs to be executed, where absolutePath needs to be the absolute path to where your executable is.
My error was due to a wrong path I used.
Thanks, I solved it. turns out I had to place enclave_test_save.signed.dll in the root folder with the .edl file and not with the .exe file.

Programming an Attiny85

I was wondering how to upload a program I wrote using AVR Studio 4 to an ATtiny85. I was basically using this tutorial http://blog.smileymicros.com/smileys-workshop-10-moving-beyond-arduino/ except doing everything with an attiny85 instead of an atmega328. I got the pins_arduino.h from HighLow tech's ATtiny library.
I have compiled successfully in AVR Studio 4 and am now wondering how to upload to an Attiny85.
Thanks
Download the Windows-Avrdude version: http://www.mikrocontroller.net/attachment/69851/avrdude-5.10.zip
Extract the avrdude.exe files (avrdude.conf and avrdude.exe anywhere in your directories.
Now in AVR Studio, create a new tool under external tools (don't know exactly if it is called external tools) and call it 'ATtiny85'.
Paste this line in the command field: C:\Path\To\Your\avrdude.exe.
Paste this in 'Arguments': -F -v -pt85 -cstk500v1 -P com7 -b19200 -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i -C
Make sure you replace 'com7' with your com port you've attached your avrisp mkii to.
Now finish the dialog and your ready to upload. (Just click your tool in the Menu)

Windows 8 driver install and catalog/signature validation

I can't get windows 8 (release preview) to accept either the inf2cat or makecat approach described as solutions to the question at
What changed in the driver signature requirements for Windows 8?
unless I disable validation.
I am not signing these with any certificates at this point, just trying to get past the errors preventing the drivers from installing at all.
Windows 8 gives me a very nondescript error:
"A problem was encountered while attempting to add the driver to the store."
Looking in the event logs, there is nothing of use; only an informational entry from "Windows Error Reporting" indicating a PnPdriverimporterror.
When i use my original files with the cab files that don't match the inf, I get the error everyone else is listing:
The hash for the file is not present in the specified catalog file.
I have one .inf file that i need to generate a .cat for.
Perhaps I am doing something wrong. Ideas??
INF2CAT Approach
c:\win_xp_vista32_64>inf2cat /driver:"." /os:XP_X86,XP_x64,Vista_X86,Vista_x64,7_X86,7_X64,8_X86,8_X64
.......................
Signability test complete.
Errors:
None
Warnings:
22.9.10: usbser.sys in [drivercopyfiles.nt] is missing from [SourceDisksFiles] s
ection in \mchpcdc.inf; ok if file source is provided via LayoutFile in [Version
].
22.9.10: %driverfilename%.sys in [drivercopyfiles.ntamd64] is missing from [Sour
ceDisksFiles] section in \mchpcdc.inf; ok if file source is provided via LayoutF
ile in [Version].
Catalog generation complete.
c:\win_xp_vista32_64\mchpcdc.cat
MAKECAT approach
--- start of catalog.cdf file---
[CatalogHeader]
Name=mchpcdc.cat
ResultDir=.\
[CatalogFiles]
<hash>mchpcdc=.\mchpcdc.inf
---end of .cdf file ---
c:\win_xp_vista32_64>makecat catalog.cdf
These same files, w/ the cat from either approach install just fine in Windows 7.
I think this problem is to do with "windows driver signing enforcement". You can resolve this by disabling this option. Go through with below link:
http://tivadj-tech.blogspot.in/2012/09/certificate-check-error-when-installing.html
I just tested this on Windows 10 and 8 PRO now, to get this right, follow these steps:
1) From your Start menu, locate your DDK's "x64 Checked Build Environment" i.e. the custom DOS build screen. Right-click, run-as administrator...
2) Compile your source with the Build tools etc.
3) Go into your compiled code, and then create your test-certificate (you don't need to purchase one just yet, use your self-signed one created with the line below):
makecert -r -pe -ss PrivateCertStore -n CN=newhex.com(Test) NewhexTest.cer
The above means your certificate is called "newhex.com(Test)" and the generated file is "NewhexTest.cer"
4) Create / Edit your .CDF file which contains items about what your CAT file's contents.
5) Create your CAT file by executing:
makecat -v MyCDF.CDF
This should generate an un-signed CAT file that includes all files specified by your CDF.
6) Sign your CAT file as follows:
Signtool sign /v /s PrivateCertStore /n newhex.com(test) /t http://timestamp.verisign.com/scripts/timestamp.dll MyDriverWhatever.cat
This should result in a CAT file that is signed, but don't just install it, because your Windows can't trust Newhex's cert since it's not in the keystore, to fix this do:
7) Add your certificate to your private Key Store, remember this step MUST be done by an administrators access, otherwise you will get an error about (Keystore not found etc):
certmgr.exe -add NewhexTest.cer -s -r localMachine root
This should add into your keystore, Once done, you can then:
8) Go into your device manager, and add your new driver, you would get a warning but will be accepted and installed without the need to reboot with a forced (Don't check cert type account).
I tried this already and it works on Windows 10 and Windows 8 pro versions.
Kind Regards
Heider Sati
You are supposed to use inf2cat, not makecat, because you have an INF file.
You should work on addressing those warnings from inf2cat by fixing your INF file. Here is my INF file that uses usbser.sys and doesn't cause any warnings: https://gist.github.com/3647208
I was able to fix my INF file thanks to the advice from chinzei in the first post of this thread: http://www.microchip.com/forums/m488342-print.aspx
If you continue to have trouble, please edit your question to include the source of your INF file, or at least a link to the source.
I encounter the same problem and was able to install my driver with a TEST certificate using the instructions provided here:
http://msdn.microsoft.com/en-us/windows/hardware/gg487328.aspx

Resources