Friday, 9 October 2020

Android development whada heck is going on...

     I am on the process of creating an Android player for the multi-room speaker project. Last time I touched Android development was 5 or 6 years ago for  'arduipush'

     I've chosen  flutter/dart. I followed the tutorials at https://flutter.dev/docs/get-started . The tutorials are good, but the platform they are for unfortunatelly is bad.

The AnsroidStudio generated 793 files and 519 Mb  for an applicaiton having one window with one button.

Is anyone from Android design team comprehends this. I have no words. Here are generated files.

 

$ find . -type f -print | wc -l
793

marius@hpp:~/sdaone/ANDROID_STUDIO/speakermr$ du -h
64K    ./android/gradle/wrapper
68K    ./android/gradle
60K    ./android/.gradle/buildOutputCleanup
8.0K    ./android/.gradle/5.6.2/fileContent
88K    ./android/.gradle/5.6.2/fileHashes
508K    ./android/.gradle/5.6.2/executionHistory
4.0K    ./android/.gradle/5.6.2/vcsMetadata-1
8.0K    ./android/.gradle/5.6.2/fileChanges
652K    ./android/.gradle/5.6.2/javaCompile
1.3M    ./android/.gradle/5.6.2
4.0K    ./android/.gradle/vcs-1
1.4M    ./android/.gradle
8.0K    ./android/app/src/profile
8.0K    ./android/app/src/main/res/mipmap-xxhdpi
8.0K    ./android/app/src/main/res/mipmap-xhdpi
8.0K    ./android/app/src/main/res/mipmap-mdpi
8.0K    ./android/app/src/main/res/mipmap-hdpi
8.0K    ./android/app/src/main/res/mipmap-xxxhdpi
8.0K    ./android/app/src/main/res/values
8.0K    ./android/app/src/main/res/drawable
60K    ./android/app/src/main/res
8.0K    ./android/app/src/main/kotlin/com/example/speakermr
12K    ./android/app/src/main/kotlin/com/example
16K    ./android/app/src/main/kotlin/com
20K    ./android/app/src/main/kotlin
8.0K    ./android/app/src/main/java/io/flutter/plugins
12K    ./android/app/src/main/java/io/flutter
16K    ./android/app/src/main/java/io
20K    ./android/app/src/main/java
108K    ./android/app/src/main
8.0K    ./android/app/src/debug
128K    ./android/app/src
136K    ./android/app
1.6M    ./android
76K    ./ios/Runner/Assets.xcassets/AppIcon.appiconset
24K    ./ios/Runner/Assets.xcassets/LaunchImage.imageset
104K    ./ios/Runner/Assets.xcassets
12K    ./ios/Runner/Base.lproj
140K    ./ios/Runner
8.0K    ./ios/Runner.xcodeproj/xcshareddata/xcschemes
12K    ./ios/Runner.xcodeproj/xcshareddata
12K    ./ios/Runner.xcodeproj/project.xcworkspace/xcshareddata
20K    ./ios/Runner.xcodeproj/project.xcworkspace
56K    ./ios/Runner.xcodeproj
24K    ./ios/Flutter
12K    ./ios/Runner.xcworkspace/xcshareddata
20K    ./ios/Runner.xcworkspace
248K    ./ios
8.0K    ./build/f1cc12647b548cd29605f4ad7410d957
97M    ./build/app/outputs/flutter-apk
20K    ./build/app/outputs/logs
49M    ./build/app/outputs/apk/debug
49M    ./build/app/outputs/apk
145M    ./build/app/outputs
4.0K    ./build/app/intermediates/validate_signing_config/debug/out
8.0K    ./build/app/intermediates/validate_signing_config/debug
12K    ./build/app/intermediates/validate_signing_config
4.0K    ./build/app/intermediates/shader_assets/debug/compileDebugShaders/out
8.0K    ./build/app/intermediates/shader_assets/debug/compileDebugShaders
12K    ./build/app/intermediates/shader_assets/debug
16K    ./build/app/intermediates/shader_assets
12K    ./build/app/intermediates/bundle_manifest/debug/processDebugManifest/bundle-manifest
16K    ./build/app/intermediates/bundle_manifest/debug/processDebugManifest
20K    ./build/app/intermediates/bundle_manifest/debug
24K    ./build/app/intermediates/bundle_manifest
8.0K    ./build/app/intermediates/compatible_screen_manifest/debug/createDebugCompatibleScreenManifests/out
12K    ./build/app/intermediates/compatible_screen_manifest/debug/createDebugCompatibleScreenManifests
16K    ./build/app/intermediates/compatible_screen_manifest/debug
20K    ./build/app/intermediates/compatible_screen_manifest
27M    ./build/app/intermediates/stripped_native_libs/debug/out/lib/arm64-v8a
29M    ./build/app/intermediates/stripped_native_libs/debug/out/lib/x86_64
28M    ./build/app/intermediates/stripped_native_libs/debug/out/lib/x86
83M    ./build/app/intermediates/stripped_native_libs/debug/out/lib
83M    ./build/app/intermediates/stripped_native_libs/debug/out
83M    ./build/app/intermediates/stripped_native_libs/debug
83M    ./build/app/intermediates/stripped_native_libs
3.0M    ./build/app/intermediates/dex/debug/mergeDexDebug/out
3.0M    ./build/app/intermediates/dex/debug/mergeDexDebug
3.0M    ./build/app/intermediates/dex/debug
3.0M    ./build/app/intermediates/dex
36K    ./build/app/intermediates/incremental/packageDebug/tmp/debug/zip-cache
44K    ./build/app/intermediates/incremental/packageDebug/tmp/debug
48K    ./build/app/intermediates/incremental/packageDebug/tmp
52K    ./build/app/intermediates/incremental/packageDebug
8.0K    ./build/app/intermediates/incremental/mergeDebugShaders
34M    ./build/app/intermediates/incremental/debug-mergeNativeLibs/zip-cache
34M    ./build/app/intermediates/incremental/debug-mergeNativeLibs
34M    ./build/app/intermediates/incremental/debug-mergeJavaRes/zip-cache
34M    ./build/app/intermediates/incremental/debug-mergeJavaRes
4.0K    ./build/app/intermediates/incremental/mergeDebugResources/stripped.dir
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-fr-rCA
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ta
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-lv
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ko
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-kn
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ky
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-as
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-uz
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ne
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-sv
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ur
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-pl
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-zh-rCN
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-et
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-mn
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-or
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-nb
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-pt-rBR
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-hr
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-fa
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-el
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ka
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ms
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-kk
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-af
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-cs
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-hy
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-bg
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-is
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-de
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-th
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-tr
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-en-rGB
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-am
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-lt
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-en-rXC
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-eu
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-be
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-hi
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-pa
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-b+sr+Latn
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-in
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ml
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-tl
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-sl
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-mr
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-vi
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-fi
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-bn
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-lo
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-mk
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-zu
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-da
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-km
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-en-rIN
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-gl
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ru
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-hu
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-my
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-en-rCA
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ja
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ca
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-en-rAU
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ar
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-nl
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-iw
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-te
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-ro
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-v16
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-v21
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-es
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-zh-rHK
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-sr
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-fr
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-sq
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-si
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-gu
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-pt-rPT
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-pt
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-it
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-bs
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-uk
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-es-rUS
20K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-sk
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-sw
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-zh-rTW
8.0K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir/values-az
720K    ./build/app/intermediates/incremental/mergeDebugResources/merged.dir
784K    ./build/app/intermediates/incremental/mergeDebugResources
8.0K    ./build/app/intermediates/incremental/mergeDebugJniLibFolders
8.0K    ./build/app/intermediates/incremental/mergeDebugAssets
4.0K    ./build/app/intermediates/incremental/processDebugResources
69M    ./build/app/intermediates/incremental
4.0K    ./build/app/intermediates/check_manifest_result/debug/checkDebugManifest/out
8.0K    ./build/app/intermediates/check_manifest_result/debug/checkDebugManifest
12K    ./build/app/intermediates/check_manifest_result/debug
16K    ./build/app/intermediates/check_manifest_result
156K    ./build/app/intermediates/merged_java_res/debug
160K    ./build/app/intermediates/merged_java_res
8.0K    ./build/app/intermediates/annotation_processor_list/debug
12K    ./build/app/intermediates/annotation_processor_list
12K    ./build/app/intermediates/manifest_merge_blame_file/debug
16K    ./build/app/intermediates/manifest_merge_blame_file
4.0K    ./build/app/intermediates/duplicate_classes_check/debug/out
8.0K    ./build/app/intermediates/duplicate_classes_check/debug
12K    ./build/app/intermediates/duplicate_classes_check
536K    ./build/app/intermediates/res/merged/debug
540K    ./build/app/intermediates/res/merged
12K    ./build/app/intermediates/res/symbol-table-with-package/debug
16K    ./build/app/intermediates/res/symbol-table-with-package
560K    ./build/app/intermediates/res
4.0K    ./build/app/intermediates/merged_jni_libs/debug/out
8.0K    ./build/app/intermediates/merged_jni_libs/debug
12K    ./build/app/intermediates/merged_jni_libs
424K    ./build/app/intermediates/blame/res/debug/multi-v2
16K    ./build/app/intermediates/blame/res/debug/single
444K    ./build/app/intermediates/blame/res/debug
448K    ./build/app/intermediates/blame/res
452K    ./build/app/intermediates/blame
3.0M    ./build/app/intermediates/external_libs_dex/debug/mergeExtDexDebug/out
3.0M    ./build/app/intermediates/external_libs_dex/debug/mergeExtDexDebug
3.0M    ./build/app/intermediates/external_libs_dex/debug
3.0M    ./build/app/intermediates/external_libs_dex
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/0/io/flutter/plugins
12K    ./build/app/intermediates/transforms/dexBuilder/debug/0/io/flutter
16K    ./build/app/intermediates/transforms/dexBuilder/debug/0/io
56K    ./build/app/intermediates/transforms/dexBuilder/debug/0/com/example/speakermr
60K    ./build/app/intermediates/transforms/dexBuilder/debug/0/com/example
64K    ./build/app/intermediates/transforms/dexBuilder/debug/0/com
48K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/fragment
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/lifecycle/viewmodel
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/lifecycle/livedata/core
16K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/lifecycle/livedata
32K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/lifecycle
48K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/loader
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/versionedparcelable
48K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/viewpager
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/savedstate
48K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/customview
48K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/core
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/arch/core
12K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/arch
48K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx/activity
352K    ./build/app/intermediates/transforms/dexBuilder/debug/0/androidx
436K    ./build/app/intermediates/transforms/dexBuilder/debug/0
8.0K    ./build/app/intermediates/transforms/dexBuilder/debug/1/com/example/speakermr
12K    ./build/app/intermediates/transforms/dexBuilder/debug/1/com/example
16K    ./build/app/intermediates/transforms/dexBuilder/debug/1/com
20K    ./build/app/intermediates/transforms/dexBuilder/debug/1
464K    ./build/app/intermediates/transforms/dexBuilder/debug
468K    ./build/app/intermediates/transforms/dexBuilder
472K    ./build/app/intermediates/transforms
8.0K    ./build/app/intermediates/signing_config/debug/out
12K    ./build/app/intermediates/signing_config/debug
16K    ./build/app/intermediates/signing_config
8.0K    ./build/app/intermediates/javac/debug/classes/io/flutter/plugins
12K    ./build/app/intermediates/javac/debug/classes/io/flutter
16K    ./build/app/intermediates/javac/debug/classes/io
56K    ./build/app/intermediates/javac/debug/classes/com/example/speakermr
60K    ./build/app/intermediates/javac/debug/classes/com/example
64K    ./build/app/intermediates/javac/debug/classes/com
48K    ./build/app/intermediates/javac/debug/classes/androidx/fragment
8.0K    ./build/app/intermediates/javac/debug/classes/androidx/lifecycle/viewmodel
8.0K    ./build/app/intermediates/javac/debug/classes/androidx/lifecycle/livedata/core
16K    ./build/app/intermediates/javac/debug/classes/androidx/lifecycle/livedata
32K    ./build/app/intermediates/javac/debug/classes/androidx/lifecycle
48K    ./build/app/intermediates/javac/debug/classes/androidx/loader
8.0K    ./build/app/intermediates/javac/debug/classes/androidx/versionedparcelable
48K    ./build/app/intermediates/javac/debug/classes/androidx/viewpager
8.0K    ./build/app/intermediates/javac/debug/classes/androidx/savedstate
48K    ./build/app/intermediates/javac/debug/classes/androidx/customview
48K    ./build/app/intermediates/javac/debug/classes/androidx/core
8.0K    ./build/app/intermediates/javac/debug/classes/androidx/arch/core
12K    ./build/app/intermediates/javac/debug/classes/androidx/arch
48K    ./build/app/intermediates/javac/debug/classes/androidx/activity
352K    ./build/app/intermediates/javac/debug/classes/androidx
436K    ./build/app/intermediates/javac/debug/classes
440K    ./build/app/intermediates/javac/debug
444K    ./build/app/intermediates/javac
12K    ./build/app/intermediates/instant_app_manifest/debug
16K    ./build/app/intermediates/instant_app_manifest
284K    ./build/app/intermediates/merged_assets/debug/out/flutter_assets/packages/cupertino_icons/assets
288K    ./build/app/intermediates/merged_assets/debug/out/flutter_assets/packages/cupertino_icons
292K    ./build/app/intermediates/merged_assets/debug/out/flutter_assets/packages
904K    ./build/app/intermediates/merged_assets/debug/out/flutter_assets/fonts
37M    ./build/app/intermediates/merged_assets/debug/out/flutter_assets
37M    ./build/app/intermediates/merged_assets/debug/out
37M    ./build/app/intermediates/merged_assets/debug
37M    ./build/app/intermediates/merged_assets
12K    ./build/app/intermediates/merged_manifests/debug
16K    ./build/app/intermediates/merged_manifests
56K    ./build/app/intermediates/processed_res/debug/processDebugResources/out
60K    ./build/app/intermediates/processed_res/debug/processDebugResources
64K    ./build/app/intermediates/processed_res/debug
68K    ./build/app/intermediates/processed_res
8.0K    ./build/app/intermediates/apk_list/debug/mainApkListPersistenceDebug
12K    ./build/app/intermediates/apk_list/debug
16K    ./build/app/intermediates/apk_list
4.0K    ./build/app/intermediates/merged_shaders/debug/out
8.0K    ./build/app/intermediates/merged_shaders/debug
12K    ./build/app/intermediates/merged_shaders
27M    ./build/app/intermediates/merged_native_libs/debug/out/lib/arm64-v8a
29M    ./build/app/intermediates/merged_native_libs/debug/out/lib/x86_64
28M    ./build/app/intermediates/merged_native_libs/debug/out/lib/x86
83M    ./build/app/intermediates/merged_native_libs/debug/out/lib
83M    ./build/app/intermediates/merged_native_libs/debug/out
83M    ./build/app/intermediates/merged_native_libs/debug
83M    ./build/app/intermediates/merged_native_libs
4.0K    ./build/app/intermediates/external_file_lib_dex_archives/debug/out
8.0K    ./build/app/intermediates/external_file_lib_dex_archives/debug
12K    ./build/app/intermediates/external_file_lib_dex_archives
8.0K    ./build/app/intermediates/metadata_feature_manifest/debug/processDebugManifest/metadata-feature
12K    ./build/app/intermediates/metadata_feature_manifest/debug/processDebugManifest
16K    ./build/app/intermediates/metadata_feature_manifest/debug
20K    ./build/app/intermediates/metadata_feature_manifest
16K    ./build/app/intermediates/symbols/debug
20K    ./build/app/intermediates/symbols
284K    ./build/app/intermediates/flutter/debug/flutter_assets/packages/cupertino_icons/assets
288K    ./build/app/intermediates/flutter/debug/flutter_assets/packages/cupertino_icons
292K    ./build/app/intermediates/flutter/debug/flutter_assets/packages
904K    ./build/app/intermediates/flutter/debug/flutter_assets/fonts
37M    ./build/app/intermediates/flutter/debug/flutter_assets
37M    ./build/app/intermediates/flutter/debug
37M    ./build/app/intermediates/flutter
316M    ./build/app/intermediates
140K    ./build/app/kotlin/compileDebugKotlin/caches-jvm/lookups
340K    ./build/app/kotlin/compileDebugKotlin/caches-jvm/jvm/kotlin
344K    ./build/app/kotlin/compileDebugKotlin/caches-jvm/jvm
60K    ./build/app/kotlin/compileDebugKotlin/caches-jvm/inputs
548K    ./build/app/kotlin/compileDebugKotlin/caches-jvm
560K    ./build/app/kotlin/compileDebugKotlin
564K    ./build/app/kotlin
8.0K    ./build/app/tmp/packLibsflutterBuildDebug
8.0K    ./build/app/tmp/kotlin-classes/debug/com/example/speakermr
12K    ./build/app/tmp/kotlin-classes/debug/com/example
16K    ./build/app/tmp/kotlin-classes/debug/com
8.0K    ./build/app/tmp/kotlin-classes/debug/META-INF
28K    ./build/app/tmp/kotlin-classes/debug
32K    ./build/app/tmp/kotlin-classes
4.0K    ./build/app/tmp/compileDebugJavaWithJavac
48K    ./build/app/tmp
4.0K    ./build/app/generated/res/pngs/debug
8.0K    ./build/app/generated/res/pngs
4.0K    ./build/app/generated/res/resValues/debug
8.0K    ./build/app/generated/res/resValues
20K    ./build/app/generated/res
4.0K    ./build/app/generated/ap_generated_sources/debug/out
8.0K    ./build/app/generated/ap_generated_sources/debug
12K    ./build/app/generated/ap_generated_sources
48K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/com/example/speakermr
52K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/com/example
56K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/com
20K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/fragment
8.0K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/lifecycle/viewmodel
8.0K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/lifecycle/livedata/core
16K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/lifecycle/livedata
32K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/lifecycle
16K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/loader
8.0K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/versionedparcelable
16K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/viewpager
8.0K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/savedstate
16K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/customview
20K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/core
8.0K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/arch/core
12K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/arch
20K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx/activity
172K    ./build/app/generated/not_namespaced_r_class_sources/debug/r/androidx
232K    ./build/app/generated/not_namespaced_r_class_sources/debug/r
236K    ./build/app/generated/not_namespaced_r_class_sources/debug
240K    ./build/app/generated/not_namespaced_r_class_sources
8.0K    ./build/app/generated/source/buildConfig/debug/com/example/speakermr
12K    ./build/app/generated/source/buildConfig/debug/com/example
16K    ./build/app/generated/source/buildConfig/debug/com
20K    ./build/app/generated/source/buildConfig/debug
24K    ./build/app/generated/source/buildConfig
28K    ./build/app/generated/source
304K    ./build/app/generated
461M    ./build/app
4.0K    ./build/kotlin/sessions
8.0K    ./build/kotlin
486M    ./build
12K    ./lib
24K    ./.idea/libraries
8.0K    ./.idea/runConfigurations
8.0K    ./.idea/codeStyles
56K    ./.idea
32M    ./.dart_tool/flutter_build/5583cfc65007a02a48b40e572284fa56
32M    ./.dart_tool/flutter_build
32M    ./.dart_tool
8.0K    ./test
519M    .
 

