how to create barebox-state for nand flash - linux-kernel

i'm facing an issue in barebox-state. when first stage bootloader runs an error occured
"state: state failed to parse path to backend: No such device"
and in kernel, when i run barebox-state it gives error that
"Neither /aliases/state nor /state found".
i am adding a state node in barebox device tree.
state: state {
#address-cells = <1>;
#size-cells = <1>;
compatible = "barebox,state";
magic = <0xab67421f>;
backend-type = "raw";
backend = <&state_part>;
backend-storage-type = "circular";
bootstate {
system0 {
remaining_attempts#0 {
reg = <0x0 0x4>;
type = "uint32";
default = <3>;
};
priority#4 {
reg = <0x4 0x4>;
type = "uint32";
default = <20>;
};
};
system1 {
remaining_attempts#8 {
reg = <0x8 0x4>;
type = "uint32";
default = <3>;
};
priority#c {
reg = <0xC 0x4>;
type = "uint32";
default = <20>;
};
};
last_chosen#10 {
reg = <0x10 0x4>;
type = "uint32";
};
};
};
and the nand partition looks like this
&gpmc {
/* ... */
nand: nand#0,0 {
/* ... */
state_part: partition#1c0000 {
label = "barebox_state";
reg = <0x1c0000 0x320000>;
};
/* ... */
};
when i add this state for eeprom it works fine. i donot know what is the issue. my barebox version is ""2018.11.0-phy3", dt-utils version is "2021.03.0" and kernel version is "linux-mainline_4.14.78-phy4".
kindly guide me if anyones know. Thanks in advance.
i tried to add the state in eeprom it works fine but in case of nand it creating an issues.

Related

HAL_RCC_OscConfig returns HAL_TIMEOUT

I'm trying to configure a development board with STM32F411CEU6.
This board have two crystals (25Mhz and 32,768KHz).
I'm trying to compile code generated from CubeMX with different configurations, but HAL_RCC_OscConfig returns always HAL_TIMEOUT.
I tried to:
stretch the timeout of 1000ms
lower the clock from 100Mhz to 96, 72 and 50MHz.
disable the LSE crystal
but is everything useless.
This is the SystemClock_Config function:
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 200;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
{
Error_Handler();
}
}

How to make GPIO init before MII init

I want to make GPIO-driven reset on 2 PHY chips inside DUAL EMAC on TI AM3352.
Because drivers don't have the ability, I have made a mod in mdio_bus.c driver, function mdiobus_register_gpiod():
if (gpiod == NULL && mdiodev->bus && mdiodev->bus->dev.of_node) {
gpiod = fwnode_get_named_gpiod(&mdiodev->bus->dev.of_node->fwnode,
"phy-reset-gpios", mdiodev->addr, GPIOD_OUT_LOW,
"PHY reset");
if (gpiod)
printk("found gpiod for addr=%d\n", mdiodev->addr);
}
mdiodev->reset = gpiod;
this is my device tree with added feature:
&cpsw_emac0 {
status = "okay";
phy_id = <&davinci_mdio>, <0>;
phy-mode = "mii";
dual_emac_res_vlan = <1>;
};
&cpsw_emac1 {
status = "okay";
phy_id = <&davinci_mdio>, <1>;
phy-mode = "mii";
dual_emac_res_vlan = <2>;
};
&davinci_mdio {
status = "okay";
phy-reset-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>, <&gpio1 1 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&mdio_pins_default>;
};
&mac {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&phy1_pins_default>,<&phy2_pins_default>;
dual_emac = <1>;
};
However GPIO controller is initialized long after MDIO drivers, so the mdio-bus cannot find GPIO chips.
Is it possible to initialize GPIO earlier? Where is this priority configured?

ET035009DH6 lcd display config

