2013-10-10 6 views
1

У меня есть спутниковый приемник Dreambox, который работает с Enigma2 OpenEmbedded. Итак, архитектура MIPS. Я хочу скомпилировать на своем Ubuntu PC файл .sh в бинарный файл Enigma2.Сценарий перекрестного компиляции sh для bin для enigma2 (mips) OpenEmbedded

Я установил набор инструментов для компиляции кросс-компилятора для архитектуры mips32 на моем компьютере Ubuntu.

Toolchain информация:

/mips-compiler/mips-linux-gnu-gcc -v 

Using built-in specs. 
COLLECT_GCC=/mips-compiler/mips-linux-gnu-gcc 
COLLECT_LTO_WRAPPER=/root/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux/bin/../libexec/gcc/mips-linux-gnu/4.7.3/lto-wrapper 
Target: mips-linux-gnu 
Configured with: /scratch/cmoore/2013.05-36-mips-linux-lite/src/gcc-4.7-2013.05/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=mips-linux-gnu --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-arch-32=mips32r2 --with-arch-64=mips64r2 --with-float=hard --with-mips-plt --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2013 -D__CS_SOURCERYGXX_MIN__=5 -D__CS_SOURCERYGXX_REV__=36 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2013.05-36' --with-bugurl=https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/mips-linux-gnu/libc --with-build-sysroot=/scratch/cmoore/2013.05-36-mips-linux-lite/install/mips-linux-gnu/libc --with-gmp=/scratch/cmoore/2013.05-36-mips-linux-lite/obj/pkg-2013.05-36-mips-linux-gnu/mips-2013.05-36-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=/scratch/cmoore/2013.05-36-mips-linux-lite/obj/pkg-2013.05-36-mips-linux-gnu/mips-2013.05-36-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=/scratch/cmoore/2013.05-36-mips-linux-lite/obj/pkg-2013.05-36-mips-linux-gnu/mips-2013.05-36-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-ppl=/scratch/cmoore/2013.05-36-mips-linux-lite/obj/pkg-2013.05-36-mips-linux-gnu/mips-2013.05-36-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/cmoore/2013.05-36-mips-linux-lite/obj/pkg-2013.05-36-mips-linux-gnu/mips-2013.05-36-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-libelf=/scratch/cmoore/2013.05-36-mips-linux-lite/obj/pkg-2013.05-36-mips-linux-gnu/mips-2013.05-36-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --disable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools=/scratch/cmoore/2013.05-36-mips-linux-lite/install/mips-linux-gnu/bin --with-build-time-tools=/scratch/cmoore/2013.05-36-mips-linux-lite/install/mips-linux-gnu/bin 
Thread model: posix 
gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-36) 

Я использовал SHC для преобразования .sh файла в .c файл Затем я перекрестно скомпилирован, что с файлом на MIPS двоичный с помощью команды:

/mips-compiler/mips-linux-gnu-gcc -mips32 -o test.bin test.sh.x.c 

Ошибок не было (я был так счастлив, но, к сожалению (см. Ниже)). Затем скопировал файл бен в моем enigma2 поле и попытался запустить его ...

Когда я побежал выходной двоичный файл на поле MIPS я вижу это:

./test.bin: line 1: syntax error: unexpected "(" 

Так, очевидно, я забыл что-то в перекрестная команда компиляции, но что?

ответ

1

(Отказ от ответственности: Я работаю CodeSourcery/Mentor Graphics.)

Используя немного более новую версию того же набора инструментов, вот мои результаты при запуске из хост-системы Ubuntu 12.04. Во-первых, версия:

[email protected]:~$ /home/lite/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux/bin/mips-linux-gnu-gcc -v 
Using built-in specs. 
COLLECT_GCC=/home/lite/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux/bin/mips-linux-gnu-gcc 
COLLECT_LTO_WRAPPER=/home/lite/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux/bin/../libexec/gcc/mips-linux-gnu/4.7.3/lto-wrapper 
Target: mips-linux-gnu 
Configured with: /scratch/cmoore/2013.05-mips-linux/src/gcc-4.7-2013.05/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=mips-linux-gnu --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-arch-32=mips32r2 --with-arch-64=mips64r2 --with-float=hard --with-mips-plt --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2013 -D__CS_SOURCERYGXX_MIN__=5 -D__CS_SOURCERYGXX_REV__=66 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2013.05-66' --with-bugurl=https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/mips-linux-gnu/libc --with-build-sysroot=/scratch/cmoore/2013.05-mips-linux/install/mips-linux-gnu/libc --with-gmp=/scratch/cmoore/2013.05-mips-linux/obj/pkg-2013.05-66-mips-linux-gnu/mips-2013.05-66-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=/scratch/cmoore/2013.05-mips-linux/obj/pkg-2013.05-66-mips-linux-gnu/mips-2013.05-66-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=/scratch/cmoore/2013.05-mips-linux/obj/pkg-2013.05-66-mips-linux-gnu/mips-2013.05-66-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-ppl=/scratch/cmoore/2013.05-mips-linux/obj/pkg-2013.05-66-mips-linux-gnu/mips-2013.05-66-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/cmoore/2013.05-mips-linux/obj/pkg-2013.05-66-mips-linux-gnu/mips-2013.05-66-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --with-libelf=/scratch/cmoore/2013.05-mips-linux/obj/pkg-2013.05-66-mips-linux-gnu/mips-2013.05-66-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr --enable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools=/scratch/cmoore/2013.05-mips-linux/install/mips-linux-gnu/bin --with-build-time-tools=/scratch/cmoore/2013.05-mips-linux/install/mips-linux-gnu/bin SED=sed 
Thread model: posix 
gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-66) 

Тогда код, построить и вывод команды файла, чтобы показать больше информации о исполняемому производства:

[email protected]:~$ /home/lite/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux/bin/mips-linux-gnu-gcc --version 
mips-linux-gnu-gcc (Sourcery CodeBench Lite 2013.05-66) 4.7.3 
Copyright (C) 2012 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

[email protected]:~$ cat hello.c 
#include <stdio.h> 

int main(int argc, char *argv[]) { 
    printf("hello world!\n"); 
} 
[email protected]:~$ /home/lite/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux/bin/mips-linux-gnu-gcc -mips32 hello.c -o hello 
[email protected]:~$ file hello 
hello: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.16, with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70401, not stripped 

Что является вывод команды файла на двоичном вы производите?

+0

Спасибо Рикардо за ответ. Цените свою помощь так много. Когда я сравниваю то, что вы написали, тем, что я сделал, похоже, что то же самое. Так что все должно быть в порядке. Вы запросили вывод команды двоичного файла. Вы имеете в виду тот же результат, что и в вашем ответе «cat hello.c»? Если это так, это будет очень большой объем вывода. У меня длинный скрипт оболочки. И сам сценарий оболочки в порядке, потому что, когда я не перекрещиваю его, но просто компилирую его с помощью gcc для своей машины Ubuntu, он работает отлично. –

+0

Здравствуйте, ni_hao. Я имел в виду команду 'file', обычно находящуюся в'/usr/bin/file' в системах Ubuntu, как показано на второй и последней последней строке вышеприведенного вывода. Вы можете видеть, что 'file' сообщает мне, что созданный мной файл hello - это 32-разрядный исполняемый файл для системы MIPS Linux. –

 Смежные вопросы

  • Нет связанных вопросов^_^