Error when instantiating i2c slave device - c

Hello I am trying to create an i2c slave device on my beaglebone black(debian 10) which is running the kernel version 4.19.94-ti-r42.I was going to implement my own i2c slave device driver by writing my own kernel module but then i cam across a command that i think would allow me to instantiate a slave device on the i2c bus 2 without having to do any of that.I used the following command to do this:
echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-2/new_device
which i got from the following site: https://www.kernel.org/doc/html/latest/i2c/slave-interface.html
yet when i ran the command i got the following error:
-bash: /sys/bus/i2c/devices/i2c-2/new_slavedevice: Permission denied
Does anyone know what i may be doing wrong? Thank you.

Are u trying to instantiate a i2c-slave(i.e access the eeprom device), or custom "linux-i2c-slave" to handle the read/write for that address.
I presume that you are using beaglebox, and want to instantiate eeprom device on it from linux.
In that case, you need an i2c-slave, and the command would be
echo 24c02 0x1064 > /sys/bus/i2c/devices/i2c-2/new_device
Hope I have understood the question correctly.

Related

EFI_TIMEOUT error on EFI_TCG2_SUBMIT_COMMAND

Inside EFI I use EFI_TCG2_PROTOCOL to communicate with TPM device.
On system start I decrypt some data calling TPM device commands with function EFI_TCG2_SUBMIT_COMMAND in protocol EFI_TCG2_PROTOCOL. That works fine.
But now (seems that after windows update) I started to receive error EFI_TIMEOUT (0x8000000000000012) on my attempts to execute command with EFI_TCG2_SUBMIT_COMMAND.
What can be the possible reason? How to fix it?

STM32F407 Disc E31 Error message in debugging

I will ask a question about my STM32F407 Discovery board. I want to learn about external interrupts and I was making a small circuit. I connected PH0 to my button and PH1 to the LED. But these pins are connected to the mcu's crystal pins. But I didn't know it at that time. I was press button that is connectet to 5V. And my IDE won't connect to my board for debugging debugging. I can connecting to my board via ST Link Utility and I can do a full chip erase with no errors. Then I turn back to code in Atollic, press the debugging button and I get this error messages:
Error in executing 'cont' command ...
CM4 Failed to read all registers
FAILED to REGISTER Values from the target
Target is not responding, retrying...
*some messages in between*
warning: Remote failure reply: E31
Remote failure reply: E31
Remote connection closed
Quit
And then I turned off the debug screen to try again but I can't because Atollic can't find any ST Link devices. This is the error message:
Target no device found
Error in initializing ST-LINK device.
Reason: No device found on target.
Note: My PC recognize my board in Device Manager.
How can I solve this problem. ST Link Utility connects to my board succesfully, My PC connects to my board. I tried St link firmware upgrade but I got more errors. Like this.
Failure at line: 13 in "Target Software Startup Scripts"
You probably have ST Utility still connected to your MCU. This results in Atollic not beeing able to connet to the MCU. Either close ST Utillity or press the disconnet button.
Since you can erase it your MCU should be ok and you chose one of the few 5V tolerant pins but it would be better practice to use 3V.
Another reason might be the option bytes if the read out protection got set to level 1 or 2 the debugger is sometimes not able to reset those and is therefore not able to read out the register.
I was solve a lot of problem. Firstly I found a problem. This is a my DCMI_Config function. In this function I have a lot of pin definition. GPIOA caused my problem.
GPIOA-> MODER = 0x00002200; //GPIOA 4,6 Set Alternate Function for DCMI
This line has my problem. I was search Discovery schematic and I found something. PA4 pin connected to Discovery's voice uc as I2S3_WS. Is this cause any problem?

How to write Linux kernel module for serial communication to arduino?

I have got Arduino MEGA 2560. What I would like to do is to send a signal to Arduino via serial port to light specified LED up. However, I cannot find any documentation about this. What steps should I follow?
I think first, I need to compile the driver of Arduino and add it to Linux kernel. Second, I have to find some header files to use them in module. Then, I have to find functions to start serial communication and to light LEDs up. However, these are just my thoughts.
Any advice will be appreciated.
The arduino-mega (the one with ATmega2560) documentation is here:
https://www.arduino.cc/en/Main/ArduinoBoardMega2560#documentation
The serial communication via UART:
https://www.arduino.cc/en/Reference/SoftwareSerial
Since there are other ways for serial communication with the ATmega please read the documentation [above] and compare that to your exercise sheet.
I think such a kernel module is already available - and used by the arduino-ide.

How to implement Serial Port Profile Link Command used in ConnectBlue Bluetooth Module?

I am trying to implement Bluetooth using "connect-blue-oem-spa-331" module using UART protocol and using MSP430 as base controller. I'm using Embedded C as a language of programming.
Everything just works fine until I reach to Serial Port Link Command "AT*ADCP". Every time I get response as ERROR. I have tried with both options by keeping ECHO ENABLED and ECHO DISABLED.
p_cmd = "AT*ADCP=XXXXXXXXXXXX,0,0,0\r";
this is my command. 'X' represents the Bluetooth confirm device address which I confirm when I execute DEVICE_INQUIRY command.
The module through which I am executing all these commands is always MASTER and will initiate pairing and communication process. As a safety I have kept it non-discoverable.
How can I implement the Serial Port Profile Link command without getting error when I confirm the bluetooth device using DEVICE_INQUIRY command.
I have been working with blue tooth for last 4 months. I had faced above issue in early days. And after running through documentation available for product I solved the issue. I thought to reply this question which I've asked.
I was using Connect Blue OEM-SPA-331i classic Bluetooth module in my project, and was using Serial Port Profile to implement Bluetooth commands.
When I inquire devices I get the list of Bluetooth Devices available and discoverable in the vicinity(mine was CLASS-I Device); and lists them as (48 bit MAC Address,Class of Device) i.e. ( 001234ab987f,786545) of the discovered Bluetooth Module.
When I'm trying to establish Serial Port Profile Link, it was required that I must write address of peer device to be connected over Serial Port Profile in Serial Port Adapter. The order of the commands should be
Inquire discoverable devices
Write the desired peer device address to Serial Port Adapter, remember it in power cycles.
Establish Profile Link.
This way I resolved my issue of link not getting established.

How to read data form WinCE 5.0 's Debug Serial port?

In my project, I need to input some command into my WinCE device through the debug Serial Port. But I found that I can only use "printf" or "RETAILMSG" to output my debug info but I can't simply call "scanf" to get the data of debug Serial Port.
By look up the MSDN, I have found a function named "OEMReadDebugByte". It is a KERNEL function of WinCE, but when I try to call this function in my WinCE application, the Platform Builder post "error LNK2019: unresolved external symbol OEMReadDebugByte referenced in function wmain"
Can I use insert a case in the KernelIoControl? How ? Which file define the "KernelIoControl"?
Or... there are any solutions else?
Thanks a lot!!!
Thank you!
This function is meant to be used in the bootloader to read input from the user to set-up bot mode, network configuration etc. It's not used by the kernel. Serial is used for debug output and there is no easy way to change this. What you may do is to implement an application that provide a serial console and change your BSP removing serial debug and changing it to a system that sends this information to the application (using shared memory or something like this) that then outputs it on the serial port console.
Implementing it will require some knowledge of the OAL and BSP structure and features.

Resources