Skip to main content
AlexandrShipovsky
Associate III
March 10, 2022
Question

HSEM between Cortex-M4&Cortex-A9

  • March 10, 2022
  • 2 replies
  • 1955 views

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?

This topic has been closed for replies.

2 replies

ArnaudP
ST Employee
March 11, 2022

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

AlexandrShipovsky
Associate III
March 15, 2022

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