Kconfig and select to get predefined and editable configurations? - kbuild

I want to provide a Kconfig / menuconfig configuration for an implementation. I'm using the toolchain from Espressif ESP-IDF 3.3, but it seems not to be related with the toolchain. I want to have a minimum resulting sdkconfig file without any additional "helper" symbols.
The user should either use (a) a predefined configuration option or choose (b) to set all values by himself.
Here is my current Kconfig code:
menu "Test"
choice PREDEFINED
prompt "Select predefined configuration"
default PREDEF_NONE
config PREDEF_NONE
bool "None"
config PREDEF_OPT_A
bool "Option A"
select BOARD_A
select FEATURE_A
config PREDEF_OPT_B
bool "Option B"
select BOARD_B
select FEATURE_B
endchoice
menu "Submenu"
visible if PREDEF_NONE
choice
prompt "Select Board"
config BOARD_A
bool "Board A"
config BOARD_B
bool "Board B"
endchoice
choice
prompt "Select Feature"
config FEATURE_A
bool "Board A"
config FEATURE_B
bool "Board B"
endchoice
endmenu
endmenu
If the predefined option A is chosen, the submenu should not be visible (this is working) and the resulting sdkconfig created by make menuconfig using this Kconfig file should read like this:
#
# Test
#
CONFIG_PREDEF_NONE=
CONFIG_PREDEF_OPT_A=y
CONFIG_PREDEF_OPT_B=
#
# Submenu
#
CONFIG_BOARD_A=y
CONFIG_BOARD_B=
CONFIG_FEATURE_A=y
CONFIG_FEATURE_B=
but I get only the first three lines
#
# Test
#
CONFIG_PREDEF_NONE=
CONFIG_PREDEF_OPT_A=y
CONFIG_PREDEF_OPT_B=
When I choose PREDEF_NONE and set the values in the Submenu manually, everything is fine.
Any idea on how to proceed or what's wrong here?
Regards
Andreas

It's a example:
choice SPI_HOST
prompt "SPI HOST"
default USE_SPI3_HOST
config USE_SPI1_HOST
bool "USE SPI1 HOST"
config USE_SPI2_HOST
bool "USE SPI2 HOST"
config USE_SPI3_HOST
bool "USE SPI3 HOST"
config USE_SPI4_HOST
bool "USE SPI4 HOST"
endchoice
config SPI_HOST
int
default 0 if USE_SPI1_HOST
default 1 if USE_SPI2_HOST
default 2 if USE_SPI3_HOST
default 3 if USE_SPI4_HOST

Related

Identify this scripting language/format

This script is part of a legacy code that runs to create a GUI interface for editing text files to be used in analysis codes. There is a windows command script that references a ".sed" file which controls the formatting, editing, and help menu for the GUI. I would like to identify the coding language/rules used in these ".sed" files so that I can make a new more complicated input text file with descriptions of inputs.
Ideally, I would like to be able to use this code to create/edit ".csv" files which can be edited in Excel. This would potentially mean needing to avoid the set variable sizes/padding in the #file block of code below.
Any googling attempts to find more about the coding result in unix sed instructions that are not helpful.
UPDATE: I did find an additional exe in the shell folder of the legacy code for "sedwin.exe". When googled this seems to refer to an old "SEDT text editor for MS-DOS".
An example section from a ".sed" file is below:
<code>
#rem( version description information here )
#version(){"2.0"}
%--------------------------------------------------------------------
#file(seal2,native){
title1(A80);
title2(A80);
title3(A80);
r(G10),del(A1),ll(G10),c(G10),lg(G10),dg(G10),ngroov(I10);
ncase(I10),necc(I10),necase(I10),#for(i,1,necase,0){entlos[i](G10)};
#for(i,1,ncase,0){
speed[i](G10),ro[i](G10),nu[i](G10),delp[i](G10);
}
}
#edit(seal2){
#prompted(22,5,"SEAL2 Input Data"){
#help(){
" Code Name Here
"",
"Code description here"
};
#icon("Titles",titles){#titles();}
#icon("Seal Parameters",seal){#seal();}
#icon("Speed, Fluid Parameters",cases){#cases();}
}
}
#titles(){
#prompted(1,7,"Three Title Lines"){
#help(){
"These title lines will appear on the output of",
"the program.",
"",
"They are useful for identifying the output but",
"do not directly affect the results."
};
#datum("",title1,75,"");
#datum("",title2,75,"");
#datum("",title3,75,"");
}
}
#seal(){
#prompted(12,8,"Seal Parameters"){
#help(){
"Descriptions of inputs in this window.",
};
#datum("Shaft Radius (in)",r,15,"0.");
#float_check("Must be > 0.0","(%g)>0.");
#datum("Land Length (in)",ll,15,"0.");
#float_check("Must be > 0.0","(%g)>0.");
#datum("Seal Radial Clearance (in)",c,15,"0.");
#float_check("Must be > 0.0","(%g)>0.");
#datum("Groove Length (in)",lg,15,"0.");
#float_check("Must be >= 0.0","(%g)>=0.");
#datum("Groove Depth (in)",dg,15,"0.");
#float_check("Must be >= 0.0","(%g)>=0.");
#datum("Number of Grooves (0=plain seal)",ngroov,15,"0");
#int_check("Must be >= 0","(%d)>=0");
#datum("Number of Eccentricities",necc,15,"1");
#int_check("Must be between 1 and 10","(%d)>0&&(%d)<11");
#icon("Entrance Loss Cases",losses){#losses();}
}
}
#new_file(seal2){
file_type=seal2;
unit_type=native;
titles=New;
title1=;
title2=;
title3="(SEAL2 Data File)";
del=",";
seal=New;
ll=0.0;
r=0.0;
c=0.0;
lg=0.0;
dg=0.0;
ngroov=0;
losses=New;
necc=1;
necase=1;
entlos[1...necase]=0.1;
cases=New;
ncase=1;
speed[1...ncase]=0.0;
delp[1...ncase]=0.0;
nu[1...ncase]=0.0;
ro[1...ncase]=0.0;
}
</code>