Looks like the OS does not have any UI capabilities and the dam app has to manage everyting. Why Android does not expose a simple damn framework on wich you use one language, some graphic primitives already built in. Why creating a platform in within platform. Why after having already the  SDK and JDK whic by themselfs contains everyting the world has written in last 1000 years  the build is bringing again the whole Java encyclopedia. Why anyone would invent syntaxes like this. I mean look at it. Does is feel naturally.


/// A [Map] whose key equality is determined by an [Equality] object.
class EqualityMap<K, V> extends DelegatingMap<K, V> {
/// Creates a map with equality based on [equality].
EqualityMap(Equality<K> equality)
: super(LinkedHashMap(
equals: equality.equals,
hashCode: equality.hash,
isValidKey: equality.isValidKey));

In  the 90's at an architecture courses I took. It was a statement I remember:
When you start having classes like Manager*, Provider* aka; ThatManager, ThisManager, ViewManager, ContentManager and so on, start redesiginig your framework
.

The OO concepts and paterns got at a level that became a BBM anyway.

I just remember what simple and digestible was the bare Windows SDK in the 2000's, a simple main entry point  and  message loop. A SDK that can be learned as a language and written as you go without the need to lookup blocks of code that has no logical and natural sense. Nowadays you don't learn anymore a language, there is noting to learn, No specification, No logical motivation. Coding is not longer coding, is a continous web search for every step you do to find recipes and obfuscated blocks of code you paste without thinking in your 'code'.
The result 500M  for 2 rectangles on the screen, as big as the whole OS by itself.


Friday, 2 October 2020

Nano Pi neo OLED HAT C++

 

Recently I purchased a nano hat oled for nano pi neo. It had the python oled application.
I hacked that to display what I would like. The board stopped working after a day or 2.
I thought that my GPSD program leaks or something. Then I realized that the crappy python and friends
was hanging up the board. I did not catch it, because the board was not running. I eliminated
the python oled services and everything went back to normal.


DIY.
  • Remove the python NanoHatOLED service if you already have it running.

