How to stop booting of Linux kernel(3.14) if sensor is not able to probe in u-boot? - linux-kernel

I ported ADXL345(accelerometer) on AM335x SOC successfully.In mux.c file in u-boot i did changes so that to communicate properly.
But I in case the communication fails, I want kernel not to boot.
please help me in this, correct me if I am wrong.

In your board file, in board_init function add the check for the accelerometer and see if communicates and on failure return -EINVAL, so you board doesnt boot up at all.

Related

How to Lock bootloader in source code- U-boot

I want to make my development board's bootloader (which is u-boot) be locked so no one can stop autoboot process at all. (In this way I will be sure that no one can alter the firmware of the board!)
So please guide me in order to locking the firmware and block any "root" attempts. I am using amlogic s905x SoC.
Another question:
Is this process relates to verified boot and signing kernel images?
If your SoC chip supports secure boot, then it is a way to make its firmware, secure of jail breaking. consult the datasheet. Otherwise you can not 'lock' the firmware.
You can use CONFIG_AUTOBOOT_KEYED=Password to require a password for stopping autoboot.
You can use CONFIG_BOOTDELAY=-2 to autoboot with no delay and not check for abort.
This will not stop users with physical access from altering the firmware. They could simply insert there own SD-card or USB stick or reprogram the eMMC.
CONFIG_AUTOBOOT_KEYED will make you live easier if you need to reflash a returned device.

I2C Kernel driver binding

Hi I am new to kernel driver developement. I am using the raspberry pi as my hostI am trying to create an I2C driver for a custom board we have. The custom board will act as the slave. I am confused about how do I go about entering the devices slave address. From what I understand
You need to either have a board setup file which I dont since its a custom board.
You can edit the device tree
Or you can do it in the user space application.
I am not sure where exactly to edit the device tree if I go with the second option. More over I would like to somehow register the slave address in the I2C driver itself. That way I donot need to rebuild the kernel. One method i was looking at was to set the i2c client from the driver code but that was advised by commentators I am not sure why. Any help would be appreciated.
Instantiating Drivers
So I have finally a working way in which I can bind the I2C device without needing a kernel rebuild. I create two driver files(.ko files). One for registering and one for the actual driver.
The way I did it is I got the bus number to which the device was connected.
(You can look into i2c user space code. i2cdetect -y (busnumber) will help you detect which bus number it is)
Once I knew that I created a driver file which would register my device by getting access to the adapter and then registering it. My bus number was 1 and slave address 0x10
static struct i2c_board_info board_info[] __initdata =
{
{
I2C_BOARD_INFO("my_device", 0x10),
},
};
And in the init function of the driver I register the device by
i2c_new_device(i2c_get_adapter(1), board_info[0])
Thats it. Now once you build this insmod the ko file before insmoding the actual driver file and everything should work.

How to ensure bootloader is started

I am working with openmote-cc2538 for the project: https://github.com/cetic/6lbr/wiki
Here when I was trying to flash openmote with this command
sudo make TARGET=cc2538dk BOARD=openmote-CC2538 bootload0/dev/ttyUSB0 slip-radio.upload
This error message is displayed
ERROR:Cant CONNECT TO TARGET:Ensure bootloader is started(no answer on sync sequence)
cc2538 bsl.py script is available for uploading binary to openmote. But I don't have much experience about this. Can anybody give me some suggestions regarding how to proceed??
Grab a scope and probe different digital I/O pins on the CC2538. Typically a bootloader will initialize all the ports on the chip and you will see them change state, which is an indication that the bootloader is indeed running. I would guess one of the LEDs would change state as well (which doesn't require a scope).

Kernel irq disable

I am using P2041 with kernel 3.12. I am using xr17v358 for serial interface. When I run serial interface it shows "try to boot with irqpoll" , " disabling irq" and so many trace messages. How to overcome this issue?
Try to boot with "irqpoll" option in uboot kernel command line. This will help the kernel to find proper ISR. After enabling this option your system may get slow.

Accessing/monitoring battery status through SMBus

I am currenlty trying to monitor my battery status through SMBus.
I have a battery along with a control board that constantly outputs the battery status.
This control board is then connected to my mother board through a I2C-USB module.
I need to write a program to recognize the SMBus connection and transmit the battery status to the user.
I'm a beginner when it comes to dealing with smart batteries and I2C/SMBus, and I'm somewhat lost with how to approach this problem.
Any help of suggestions would be appreciated. Thanks.
Your question is a bit lacking. What kind of I2C-USB module? Or rather does it come with a Linux driver? If it does you probably won't need to write one. An application will do. You can read more about I2C and SMBus here.
Basically what you need is the I2C address of the control board (a single byte). When you have the address you (as the master) issue read commands over the I2C bus to the control board using its address and reads the response. If there's a driver for the I2C-USB module this should be straightforward enough. Plug in the device and open() the device (/dev/[i2c-usb-name] where [i2c-usb-name] is the name of the device). Then follow the driver implementer's guide how to setup and send data over that device (typically using read()/write() or ioctl()). Here are some additional information on working with I2C from user space: http://www.mjmwired.net/kernel/Documentation/i2c (select topics in the menu on the left hand side).
If you must write the driver yourself, the first stop for a Linux device driver beginner is the LDD3. Read it, it's quite a pleasant read.

Resources