How do I upload an object file generated by LLVM to Arduino? - arduino

I'm making a simple language for Arduino, and want to compile this with LLVM.
I tried to generate LLVM IR (to understand what LLVM IR is generated from the Arduino code). I used this command:
> clang -S -emit-llvm -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -x c++ -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I "C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" Blink.cc -o ./Blink.cc.ll -I "C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include" --target=avr
It generates Blink.ll. And likewise, I also can compile the source code to .o (object) file.
But this file is not able to upload to the Arduino board.
To upload to the Arduino, I have to use avrdude. But it requires.hex file.
And LLVM outputs .o file, only. I have no clue what have I do to upload this file to the Arduino board.

Related

How long does compiling minix take?

I downloaded the Minix source code through git:
git clone git://git.minix3.org/minix minixsrc
Then I followed the instructions on Crosscompiling MINIX with build.sh
and ran the command
sh build.sh -mi386 -O ../build tools
Now I have been waiting for about an hour for it to compile and it is continuously showing messages on my terminal like this:
# compile libclangSema/SemaExprMember.lo
c++ -O -O2 -fno-rtti -fno-exceptions -I. -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/clang/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/lld/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/llvm/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/mclinker/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/lldb/include -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCLANG_ENABLE_STATIC_ANALYZER -I/home/keeyan/git/minixsrc/../build/tools/llvm-include -I/home/keeyan/git/minixsrc/../build/tools/llvm/config/include -I/home/keeyan/git/minixsrc/../build/tools/llvm/config/tools/clang/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../config/mclinker -std=c++11 -std=c++11 -c -o SemaExprMember.lo.o /home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/clang/lib/Sema/SemaExprMember.cpp
mv SemaExprMember.lo.o SemaExprMember.lo
My question is, how long should this process take? Is something wrong?
System Specs:
OS: Linux Mint 18 64bit
CPU: Intel Core i7-5500U CPU # 2.4GHz x 2
I believe it should take this long to do the job. It took me about 2 hours for the sh build.sh -mi386 -O ../build tools c to finish and it completed successfully and I got the build tools. After that process I ran the sh build.sh -mi386 -O ../build -U distribution command and that also took a number of hours. I ended up with the built distribution of MINIX which is what was expected of the process. It seems after that there is no way to turn this into an ISO though.
I don't know if the build script unsets MAKEFLAGS but you can do:
MAKEFLAGS=-j\ $(nproc) sh build.sh -mi386 -O ../build tools
nproc returns the number of cores in your CPU so it uses all cores and is faster.

Qt5.7 qmake; what does "The system cannot find the path specified." mean and how to fix it?