  • Configure the buttons at startup

Code: Select all

#!/bin/bash
pushd /sys/class/gpio
echo 0 > export
echo 2 > export
echo 3 > export
echo in  > ./gpio0/direction
echo in  > ./gpio2/direction
echo in  > ./gpio3/direction
popd

  • Get the libSSD1306
  • Patch the code
  • The ./examples/tempprint.cxx new file content would print the output of /tmp/oled file every second. The file is listed at the bottom.
    Create a new file in ./examples/tempprint.cxx and paste that content.

Code: Select all

marius@odrisyan1:~$ cd libSSD1306/
marius@odrisyan1:~/libSSD1306$ 
  • The patch file

Code: Select all

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 930b7fe..8fea5cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
 
+add_definitions(-Dcimg_display=0 -Dcimg_use_jpeg)
+
 #--------------------------------------------------------------------------
 
 add_library(SSD1306 STATIC lib/FileDescriptor.cxx
@@ -34,6 +36,9 @@ target_link_libraries(clock SSD1306)
 add_executable(ipaddress examples/ipaddress.cxx examples/LinuxKeys.cxx)
 target_link_libraries(ipaddress SSD1306)
 
+add_executable(tempprint examples/tempprint.cxx examples/LinuxKeys.cxx)
+target_link_libraries(tempprint SSD1306)
+
 add_executable(life examples/life.cxx examples/LinuxKeys.cxx)
 target_link_libraries(life SSD1306)
 
diff --git a/examples/analog.cxx b/examples/analog.cxx
index e1fed84..f7ceb93 100644
--- a/examples/analog.cxx
+++ b/examples/analog.cxx
@@ -158,7 +158,7 @@ main()
 
         SSD1306::OledBitmap<64, 64> bitmap;
         SSD1306::OledPoint offset{32, 0};
-        SSD1306::OledI2C oled{"/dev/i2c-1", 0x3C};
+        SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};
 
         while (run)
         {
diff --git a/examples/clock.cxx b/examples/clock.cxx
index 94a5d08..914d24d 100644
--- a/examples/clock.cxx
+++ b/examples/clock.cxx
@@ -133,7 +133,7 @@ main()
             }
         }
 
-        SSD1306::OledI2C oled{"/dev/i2c-1", 0x3C};
+        SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};
 
         while (run)
         {
diff --git a/examples/ipaddress.cxx b/examples/ipaddress.cxx
index 2af0e30..2502787 100644
--- a/examples/ipaddress.cxx
+++ b/examples/ipaddress.cxx
@@ -155,7 +155,7 @@ main()
             }
         }
 
-        SSD1306::OledI2C oled{"/dev/i2c-1", 0x3C};
+        SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};
 
         while (run)
         {
diff --git a/examples/life.cxx b/examples/life.cxx
index ca742c7..2da44b4 100644
--- a/examples/life.cxx
+++ b/examples/life.cxx
@@ -220,7 +220,7 @@ main()
             }
         }
 
-       SSD1306::OledI2C oled{"/dev/i2c-1", 0x3C};
+       SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};
 
         Bitmap pixels;
 
diff --git a/examples/testbitmap.cxx b/examples/testbitmap.cxx
index ba2d334..44a499a 100644
--- a/examples/testbitmap.cxx
+++ b/examples/testbitmap.cxx
@@ -61,7 +61,7 @@ main()
              0b00000000, 0b00000000
         };
 
