I'm trying to make a modified version of the FlySky FS-i6 firmware. After a bit of searching, I found someone who decompiled the source code here.
I'm trying to compile using arm-none-eabi, which I already have installed from the Arduino IDE.
Here's a batch file I made to compile the files, which are just a bunch of .c and .h files under several directories, but I have no clue what arguments I'm supposed to be giving the arm-none-eabi-gcc command...
#echo off
set EABI_PATH="%LocalAppData%\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\bin"
#RD /S /Q temp
mkdir temp
for /D %%d in (*) do (
echo ---- Compiling Directory: %%d
rem C Files:
for %%f in (%%d/*.c) do (
"%EABI_PATH%/arm-none-eabi-gcc" -c -mcpu=cortex-m0plus -g "%%d/%%f" -o "temp/%%~nf.o" -mthumb -g3
)
rem Header Files:
rem for %%f in (%%d/*.h) do (
rem "%EABI_PATH%/arm-none-eabi-gcc" -c -mcpu=cortex-m0plus -g "%%d/%%f" -o "temp/%%~nf.o" -mthumb -g3
rem )
)
I've searched everywhere, but I can't find any tutorials or anything about how to use the tool. All I want to do is compile the files to a firmware.hex file, you'd think it would just be a simple one-liner...
Related
I am trying to compile a bunch of c files but for some reason compiler won't detect the header files which are located in the same exact folder. Here is the error I am getting
C:\Users\bz733p\Desktop\EBI20\source\application.c:45:25: fatal error: application.h: No such file or directory
compilation terminated.
Batch file:
set COMP_DIR=C:\Users\xxxx\Desktop\EBI20\source
set BIN_DIR=C:\Apps\opentoolsuite\runtime\msys\gcc\4.5.1-tdm-x32\bin
set CFLAGS=-g -Wall -m32
:: Clean
echo Cleaning directory...
::call clean.bat
:: Start the build
::COMPiling
echo COMPiling files....
for %%i in ("%COMP_DIR%\*.C")do %BIN_DIR%\i686-w64-mingw32-gcc-4.5.1.exe -c %CFLAGS% "%%~i" -o "%%~dpni.o" > results.txt
pause
I verified that both files are located in the same directory Files in directory. This happens for all header files in the directory. I looked into but could not find any solution
I tried building vim and gvim with MinGW according to this instruction. For convenience I'm posting them here
#echo off
REM Run this batch file from any directory to build gvim.exe and vim.exe.
REM But first edit the paths and Python version number.
REM --- Specify Vim /src folder ---
set VIMSRC=C:\Downloads\vim\src
REM --- Add MinGW /bin directory to PATH ---
PATH = C:\MinGW\bin;%PATH%
REM --- Also make sure that PYTHON, PYTHON_VER below are correct. ---
REM get location of this batch file
set WORKDIR=%~dp0
set LOGFILE=%WORKDIR%log.txt
echo Work directory: %WORKDIR%
echo Vim source directory: %VIMSRC%
REM change to Vim /src folder
cd /d %VIMSRC%
REM --- Build GUI version (gvim.exe) ---
echo Building gvim.exe ...
REM The following command will compile with both Python 2.7 and Python 3.3
mingw32-make.exe -f Make_ming.mak PYTHON="C:/Python27" PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON3="C:/Python35" PYTHON3_VER=35 DYNAMIC_PYTHON3=yes FEATURES=HUGE GUI=yes gvim.exe > "%LOGFILE%"
REM --- Build console version (vim.exe) ---
echo Building vim.exe ...
REM The following command will compile with both Python 2.7 and Python 3.3
mingw32-make.exe -f Make_ming.mak PYTHON="C:/Python27" PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON3="C:/Python35" PYTHON3_VER=35 DYNAMIC_PYTHON3=yes FEATURES=HUGE GUI=no vim.exe >> "%LOGFILE%"
echo Moving files ...
move gvim.exe "%WORKDIR%"
move vim.exe "%WORKDIR%"
echo Cleaning Vim source directory ...
REM NOTE: "mingw32-make.exe -f Make_ming.mak clean" does not finish the job
IF NOT %CD%==%VIMSRC% GOTO THEEND
IF NOT EXIST vim.h GOTO THEEND
IF EXIST pathdef.c DEL pathdef.c
IF EXIST obj\NUL RMDIR /S /Q obj
IF EXIST obji386\NUL RMDIR /S /Q obji386
IF EXIST gobj\NUL RMDIR /S /Q gobj
IF EXIST gobji386\NUL RMDIR /S /Q gobji386
IF EXIST gvim.exe DEL gvim.exe
IF EXIST vim.exe DEL vim.exe
:THEEND
pause
I'm getting the following error during a build process:
Building gvim.exe ...
diff.c: In function 'ex_diffpatch':
diff.c:891:12: error: storage size of 'st' isn't known
stat_T st;
^
diff.c:891:12: warning: unused variable 'st' [-Wunused-variable]
mingw32-make.exe: *** [gobjx86-64/diff.o] Error 1
Building vim.exe ...
diff.c: In function 'ex_diffpatch':
diff.c:891:12: error: storage size of 'st' isn't known
stat_T st;
^
diff.c:891:12: warning: unused variable 'st' [-Wunused-variable]
mingw32-make.exe: *** [objx86-64/diff.o] Error 1
Does anyone know what could be the problem?
I figured out what was the problem. I was using a 32 bit MinGW instead of the one for 64 bit system. In other words I needed to download MinGW-w64 from https://mingw-w64.org/doku.php instead of downloading MinGW from http://www.mingw.org/.
I don't know what this problem is; but if I were you I would follow the instructions by Antoine Mechelynck, which are very detailed. I've used his guide for building at Unix/Linux guide and they are very good.
You could consider downloading the binary from vim.org if you still have problems to build it. There is also a portable version (from PortableApps), which doesn't requires privileges to install and even run from USB stick.
I'm trying to convert a folder of SWFs to images using swftools.
The actual conversion is working fine, however I'm having issues trying to get it to run for all files in a folder. (and would be nice to get it to work for all subfolders as well).
Let's say the folder contains the following files: 1.swf, 2.swf, ...
Now the script I wrote for this is:
for %i in (*.swf) do (
set fileName=%i
swfrender "%fileName%" -o "%fileName:~0,-4%.png"
)
Which I'm running from inside the folder containing the SWF files. However rather than the expected result I'm seeing the following in my command prompt:
set fileName=1.swf swfrender "3.swf" -o "3.png" )
set fileName=2.swf swfrender "3.swf" -o "3.png" )
Now from what I could find the script should be fine, so I have no clue what's going wrong.
Oddly enough the following does seem to work:
for /R %x in (*.swf) do swfrender %x -o %x.png
But I'd rather not have to rename a couple of hundred files to remove the redundant .swf portion from the filename.
you need delayed expansion (and in batch files you need doubled % for the loops tokens):
setlocal enableDelayedExpansion
for %%i in (*.swf) do (
set fileName=%%i
swfrender "!fileName!" -o "!fileName:~0,-4!.png"
)
or you can extract the file name without extension:
for %%i in (*.swf) do (
swfrender "%%~i" -o "%%~ni.png"
)
I created this makefile almost two years ago in Windows 7:
SRC_DIRS = ./src/oasis ./src/oasis/commands/basic ./src/oasis/commands/immortal ./src/oasis/commands/socials ./src/oasis/util
COMPILE_FLAGS = -d ./classes
DOC_FLAGS = -quiet -private -d ./doc -sourcepath ./src -subpackages oasis -linkoffline http://java.sun.com/j2se/1.4.2/docs/api .
all:
#echo Compiling source code...
#javac $(COMPILE_FLAGS) $(foreach dir,$(SRC_DIRS),$(dir)/*.java)
#echo Creating javadocs...
#javadoc $(DOC_FLAGS)
#echo Done.
class:
#echo Compiling source code...
#javac $(COMPILE_FLAGS) $(foreach dir,$(SRC_DIRS),$(dir)/*.java)
#echo Done.
docs:
#echo Creating javadocs...
#javadoc $(DOC_FLAGS)
#echo Done.
clean:
#echo Removing classes...
#rmdir classes /q /s
#mkdir classes
#echo Removing javadocs...
#rmdir doc /q /s
#mkdir doc
#echo Done.
I used to navigate to its folder with cmd.exe, and then type "make all" or "make class" or whatever... and it would work! Now I'm returning to this project almost 2 years later, on a new computer (also Windows 7) and the "make" command isn't recognized. I don't remember installing any special software to use makefiles in Windows. Why won't it work anymore?
I am trying to build Lua from source and when I look at http://www.lua.org/source/5.2/ I basically see what I got in the source file, and I don't see print.c.
In my build.bat (I am doing this on Windows 7) I have this:
cl /MD /O2 /W3 /c /DLUA_BUILD_AS_DLL *.c
del *.o
ren lua.obj lua.o
ren luac.obj luac.o
ren print.obj print.o
link /DLL /IMPLIB:lua5.2.lib /OUT:lua5.2.dll *.obj
link /OUT:lua.exe lua.o lua5.2.lib
lib /out:lua5.2-static.lib *.obj
link /OUT:luac.exe luac.o print.o lua5.2-static.lib
If I just remove all references to print.o will there be a problem with what I compile when I try to embed this in my game?
In lua 5.1, under compiler you will see print.c, so I wonder if I should not do 5.2.
http://www.lua.org/source/5.1/
UPDATE
So, what I did was change my build.bat and removed the print.obj, but I think the rename was useful in order to not include lua.obj and luac.obj in the .lib file, so I rename them and then rename them back.
cl /MD /O2 /W3 /c /DLUA_BUILD_AS_DLL *.c
del *.o
ren lua.obj lua.o
ren luac.obj luac.o
link /DLL /IMPLIB:lua5.2.lib /OUT:lua5.2.dll *.obj
link /OUT:lua.exe lua.o lua5.2.lib
lib /out:lua5.2-static.lib *.obj
ren lua.o lua.obj
ren luac.o luac.obj
link /OUT:luac.exe luac.obj lua5.2-static.lib
You don't need print.c in Lua 5.2, the only public function it defined is moved to luac.c. See PrintFunction() now found in luac.c.
Also, it is not a good idea to rename .obj to .o in Windows. Use whatever object file name is preferred by your tool chain.
Edit: I now see the purpose of the renaming, and while it does work, I still think it is a bad practice.
The trick is that the CL command in your batch file is compiling every .c file in your current directory with identical options. As it happens, that isn't a problem, but it isn't a conventional way of doing this sort of thing.
Then, because a few of those files aren't actually part of the DLL you want to build, you rename those so that you can fit the rest on the LINK command line as a single wild card *.obj.
If you are going to use a batch file to build Lua yourself, then it would be better to list the .obj files that make up the DLL and each application on each relevant link line rather than depend on a wild card. As it is, if you had a build error in the CL command, you still build a DLL with all the rest of the objects, or worse, possibly with an out of date object for the file that didn't compile.
Then you might or might not successfully link lua.exe and luac.exe even though there were errors.
The right answer here is to use a build tool of some form to compile and link. Microsoft should have provided you NMake, it might have provided you their internal tool (used to drive builds of the Windows kernel and device drivers, I know it comes with the DDK tools but I think it is also in the Platform SDK and may be buried in VS) named BUILD, and there is always the option of adding a more broadly used build system such as GNU Make, CMAKE, or countless others.
If you insist on using the renaming trick because it is more expedient than learning to do it the right way right now, then please at least add some testing for the successful completion of each compile and link step with IF ERRORLEVEL 1 GOTO :EOF commands to end the batch file after a failure, as shown below.
As I edited the batch file, I notice another potential issue. You built all the OBJ files with /DLUA_BUILD_AS_DLL, but then make a static library and link luac.exe from it. I don't know offhand what features of the source text are modified by that definition, but it probably isn't wise to make a static library from OBJ files compiled with it instead of a DLL.
cl /MD /O2 /W3 /c /DLUA_BUILD_AS_DLL *.c
if ERRORLEVEL 1 goto :EOF
del *.o
ren lua.obj lua.o
ren luac.obj luac.o
link /DLL /IMPLIB:lua5.2.lib /OUT:lua5.2.dll *.obj
if ERRORLEVEL 1 goto :EOF
link /OUT:lua.exe lua.o lua5.2.lib
if ERRORLEVEL 1 goto :EOF
cl /MD /O2 /W3 /c *.c
if ERRORLEVEL 1 goto :EOF
del *.o
ren lua.obj lua.o
ren luac.obj luac.o
lib /out:lua5.2-static.lib *.obj
if ERRORLEVEL 1 goto :EOF
ren lua.o lua.obj
ren luac.o luac.obj
link /OUT:luac.exe luac.obj lua5.2-static.lib
if ERRORLEVEL 1 goto :EOF