Skip to content

Instantly share code, notes, and snippets.

View l2dy's full-sized avatar

Zero King l2dy

View GitHub Profile

Protobuf-C For Embedded Developers (and other cross compilers)

TODO: move these general comments to a new page and provide an example, as promised by the page title.

Most embedded developers need to compile protobuf-c twice: 1. they need a copy of protoc-c that runs on their build environment (the build environment is for the machine on which they develop the application. 1. they need to have a copy of libprotobuf-c, which is the runtime library, that is compiled for the embedded platform (which we will call the target environment).

For (1), you need to install the main protobuf package, since protoc-c uses its parser and code generator libraries. Running 'configure' as usual should be fine.

For (2), you can configure with --disable-protoc which means you won't have to build the main protobuf package for the embedded platform (since you don't need to do code gen on the embedded platform). The usual details of cross-compilation for your specific embedded platform apply. Sometimes merely providing the name

#!/bin/sh
tar xvzf protobuf-c-1.2.1.tar.gz
cd protobuf-c-1.2.1
./configure --prefix=$STAGING_DIR --build=x86_64-unknown-linux-gnu --host=mipsel-openwrt-linux-musl --disable-protoc
make install
cd ..
tar xvzf libconfig-1.5.tar.gz
cd libconfig-1.5
./configure --prefix=$STAGING_DIR --build=x86_64-unknown-linux-gnu --host=mipsel-openwrt-linux-musl
make install

Signing Your App Manually

You do not need Android Studio to sign your app. You can sign your app from the command line using standard tools from the Android SDK and the JDK. To sign an app in release mode from the command line:

  1. Generate a private key using keytool. For example:

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

This example prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app.

awk '{print $2}' key.pub | base64 -d | md5sum -b | sed 's/../&:/g; s/: .*$//'
awk '{print $2}' key.pub | base64 -d | sha256sum -b | sed 's/ .*$//' | xxd -r -p | base64
API_KEY = "9f65b19b7a6648346dda93c6973a682c"

run-as com.example.app tar -cf - . | cat >backup.tar

cat backup.tar | run-as com.example.app tar -xf -

run-as: Usage:
    run-as <package-name> [--user <uid>] <command> [<args>]
@l2dy
l2dy / skin.puml
Last active November 24, 2016 12:12
@startuml
skinparam monochrome true
skinparam shadowing false
hide circle
@enduml
@l2dy
l2dy / git.sh
Last active June 3, 2019 05:33
git reflog expire --expire=now --all && git gc --prune=now --aggressive # prunes stashes!
git reflog expire --expire=now && git gc --prune=now --aggressive
git remote prune origin
git fetch -p
pip install -U --user $pkg
gem install --user-install $pkg
>echo %NLS_LANG%
AMERICAN_AMERICA.AL32UTF8