-        SSD1306::OledI2C oled{"/dev/i2c-1", 0x3C};
+        SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};
 
         for (auto y = -(bitmap.height() / 2) ;
              y < (oled.height() + (bitmap.height() / 2)) ;
diff --git a/examples/testoled.cxx b/examples/testoled.cxx
index cba0723..4e45ea4 100644
--- a/examples/testoled.cxx
+++ b/examples/testoled.cxx
@@ -39,7 +39,7 @@ main()
 {
     try
     {
-        SSD1306::OledI2C oled{"/dev/i2c-1", 0x3C};
+        SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};
         drawString8x16(SSD1306::OledPoint{32, 24},
                        "Oled I" "\xFD" "C",
                        SSD1306::PixelStyle::Set,
  • cmake and make

Code: Select all

marius@odrisyan1:~/libSSD1306$ make -j4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marius/libSSD1306
[ 30%] Built target SSD1306
[ 40%] Building CXX object CMakeFiles/testbitmap.dir/examples/testbitmap.cxx.o
[ 40%] Building CXX object CMakeFiles/life.dir/examples/life.cxx.o
[ 40%] Building CXX object CMakeFiles/testoled.dir/examples/testoled.cxx.o
[ 43%] Building CXX object CMakeFiles/tempprint.dir/examples/tempprint.cxx.o
[ 46%] Building CXX object CMakeFiles/testoled.dir/examples/LinuxKeys.cxx.o
[ 50%] Building CXX object CMakeFiles/testbitmap.dir/examples/LinuxKeys.cxx.o
[ 53%] Linking CXX executable bin/testoled
[ 56%] Linking CXX executable bin/testbitmap
[ 56%] Built target testoled
[ 56%] Built target testbitmap
[ 60%] Building CXX object CMakeFiles/tempprint.dir/examples/LinuxKeys.cxx.o
[ 63%] Building CXX object CMakeFiles/analog.dir/examples/analog.cxx.o
[ 66%] Building CXX object CMakeFiles/life.dir/examples/LinuxKeys.cxx.o
[ 70%] Building CXX object CMakeFiles/analog.dir/examples/LinuxKeys.cxx.o
[ 73%] Linking CXX executable bin/life
[ 76%] Building CXX object CMakeFiles/clock.dir/examples/clock.cxx.o
[ 76%] Built target life
[ 80%] Building CXX object CMakeFiles/ipaddress.dir/examples/ipaddress.cxx.o
[ 86%] Linking CXX executable bin/analog
[ 86%] Building CXX object CMakeFiles/clock.dir/examples/LinuxKeys.cxx.o
[ 90%] Linking CXX executable bin/clock
[ 90%] Built target analog
[ 93%] Building CXX object CMakeFiles/ipaddress.dir/examples/LinuxKeys.cxx.o
[ 93%] Built target clock
[ 96%] Linking CXX executable bin/ipaddress
[ 96%] Built target ipaddress
[100%] Linking CXX executable bin/tempprint
[100%] Built target tempprint
You can run samples now

Code: Select all

cd bin
marius@odrisyan1:~/libSSD1306/bin$ ls -l
total 352
-rwxrwxr-x 1 marius marius 50204 Feb 11 11:58 analog
-rwxrwxr-x 1 marius marius 49192 Feb 11 11:58 clock
-rwxrwxr-x 1 marius marius 48876 Feb 11 11:58 ipaddress
-rwxrwxr-x 1 marius marius 44460 Feb 11 11:57 life
-rwxrwxr-x 1 marius marius 65496 Feb 11 11:58 tempprint
-rwxrwxr-x 1 marius marius 44876 Feb 11 11:57 testbitmap
-rwxrwxr-x 1 marius marius 48708 Feb 11 11:57 testoled
marius@odrisyan1:~/libSSD1306/bin$ 

Image
Image
Image
Image


  • tempprint.cxx file

Code: Select all

#include <array>
#include <chrono>
#include <cmath>
#include <csignal>
#include <cstring>
#include <string>
#include <exception>
#include <iostream>
#include <sstream>
#include <fstream>
#include <memory>
#include <thread>
#include <system_error>
#include <vector>

#include <sys/types.h>
#include <time.h>
#include <unistd.h>


#include "OledFont8x16.h"
#include "OledFont8x12.h"
#include "OledFont8x8.h"
#include "OledBitmap.h"
#include "OledGraphics.h"

#include "OledI2C.h"
#include "cimg.h"


using namespace cimg_library;
//-------------------------------------------------------------------------

namespace 
{
	volatile static std::sig_atomic_t run = 1;
}


//-------------------------------------------------------------------------

static void
signalHandler(
    int signalNumber)
{
    switch (signalNumber)
    {
    case SIGINT:
    case SIGTERM:

        run = 0;
        break;
    };
}

int split(const std::string& s, const char* delim, std::vector<std::string>& a)
{
    const char* pdelim=delim;
    std::string st;
    std::istringstream ss(s);
    a.clear();
    while(*pdelim)
    {
        if(s.find(*pdelim)!=std::string::npos)
        {
            while (getline(ss, st, *pdelim))
            {
                a.push_back(st);
            }
            return a.size();
        }
        ++pdelim;
    }
    return 0;
}

//-------------------------------------------------------------------------
//CImg
void scanTemp( SSD1306::OledI2C& oled)
{
	static std::string prev;
	std::string current;
	std::vector<std::string> lines;
	std::ifstream s;
	std::string ss;

	s.open( "/tmp/oled", std::ios::in);
	if(s.is_open())
	{
		while(!s.eof())
		{
		    std::getline(s,ss);
		    current.append(ss);
		    lines.push_back(ss);
		    ss.clear();
		}
		s.close();
	}

	if(prev != current)
	{
		std::vector<std::string> tokens;
		prev = current;
		oled.clear();
		for(const auto& l : lines)
		{
			//1,2,3,l,c,string
			split(l, ",", tokens);
			if(tokens.size()==5 && tokens[0]=="T") // T|1|4|4|text
			{
				int font = ::atoi(tokens[1].c_str());
				int line = ::atoi(tokens[3].c_str());
				int row  = ::atoi(tokens[2].c_str());

				if(font<=1)
					drawString8x8(SSD1306::OledPoint{line, row},
		            	               tokens[4].c_str(),
		            	               SSD1306::PixelStyle::Set,
		            	               oled);
				else if(font==2)
					drawString8x12(SSD1306::OledPoint{line, row},
		            	               tokens[4].c_str(),
		            	               SSD1306::PixelStyle::Set,
		            	               oled);
				else if(font==3)
					drawString8x16(SSD1306::OledPoint{line, row},
		            	               tokens[4].c_str(),
		            	               SSD1306::PixelStyle::Set,
		            	               oled);
			}
			else if(tokens.size() == 6 && tokens[0]=="I") //I,X,Y,W,H,file.png
			{
/*
				int line = ::atoi(tokens[1].c_str());
				int row  = ::atoi(tokens[2].c_str());
				int w = ::atoi(tokens[3].c_str());
				int h  = ::atoi(tokens[4].c_str());
			        CImg<unsigned char> image(tokens[5].c_str()),
         			     gray(image.width(), image.height(), 1, 1, 0),
			             grayWeight(image.width(), image.height(), 1, 1, 0),
        			     imgR(image.width(), image.height(), 1, 3, 0),
			             imgG(image.width(), image.height(), 1, 3, 0),
        			     imgB(image.width(), image.height(), 1, 3, 0);
				
				cimg_forXY(image,x,y)
				{
					std::cout << x << y << "\n";
				        int R = (int)image(x,y,0,0);
    					int G = (int)image(x,y,0,1);
    					int B = (int)image(x,y,0,2);
					int grayValueWeight = (int)(0.299*R + 0.587*G + 0.114*B);
				}
*/
			}
		}
		oled.displayUpdate();
	}
}

//-------------------------------------------------------------------------

int main()
{
    try
    {
        constexpr std::array<int, 2> signals{SIGINT, SIGTERM};

        for (auto signal : signals)
        {
            if (std::signal(signal, signalHandler) == SIG_ERR)
            {
                std::string what{"installing "};
                what += strsignal(signal);
                what += " signal handler";

                throw std::system_error(errno,
                                        std::system_category(),
                                        what);
            }
        }

        SSD1306::OledI2C oled{"/dev/i2c-0", 0x3C};

        while (run)
        {
            scanTemp(oled);
            ::usleep(128000);
        }

        oled.clear();
        oled.displayUpdate();
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << "\n";
    }

    return 0;
}

How to mount Sdcard ISO images

 

Prerequisites

Linux on x86 PC
A sdcard image *.iso

We take as an example the volumio image retropie-4.4-rpi2_rpi3.img
To view the image partition we can use fdisk or parted
  • Using fdisk

Code: Select all

redypis> fdisk ./retropie-4.4-rpi2_rpi3.img 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): 
type p (print partition information)

Code: Select all

redypis> fdisk ./retropie-4.4-rpi2_rpi3.img 

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk ./retropie-4.4-rpi2_rpi3.img: 2.3 GiB, 2416967680 bytes, 4720640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf2d3cb4f

Device                        Boot  Start     End Sectors  Size Id Type
./retropie-4.4-rpi2_rpi3.img1 *      8192  124927  116736   57M  e W95 FAT16 (LBA)
./retropie-4.4-rpi2_rpi3.img2      124928 4718591 4593664  2.2G 83 Linux

Command (m for help): 

type q

What we see here are 3 partitions

Code: Select all

Device                        Boot  Start     End Sectors  Size Id Type
./retropie-4.4-rpi2_rpi3.img1 *      8192  124927  116736   57M  e W95 FAT16 (LBA)
./retropie-4.4-rpi2_rpi3.img2      124928 4718591 4593664  2.2G 83 Linux
We see here the LInux partition starting at block 124928 and ending at block 4718591. The size = end-start+1 -> 4593664
These offsets are inblock size. A block size has 512 bytes. Let's check this with parted.

Using parted

If the image was created form a much bigger sdcard than the OS size by using parted we
can resize the partitions to fit on a smaller sdcard

Let's type the following commands.

Code: Select all

redypis> info=$(parted -m ./retropie-4.4-rpi2_rpi3.img unit B print | grep ext4)
WARNING: You are not superuser.  Watch out for permissions.
redypis> echo $info
2:63963136B:2415919103B:2351955968B:ext4::;
redypis> 
The line we are interested in is the ext4.

Code: Select all

2:63963136B:2415919103B:2351955968B:ext4::;
  • 2 is the partition number. Is 2 because 1 is the boot fat partition
  • 63963136 is the start offset in bytes. This matches the fdisk information of start blocks multiplied with the block size (512 * 124928) = 63963136
  • 2351955968 is the end offset of the partition in bytes. The math verifies this. 2351955968/512 = 4593664 which matches the fdisk information
We can simply mount the Linux partition now on an arbitrary folder from the offset 63963136.

Code: Select all

sudo mount -o loop,offset=63963136 
redypis> mkdir somedir
redypis> sudo mount -oloop,offset=63963136 ./retropie-4.4-rpi2_rpi3.img ./somedir/
[sudo] password for marius: 
redypis> ls somedir/
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
redypis> 
We can add some files to the image and umount. This is valid if the os size is smaller than the sdcard image.
We can verify that with gparted.
For this we would have to make the partition a block device so that the gparted would be able to see it.

Prerequisites

Code: Select all

sudo apt-get update && sudo apt-get install dcfldd gparted
Find out latest loop device and bind it with the image from offset of the Linux partition.
Keep in mind the start of linux partition in bytes: 63963136

Code: Select all

redypis> losetup -f --show -o 63963136 ./retropie-4.4-rpi2_rpi3.img
/dev/loop20
redypis> 
  • That's loop20. Let's make a block disk

Code: Select all

redypis> e2fsck -p -f /dev/loop20
retropie: 104235/143712 files (0.1% non-contiguous), 534692/574208 blocks
  • Run gparted

Code: Select all

redypis> sudo gparted /dev/loop20
[sudo] password for marius: 
Unit -.mount does not exist, proceeding anyway.
======================
libparted : 3.2
======================


It looks like there is space beyond the end of the OS, so some files can be created on the mounted image.
The created file would be retained inside the iso/

Exit gparted and remove the loop device

Code: Select all

sudo losetup -d  /dev/loop20

If you would like to resize the image right to match the OS size use a very good script from.

https://www.matteomattei.com/how-to-shr ... up-images/
  • One change at this line

Code: Select all

INFO=$(resize2fs -P ${LOOPBACK} 2>&1)
SIZE=$(echo ${INFO} | awk -F': ' '{print $2}') 
SIZE=$((${SIZE} + 65535))   # instead 1K <<------------chnnge this

Bio: [size=50]https://www.matteomattei.com/h ... es/[/size]

ARM crosscompiler, CROSSCOMPILER vs CHROOT

 A toolchain is a set of compilers/linkers programs that allows you to build a binary on a
system with architecture A targeting architecture B.
Eg: building a raspberry PI program of a Linux PC of X86 architecture which would
run on a R_PI ARM architecture.

Linux chroot and qemu allows to switch the platform you are working on to another platform.

For a better understanding ;Ill use an example with a Beaglebone ARM architecture.
The platform I am using is a Linux OS (Ubuntu) running on a HP x86 architecture.
I would setup

  • A chroot into the Beagebone Linux OS (the procedure is similar for R-PI's and any other platforms)
  • A toochain for ARM targeting Beagebone

CHROOT & QEMU

Prerequisites
  • A beaglebone operating sdcard system image
  • qemu installed don the PC under Linux

Code: Select all

sudo apt-get install qemu
apt-get install binfmt-support qemu-user-static
update-binfmts --display
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install libc6:armhf
Download a known ARM Image like bone-debian-9.9-iot-armhf-2019-06-30-4gb from https://debian.beagleboard.org/images/
Uncompress it
Use this command to mount the image and copy the whole filesystem in ./rootfs

Code: Select all

./mount_iso.sh ./bone-debian-9.9-iot-armhf-2019-06-30-4gb.img ./mnt ./rootfs
mount_iso.sh file content

Code: Select all

#!/bin/bash

if [ -z "$(which parted 2> /dev/null)" ]; then
    echo "parted command not found. install parted"
    exit 1
fi

[[ ! $1 ]] && echo " expects image file as 1th  argument" && exit
[[ ! $2 ]] && echo " expects where to mount folder as 2th argument" && exit
[[ ! $3 ]] && echo " expects where to make the whole /  copy of the os as 3th argument" && exit

img=$1
info=$(parted -m $img unit B print | grep ext4)
echo $info
if [[ $info ]];then
    start=$(echo ${info} | awk -F':' '{print $2}')
    if [[ ! -z $start ]];then
        start=${start::-1}
#        echo "sudo mount -o loop,offset=${start} $img $2"
        sudo mount -o loop,offset=${start} $img $2
        sync
        if [[ -d $2/home ]];then 
            echo "so you want to make a copy of the os rootfs to $2 (y/n)"
            read yn
            [[ $yn == 'y' ]] && sudo rsync -rav $2/ $3
        fi
        sync
        sudo umount $2
    fi
fi
Use this script to chroot into the image.
It mounts all required folders and makes the network DNS from the PC being accessible

Code: Select all

#!/bin/bash

i=$(whoami)
[[ $i != 'root' ]] && echo  "run with sudo" && exit
[[ -z $1 ]] && echo "expects the rootfs file folder as first argument" && exit
ROOTFS=$1
[[ ! -f /usr/bin/qemu-arm-static ]] && echo "install qemu arm static please" && exit
[[ ! -f ./$ROOTFS/bin/qemu-arm-static  ]] && cp /usr/bin/qemu-arm-static ./$ROOTFS/usr/bin/qemu-arm-static

islink=$(readlink ./$ROOTFS/etc/resolv.conf)
echo $islink
if [[ -z ${islink} ]];then
    [[ -f ./$ROOTFS/etc/resolv.conf ]] && cp ./$ROOTFS/etc/resolv.conf ./$ROOTFS/etc/resolv.conf-old
    [[ -f /etc/resolv.conf ]] && cp /etc/resolv.conf ./$ROOTFS/etc/resolv.conf
else
    echo "resolf.conf is a symlink"
    rm ./$ROOTFS/etc/resolv.conf
    [[ -f /etc/resolv.conf ]] && cp /etc/resolv.conf ./$ROOTFS/etc/resolv.conf
fi

mount -t proc proc ./$ROOTFS/proc/
mount -t sysfs sys ./$ROOTFS/sys/
mount -o bind /dev ./$ROOTFS/dev/
mount --bind /dev/pts  ./$ROOTFS/dev/pts
echo "type exit to exit the chroot enviroment"
chroot ./$ROOTFS qemu-arm-static /bin/bash

if [[ -z $islink ]];then
    [[ -f ./$ROOTFS/etc/resolv.conf-old ]] && cp ./$ROOTFS/etc/resolv.conf-old ./$ROOTFS/etc/resolv.conf
else
    echo "restoring resolv.conf as a symlink to $islink"
    rm ./$ROOTFS/etc/resolv.conf
    ln -s ${islink}  ./$ROOTFS/etc/resolv.conf
fi

umount  ./$ROOTFS/dev/pts
umount ./$ROOTFS/dev/
umount ./$ROOTFS/sys/
umount ./$ROOTFS/proc/

Testing the chroot

Code: Select all

rp>sudo ./chroot.sh ./rootfs/
[sudo] password for marius: 
/run/connman/resolv.conf
resolf.conf is a symlink
type exit to exit the chroot enviroment
root@pc:/# 

root@pc:/# uname -a
Linux pc 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 armv7l GNU/Linux
root@pc:/# 

root@pc:/# ping redypis.org
PING redypis.org (173.249.22.226) 56(84) bytes of data.
64 bytes from vmi158535.contaboserver.net (173.249.22.226): icmp_seq=1 ttl=49 time=194 ms
64 bytes from vmi158535.contaboserver.net (173.249.22.226): icmp_seq=2 ttl=49 time=216 ms
64 bytes from vmi158535.contaboserver.net (173.249.22.226): icmp_seq=3 ttl=49 time=137 ms
^C
--- redypis.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 137.169/182.968/216.969/33.631 ms
root@pc:/# 

Build a program test. Start with some example that needs a dependency library which is not yet part of the BBB official release distro, like sqlite3 database.

The program

Code: Select all

#include <iostream>
#include <string>
#include <sqlite3.h>

int main(int n, char* s[])
{

    sqlite3     *db = nullptr;
    char         *szerr = 0;
    int err = sqlite3_open("./dbtest.sql", &db);
    std::string sql =  "CREATE TABLE IF NOT EXISTS MyTable (";
    sql += "Id integer primary key autoincrement,";
    sql += "Text TEXT NOT NULL,";
    sql += "DateTime DATETIME NOT NULL);";
    sqlite3_exec(db, sql.c_str(), 0, 0, &szerr);
    sqlite3_close(db);
    return 0;
}

  • let's compile it inside the chroot.

Code: Select all

root@pc:/home/debian# g++ ./test.cpp 
./test.cpp:5:21: fatal error: sqlite3.h: No such file or directory
 #include <sqlite3.h>
                     ^
compilation terminated.

Oops! ... the sqlite3 header is not found. Search on google the error line 'error: sqlite3.h: No such file or directory'
In the blast of answers the one that fixed our issue was t o install the sqlite3 database headers and libraries.
Yield this command at the shell inside chroot prompt

Code: Select all

root@pc:/home/debian# sudo apt-get update
...# all that output was deleted for clarity.
Get:13 http://deb.debian.org/debian stretch/main armhf Packages [6915 kB]        
Get:14 http://repos.rcn-ee.com/debian stretch/main armhf Packages [1037 kB]                                                                      
Fetched 8881 kB in 15s (584 kB/s)                                                                                                                
Reading package lists... Done
root@pc:/home/debian# 

root@pc:/home/debian# apt-get install libsqlite3-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  sqlite3-doc
The following NEW packages will be installed:
  libsqlite3-dev
0 upgraded, 1 newly installed, 0 to remove and 41 not upgraded.
Need to get 645 kB of archives.
After this operation, 1467 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian stretch/main armhf libsqlite3-dev armhf 3.16.2-5+deb9u1 [645 kB]
Fetched 645 kB in 0s (1678 kB/s)        
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_CA:en",
	LC_ALL = (unset),
	LANG = "en_CA.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package libsqlite3-dev:armhf.
(Reading database ... 41266 files and directories currently installed.)
Preparing to unpack .../libsqlite3-dev_3.16.2-5+deb9u1_armhf.deb ...
Unpacking libsqlite3-dev:armhf (3.16.2-5+deb9u1) ...
Setting up libsqlite3-dev:armhf (3.16.2-5+deb9u1) ...
root@pc:/home/debian# 
  • recompile again.

Code: Select all

root@pc:/home/debian# g++ ./test.cpp 
/tmp/cczBZIhx.o: In function `main':
test.cpp:(.text+0x1e): undefined reference to `sqlite3_open'
test.cpp:(.text+0x96): undefined reference to `sqlite3_exec'
test.cpp:(.text+0x9e): undefined reference to `sqlite3_close'
collect2: error: ld returned 1 exit status
root@pc:/home/debian# 
We have the headers for sqlite3 but we have to link with the sqlite3 library as well
Let's search for it in the lib folder of the rootfs

Code: Select all

root@pc:/home/debian# find /usr -name libsqlit*
/usr/share/doc/libsqlite3-0
/usr/share/doc/libsqlite3-dev
/usr/lib/arm-linux-gnueabihf/libsqlite3.a
/usr/lib/arm-linux-gnueabihf/libsqlite3.la
/usr/lib/arm-linux-gnueabihf/libsqlite3.so.0
/usr/lib/arm-linux-gnueabihf/libsqlite3.so.0.8.6
/usr/lib/arm-linux-gnueabihf/libsqlite3.so
The .a and or .so is the ones. We focus on libsqlite3.*
To add the library to g++ we use the linker flag '-l'
When we use -l flag to link a library we remove out the 'lib' prefix and the extension [lib]sqlite3[.a]
The flag would be '-lsqlite3'. We also add the out flag to generate out test binary program.

Code: Select all

root@pc:/home/debian# g++ ./test.cpp -lsqlite3 -o test
root@pc:/home/debian# ls
bin  test  test.cpp
root@pc:/home/debian# 
run the program

Code: Select all


root@pc:/home/debian# ./test
root@pc:/home/debian# ls
bin  dbtest.sql  test  test.cpp
root@pc:/home/debian# 

  • Success the database was created: dbtest.sql
We exit from the chroot, typing exit

Code: Select all

root@pc:/# exit
exit
restoring resolv.conf as a symlink to /run/connman/resolv.conf
rp>
we go into ./rootfs/home/debian and get the test program and we copy it onto a live BBB.
We installl on the live BBB the sqlite3 as well, then we can run our program ont he BBB.

TOOCHAIN CROSSCOMPILE ...

Beaglebone MUX PINS

 LINK

 php

bone.js  parser

https://redypis.mine.nu/addons/bb_pins.php

 

Reading I2C from C++ LINUX


Use i2cdetect to see if you have any devices.

I2C reading

Code: Select all


#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>

bool I2Cwrite(int reg_addr, uint8_t *reg_data, uint16_t length)
{

    int file = ::open("/dev/i2cfile", O_RDWR);
    if(file < 0)
    {
        return false;
    }
    int err = ioctl(file, I2C_SLAVE, _addr);
    if(err)
    {
        return false;
    }

    struct i2c_rdwr_ioctl_data packets;
    struct i2c_msg req[1];

    uint8_t buff[length + 1];
    buff[0] = reg_addr;
    uint16_t i;
    for ( i = 0; i < length; i++)
    {
        buff[i + 1] = reg_data[i];
        GLOG2(std::hex << int(buff[i]) << std::dec) ;
    }
    req[0].addr = _addr;
    req[0].flags = 0;
    req[0].len = length + 1;
    req[0].buf = buff;

    packets.msgs = req;
    packets.nmsgs = 1;
    if (ioctl(file, I2C_RDWR, &packets) < 0)
    {
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}

int  I2Cread(int reg_addr, uint8_t *reg_data, uint16_t length)
{
    int file = ::open("/dev/i2cdevice", O_RDWR);
    if(file < 0)
    {
        return 0;
    }
    int err = ioctl(file, I2C_SLAVE, _addr);
    if(err)
    {
        ::close(file);
        return 0;
    }

    struct i2c_rdwr_ioctl_data packets;
    struct i2c_msg req[2];

    req[0].addr = _addr;
    req[0].flags = 0;
    req[0].len = 1;
    req[0].buf = (__u8*)&reg_addr;

    req[1].addr = _addr;
    req[1].flags = I2C_M_RD;///* | I2C_M_NOSTART*/;
    req[1].len = length;
    req[1].buf = reg_data;

    packets.msgs = req;
    packets.nmsgs = 2;
    if (ioctl(file, I2C_RDWR, &packets) < 0)
    {
        ::close(file);
        return 0;
    }
    ::close(file);
    return length;
}





Code: Select all

#include <iostream>
#include <string>
#include <string.h>
#include <fstream>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#if defined (__linux__)
#   include <linux/i2c.h>
#   include <linux/i2c-dev.h>
#endif
#if defined (__FreeBSD__)
#   include <dev/iicbus/iic.h>
#endif

class I2CGen
{
public:
    I2CGen(const char* i2c, uint8_t addr, bool noerr=false):_sysfs(i2c),_addr(addr),_noerr(noerr){};
    ~I2CGen(){};
    bool write(uint16_t reg_addr, const uint8_t *reg_data, uint16_t length);
    bool read(uint16_t reg_addr, uint8_t *reg_data, uint16_t length);
    static void scan(const char* fn);
private:
    std::string     _sysfs;
    uint8_t         _addr;
	bool			_noerr;
};


#if defined (__linux__)
bool I2CGen::write(uint16_t reg_addr, const uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
		::perror("Failed to open i2c file");
        return false;
    }
    if(ioctl(file, I2C_SLAVE, _addr))
    {
		::perror("Failed to I2C_SLAVE i2c:");
        ::close(file);
        return false;

    }
    struct i2c_rdwr_ioctl_data pcks;
    struct i2c_msg mss[1];
    uint8_t buff[length + 1];
    buff[0] = reg_addr;
    ::memcpy(buff+ 1, reg_data, length);
    mss[0].addr = _addr;
    mss[0].flags = 0;
    mss[0].len = length + 1;
    mss[0].buf = buff;
    pcks.msgs = mss;
    pcks.nmsgs = 1;
    if (ioctl(file, I2C_RDWR, &pcks) < 0)
    {
		if(_noerr==false)        
	        perror("write");
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}

bool  I2CGen::read(uint16_t reg_addr, uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
		::perror("Failed to open i2c file");
        return false;
    }
    int err = ioctl(file, I2C_SLAVE, _addr);
    if(err)
    {
        if(_noerr==false)        
			perror("Failed I2C_SLAVE");
        ::close(file);
        return false;
    }

    struct i2c_rdwr_ioctl_data pcks;
    struct i2c_msg mss[2];
    //reg
    mss[0].addr = _addr;
    mss[0].flags = 0;
    mss[0].len = 1;
    mss[0].buf = (uint8_t*)&reg_addr;
    //data
    mss[1].addr = _addr;
    mss[1].flags = I2C_M_RD;///* | I2C_M_NOSTART*/;
    mss[1].len = length;
    mss[1].buf = reg_data;

    pcks.msgs = mss;
    pcks.nmsgs = 2;
    if (ioctl(file, I2C_RDWR, &pcks) < 0)
    {
        if(_noerr==false)        
			perror("read: failed to I2C_RDWR");
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}
#endif // __linux__

#if defined __FreeBSD__

bool I2CGen::write(uint16_t reg_addr, const uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
		::perror("Failed to open i2c file");
        return false;
    }
    uint8_t local[length+1] = {0};
    uint8_t addr = _addr << 1;
    uint8_t result[2] = {0,0};
    struct iic_msg msgs[3] = {{uint16_t(addr|IIC_M_WR), IIC_M_WR, (uint16_t)length+1, local},
                              {uint16_t(addr|IIC_M_RD), IIC_M_RD, (uint16_t)2, result}};
    struct iic_rdwr_data data = {msgs, 1};

    ::memcpy(local+1, reg_data, length);
    local[0] = (uint8_t)reg_addr;
    if (ioctl(file, I2CRDWR, &data) < 0)
    {
        if(_noerr==false)        
			::perror("/dev/iic2 I2CRDWR writing");
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}

bool  I2CGen::read(uint16_t reg_addr, uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
		::perror("Failed to open i2c file");
        return false;
    }
    uint8_t addr   = _addr << 1;
    uint8_t reg[1] = {reg_addr};
    struct iic_msg msgs[3] = {{uint16_t(addr|IIC_M_WR), IIC_M_WR, 1,     reg},
    						  {uint16_t(addr|IIC_M_RD), IIC_M_RD, length, reg_data}};
    struct iic_rdwr_data regsel = {&msgs[0], 1};
    struct iic_rdwr_data data   = {&msgs[1], 1};

    if (ioctl(file, I2CRDWR, &regsel) < 0)
    {
		if(_noerr==false)        
	        ::perror("/dev/iic2 I2CRDWR selecting register");
        ::close(file);
        return 0;
    }
    if (ioctl(file, I2CRDWR, &data) < 0)
    {
		if(_noerr==false)        
	        perror("/dev/iic2 I2CRDWR reading");
        ::close(file);
        return 0;
    }
    ::close(file);
    return 1;
}
#endif
void I2CGen::scan(const char* i2cdev)
{
	int col=0;
    std::cout << "scanning: " << i2cdev << "\n";

    for(uint8_t addr=0; addr<16;addr++)
	{
		printf("%02x   ",addr);
	}
	printf("\n%02x ",col++);			
    for(uint8_t addr=0x1; addr<0x80;addr++)
    {
        uint8_t dummy[2]={0,0};
        I2CGen  i2c(i2cdev, addr,true);

        if(i2c.read(0, dummy,2))
        {
            printf("0x%02x ",addr);
        }
		else
		{
			printf(".    ");
		}
		if(addr%16==0)
		{
			printf("\n%02x ",col++);
		}
    }
	printf("\n");
}

int main(int argc, char *argv[])
{
    if(argc==2)
    {
        I2CGen::scan(argv[1]);
    }
    else {
        std::cout << "pass the /dev/i2c* device\n";
    }
    return 0;
}


BeagleBone freeBSD UART2 UART4 UART1

 Currently I had to enable an extra UART on beaglebone for freeBSD.

I tried freeBSD13 cut for beaglebone and 11. I spent 3 days with no success. The dtb is kind of screwed.
Finally I end up on version 11 from here: https://download.freebsd.org/ftp/releas ... ONE.img.xz

The differences in am355 dts are here.
Also the pwm's on rail 9 which are not muxed with i2c's and spis are enabled.

Code: Select all

--- am335x-boneblack-original.dts	2019-09-17 03:01:54.545597000 +0000
+++ /boot/dtb/am335x-boneblack.dts	2019-09-20 17:23:14.379241000 +0000
@@ -812,6 +812,41 @@
 						phandle = <0x2d>;
 					};
 
+
+/*  mco-mco start */
+
+	ehrpwm2_pins {
+	        pinctrl-single,pins = <0x24 0x4 0x20 0x4>;
+	                linux,phandle = <0xcc>;
+                        phandle = <0xcc>;
+	};
+
+	ecap0_pins {
+	        pinctrl-single,pins = <0x164 0x7>;
+	        linux,phandle = <0xcb>;
+                phandle = <0xcb>;
+	};
+
+            pinmux_uart1_pins {
+                pinctrl-single,pins = <0x180 0x30 0x184 0x00>;
+                linux,phandle = <0xcf>;
+                phandle = <0xcf>;
+            };
+
+		    pinmux_uart2_pins {
+			pinctrl-single,pins = <0x150 0x21 0x154 0x01>;
+                        linux,phandle = <0xcd>;
+                        phandle = <0xcd>;
+		    };
+
+            pinmux_uart4_pins {
+                pinctrl-single,pins = <0x070 0x2e 0x074 0x06>; 
+                linux,phandle = <0xce>;
+                phandle = <0xce>;
+            };
+/*  mco-mco end */
+
+
 					pinmux_clkout2_pin {
 						pinctrl-single,pins = <0x1b4 0x3>;
 						linux,phandle = <0x20>;
@@ -1183,30 +1218,34 @@
 			phandle = <0x83>;
 		};
 
-		serial@48022000 {
+		serial@48022000 { 
 			compatible = "ti,am3352-uart", "ti,omap3-uart";
-			ti,hwmods = "uart2";
+			ti,hwmods = "uart2";  /* uart1 @ pins  mco-mco */
 			clock-frequency = <0x2dc6c00>;
 			reg = <0x48022000 0x2000>;
 			interrupts = <0x49>;
-			status = "disabled";
+			status = "okay";
 			dmas = <0x29 0x1c 0x0 0x29 0x1d 0x0>;
 			dma-names = "tx", "rx";
 			linux,phandle = <0x84>;
 			phandle = <0x84>;
+            pinctrl-names = "default"; /* mco-mco */
+            pinctrl-0 = <0xcf>; /* mco-mco */
 		};
 
-		serial@48024000 {
+		serial@48024000 { /* 48024000 */
 			compatible = "ti,am3352-uart", "ti,omap3-uart";
-			ti,hwmods = "uart3";
+			ti,hwmods = "uart3"; /*uart2*/
 			clock-frequency = <0x2dc6c00>;
 			reg = <0x48024000 0x2000>;
 			interrupts = <0x4a>;
-			status = "disabled";
+			status = "okay";
 			dmas = <0x29 0x1e 0x0 0x29 0x1f 0x0>;
 			dma-names = "tx", "rx";
 			linux,phandle = <0x85>;
 			phandle = <0x85>;
+            pinctrl-names = "default"; /* mco-mco */
+            pinctrl-0 = <0xcd>;        /* mco-mco */
 		};
 
 		serial@481a6000 {
@@ -1216,19 +1255,25 @@
 			reg = <0x481a6000 0x2000>;
 			interrupts = <0x2c>;
 			status = "disabled";
+			dmas = <0x29 0x1e 0x0 0x29 0x1f 0x0>;
+			dma-names = "tx", "rx";
 			linux,phandle = <0x86>;
 			phandle = <0x86>;
 		};
 
 		serial@481a8000 {
 			compatible = "ti,am3352-uart", "ti,omap3-uart";
-			ti,hwmods = "uart5";
+			ti,hwmods = "uart5"; /*uart4*/
 			clock-frequency = <0x2dc6c00>;
 			reg = <0x481a8000 0x2000>;
 			interrupts = <0x2d>;
-			status = "disabled";
+			status = "okay";
+			dmas = <0x29 0x1e 0x0 0x29 0x1f 0x0>;
+			dma-names = "tx", "rx";
 			linux,phandle = <0x87>;
 			phandle = <0x87>;
+			pinctrl-names = "default"; //mco-mco
+			pinctrl-0 = <0xce>; //mco-mco
 		};
 
 		serial@481aa000 {
@@ -1798,14 +1843,16 @@
 
 			ecap@48300100 {
 				compatible = "ti,am33xx-ecap";
-				#pwm-cells = <0x3>;
+				pwm-cells = <0x3>;
 				reg = <0x48300100 0x80>;
 				interrupts = <0x1f>;
 				interrupt-names = "ecap0";
 				ti,hwmods = "ecap0";
-				status = "disabled";
+				status = "okay";         // mco-mco GPIO 7
 				linux,phandle = <0xb2>;
 				phandle = <0xb2>;
+          		pinctrl-names = "default"; /* mco-mco */
+		        pinctrl-0 = <0xcb>;        /* mco-mco */
 			};
 
 			ehrpwm@48300200 {
@@ -1813,7 +1860,7 @@
 				#pwm-cells = <0x3>;
 				reg = <0x48300200 0x80>;
 				ti,hwmods = "ehrpwm0";
-				status = "disabled";
+				status = "disabled";     
 				linux,phandle = <0xb3>;
 				phandle = <0xb3>;
 			};
@@ -1881,9 +1928,11 @@
 				#pwm-cells = <0x3>;
 				reg = <0x48304200 0x80>;
 				ti,hwmods = "ehrpwm2";
-				status = "disabled";
+				status = "okay";        // mco-mco GPIO 22 and 23
 				linux,phandle = <0xb9>;
 				phandle = <0xb9>;
+	          		pinctrl-names = "default"; /* mco-mco */
+			        pinctrl-0 = <0xcc>;      /* mco-mco */
 			};
 		};
 
@@ -2228,7 +2277,15 @@
 		user_leds_s0 = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/user_leds_s0";
 		i2c0_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c0_pins";
 		i2c2_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c2_pins";
-		uart0_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_uart0_pins";
+
+        /* mco-mco { */
+        uart1_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_uart1_pins";
+        uart2_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_uart2_pins";
+        uart4_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_uart4_pins";
+
+        ehrpwm2_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/ehrpwm2_pins";
+        ecap0_pins = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/ecap0_pins";
+
 		clkout2_pin = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_clkout2_pin";
 		cpsw_default = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/cpsw_default";
 		cpsw_sleep = "/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/cpsw_sleep";
@@ -2352,3 +2409,4 @@
 		vmmcsd_fixed = "/fixedregulator@0";
 	};
 };
+
apply the patch to am335_boneblack.dts
compile it to dtb
if you are using bone green no wifi (does not boot on wifi one), make aside copy of the am335_boneblack.dtb as am335_bonegreen.dtb
After the reboot you will have following devices.

UART0 default one on UART0 pins always enabled by default /dv/cuau0
  • UART1 P9 24 - 26 /dev/cuau1
  • WHITE UART PORT ABOVE SDCARD /dev/cuau2
  • UART4 P9 11 - 13 /dev/cuau3

 

2.8 TFT SPI ILI-9341 Display R-PI and BBB

 

Purchased this display: ILI9341 2.8 inch SPI TFT LCD Display Touch Panel 240x320 with PCB


RPI


Wiring:

Code: Select all

Display--------- Raspberry Pi
BL-------------- pin 12 (GPIO 18)
SCK------------- pin 23 (GPIO 11)
MISO------------ pin 21 (GPIO 9)
MOSI------------ pin 19 (GPIO 10)
CS-------------- pin 24 (GPIO 8)
RST------------- pin 22 (GPIO 25)
D/C------------- pin 18 (GPIO 24)
VIN------------- pin 17 (3.3v)
GND------------- pin 20 (GND)
Drawbacks: No EGL on SPI so far. I guess I need a RGB bus.


Image

Then insert the driver

Code: Select all

sudo modprobe fbtft_device custom name=fb_ili9341  gpios=reset:25,dc:24,led:18 speed=16000000
Then activate

Code: Select all

con2fbmap 1 1


BBB

Edit /boot/uEnv.txt and make sure this line is not commented

Code: Select all

disable_uboot_overlay_video=1
reboot

Wiring

Code: Select all

FUNC----BBBFUNC-------- PX_##------DISP-------BBBGPIO----- ILI-9341  TFT
5 V     power          P9_5        Vin       IF  display has 3.3v power regulator (OR NEXT)
3 V     power          P9_3        Vin       IF  display has 3.3v power in (reg strapped)
GND     pin            P8_2        GND       GND PIN
CS      SPI0_CS0       P9_17       CS        GPIO 4
RESET   GPIO_60        P9_12       RST       GPIO 60
DC      GPIO_48        P9_15       D/C       GPIO 48
MOSI    SPI0_D1        P9_18       MOSI      SPI 0 D1
SCLK    SPI0_SCLK      P9_22       CLK       SPI 0 CLK  (GPIO_2)
BL/LED  power          3V          LED/BL    3.3V   (no led power for now)
MISO    SPI0_D0        P9_21       MISO      SPI 0 D0
Image


Init script

Code: Select all

bbb@beaglebone:~/autostart$ cat 2-spis.sh 
#!/bin/bash

sleep 4
config-pin P9.17 spi_cs
config-pin P9_18 spi
config-pin P9_21 spi
config-pin P9.22 spi_sclk

sudo modprobe fbtft_device custom busnum=1 name=fb_ili9341 gpios=reset:60,dc:48 speed=16000000
sleep 1
echo -n -e '\e[?17;14;0c' > /dev/tty0                          # no cursor
echo 0 > /sys/class/graphics/fbcon/cursor_blink                # no blink
echo -n -e  '\e[3J' > /dev/tty0                                # clear display
echo -n -e  'HELLO BBB' > /dev/tty0    

Insert Module

Code: Select all

sudo modprobe fbtft_device custom name=fb_ili9341  gpios=reset:60,dc:48,cs:4,clk:2,led:20 speed=16000000

Image

I2C C++ GENERIC CLASS FOR LINUX AND FREEBSD

 

Code: Select all

#include <iostream>
#include <string>
#include <string.h>
#include <fstream>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#if defined (__linux__)
#   include <linux/i2c.h>
#   include <linux/i2c-dev.h>
#endif
#if defined (__FreeBSD__)
#   include <dev/iicbus/iic.h>
#endif

class I2CGen
{
public:
    I2CGen(const char* i2c, uint8_t addr, bool noerr=false):_sysfs(i2c),_addr(addr),_noerr(noerr){};
    ~I2CGen(){};
    bool write(uint16_t reg_addr, const uint8_t *reg_data, uint16_t length);
    bool read(uint16_t reg_addr, uint8_t *reg_data, uint16_t length);
    static void scan(const char* fn);
private:
    std::string     _sysfs;
    uint8_t         _addr;
    bool			_noerr;
};


#if defined (__linux__)
bool I2CGen::write(uint16_t reg_addr, const uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
        ::perror("Failed to open i2c file");
        return false;
    }
    if(ioctl(file, I2C_SLAVE, _addr))
    {
        ::perror("Failed to I2C_SLAVE i2c:");
        ::close(file);
        return false;

    }
    struct i2c_rdwr_ioctl_data pcks;
    struct i2c_msg mss[1];
    uint8_t buff[length + 1];
    buff[0] = reg_addr;
    ::memcpy(buff+ 1, reg_data, length);
    mss[0].addr = _addr;
    mss[0].flags = 0;
    mss[0].len = length + 1;
    mss[0].buf = buff;
    pcks.msgs = mss;
    pcks.nmsgs = 1;
    if (ioctl(file, I2C_RDWR, &pcks) < 0)
    {
        if(_noerr==false)
            perror("write");
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}

bool  I2CGen::read(uint16_t reg_addr, uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
        ::perror("Failed to open i2c file");
        return false;
    }
    int err = ioctl(file, I2C_SLAVE, _addr);
    if(err)
    {
        if(_noerr==false)
            perror("Failed I2C_SLAVE");
        ::close(file);
        return false;
    }

    struct i2c_rdwr_ioctl_data pcks;
    struct i2c_msg mss[2];
    //reg
    mss[0].addr = _addr;
    mss[0].flags = 0;
    mss[0].len = 1;
    mss[0].buf = (uint8_t*)&reg_addr;
    //data
    mss[1].addr = _addr;
    mss[1].flags = I2C_M_RD;///* | I2C_M_NOSTART*/;
    mss[1].len = length;
    mss[1].buf = reg_data;

    pcks.msgs = mss;
    pcks.nmsgs = 2;
    if (ioctl(file, I2C_RDWR, &pcks) < 0)
    {
        if(_noerr==false)
            perror("read: failed to I2C_RDWR");
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}
#endif // __linux__

#if defined __FreeBSD__

bool I2CGen::write(uint16_t reg_addr, const uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
        ::perror("Failed to open i2c file");
        return false;
    }
    uint8_t local[length+1] = {0};
    uint8_t addr = _addr << 1;
    uint8_t result[2] = {0,0};
    struct iic_msg msgs[3] = {{uint16_t(addr|IIC_M_WR), IIC_M_WR, (uint16_t)length+1, local},
    {uint16_t(addr|IIC_M_RD), IIC_M_RD, (uint16_t)2, result}};
    struct iic_rdwr_data data = {msgs, 1};

    ::memcpy(local+1, reg_data, length);
    local[0] = (uint8_t)reg_addr;
    if (ioctl(file, I2CRDWR, &data) < 0)
    {
        if(_noerr==false)
            ::perror("/dev/iic2 I2CRDWR writing");
        ::close(file);
        return false;
    }
    ::close(file);
    return true;
}