Qt5.7/mingw/windows8.1 qmake. New installation. when i run qmake on a project file, i get the above error message, although the makefiles are emitted, they build and the project works (it would seem).
running qmake from the command line; here are the paths i added to PATH:
I:\Qtmg\Qt5.7.0\5.7\mingw53_32\bin;i:\Qtmg\Qt5.7.0\Tools\mingw530_32\bin;I:\Qtmg\Qt5.7.0\Tools\QtCreator\bin
Is this something to do with config files or caches? If so, where would these be. Also is there any other external state that qmake requires.
thanks.
EDIT#1
here is the project file:
TEMPLATE = app
QT += qml quick quickcontrols2
CONFIG += console
SOURCES += main.cpp
RESOURCES += qml.qrc
Edit #2: output from QtCreator 4.0.2
general messages tab:
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Compile output tab, run qmake:
14:49:57: Running steps for project Q1...
14:49:57: Starting: "I:\Qtmg\Qt5.7.0\5.7\mingw53_32\bin\qmake.exe" I:\larry\qt\q9edit\Q1.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
14:49:57: The process "I:\Qtmg\Qt5.7.0\5.7\mingw53_32\bin\qmake.exe" exited normally.
14:49:57: Elapsed time: 00:00.
Compile output, rebuild:
14:51:32: Running steps for project Q1...
14:51:32: Starting: "I:\Qtmg\Qt5.7.0\Tools\mingw530_32\bin\mingw32-make.exe" clean
I:/Qtmg/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug clean
mingw32-make[1]: Entering directory 'I:/larry/qt/q9edit'
rm -f debug/qrc_qml.cpp
rm -f debug/main.o debug/qrc_qml.o
mingw32-make[1]: Leaving directory 'I:/larry/qt/q9edit'
I:/Qtmg/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make -f Makefile.Release clean
mingw32-make[1]: Entering directory 'I:/larry/qt/q9edit'
rm -f release/qrc_qml.cpp
rm -f release/main.o release/qrc_qml.o
mingw32-make[1]: Leaving directory 'I:/larry/qt/q9edit'
14:51:33: The process "I:\Qtmg\Qt5.7.0\Tools\mingw530_32\bin\mingw32-make.exe" exited normally.
14:51:33: Configuration unchanged, skipping qmake step.
14:51:33: Starting: "I:\Qtmg\Qt5.7.0\Tools\mingw530_32\bin\mingw32-make.exe"
I:/Qtmg/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'I:/larry/qt/q9edit'
g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_QUICKCONTROLS2_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtQuickControls2 -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtQuick -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtGui -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtANGLE -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtQml -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtNetwork -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtCore -Idebug -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/mkspecs/win32-g++ -o debug/main.o main.cpp
'I:\Qtmg\Qt5.7.0\5.7\mingw53_32\bin\rcc.exe' -name qml qml.qrc -o debug/qrc_qml.cpp
g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_QUICKCONTROLS2_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtQuickControls2 -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtQuick -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtGui -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtANGLE -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtQml -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtNetwork -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/include/QtCore -Idebug -I../../../Qtmg/Qt5.7.0/5.7/mingw53_32/mkspecs/win32-g++ -o debug/qrc_qml.o debug/qrc_qml.cpp
g++ -Wl,-subsystem,console -mthreads -o debug/Q1.exe debug/main.o debug/qrc_qml.o -LI:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib I:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib/libQt5QuickControls2d.a I:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib/libQt5Quickd.a I:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib/libQt5Guid.a I:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib/libQt5Qmld.a I:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib/libQt5Networkd.a I:/Qtmg/Qt5.7.0/5.7/mingw53_32/lib/libQt5Cored.a
mingw32-make[1]: Leaving directory 'I:/larry/qt/q9edit'
14:51:34: The process "I:\Qtmg\Qt5.7.0\Tools\mingw530_32\bin\mingw32-make.exe" exited normally.
14:51:34: Elapsed time: 00:02.
Try editing your changes to the PATH variable, to remove one directory at a time. Looks to me like you are trying to add an unnecessary path (unnecessary since the build succeeds) that is not present on your system.

How to make gnatmake tool compile RTS with project?

Is there a way to make gnatmake tool recompile the Ada's runtime library ("RTS") with the project I'm building file by file? I want to integrate my custom preprocessor that adds some features to ada source code and then compiles it with gcc. I'm passing --GCC=<preprocessor> flag to the gnatmake utility, it figures out dependencies automatically and runs my preprocessor for all of my source files. However I want custom preprocessing to be done on code in the RTS as well, is there any way to do it?
The -a flag tells gnatmake to recompile any RTS files that need to be recompiled.
After a little experiment here it seems that if you copy system.ads (and maybe gnat.ads, interfac.ads .. yes) from the compiler’s adainclude/ directory to your source tree (I think you’ll need to touch it whenever you update your preprocessor), gnatmake may be able do what you want.
$ cp /opt/gcc-4.9.0/lib/gcc/x86_64-apple-darwin13/4.9.0/adainclude/system.ads .
$ gnatmake -a int
gcc -c int.adb
gcc -gnatpg -c -I./ -I- /opt/gcc-4.9.0/lib/gcc/x86_64-apple-darwin13/4.9.0/adainclude/s-stalib.adb
gcc -gnatpg -c -I./ -I- /opt/gcc-4.9.0/lib/gcc/x86_64-apple-darwin13/4.9.0/adainclude/a-except.adb
gcc -gnatpg -c -I./ -I- /opt/gcc-4.9.0/lib/gcc/x86_64-apple-darwin13/4.9.0/adainclude/s-valint.adb
gcc -gnatpg -c system.ads
...
gcc -gnatpg -c -I./ -I- /opt/gcc-4.9.0/lib/gcc/x86_64-apple-darwin13/4.9.0/adainclude/s-conca4.adb
gnatbind -x int.ali
gnatlink int.ali
and, after I realised I hadn’t used -gnata,
$ touch int.adb
$ gnatmake -a -gnata int
gcc -c -gnata int.adb
gcc -gnatpg -c -I./ -gnata -I- /opt/gcc-4.9.0/lib/gcc/x86_64-apple-darwin13/4.9.0/adainclude/s-assert.adb
gnatbind -x int.ali
gnatlink int.ali
(I do not want to use -f here, because it’ll rebuild everything.)

