AACS icon indicating copy to clipboard operation
AACS copied to clipboard

Pi4 potential?

Open paulhothersall opened this issue 3 years ago • 38 comments

The USB-C connection has full OTG support, and the hardware is "reasonable" with 2,4,8GB ram options.

Have hardware, and happy to help support / test

paulhothersall avatar Feb 21 '21 07:02 paulhothersall

RPi4 indeed should work. Great, please follow the steps from doc/INSTALL.md file. I do not expect any major differences, except maybe getting kernel 5.4.x+ ready. Please report any questions/issues encountered here and I will do my best to help. When actually running AACS openauto will be useful for initial testing so please have it ready on your PC.

tomasz-grobelny avatar Feb 21 '21 21:02 tomasz-grobelny

I have openauto PRO (licensed) on a pi3, and also crankshaft.

Both of those work as head units from a stock pixel setup

starting setting up with a ubuntu 20.10 arm64b server first. I will fallback to raspbian (aka raspberry pi OS) if i have issues with the USB OTG part.

paulhothersall avatar Feb 21 '21 21:02 paulhothersall

First basic check would be to verify existence of /sys/kernel/config/usb_gadget and contents of /sys/class/udc after libcomposite kernel module is loaded.

tomasz-grobelny avatar Feb 21 '21 22:02 tomasz-grobelny

the Pi4 2GB Ram version REALLY doesn't like building anbox! I could make a coffee on the CPU. Even the uSD card gets hot from IO thrashing, so dropping that back to single thread building

paulhothersall avatar Feb 21 '21 22:02 paulhothersall

To test AACS alone you could skip anbox for now - this one is used only for running OsmAnd navigation.

tomasz-grobelny avatar Feb 21 '21 23:02 tomasz-grobelny

good point,

a lightweight "video stream only" --> head unit is a thought I have right now possible by having the hardware encoder on the pi4 even taking the framebuffer (some optimisation on the GST chain to not then software decode/size/encode)

paulhothersall avatar Feb 21 '21 23:02 paulhothersall

/home/ubuntu/AA/AACS/AAServer/include/InputChannelHandler.h:14:8: error: ‘set’ in namespace ‘std’ does not name a template type 14 | std::set registered_clients; | ^~~ /home/ubuntu/AA/AACS/AAServer/include/InputChannelHandler.h:6:1: note: ‘std::set’ is defined in header ‘’; did you forget to ‘#include ’? 5 | #include "ChannelHandler.h" +++ |+#include 6 | #include [ 89%] Building CXX object AAServer/CMakeFiles/AAServer.dir/MediaChannelSetupResponse.pb.cc.o [ 89%] Building CXX object AAServer/CMakeFiles/AAServer.dir/Channel.pb.cc.o /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp: In member function ‘void InputChannelHandler::sendHandshakeRequest()’: /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp:29:43: warning: ‘int google::protobuf::MessageLite::ByteSize() const’ is deprecated: Please use ByteSizeLong() instead [-Wdeprecated-declarations] 29 | int bufSize = handshakeRequest.ByteSize(); | ^ In file included from /usr/include/google/protobuf/generated_enum_util.h:36, from /usr/include/google/protobuf/map.h:55, from /usr/include/google/protobuf/generated_message_table_driven.h:34, from /home/ubuntu/AA/AACS/build/AAServer/InputChannel.pb.h:26, from /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp:4: /usr/include/google/protobuf/message_lite.h:420:7: note: declared here 420 | int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); } | ^~~~~~~~ /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp: In member function ‘virtual bool InputChannelHandler::handleMessageFromHeadunit(const Message&)’: /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp:56:24: error: ‘registered_clients’ was not declared in this scope 56 | for (auto &&rc : registered_clients) | ^~~~~~~~~~~~~~~~~~ /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp: In member function ‘virtual bool InputChannelHandler::handleMessageFromClient(int, uint8_t, bool, const std::vector&)’: /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp:69:3: error: ‘registered_clients’ was not declared in this scope 69 | registered_clients.insert(clientId); | ^~~~~~~~~~~~~~~~~~ /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp: In member function ‘virtual void InputChannelHandler::disconnected(int)’: /home/ubuntu/AA/AACS/AAServer/src/InputChannelHandler.cpp:78:3: error: ‘registered_clients’ was not declared in this scope 78 | registered_clients.erase(clientId); | ^~~~~~~~~~~~~~~~~~

paulhothersall avatar Feb 21 '21 23:02 paulhothersall

The error message is quite informative :-) Try adding #include <set> in InputChannelHandler.h - for some reason for me it works without this one, but it should be there.

