summaryrefslogtreecommitdiffstats
path: root/meta-agl-core/conf/distro/poky-agl.conf
blob: cbb97c544fbe607bb3eaa82dc29420402e757e18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require conf/distro/poky.conf

# AGL specific derivations
DISTRO = "poky-agl"
DISTRO_NAME = "Automotive Grade Linux"


# Release flags
DISTRO_CODENAME = "lamprey"
AGL_BRANCH = "lamprey"
AGLVERSION = "12.1.8"
# switch  devel/release
#AGLRELEASETYPE ?= "agldevelopment"
AGLRELEASETYPE = "aglrelease"
OVERRIDES .= ":${AGLRELEASETYPE}"
#

#for development
DISTRO_VERSION:agldevelopment := "${AGLVERSION}+snapshot-${DATE}"
AGL_APP_REVISION:agldevelopment = "${AUTOREV}"
AGL_DEFAULT_REVISION:agldevelopment = "${AUTOREV}"

#for release
DISTRO_VERSION:aglrelease := "${AGLVERSION}"
DISTRO_BRANCH_VERSION_TAG = "${DISTRO_CODENAME}/${@'${DISTRO_VERSION}'.replace('+snapshot-${DATE}','')}"
AGL_APP_REVISION:aglrelease := "refs/tags/${DISTRO_BRANCH_VERSION_TAG}"
AGL_DEFAULT_REVISION:aglrelease := "refs/tags/${DISTRO_BRANCH_VERSION_TAG}"

# reproducible builds:
# enable the flag
BUILD_REPRODUCIBLE_BINARIES = "1"
# Set the desired timestamps
export SOURCE_DATE_EPOCH = "1671000000"
REPRODUCIBLE_TIMESTAMP_ROOTFS = "1671000000"
# inherit the class
INHERIT += "reproducible_build"


# SDK
SDK_VENDOR = "-aglsdk"

# SDKPATHINSTALL is the folder where the SDK is going to be installed
# Due to an issue with the qt5 environment (see SPEC-1667),
# we add DEFAULTTUNE to the SDKPATH to mitigate the issue.
SDKPATHINSTALL = "/opt/agl-sdk/${SDK_VERSION}-${DEFAULTTUNE}"


MAINTAINER = "AGL https://lists.automotivelinux.org/g/agl-dev-community"

TARGET_VENDOR = "-agl"

# Override these in poky based distros
AGL_DEFAULT_DISTRO_FEATURES = "largefile opengl wayland pam bluetooth bluez5 3g polkit"
POKY_DEFAULT_DISTRO_FEATURES := "${AGL_DEFAULT_DISTRO_FEATURES}"
OVERRIDES .= ":${DISTRO_CODENAME}"

DISTRO_FEATURES:remove = "x11"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "pulseaudio"

INIT_MANAGER = "systemd"
# Override default of "systemd-compat-units"
VIRTUAL-RUNTIME_initscripts = ""
# Override default of "busybox-syslog"
VIRTUAL-RUNTIME_base-utils-syslog = ""

# network manager to use (possible values: systemd, connman)
VIRTUAL-RUNTIME_net_manager = "connman"


QEMU_TARGETS ?= "arm aarch64 i386 x86_64 riscv64"
# Other QEMU_TARGETS "mips mips64 mips64el ppc sh4"