Missing space between define and initializer sphynx rtd_theme

I am using doxygen + breathe + Sphinx to document C source code.
In my conf.py I have set:
breathe_show_define_initializer = True
and
html_theme = 'sphinx_rtd_theme'
In my C source code I have defines such as:
#define FOO 12U //!< example #define
In the xml generated from doxygen, I see:
<name>FOO</name>
<initializer>12U</initializer>
<briefdescription>
<para>example #define </para>
</briefdescription>
So far so good!
The problem is the output from Sphinx is missing white space between the name and the initializer. i.e. as shown, no space between FOO and 12U:
FOO12U
example #define
I tried using both:
.. doxygendefine:: FOO
and I tried the group which has a number of defines:
.. doxygengroup:: MY_DEFINES_GROUP
If I change html_theme = 'alabaster'
Then there is a space between FOO and 12U
Any thoughts - am I missing a configuration?
I found this question via Google since I ran into the same issue. I'm posting my solution here which I hacked up and it seems to work for my case in the hopes of saving someone else time. My solution was to insert a "no break space" after each name of the define (but before the value).
Create a custom css: under _static/custom-signame.css (which is where I store my other custom css files)
The contents of the file are:
/* add a space to fix Breathe+Sphinx rtd_theme with
breathe_show_define_initializer */
.sig-name::after {
content: "\00a0";
}
Make sure that conf.py is updated to include the new custom css created in step 2:
html_static_path = ['_static']
html_css_files = [
'custom-table.css',
'custom-signame.css',
]

The %procid% sometimes blank in rsyslog template

I'm trying to configure rsyslog to output in RFC5424 format. This means that the PROCID must be output in the syslog header. If there's no header, it should output a single dash (-) in its place. However, some of the events output have it just blank, and some have an actual value.
This is rsyslogd 5.8.10 running on Amazon Linux.
Here are the config lines:
$template CustomFormat,"<%PRI%>1 %timegenerated:1:23:date-rfc3339%-00:00 %HOSTNAME% %app-name% b%procid%b %msgid% %STRUCTURED-DATA%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
$ActionFileDefaultTemplate CustomFormat
Note that I put a "b" on each side of %procid% to make it more visible (this part is not RFC5424-compliant). Here are two lines of sample output.
<87>1 2019-06-19T20:03:01.929-00:00 ip-10-90-0-15 crond b29408b - - pam_unix(crond:account): expired password for user root (password aged)
<85>1 2019-06-19T20:17:18.150-00:00 ip-10-90-0-15 sudo bb - - ssm-user : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/vi /etc/rsyslog.conf
The first line is correct, but the second example should have "b-b" instead of "bb". What should I do to make the blank %procid% show up as a dash? It works fine for the %msgid% and %STRUCTURED-DATA%.
Is there a better way to get RFC5424 output? (I have to use -00:00 instead of Z.)
There may be a better way, but one thing you can try is to use a Rainer script variable in the template instead of the property, and set this variable to "-" if the procid is empty. For example,
$template CustomFormat,"<%PRI%>1 ... b%$.myprocid%b ..."
$ActionFileDefaultTemplate CustomFormat
if ($procid == "") then {
set $.myprocid = "-";
} else {
set $.myprocid = $procid;
}
*.* ./outputfile
Just make sure the if statement is before any action statements. Note, you cannot change the procid property itself with set.