bool  I2CGen::read(uint16_t reg_addr, uint8_t *reg_data, uint16_t length)
{
    int file = ::open(_sysfs.c_str(), O_RDWR);
    if(file < 0)
    {
        ::perror("Failed to open i2c file");
        return false;
    }
    uint8_t addr   = _addr << 1;
    uint8_t reg[1] = {reg_addr};
    struct iic_msg msgs[3] = {{uint16_t(addr|IIC_M_WR), IIC_M_WR, 1,     reg},
    {uint16_t(addr|IIC_M_RD), IIC_M_RD, length, reg_data}};
    struct iic_rdwr_data regsel = {&msgs[0], 1};
    struct iic_rdwr_data data   = {&msgs[1], 1};

    if (ioctl(file, I2CRDWR, &regsel) < 0)
    {
        if(_noerr==false)
            ::perror("/dev/iic2 I2CRDWR selecting register");
        ::close(file);
        return 0;
    }
    if (ioctl(file, I2CRDWR, &data) < 0)
    {
        if(_noerr==false)
            perror("/dev/iic2 I2CRDWR reading");
        ::close(file);
        return 0;
    }
    ::close(file);
    return 1;
}
#endif
void I2CGen::scan(const char* i2cdev)
{
    int col=0;
    std::cout << "scanning: " << i2cdev << "\n";

    for(uint8_t addr=0; addr<16;addr++)
    {
        printf("%02x   ",addr);
    }
    printf("\n%02x ",col++);
    for(uint8_t addr=0x1; addr<0x80;addr++)
    {
        uint8_t dummy[2]={0,0};
        I2CGen  i2c(i2cdev, addr,true);

        if(i2c.read(0, dummy,2))
        {
            printf("0x%02x ",addr);
        }
        else
        {
            printf(".    ");
        }
        if(addr%16==0)
        {
            printf("\n%02x ",col++);
        }
    }
    printf("\n");
}