MIRRORS =+ "\
bzr://.*/.*      https://download.automotivelinux.org/AGL/mirror/ \n \
cvs://.*/.*      https://download.automotivelinux.org/AGL/mirror/ \n \
git://.*/.*      https://download.automotivelinux.org/AGL/mirror/ \n \
gitsm://.*/.*    https://download.automotivelinux.org/AGL/mirror/ \n \
hg://.*/.*       https://download.automotivelinux.org/AGL/mirror/ \n \
osc://.*/.*      https://download.automotivelinux.org/AGL/mirror/ \n \
p4://.*/.*       https://download.automotivelinux.org/AGL/mirror/ \n \
svn://.*/.*      https://download.automotivelinux.org/AGL/mirror/ \n \
bzr://.*/.*      http://download.automotivelinux.org/AGL/mirror/  \n \
cvs://.*/.*      http://download.automotivelinux.org/AGL/mirror/  \n \
git://.*/.*      http://download.automotivelinux.org/AGL/mirror/  \n \
gitsm://.*/.*    http://download.automotivelinux.org/AGL/mirror/  \n \
hg://.*/.*       http://download.automotivelinux.org/AGL/mirror/  \n \
osc://.*/.*      http://download.automotivelinux.org/AGL/mirror/  \n \
p4://.*/.*       http://download.automotivelinux.org/AGL/mirror/  \n \
svn://.*/.*      http://download.automotivelinux.org/AGL/mirror/  \n \
                 \
ftp://.*/.*      https://download.automotivelinux.org/AGL/mirror/ \n \
http://.*/.*     https://download.automotivelinux.org/AGL/mirror/ \n \
https://.*/.*    https://download.automotivelinux.org/AGL/mirror/ \n \
ftp://.*/.*      http://download.automotivelinux.org/AGL/mirror/  \n \
http://.*/.*     http://download.automotivelinux.org/AGL/mirror/  \n \
https://.*/.*    http://download.automotivelinux.org/AGL/mirror/  \n \
"

# The CONNECTIVITY_CHECK_URI's are used to test whether we can succesfully
# fetch from the network (and warn you if not). To disable the test set
# the variable to be empty.
# Git example url: git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=HEAD
CONNECTIVITY_CHECK_URIS ?= ""

# using multiple BSP layers causes dangling bbappends in meta-agl-bsp
# turn it into a warning
#BB_DANGLINGAPPENDS_WARNONLY = "1"

# Not yet upstreamed; should be submitted.
SECURITY_CFLAGS:pn-qtwebengine = "${SECURITY_NO_PIE_CFLAGS}"

#Redefined USER_CLASSES
#Disable prelink. It is unmaintained and likely will go away.
#default: USER_CLASSES ?= "buildstats image-mklibs image-prelink"
USER_CLASSES = "buildstats image-mklibs"

# AGL uses 4 optimization levels
# 2 for ARM 32bit 
#   - a high and a medium setting for the CCARGS
#   - the high setting is default (needs >= cortex-a15)
#   - the medium setting is enabled with: DISTRO_FEATURES:append = " agl-medium-arm-compiler "
# 1 for ARM 64bit / AARCH64
# 1 for x86-64
# 1 for RISC-V 64-bit
require conf/distro/include/${TARGET_ARCH}-tune.inc

# Generic qemu and qemuboot (runqemu) enhancements
# check qemuboot.bbclass
# - use 2G RAM by default
QB_MEM ?= "-m 2048"
# use pulseaudio on the host side - off as qemu-native is built with alsa
#QB_AUDIO_DRV = "pa"
# expose a virtual 'hda' sound card to the guest (arm/aarch64/x86-64)
QB_AUDIO_OPT = "-soundhw hda"

# Board templates can add extra IMAGE_FSTYPES through this.
# It is added (late) through the AGL image recipes.
AGL_EXTRA_IMAGE_FSTYPES ??= ""
AGL_EXTRA_INITRAMFS_FSTYPES ??= ""
#
# Default IMAGE FSTYPES wic.xz
AGL_DEFAULT_IMAGE_FSTYPES ?= "wic.xz wic.bmap wic.xz.sha256sum"
AGL_DEFAULT_IMAGE_FSTYPES:qemuall ?= "${@bb.utils.contains('DISTRO_FEATURES', 'AGLCI', 'ext4.xz', 'ext4', d)}"
AGL_DEFAULT_IMAGE_FSTYPES:append:netboot = " ${@bb.utils.contains('DISTRO_FEATURES', 'AGLCI', 'ext4.xz', 'ext4', d)}"
AGL_DEFAULT_INITRAMFS_FSTYPES ?= "ext4.gz"

# DEFAULT IMAGE_FSTYPES for AGL (no - BSPs should not set this)
#
IMAGE_FSTYPES = "${AGL_DEFAULT_IMAGE_FSTYPES} ${AGL_EXTRA_IMAGE_FSTYPES}"
INITRAMFS_FSTYPES = "${AGL_DEFAULT_INITRAMFS_FSTYPES} ${AGL_EXTRA_INITRAMFS_FSTYPES}"
#
# THE FUTURE is 'wic'
# IMAGE_FSTYPES:append = " wic"

