2

This is my first attempt at posting for help on Stack Overflow.

My Project: Using an STM32F4-Discovery with the STM32F407VGT6 chip with the FPv4-SP and a camera/LCD peripheral setup, I need to record video at QVGA and output into a compressed MPEG-4 format with at least a 25:1 ratio.

I have identified the desired codec library (avconv, unless ffmpeg proves more useable) and am now in the process of trying to build the compiler options to give me a light-weight version that will be able to execute on the chip in ANSI-C and Thumb architecture.

This board has very limited space (192KB SRAM and 1MB of Flash - there is the possibility of expansion, but it would be preferred to use just what I have) and currently the "main" executable of either library is over 1MB.

Judging by the output with the different solutions I have tried - it does not appear many of the compiler options are successfully applying to the build. So my questions are:

1) Is it even possible to compile either library into the space desired using only rawvideo decoders, mpeg4 encoders, and the most basic utilities possible? If not, is there a guesstimate out there of how much would be required?

2) I've spent many hours scouring the internet, and it doesn't appear that anyone has attempted this - is there anyone out there who can tell me otherwise?

I have my configure/build script on hand for anyone who wants to take a look and see if I have missed something basic. Just ask and I will email it, I don't want to clutter the thread more than my seemingly verbose inquisition already has.

I would assume that neither library is likely broken. I have been attempting this on Ubuntu 12.04 32-bit.

I am a software intern and would be extremely appreciative of any help available.

One final question, should my solution prove unworkable, is there another open-source mpeg4 compression library that can easily compile for embedded ARMv7E-M/Thumb set architecture?

EDIT: Here is the build command, previously unincluded.

#!/bin/bash

NDK=~/Desktop/android-ndk-r9
PLATFORM=~/Desktop/gcc-arm-none-eabi-4_7-2013q2
PREBUILT=~/Desktop/gcc-arm-none-eabi-4_7-2013q2/arm-none-eabi
function build_one
{
./configure --target-os=symbian \
    --prefix=$PREFIX \
    --disable-everything \
    --enable-cross-compile \
    --disable-shared \
    --enable-static \
    --enable-small \
  #  --disable-asm \
    --enable-thumb \
    --extra-libs="-lgcc" \
    --arch=armv7e-m \
    --cc=$PREBUILT/bin/gcc \
    --cross-prefix=$PREBUILT/bin \
    --nm=$PREBUILT/bin/nm \
    --sysroot=$PLATFORM \
    --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -mthumb-interwork -finline-limit=300 $OPTIMIZE_CFLAGS -I/usr/local/include" \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/arm-none-eabi/lib/armv7e-m -L $PLATFORM/arm-none-eabi/lib/armv7e-m -nostdlib -lc -lm -ldl -llog -L/usr/local/lib " \
--enable-gpl \
   # --enable-libx264 \
    --enable-demuxer=mov \
    --enable-demuxer=h264 \
    --disable-ffplay \
    --disable-ffserver \
    --disable-ffprobe \
    --enable-protocol=file \
    --enable-avformat \
    --enable-avcodec \
    --enable-decoder=rawvideo \
    --enable-decoder=mjpeg \
    --enable-decoder=h263 \
    --enable-decoder=mpeg4 \
    --enable-decoder=h264 \
    --enable-encoder=mjpeg \
    --enable-encoder=h263 \
    --enable-encoder=mpeg4 \
    --enable-encoder=h264 \
    --enable-parser=h264 \
    --disable-network \
    --enable-zlib \
    --disable-avfilter \
    --disable-avdevice \
    $ADDITIONAL_CONFIGURE_FLAG

make clean
make -j4 install
$PREBUILT/bin/ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/ld -rpath-link=$PLATFORM/arm-none-eabi/lib/armv7e-m -L$PLATFORM/arm-none-eabi/lib/armv7e-m  -soname libffmpeg.so -shared -Bshareable -nostdlib -Bdynamic --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker $PREBUILT../lib/gcc/arm-none-eabi/4.7.4/armv7e-m/libgcc.a
}

CPU=armv7e-m
OPTIMIZE_CFLAGS="-mfloat-abi=hard -mfpu=vfpv4 -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one

This is a script I have obtained and modified. It originally built successfully for ARMv7-a which will not execute on the ARMv7e-m chip (the discovery board).

1 Answers1

0

Got some questions first:

What compiler options are you using? It's important to get them right to enable the correct libraries and floating point support. Can you post your build commands? Are you separating the compile and link stages?

Are you using newlib or newlib-nano? You can save space with newlib-nano.

Are you running bare metal or with an RTOS?

reign_man
  • 569
  • 2
  • 8
  • 21
  • First off, I appreciate the response. I will add my build commands to an edit on my original post to avoid clutter of this comment. I believe now that my problem lies in architecture. When I compiled and tried to link against the shared libraries from IAR Workstation, I got an error "This code was compiled for ARMv7-a.. ..cannot run on ARMv7e-m.." After attempting to brute force using other toolchains, I believe the problem lies with the source being unable to build for my target platform. Also I am an embedded noob, I think I'm using an RTOS. After looking, I don't think I have used newlib. – Jack Sanchez Aug 26 '13 at 16:02
  • What toolchain are you using? You need to be using a cross-compiler that can build for the arm cortex m4. – reign_man Aug 26 '13 at 16:54
  • Most likely those shared libraries are compiled for the ARMv7-a, if the build script you've received was for the ARMv7-a. You'll need to rebuild the libraries and compiler to support the ARMv7e-m – reign_man Aug 26 '13 at 16:55
  • Yea, originally the build script was configured for ARMv7-a, however, I obtained a toolchain (gcc-arm-none-eabi-4_7-2013q2) which was documented to be able to compile for ARMv7e-m. I configured the script for what I understood was the correct option set for the FPU options, Thumb options, as well as the specific architecture - however, my IDE still reported to me that the build was for ARMv7-a. – Jack Sanchez Aug 26 '13 at 17:10
  • Sorry for the long wait. Did you download prebuilt compiler binaries? You need to rebuild your libraries for the ARMv7-a, and if you only downloaded prebuilt compiler binaries, you won't have those. – reign_man Aug 28 '13 at 20:54
  • https://launchpad.net/gcc-arm-embedded You can get the source code for the ARM supported toolchain here. This is what I use and I know it works for the stm32f4. Simply download the source package and follow the instructions. – reign_man Aug 28 '13 at 20:55