GNU makefile detect header changes

I have a directory with dozens of source and header files. Is there a better or cleaner way than the following %.o target for make to detect changes to header files? When the object is compiled, g++ is invoked with both the .cc and .h files which doesn't seem right, it should find the .h file automatically.
%.o: %.cc %.h
g++ -c $^
OBJECTS=headless-driver.o config.o simplefm2.o emulator.o basis-util.o objective.o weighted-objectives.o motifs.o util.o
learnfun : $(OBJECTS) learnfun.o
g++ $^ -o $#
%.o: %.cc %.h
g++ -c $^
You are specifying $^ which expands to all dependencies. If you just want the first dependency on the Gcc command line, use $< instead.

Can't program ATtiny2313a with Arduino. Is my chip bricked?

I've been trying to burn a program into ATtiny2313A-PU with my Arduino Uno R3 used as a programmer.
First I tried to program it from Arduino IDE 1.0.1 (Windows 7) and it seemed to uploade the sketch, but the blink program didn't work.
Then I found Michael Holachek's tutorial and followed his instructions:
uploaded ArduinoISP sketch to my Arduino Uno
wired the circuit on a breadboard
installed WinAVR on my Windows 7.
downloaded Michael's template files (Makefile and main.c) and edited Makefile to match my settings (external 8 MHz crystal). I used this online fuse calculator to get correct fuse parameters.
then, in cmd.exe, changed directory to the directory where I saved Makefile and main.c and ran 'make flash'
Makefile
DEVICE = attiny2313a
CLOCK = 8000000
PROGRAMMER = -c arduino -P COM5 -b 19200
OBJECTS = main.o
FUSES = -U lfuse:w:0x5e:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m
######################################################################
######################################################################
# Tune the lines below only if you know what you are doing:
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o $#
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $#
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
.c.s:
$(COMPILE) -S $< -o $#
flash: all
$(AVRDUDE) -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID main.hex
clean:
rm -f main.hex main.elf $(OBJECTS)
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d main.elf
cpp:
$(COMPILE) -E main.c
main.c
Below is the output I got:
C:\Users>cd /D D:\electronics
D:\electronics>cd nikon/mi
D:\electronics\nikon\mi>make flash
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny2313a -c main.c -o main.o
main.c:6: error: stray '\342' in program
main.c:6: error: stray '\200' in program
main.c:6: error: stray '\250' in program
main.c: In function 'main':
main.c:9: error: stray '\342' in program
main.c:9: error: stray '\200' in program
main.c:9: error: stray '\250' in program
make: *** [main.o] Error 1
I suspect that I might brick the fuses on Attiny 2313a. If that is the case, I think I will have to build this AVR rescue shield.
Maybe the Makefile was configured incorrectly?
How can I identify the problem? How can I check whether the chip is still alive?
You are getting compile errors there. I would check the contents of main.c for what the compiler is telling you to check. It looks like in the copy and paste of the code, something was lost. Also
PORTD ^= (1 << PD6); // toggle PD6
can be replaced with
PIND = (1 << PD6); // or _BV(PD6), since you should be using avr-libc anyway.
as per Atmel's datasheets.
well, I googled a little bit more and found that the most common solution, when chips are identical, but have different suffixes (like attiny2313 and attiny2313a) is to use -F key for overriding the signature check.
So, I added the key in Makefile DEVICE = attiny2313 -F and my attiny2313a was programmed successfully!
TRON, thanks for pointing me in the direction of main.c! Unfortunately I can't upvote your answer because my reputation is 11.
I still wonder how those square characters could get there?

Resources