# Complementary package definitions for agl-test-wgt and agl-devel-wgt
# image features
COMPLEMENTARY_GLOB[agl-test-wgt] = '*-test'
COMPLEMENTARY_GLOB[agl-devel-wgt] = '*-coverage *-debug'

# Fix for rpm metadata clash between nativesdk-cmake and nativesdk-qtbase-tools
# (revalidate after 2017-10-15, 2018-06-12: still required)
DIRFILES:pn-nativesdk-cmake = "1"

# For https://jira.automotivelinux.org/browse/SPEC-1629 :
# We exclude the conflicting vars from the sstate task hash.
# This needs to be verified.
do_package_write_rpm[vardepsexclude] += "ARCHIVER_TOPDIR PF"

# Set preferred provider to new navi application
PREFERRED_RPROVIDER_virtual/navigation ?= "ondemandnavi"

# Set preferred provider for low-can device mapping configuration
PREFERRED_RPROVIDER_virtual/low-can-dev-mapping ?= "dev-mapping"

# Mask upstream meta-security bbappend that interferes with non-linux-yocto
# kernels due to the bug of having two wildcards, which bitbake does not
# support. Not having it is not an issue, since there is also explicit
# enabling of required security features done by meta-agl/meta-security.
BBMASK += "meta-security/recipes-kernel/linux/linux-%_5.%.bbappend"