int main(int argc, char *argv[])
{
    if(argc==2)
    {
        I2CGen::scan(argv[1]);
    }
    else {
        std::cout << "pass the /dev/i2c* device\n";
    }
    return 0;
}


Result for i2c display on I2C2.
Linux:
Image

0.96" I2C IIC SPI Serial 128X64 White OLED LCD LED

On Orange PI.


I took this repository

Code: Select all

https://github.com/bitbank2/oled_96
I don't remember doing some changes except the sample.c file.

Here is a _imgs/oled96.tar.gz having my changes for sample.c.

The sample.c file loops forever, trying to read the content of /tmp/oled
file each 30 ms or so. If the file has a content as:


Code: Select all

F,C,L,T\n<F,C,L,T\>
where
  • F - is font index 0 to 3 (0 large, 3 small)
  • C - is column position from 0 to whatever, depending of the font size
  • L - is line position, from 0 to whatever, depending of the font size
  • T - is the text to display.
Any other program can update the /tmp/oled file by putting data into it.

This cat would

Code: Select all

marius@orangepizero:~$ echo -e "1,0,0,line 1 \n2,2,3,line 23" > /tmp/oled
show this on the display.

Image

The wiring diagram


Image

and a picture of it

Image


on Beaglebone

Code: Select all

marius@beaglebone:~/oled/oled_bbb_bsd$ config-pin P9.19 i2c
marius@beaglebone:~/oled/oled_bbb_bsd$ config-pin P9.20 i2c
http://redypis.mine.nu/phpBB3/_imgs/oled_ ... ux.tar.gz