tomasz-grobelny avatar Feb 21 '21 23:02 tomasz-grobelny

#include

worked, and RealWorld™ in the way of any more setup for next few hours. will let you know how I get on later

paulhothersall avatar Feb 21 '21 23:02 paulhothersall

ok, ubuntu and OTG stuff seems "interesting". So AAServer can't find USB to use etc

Using raspberry pi OS seems easier for that, however, I can't build with cmake

-- Checking for module 'gstreamer-base-1.0' -- Found gstreamer-base-1.0, version 1.14.4 -- Checking for module 'libusbgx' -- Found libusbgx, version 0.2.0 -- Checking for module 'libpcap' -- No package 'libpcap' found CMake Error at /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message): A required package was not found Call Stack (most recent call first): /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal) CMakeLists.txt:13 (pkg_check_modules)

I know libpcap (inc dev) is installed

ls /usr/lib/arm-linux-gnueabihf/ | grep pcap

libpcap.a libpcap.so libpcap.so.0.8 libpcap.so.1.8.1

build and install from source works ..

will try testing tomorrow

paulhothersall avatar Feb 22 '21 06:02 paulhothersall

Looks to me like pkgconfig file might be missing:

# dpkg -S  `find /usr -name libpcap.pc`
libpcap0.8-dev:arm64: /usr/lib/aarch64-linux-gnu/pkgconfig/libpcap.pc
#

I would call it libpcap packaging issue on your system.

tomasz-grobelny avatar Feb 22 '21 21:02 tomasz-grobelny

Yeah. It will pass that with a manual libpcap build . The base raspberry Pi OS is still 32bit !

paulhothersall avatar Feb 22 '21 23:02 paulhothersall

hmm

/AACS/build/AAServer $ sudo ./AAServer

Got 51, write=2 Got 51, write=2 Got 51, write=2 Got some info: 0= Got some info: 0= Got some info: 0= Got some info: 1=Android Auto Got some info: 1=Android Auto Got some info: 1=Android Auto Got some info: 2=Android Auto Got some info: 2=Android Auto Got some info: 2=Android Auto Got some info: 3= Got some info: 3= Got some info: 3= Got some info: 4=https://f1xstudio.com Got some info: 4=https://f1xstudio.com Got some info: 4=https://f1xstudio.com Got some info: 5=HU-AAAAAA001 Got some info: 5=HU-AAAAAA001 Got some info: 5=HU-AAAAAA001 Got 53, exit DefaultChannelHandler: 0 dumpfile: ep0 event 0 ep0 event 2 got version request version negotiation ok auth complete got service discovery response channels { channel_id: 7 media_input_channel { stream_type: Audio audio_config { sample_rate: 16000 bits_per_sample: 16 channel_count: 1 } } } channels { channel_id: 6 media_channel { media_type: Audio 2: 2 3 { 1: 16000 2: 16 3: 1 } 5: 1 } } channels { channel_id: 1 input_channel { available_buttons: ENTER available_buttons: LEFT available_buttons: RIGHT available_buttons: UP available_buttons: DOWN available_buttons: BACK available_buttons: HOME available_buttons: PHONE available_buttons: CALL_END available_buttons: PLAY available_buttons: PAUSE available_buttons: PREV available_buttons: TOGGLE_PLAY available_buttons: NEXT available_buttons: MICROPHONE_1 available_buttons: SCROLL_WHEEL available_buttons: SCROLL_WHEEL screen_config { width: 800 height: 452 } 1: 65537 1: 65538 1: 65540 } } channels { channel_id: 2 sensor_channel { sensors { type: DrivingStatus } sensors { type: NightData } sensors { type: Location } } } channels { channel_id: 3 media_channel { media_type: Video 4 { 1: 1 2: 2 5: 140 } 5: 1 } } 2: "OpenAuto Pro" 3: "Universal" 4: "2018" 5: "20180301" 6: 1 7: "BlueWave Studio" 8: "OpenAuto Pro Autoapp" 9: "1" 10: "1.0" 11: 1

DefaultChannelHandler: 7 DefaultChannelHandler: 6 InputChannelHandler: 1 DefaultChannelHandler: 2 VideoChannelHandler: 3 Error: Unhandled message type: 11

paulhothersall avatar Feb 25 '21 05:02 paulhothersall

Looks like unimplemented feature. 11 is MessageType::PingRequest sent by headunit and AACS should probably send PingResponse. In my setup the headunit did not send ping request so I have no way to test. Therefore this is a first opportunity to implement a feature in AAServer :-) Shouldn't be too complicated, best to start with sniffing transmission between your Openauto headunit and phone to see how the phone replies. Or analyze openauto source code to see what it expects.