Creating SNMPD Agent - Writeable objects and more

Apologize for the long post, majority of it are config files that need to be shown.
I've been creating my own SNMP agent. For creating my MIB and snmpd.conf file I've just searched the web for answers. For actually implementing the handlers I've used the example.c/.h found at http://www.net-snmp.org/dev/agent/example_8c_source.html
I'm using another PC (all Linux) to test my implementation and so far I've only been able to get snmpwalk/snmpget commands to work.
I've setup the WriteMethod function inside my source file for my setable objects. Problem is, I do not think this code is getting executed when trying to set the object.
Below is an example of trying to set the object:
root#jt:/usr/share/snmp/mibs# snmpset -v 2c -c communityNameHere -m MIB-NAME-HERE.txt 10.20.30.40 1.3.6.1.4.1.12345.1 s "0"
MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (MIB-NAME-HERE.txt): At line 0 in (none)
Error in packet.
Reason: notWritable (That object does not support modification)
Failed object: iso.3.6.1.4.1.12345.1
I've also tried to use snmpset without the -m option. I've tried using -m +MIB-NAME-HERE.txt as well.
Question - I have snmp.conf commented out. How can it not find the module when the MIB I specify is in /usr/share/snmp/mibs ?
Below is my MIB :
MIB-NAME-HERE DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises,
NOTIFICATION-TYPE FROM SNMPv2-SMI
OBJECT-GROUP, NOTIFICATION-GROUP FROM SNMPv2-CONF
;
testSnmp MODULE-IDENTITY
LAST-UPDATED "201505200000Z"
ORGANIZATION "www.example.com"
CONTACT-INFO
"email: support#example.com"
DESCRIPTION
"MIB Example."
REVISION "201505200000Z"
DESCRIPTION
"version 1.0"
::= { enterprises 12345 }
--
-- top level structure
--
testSnmpValues OBJECT IDENTIFIER ::= { testSnmp 1 }
testSnmpValuesGroup OBJECT-GROUP
OBJECTS { testObject
}
STATUS current
DESCRIPTION
"Group of all test variables."
::= { testSnmp 4 }
--
-- Values
--
testObject OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(1..4096))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Test Example"
::= { testSnmpValues 1 }
Question - What is the purpose of :
testSnmpValues OBJECT IDENTIFIER ::= { testSnmp 1 }
testSnmpValuesGroup OBJECT-GROUP
OBJECTS { testObject
}
STATUS current
DESCRIPTION
"Group of all test variables."
::= { testSnmp 4 }
Now for my snmpd.conf file :
###############################################################################
#
# snmpd.conf:
# Test snmpd configuration file. (See EXAMPLE.conf as a reference)
#
###############################################################################
# By default snmp looks here:
# /etc/snmp/snmpd.conf.
# Use '-C -c <configfile>' to override.
#
###############################################################################
# Access Control
###############################################################################
# sec.name source community
com2sec testall default communityNameHere
#---- Community 'communityNameHere' uses security name 'testall'. 'source' selects which IPs can connect.
####
# Second, map the security names into group names:
# sec.model sec.name
group TestGroup v1 testall
group TestGroup v2c testall
group TestGroup usm testall
####
# Third, create a view for us to let the groups have rights to:
# incl/excl subtree mask
#view all included .1 80
view testview included .1.3.6.1.4.1.12345
#---- testview - A view which only allows access to Test OIDs.
####
# Finally, grant the groups access to the 1 view with different
# write permissions:
# context sec.model sec.level match read write notif
#---- Grant read access to TEST group for all security models.
access TestGroup "" any noauth exact testview testview testview
# -----------------------------------------------------------------------------
# load the testsnmp module
dlmod testsnmp /usr/local/testsnmp.so
Question - Is there something I am missing to make an object writeable? I've seen other snmpd.conf files with different formats but I assume that shouldn't matter?
You generally don't need a MIB for net-snmp to work. It is enough when you have the OID specified in the .c file.
Are you trying the snmpset/get/walk on a remote PC or on the same one.
I had to specifie in my snmpd.conf the
-> agentAddress udp:161
Without it i didn't had access.
Your MIB file missing "END" at the end, you can validate it here: simpleweb mib validation
I named my community "public" and had to add this in /etc/snmp/snmpd.conf
com2sec ConfigUser default public
com2sec AllUser default public
group ConfigGroup v1 ConfigUser
group AllGroup v2c AllUser
Now you shall be able to do your tests with v1.
I had to do export MIBS="MY-MIB", whereas MY-MIB.txt is my MIB file, which I put info /usr/local/share/snmp/mibs/. I don't remember exactly whether it was required for mib2c tool or if you can skip defining MIBS variable.
Then you could start snmpd with -d switch to see debug output, start your agent and can do testing. I had to enable ports used by snmpd in my firewall, which were blocked by default. I can test read/write on my dummy value with:
snmpget -v1 -c public localhost:10161 MY-MIB::test2.0
MY-MIB::test2.0 = INTEGER: 43 tests
snmpset -v1 -c public localhost:10161 MY-MIB::test2.0 = 123
MY-MIB::test2.0 = INTEGER: 123 tests
As long as you have a working agent, this shall work, you can use also mib2c to create simple sub-agent for your test-MIB and test it with it, just to make sure your config+agent is all right.