# Workaround for https://jira.automotivelinux.org/browse/SPEC-3621
# TLDR: do_image_wic will modify the target's /etc/fstab while
# do_image_tar and do_image_ext4 can run in parallel
# This needs to be fixed upstream:
# See https://bugzilla.yoctoproject.org/show_bug.cgi?id=13994
INHERIT += "image_types_wic_workaround"
http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define _GNU_SOURCE #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <net/if.h> #include <linux/can.h> #include <math.h> #include <json-c/json.h> #include <afb/afb-binding.h> #include <afb/afb-service-itf.h> // Uncomment this line to pass into can simulation mode //#define SIMULATE_HVAC #define CAN_DEV "vcan0" static const struct afb_binding_interface *interface; /*****************************************************************************************/ /*****************************************************************************************/ /** **/ /** **/ /** SECTION: UTILITY FUNCTIONS **/ /** **/ /** **/ /*****************************************************************************************/ /*****************************************************************************************/ /* * @brief Retry a function 3 times * * @param int function(): function that return an int wihtout any parameter * * @ return : 0 if ok, -1 if failed * */ static int retry( int(*func)()) { int i; for (i=0;i<4;i++) { if ( (*func)() >= 0) { return 0; } usleep(100000); } return -1; } /*****************************************************************************************/ /*****************************************************************************************/ /** **/ /** **/ /** SECTION: HANDLE CAN DEVICE **/ /** **/ /** **/ /*****************************************************************************************/ /*****************************************************************************************/ // Initialize CAN hvac array that will be sent trough the socket static struct { const char *name; uint8_t value; } hvac_values[] = { { "LeftTemperature", 21 }, { "RightTemperature", 21 }, { "Temperature", 21 }, { "FanSpeed", 0 } }; struct can_handler { int socket; struct sockaddr_can txAddress; }; static struct can_handler can_handler = { .socket = -1 }; static int open_can_dev() { #if defined(SIMULATE_HVAC) DEBUG(interface, "Defining can handler socket to 0 and return"); can_handler.socket = 0; return 0; #else struct ifreq ifr; DEBUG(interface, "CAN Handler socket : %d", can_handler.socket); close(can_handler.socket); can_handler.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW); if (can_handler.socket < 0) { ERROR(interface, "socket could not be created"); } else { // Attempts to open a socket to CAN bus strcpy(ifr.ifr_name, CAN_DEV); if(ioctl(can_handler.socket, SIOCGIFINDEX, &ifr) < 0) { ERROR(interface, "ioctl failed"); } else { can_handler.txAddress.can_family = AF_CAN; can_handler.txAddress.can_ifindex = ifr.ifr_ifindex; // And bind it to txAddress if (bind(can_handler.socket, (struct sockaddr *)&can_handler.txAddress, sizeof(can_handler.txAddress)) < 0) { ERROR(interface, "bind failed"); } else { return 0; } } close(can_handler.socket); can_handler.socket = -1; } return -1; #endif } // Get original get temperature function from cpp hvacplugin code static uint8_t to_can_temp(uint8_t value) { int result = ((0xF0 - 0x10) / 15) * value - 16; if (result < 0x10) result = 0x10; if (result > 0xF0) result = 0xF0; return (uint8_t)result; } static uint8_t read_temp_left_zone() { return hvac_values[0].value; } static uint8_t read_temp_right_zone() { return hvac_values[1].value; } static uint8_t read_temp() { return (uint8_t)(((int)read_temp_left_zone() + (int)read_temp_right_zone()) >> 1); } static uint8_t read_fanspeed() { return hvac_values[3].value; } static int write_can() { struct can_frame txCanFrame; int rc = 0; rc = can_handler.socket; if (rc >= 0) { // Hardcoded can_id and dlc (data lenght code) txCanFrame.can_id = 0x30; txCanFrame.can_dlc = 8; txCanFrame.data[0] = to_can_temp(read_temp_left_zone()); txCanFrame.data[1] = to_can_temp(read_temp_right_zone()); txCanFrame.data[2] = to_can_temp(read_temp()); txCanFrame.data[3] = 0xf0; txCanFrame.data[4] = read_fanspeed(); txCanFrame.data[5] = 1; txCanFrame.data[6] = 0; txCanFrame.data[7] = 0; DEBUG(interface, "%s: %d %d [%02x %02x %02x %02x %02x %02x %02x %02x]\n", #if defined(SIMULATE_HVAC) "FAKE CAN FRAME", #else "SENDING CAN FRAME", #endif txCanFrame.can_id, txCanFrame.can_dlc, txCanFrame.data[0], txCanFrame.data[1], txCanFrame.data[2], txCanFrame.data[3], txCanFrame.data[4], txCanFrame.data[5], txCanFrame.data[6], txCanFrame.data[7]); #if !defined(SIMULATE_HVAC) rc = sendto(can_handler.socket, &txCanFrame, sizeof(struct can_frame), 0, (struct sockaddr*)&can_handler.txAddress, sizeof(can_handler.txAddress)); if (rc < 0) { ERROR(interface, "Sending can frame failed. Attempt to reopen can device socket."); retry(open_can_dev); } #endif } else { ERROR(interface, "socket not initialized. Attempt to reopen can device socket."); retry(open_can_dev); } return rc; } /*****************************************************************************************/ /*****************************************************************************************/ /** **/ /** **/ /** SECTION: BINDING VERBS IMPLEMENTATION **/ /** **/ /** **/ /*****************************************************************************************/ /*****************************************************************************************/ /* * @brief Get fan speed HVAC system * * @param struct afb_req : an afb request structure * */ static void get_fanspeed(struct afb_req request) { json_object *ret_json; uint8_t fanspeed = read_fanspeed(); ret_json = json_object_new_object(); json_object_object_add(ret_json, "FanSpeed", json_object_new_int(fanspeed)); afb_req_success(request, ret_json, NULL); } /* * @brief Read Consign right zone temperature for HVAC system * * @param struct afb_req : an afb request structure * */ static void get_temp_right_zone(struct afb_req request) { json_object *ret_json; uint8_t temp = read_temp_right_zone(); ret_json = json_object_new_object(); json_object_object_add(ret_json, "RightTemperature", json_object_new_int(temp)); afb_req_success(request, ret_json, NULL); } /* * @brief Read Consign left zone temperature for HVAC system * * @param struct afb_req : an afb request structure * */ static void get_temp_left_zone(struct afb_req request) { json_object *ret_json; uint8_t temp = read_temp_left_zone(); ret_json = json_object_new_object(); json_object_object_add(ret_json, "LeftTemperature", json_object_new_int(temp)); afb_req_success(request, ret_json, NULL); } /* * @brief Read all values * * @param struct afb_req : an afb request structure * */ static void get(struct afb_req request) { DEBUG(interface, "Getting all values"); json_object *ret_json; ret_json = json_object_new_object(); json_object_object_add(ret_json, "LeftTemperature", json_object_new_int(read_temp_left_zone())); json_object_object_add(ret_json, "RightTemperature", json_object_new_int(read_temp_right_zone())); json_object_object_add(ret_json, "FanSpeed", json_object_new_int(read_fanspeed())); afb_req_success(request, ret_json, NULL); } /* * @brief Set a component value using a json object retrieved from request * * @param struct afb_req : an afb request structure * */ static void set(struct afb_req request) { int i, rc, x, changed; double d; struct json_object *query, *val; uint8_t values[sizeof hvac_values / sizeof *hvac_values]; uint8_t saves[sizeof hvac_values / sizeof *hvac_values]; /* records initial values */ DEBUG(interface, "Records initial values"); i = (int)(sizeof hvac_values / sizeof *hvac_values); while (i) { i--; values[i] = saves[i] = hvac_values[i].value; } /* Loop getting arguments */ query = afb_req_json(request); changed = 0; i = (int)(sizeof hvac_values / sizeof *hvac_values); DEBUG(interface, "Looping for args. i: %d", i); while (i) { i--; DEBUG(interface, "Searching... query: %s, i: %d, comp: %s", json_object_to_json_string(query), i, hvac_values[i].name); if (json_object_object_get_ex(query, hvac_values[i].name, &val)) { DEBUG(interface, "We got it. Tests if it is an int or double."); if (json_object_is_type(val, json_type_int)) { x = json_object_get_int(val); DEBUG(interface, "We get an int: %d",x); } else if (json_object_is_type(val, json_type_double)) { d = json_object_get_double(val); x = (int)round(d); DEBUG(interface, "We get a double: %f => %d",d,x); } else { afb_req_fail_f(request, "bad-request", "argument '%s' isn't integer or double", hvac_values[i].name); return; } if (x < 0 || x > 255) { afb_req_fail_f(request, "bad-request", "argument '%s' is out of bounds", hvac_values[i].name); return; } if (values[i] != x) { values[i] = (uint8_t)x; changed = 1; DEBUG(interface,"%s changed to %d",hvac_values[i].name,x); } } else { DEBUG(interface, "%s not found in query!",hvac_values[i].name); } } /* attemps to set new values */ DEBUG(interface, "Diff: %d", changed); if (changed) { i = (int)(sizeof hvac_values / sizeof *hvac_values); while (i) { i--; hvac_values[i].value = values[i]; } rc = write_can(); if (rc >= 0) afb_req_success(request, NULL, NULL); else if (retry(write_can)) { /* restore initial values */ i = (int)(sizeof hvac_values / sizeof *hvac_values); while (i) { i--; hvac_values[i].value = saves[i]; } afb_req_fail(request, "error", "CAN error"); } } else { afb_req_success(request, NULL, "No changes"); } } // TODO: Have to change session management flag to AFB_SESSION_CHECK to use token auth static const struct afb_verb_desc_v1 verbs[]= { {"get_temp_left_zone" , AFB_SESSION_NONE, get_temp_left_zone , "Get the left zone temperature"}, {"get_temp_right_zone" , AFB_SESSION_NONE, get_temp_right_zone , "Get the right zone temperature"}, {"get_fanspeed" , AFB_SESSION_NONE, get_fanspeed , "Read fan speed"}, {"get" , AFB_SESSION_NONE, get , "Read all values"}, {"set" , AFB_SESSION_NONE, set , "Set a HVAC component value"}, {NULL} }; static const struct afb_binding binding_desc = { .type = AFB_BINDING_VERSION_1, .v1 = { .info = "hvac service", .prefix = "hvac", .verbs = verbs } }; const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *itf) { interface = itf; return &binding_desc; } int afbBindingV1ServiceInit(struct afb_service service) { return retry(open_can_dev); }