tomasz-grobelny avatar Feb 25 '21 10:02 tomasz-grobelny

I have an idea, I can setup a couple of pi4, 1 with ubuntu arm64, and the other with raspberry pi os ( armv7 / armmhf / 32 bit) such they can be remote connected to for any remote debugging ?

and given the 32 bit seems to work, at least before the last error of unexpected messageType, I can throw a piZeroW in as well. whilst a (very) slow CPU, its hot hardware h264 decode and encode to take for example a cast or sinked video source to it to onward send (transcode) to the head unit. so airplay / chromecast for media could both be options!

paulhothersall avatar Feb 25 '21 16:02 paulhothersall

very interesting project, I was wondering if I can test on PI zero, got one in hand and ready to play with it.

Is there some sort of image that I can use directly?

samehhady avatar Feb 25 '21 18:02 samehhady

Would love to see the posibility to open web page on the screen, lots of ideas can be implemented in that case

samehhady avatar Feb 25 '21 18:02 samehhady

I have an idea, I can setup a couple of pi4, 1 with ubuntu arm64, and the other with raspberry pi os ( armv7 / armmhf / 32 bit) such they can be remote connected to for any remote debugging ?

You could try. I have some doubts how this would work for remote debugging given there will be no possibility to disconnect USB cable or reset/see/interact with headunit - or would that be an option as well?

tomasz-grobelny avatar Feb 25 '21 22:02 tomasz-grobelny

Would love to see the posibility to open web page on the screen, lots of ideas can be implemented in that case

My idea was to go for electronjs app, I even started fiddling with it (do not expect anything end-user ready anytime soon). It would also be great to have possibility to launch new apps and switch between apps dynamically - that however requires kind of 'gstreamer router' - I haven't investigated that yet though.

tomasz-grobelny avatar Feb 25 '21 22:02 tomasz-grobelny

I have an idea, I can setup a couple of pi4, 1 with ubuntu arm64, and the other with raspberry pi os ( armv7 / armmhf / 32 bit) such they can be remote connected to for any remote debugging ?

You could try. I have some doubts how this would work for remote debugging given there will be no possibility to disconnect USB cable or reset/see/interact with headunit - or would that be an option as well?

I can easily have HDMI capture connected back to the USB , so it's easy to frame grab or restream what's going on, even remotely.

And at least on the primary usb A ports on the raspberry Pi, possible on all, to disable and re enable data. Essentially the same as physically inserting cables.

With a small caveat on one particular port that you have to disable the whole hub only, it can be done on an individual port level.

paulhothersall avatar Feb 25 '21 22:02 paulhothersall

Would love to see the posibility to open web page on the screen, lots of ideas can be implemented in that case

My idea was to go for electronjs app, I even started fiddling with it (do not expect anything end-user ready anytime soon). It would also be great to have possibility to launch new apps and switch between apps dynamically - that however requires kind of 'gstreamer router' - I haven't investigated that yet though.

Depending on the device,, extracting the GPU framebuffer maybe "all" that's needed.

The pi is quite capable of doing it, so whatever is rendered to it's (headless) concept of the display can be forwarded to the head unit (GStreamer)

I should have some time later to do a setup. I could message you directly with details of login etc etc for it?

paulhothersall avatar Feb 25 '21 22:02 paulhothersall

Depending on the device,, extracting the GPU framebuffer maybe "all" that's needed.

I bet it is not very complicated - it just requires time for someone to test/implement/describe it :-) For sure it should be done outside AAServer and I am wondering whether some solution already exists. Currently window contents of anbox+OsmAnd is sent to AAServer using ximagesrc plugin. What need to be done is an app that would dynamically switch video streams sent to AAServer and direct events received from AAServer to correct application.

As for login data - sure, my mail is publicly available on github.

tomasz-grobelny avatar Feb 25 '21 23:02 tomasz-grobelny

Hello @tomasz-grobelny , i managed to setup openauto on my linux laptop in order to test AAC. I can run autoapp with QtCreator, and first i wanted to try openauto with my phone. When connecting my phone to laptop via USB, video stream cannot start and i get:

Warning: "No decoder available for type 'video/x-h264, stream-format=(string)byte-stream'."
Error: "Your GStreamer installation is missing a plug-in."
appsrc: push buffer wrong state
appsrc: push buffer wrong state
appsrc: push buffer wrong state
appsrc: push buffer wrong state
...

Did you encountered this error as well? If so how did you fixed it?

adrianalin avatar Mar 01 '21 12:03 adrianalin