Including/excluding entire groups from targets

My project has a group with a few hundred files (organized into a couple dozen subgroups two levels deep). The files in that group are themselves being changed reasonably often. I want those files to be included in some targets, but not others.
In Xcode 3.x, after each change to the group, I would just Get Info on the group itself, go to the Targets tab, and (re-)select the targets I wanted. (This was, in fact, the answer to a nearly-identical question from 2010, Xcode — groups and targets.)
In Xcode 5, the equivalent File Inspector panel doesn't have a Target Membership section if you have a group selected (and, even if selecting a group were the same as selecting all of its files, the Target Membership checkboxes are disabled if you select more than one file).
So, is this functionality still there, but hidden somewhere I haven't been able to find it?
If not, obviously there are other ways I can do what I want—script Xcode, parse the .pbxproj file, or abstract the group into a subproject or an entirely separate project that builds a static lib, etc. But I'd love to be able to work with Xcode here, the way I did in 3.x, instead of have to fight against it.
Actually, scripting Xcode doesn't seem to work. Any attempt to get the build files of a build phase fails with a generic -10000 error. For example:
tell application "Xcode"
set theproject to project "SampleProject"
set thetarget to target "SampleTarget" of theproject
set thephase to build phase "Compile Sources" of thetarget
build files of phase
end tell
… fails on the last line with:
error "Xcode got an error: AppleEvent handler failed." number -10000
Here's the hack I ended up using—I'd obviously still appreciate a better solution.
#!/usr/bin/env python3
import os
import plistlib
import sys
pbxproj = os.path.join(sys.argv[1], 'project.pbxproj')
groupname = sys.argv[2]
extensions = 'm mm c cc cpp'.split()
with open(pbxproj, 'rb') as f:
p = plistlib.load(f)
objs = p['objects']
groupid, group = next((k, v) for k, v in objs.items()
if v.get('path') == groupname)
def descendants(id):
obj = objs[id]
if obj['isa'] == 'PBXFileReference':
yield (id, obj)
for child in obj.get('children', []):
yield from descendants(child)
mdict = {id: obj for id, obj in descendants(group_id)
if os.path.splitext(obj['path'])[-1] in extensions}
proj_id, proj = next((k, v) for k, v in objs.items()
if v['isa'] == 'PBXProject')
for target_id in proj['targets']:
target = objs[target_id]
phase_ids = target['buildPhases']
phases = [(phase_id, objs[phase_id]) for phase_id in phase_ids]
phase_id, phase = next((phase_id, phase)
for phase_id, phase in phases
if phase['isa'] == 'PBXSourcesBuildPhase')
fileref_ids = [i
for i, buildfile_id in enumerate(phase['files'])
if objs[buildfile_id]['fileRef'] in mdict]
fileref_ids.sort(reverse=True)
for i in fileref_ids:
del phase['files'][i]
with open(pbxproj + '.new', 'wb') as f:
plistlib.dump(p, f)
os.rename(pbxproj, pbxproj + '.bak')
os.rename(pbxproj + '.new', pbxproj)

Resources