The display (ET035009DH6) stays dark with the following configuration. The backlight is on. Touch is working.
ETM035009EDH6 Spec
Toradex Colibri iMX6ULL 512MB V1.1A
Toradex Colibri Evaluation Board Rev. 3.2
ET035009DH6
angstrom-lxde-image
Device Tree
lcdif#021c8000 {
compatible = "fsl,imx6ul-lcdif", "fsl,imx28-lcdif";
reg = <0x021c8000 0x00004000>;
interrupts = <0x00000000 0x00000005 0x00000004>;
clocks = <0x00000001 0x000000a2 0x00000001 0x000000a1 0x00000001 0x00000000>;
clock-names = "pix", "axi", "disp_axi";
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <0x0000003f 0x00000040>;
display = <0x00000041>;
lcd-display {
bits-per-pixel = <0x00000010>;
bus-width = <0x00000012>;
linux,phandle = <0x00000041>;
phandle = <0x00000041>;
display-timings {
native-mode = <0x00000042>;
320x240 {
phandle = <0x00000042>;
linux,phandle = <0x00000042>;
clock-frequency = <0x00632ea0>;
hactive = <0x00000140>;
vactive = <0x000000f0>;
hback-porch = <0x00000044>;
hsync-len = <0x00000058>;
hfront-porch = <0x00000014>;
vback-porch = <0x00000012>;
vsync-len = <0x00000016>;
vfront-porch = <0x00000004>;
hsync-active = <0x00000000>;
vsync-active = <0x00000000>;
de-active = <0x00000001>;
pixelclk-active = <0x00000000>;
};
640x480 {
clock-frequency = <0x018023d8>;
hactive = <0x00000280>;
vactive = <0x000001e0>;
hback-porch = <0x00000028>;
hfront-porch = <0x00000018>;
vback-porch = <0x00000020>;
vfront-porch = <0x0000000b>;
hsync-len = <0x00000060>;
vsync-len = <0x00000002>;
de-active = <0x00000001>;
hsync-active = <0x00000000>;
vsync-active = <0x00000000>;
pixelclk-active = <0x00000000>;
};
800x480 {
};
800x480pixclkact {
};
800x600 {
};
1024x600 {
};
1024x768 {
};
};
U-Boot
setenv vidargs video=mxsfb:320x240M-18#60
When connecting a screen via VGA to the Eval Board (Toradex Colibri Evaluation Board Rev3.2) and leave the default LCD timings to 640x480 (phandle and linux,phandle in 640x480) the screen shows the LXDE desktop.

How to get a device's serial no with Nativescript?

Does anybody know how to get the serial number of a device?
I know I can do this in a NativeScript-5 application (TypeScript):
import { Page } from "tns-core-modules/ui/page";
import * as platformModule from "tns-core-modules/platform";
export function onNavigatingTo(args: EventData) {
let page = <Page>args.object;
console.log("Manufacturer:" + platformModule.device.manufacturer);
console.log("Model:" + platformModule.device.model);
console.log("UUID:" + platformModule.device.uuid);
}
But I couldnt find any property for the device's serial number.
Anybody an idea? It's alright if your solution only covers Android (since my project is targeting Android tablets only).
Thanks!
Update:
Manoj pointed me to some Java code that probably solves my problem. However, I wasn't able to marshal the following code to TypeScript.
public static String getManufacturerSerialNumber() {
String serial = null;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class);
serial = (String) get.invoke(c, "ril.serialnumber", "unknown");
} catch (Exception ignored) {}
return serial;
}
Maybe anybody could help me? That would be awesome!
iOS never allows any confidential information to be accessed by apps, that applies to serial number too. With Android, you may read the serial number with
android.os.Build.SERIAL
I had it tested with Playground
Edit 1:
Manufactures like Samsung seems to have a different serial number which is not same as android.os.Build.SERIAL. Here is another SO thread that seems very relevant for Samsung, the sample code is written in Java.
Edit 2:
Here is how you may get serial number on Samsung devices
let serialNumber = '';
try {
const cl = application.android.context.getClassLoader();
const SystemProperties = cl.loadClass('android.os.SystemProperties');
const paramTypes = (<any>Array).create(java.lang.Class, 2);
paramTypes[0] = java.lang.String.class;
paramTypes[1] = java.lang.String.class;
const getMethod = SystemProperties.getMethod('get', paramTypes);
const params = (<any>Array).create(java.lang.Object, 2);
params[0] = new java.lang.String('ril.serialnumber');
params[1] = new java.lang.String('unknown');
serialNumber = getMethod.invoke(SystemProperties, params);
} catch (err) {
console.error(err);
}
Updated Playground
You can check properties 'ro.serialno', 'ril.serialnumber', 'gsm.sn1', 'sys.serialnumber'
Android: How to programmatically access the device serial number shown in the AVD manager (API Version 8)
In my case Samsung TAB S2 has 2 serials. Property 'ro.serialno' more accurate then 'ril.serialnumber'. So i check it first.
getSerial() {
if (isAndroid) {
let serialNumber = null;
try {
const cl = application.android.context.getClassLoader();
const SystemProperties = cl.loadClass('android.os.SystemProperties');
const paramTypes = (<any>Array).create(java.lang.Class, 2);
paramTypes[0] = java.lang.String.class;
paramTypes[1] = java.lang.String.class;
const getMethod = SystemProperties.getMethod('get', paramTypes);
const params = (<any>Array).create(java.lang.Object, 2);
// Reorder if needed
const props = ['ro.serialno', 'ril.serialnumber', 'gsm.sn1', 'sys.serialnumber'];
for(let i = 0, len = props.length; i < len; i++) {
params[0] = new java.lang.String(props[i]);
serialNumber = getMethod.invoke(SystemProperties, params);
if (serialNumber !== '') {
return serialNumber;
}
}
} catch (err) {
console.error(err);
}
return serialNumber;
}
}
Full code: https://play.nativescript.org/?template=play-tsc&id=ViNo6g&v=6

How to add new /proc/sys/kernel entries?

I wanted to add the new sysctl parameter in kernel module for the code audit.c and this parameter value should be changed during runtime.Where exactly I need to add the new sysctl code and How to achieve it?
You should use ctl_table in tree hierarchy and handle it in your module.
static struct ctl_table sample_child_table1[] = {
{
.ctl_name = CTL_UNNUMBERED1,
.procname = "sample",
.maxlen = sizeof(int),
.mode = 0444,
.data = &global_var,
.proc_handler = &proc_dointvec_minmax,
.extra1 = &min_val,
.extra2 = &max_val,
},
{}
};
static struct ctl_table sample_parent_table[] = {
{
.ctl_name = CTL_KERN,
.procname = "kernel",
.mode = 0777,
.child = sample_child_table,
{}
},
register_sysctl_table(sample_parent_table)

Resources