Run it:

Code: Select all

make
marius@beaglebone:~/oled/oled_bbb_bsd$ config-pin P9.19 i2c
marius@beaglebone:~/oled/oled_bbb_bsd$ config-pin P9.20 i2c
sudo ./sample 2 &
echo 2,2,2,sometext > /tmp/oled
Image

Image





Disclaimer: This post uses images from https://www.armbian.com/

Variscite Starter Kit VAR-6UL CustomBoard PINS

 Easy lookup pins.

Image

Image

Where GPIOX_Y means GPIO(BANK)_(BIT).
To find the gpio# apply

Code: Select all


      GPIO = (BANK-1)*32 + BIT
      

Qt Creator debug on Target Beagelbone

 Prerequisites:

  • Root file system Debian GNU/Linux 9 BeagleBoard.org Debian Image 2019-06-30
  • Beaglebone with same image on Sdcard
On BBB shell

Create a user for development
Deploy ssh login keys as

On Linux PC
  • create keys if you don't have them

Code: Select all

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):    leave it empty
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
On BBB deploy the keys
  • login to BBB with your debian/temppwd
  • create a new user, like: dev

Code: Select all

sudo adduser dev -s /bin/bash -m
sudo passwd dev   (add a password)
sudo adduser dev root
sudo adduser dev admin
sudo adduser dev sudo
sudo adduser dev i2c
sudo adduser dev gpio
sudo adduser dev pwm
sudo adduser dev dialout
sudo adduser dev spi
  • log out and log back to BBB over ssh with de user dev