I do not recall anything like that, but my first thought would be to install all available packages with gstreamer plugins on your system (good, bad, ugly, etc.).

tomasz-grobelny avatar Mar 01 '21 17:03 tomasz-grobelny

Thank you, got it working after i installed gst-plugins-bad.

adrianalin avatar Mar 02 '21 06:03 adrianalin

Hello, I managed to build a yocto image for Raspberry Pi4 which run AAServer. You can check it out here https://github.com/adrianalin/meta-aacs

adrianalin avatar Mar 07 '21 12:03 adrianalin

That's great :-) I was thinking of some kind of build image automation, but wasn't aware of yocto. Do you think it makes sense to have the yocto build definition in AACS repository or are you planning to maintain separate repository with AACS image definition? Also, I see you disabled GetEvents - any particular reason for that? X11 dependency? Any plans to work on that in the future?

Getting back to reading about yocto and trying your work.

tomasz-grobelny avatar Mar 07 '21 19:03 tomasz-grobelny

$ git remote -v
origin  https://github.com/adrianalin/csng_yocto.git (fetch)
origin  https://github.com/adrianalin/csng_yocto.git (push)
$ git branch -v
* aacs-image 63911fc Add image for building aacs.
  main       aec3884 Local audio on jack;
$ bitbake aacs-image
ERROR: no recipe files to build, check your BBPATH and BBFILES?
NOTE: Cache: default: Not using a cache. Set CACHE = <directory> to enable.
Loading cache: 100% |                                                                                                 | ETA:  --:--:--
Loaded 0 entries from dependency cache.
ERROR: Nothing PROVIDES 'aacs-image'

Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
$ cd images/
$ bitbake aacs-image
NOTE: Cache: default: Not using a cache. Set CACHE = <directory> to enable.
Loading cache: 100% |                                                                                                 | ETA:  --:--:--
Loaded 0 entries from dependency cache.
Parsing recipes: 100% |################################################################################################| Time: 0:00:00
Parsing of 4 .bb files complete (0 cached, 4 parsed). 4 targets, 0 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |#############################################################################################| Time: 0:00:00
NOTE: No setscene tasks
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.
$

Being new to yocto I am probably missing something simple.

UPDATE: reading more and more about yocto there is some progress with the build as well...

tomasz-grobelny avatar Mar 07 '21 19:03 tomasz-grobelny

That's great :-) I was thinking of some kind of build image automation, but wasn't aware of yocto. Do you think it makes sense to have the yocto build definition in AACS repository or are you planning to maintain separate repository with AACS image definition? Also, I see you disabled GetEvents - any particular reason for that? X11 dependency? Any plans to work on that in the future?

Getting back to reading about yocto and trying your work.

Regarding separate repo i'm not sure i can maintain one for long time. Anyway the yocto layer (which will contain the AACS recipe) will have to be separate from the source code, not in the AACS repository.

Will try to build with X11 as well, and enable back GstEvents.

adrianalin avatar Mar 08 '21 05:03 adrianalin

$ git remote -v
origin  https://github.com/adrianalin/csng_yocto.git (fetch)
origin  https://github.com/adrianalin/csng_yocto.git (push)
$ git branch -v
* aacs-image 63911fc Add image for building aacs.
  main       aec3884 Local audio on jack;
$ bitbake aacs-image
ERROR: no recipe files to build, check your BBPATH and BBFILES?
NOTE: Cache: default: Not using a cache. Set CACHE = <directory> to enable.
Loading cache: 100% |                                                                                                 | ETA:  --:--:--
Loaded 0 entries from dependency cache.
ERROR: Nothing PROVIDES 'aacs-image'

Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
$ cd images/
$ bitbake aacs-image
NOTE: Cache: default: Not using a cache. Set CACHE = <directory> to enable.
Loading cache: 100% |                                                                                                 | ETA:  --:--:--
Loaded 0 entries from dependency cache.
Parsing recipes: 100% |################################################################################################| Time: 0:00:00
Parsing of 4 .bb files complete (0 cached, 4 parsed). 4 targets, 0 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |#############################################################################################| Time: 0:00:00
NOTE: No setscene tasks
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.
$

Being new to yocto I am probably missing something simple.

UPDATE: reading more and more about yocto there is some progress with the build as well...

Be aware that a yocto build may take quite a long time. The repo i prepared is actually just a layer for yocto, so you need to download all the other layers and prepare the layer directories yourself (see bblayers.conf). After that you also need to source poky/oe-init-build-env build/

This is how my layers directories look on my side (notice csng_yocto layer which contains the aacs recipes):

image

adrianalin avatar Mar 08 '21 05:03 adrianalin