cancel
Showing results for 
Search instead for 
Did you mean: 

HSEM between Cortex-M4&Cortex-A9

AlexandrShipovsky
Associate III

Hi everyone!

I want to use a hardware semaphore to access SRAM4 memory from both Linux and M4 firmware on STM32MP157A-DK1 board. There are no problems with the M4 firmware. But for Linux I have to create a driver. There is an example in this article: https://wiki.st.com/stm32mpu/wiki/Hardware_spinlock_overview

But according to this example, I can't choose the number of the hardware semaphore that I want to use. I ask for advice on how best to organize what I want to do. Maybe I can use a hardware semaphore from user space?

2 REPLIES 2
ArnaudP
Senior

Hello @AlexandrShipovsky​ 

The semaphore number is selected thanks to the device tree configuration as described here:

https://wiki.st.com/stm32mpu/wiki/HSEM_device_tree_configuration#DT_configuration_examples

Okay, thank you for answer. But I found another way. In the driver code I write this:

	hwlock = hwspin_lock_request_specific(HSEM_ID);
 
	if (hwlock)
	{
		/* try to take it, but don't spin on it */
		ret = hwspin_trylock(hwlock);
		if (!ret) {
			pr_info("lock is taken\n");
		}
		/*
		 * we took the lock, do our thing now, but do NOT sleep
		 */
		hwspin_unlock(hwlock);
 
	}

It work for any number hardware semaphore