On BBB shell

Code: Select all

       sudo apt-get install gdbserver
      mkdir -p .ssh
      nano authorized_keys
On PC another shell

Code: Select all

cd
nano ./.ssh/id_rsa.pub
# copy the content from id_rsa_pub  tp BBB /home/dev/.ssh/authorized_keys
Ctrl + O
sudo service sshd restart
sudo service ssh restart
  • log out from BBB, log back in to BBB. The password should not be asked
On PC, prepare the toolchain, qt, and ARM Beaglebone rootfs
On some arbitrary folder let's call it 'TOOLS' have the following things
Make sure you already have downloaded the toolchain and qt everywhere in some
arbitrary folders where you keep such things.
  • On PC let's have your base folder for future ARM projects. I call it ARMS
  • Under ARMS create a folder name TOOLS.
Navigate under tools and make some symbolic links. Here are mine

Code: Select all

ARMS├
     TOOLS
        ├── beaglebone      ->  /home/marius/HOMEBOARDS/BBG/debfs/
        ├── qteverywhere   ->  /home/marius/APPS/RPIQT/qt-everywhere-opensource-src-5.8.0
        └── toolchain          -> /sdaone/armgcc/
Fire up qtcreator

QT ADD KIT
Add a Device
  • Main Menu->Tools->Options
  • add a new device as shown. Replace the IP with your BBB IP
Image

Add a KIT called beaglebone
Image

Configure each tab settings as shown in following images. Replace the paths with your paths.

Image
Image

Add 2 new compilers C++ and C as shown
Image
Image

Configure the new kit as shown

Image

Apply.

At this stage you can create a new project under your folder.

Image


Compile it

Code: Select all

Project ERROR: Library 'libatomic' is not defined.
13:47:39: The process "/home/marius/HOMEBOARDS/BBG/qt5/qtbase/bin/qmake" exited with code 3.
Error while building/deploying project helobbb (kit: Beaglebone)
When executing step "qmake"
  • Let's fix it
  • Open the pro file from qt editor, and add what you see between ADD and END ADD

Code: Select all

# replace what's generated  with these
QT -= gui
QT -= core
QT -= gui

TEMPLATE = app

# ADD {
BOARD=beaglebone   # the root fs under TOOLS
PRO_PATH=$${PWD}
TUL_PATH=$${PWD}/..

QMAKE_LFLAGS = "-Wl,-rpath-link,$${TUL_PATH}/TOOLS/beaglebone/lib/arm-linux-gnueabihf,-rpath-link,$${TUL_PATH}/TOOLS/beaglebone/usr/lib/arm-linux-gnueabihf"
QMAKE_LIBDIR += $${TUL_PATH}/TOOLS/beaglebone/lib/arm-linux-gnueabihf
QMAKE_LIBDIR += $${TUL_PATH}/TOOLS/beaglebone/usr/lib/arm-linux-gnueabihf
# QMAKE_CXX.LIBDIRS = $${TUL_PATH}/TOOLS/beaglebone/lib/arm-linux-gnueabihf
# QMAKE_CXX.LIBDIRS = $${TUL_PATH}/TOOLS/beaglebone/usr/lib/arm-linux-gnueabihf

# END_ADD }

Then at the ens of the pro file before deploy section add

Code: Select all

SOURCES += \
        main.cpp

# ADD 
LIBS += --sysroot=$${TUL_PATH}/TOOLS/$${BOARD}/
#    LIBS += -L$${TUL_PATH}/TOOLS/$${BOARD}/usr/lib/arm-linux-gnueabihf -lsqlite3
LIBS += -L$${TUL_PATH}/TOOLS/$${BOARD}/usr/lib/arm-linux-gnueabihf -lpthread
LIBS += -L$${TUL_PATH}/TOOLS/$${BOARD}/usr/lib/arm-linux-gnueabihf -ldl
LIBS += -L$${TUL_PATH}/TOOLS/$${BOARD}/usr/lib/arm-linux-gnueabihf -lm
LIBS += "-Wl,-rpath-link,$${TUL_PATH}/TOOLS/$${BOARD}/lib/arm-linux-gnueabihf,-rpath-link,$${TUL_PATH}/TOOLS/$${BOARD}/usr/lib/arm-linux-gnueabihf"
# END ADD

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /tmp/$${TARGET}/bin   #### <<<<<<<<  have it in tmp
!isEmpty(target.path): INSTALLS += target

  • Then, Main Menu->build->run Qmake
  • Main Menu -> Build
  • Set a breakpoint
make sure on BBB y'u had: sudo apt-get install gdbserver
Image
  • Start Debugger F5
  • You should get the breakpoint stopped
Image



Jan 2020