diff --git a/buildme b/buildme deleted file mode 100755 index b8fd4408e..000000000 --- a/buildme +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -BUILDTYPE=Release - -if [ "$1" = "--debug" ]; then - BUILDTYPE=Debug - shift -fi - -BUILDSUBDIR=`echo $BUILDTYPE | tr '[A-Z]' '[a-z]'`; - -if [ "armv6l" = `arch` ] || [ "armv7l" = `arch` ]; then - # Native compile on the Raspberry Pi - mkdir -p build/raspberry/$BUILDSUBDIR - pushd build/raspberry/$BUILDSUBDIR - cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. - if [ "armv6l" = `arch` ]; then - make - else - make -j4 - fi - if [ "$1" != "" ]; then - sudo make install DESTDIR=$1 - else - sudo make install - fi -elif [ "$1" = "--native" ]; then - # Build natively on the host - mkdir -p build/native/$BUILDSUBDIR - pushd build/native/$BUILDSUBDIR - cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. - shift - make -j `nproc` $* -else - # Cross compile on a more capable machine - mkdir -p build/arm-linux/$BUILDSUBDIR - pushd build/arm-linux/$BUILDSUBDIR - cmake -DCMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. - make -j `nproc` - - if [ "$1" != "" ]; then - sudo make install DESTDIR=$1 - fi -fi -popd diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index 9b48cf902..4227bfd5b 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -2,6 +2,9 @@ Copyright (c) 2012, Broadcom Europe Ltd All rights reserved. +Copyright (c) 2019 Andrew Pattison +All rights reserved. + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright @@ -36,6 +39,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "interface/vmcs_host/vc_vchi_gencmd.h" +void show_usage() +{ + printf( "Usage: vcgencmd [-t] [COMMAND]\n" ); + printf( "Send a command to the Videocore and print the result.\n\n" ); + printf( " -t Time how long the command takes to complete\n"); + printf( " commands Display a list of commands\n\n" ); + printf( "Exit status:\n" ); + printf( " 0 command completed successfully\n" ); + printf( " -1 problem with VCHI\n" ); + printf( " -2 Videocore returned error\n" ); +} + int main( int argc, char **argv ) { int instNum = 0; @@ -50,6 +65,9 @@ int main( int argc, char **argv ) argv++; argc--; } + } else { + // no arguments passed, so show basic usage + show_usage(); } vcos_init(); @@ -71,6 +89,14 @@ int main( int argc, char **argv ) if (argc > 1) { + // first check if we were invoked with either -? or --help + // in which case show basic usage and exit + if( ( strcmp( argv[1], "-?" ) == 0) || strcmp( argv[1], "--help" ) == 0 ) + { + show_usage(); + return(0); + } + int i = 1; char buffer[ 1024 ]; size_t buffer_offset = 0; @@ -130,6 +156,14 @@ int main( int argc, char **argv ) { printf("%s\n", buffer ); } + if (strncmp( buffer, "error=", 5) == 0 ) + { + if ( strcmp( buffer, "error=1 error_msg=\"Command not registered\"" ) == 0 ) + { + printf( "Use 'vcgencmd commands' to get a list of commands\n" ); + } + return -2; + } } }