f9micro / f9-kernel

An efficient and secure microkernel built for ARM Cortex-M cores, inspired by L4
Other
682 stars 145 forks source link

feature: support stm32f4 gpio output function and example app: gpioer #86

Closed benwei closed 10 years ago

benwei commented 10 years ago

Here is first version of gpio function support , just gpio with output-only api. An Example of gpioer with user the stm32f407 built-in four leds. The gpioer app will make the 4 leds blink with 1 second interval.

georgekang commented 10 years ago

Because F9 is microkernel based, it would be better to put hardware driver in user space.
In my opinion, both user-log and user-gpioer violate the design principle of microkernel.
They will let F9 look like a monolithic kernel. user-log is a workaround just for easy dump but not a good design.

benwei commented 10 years ago

Thank for your opinion. Sure, I agreed with you. Now, I'm trying to do the following modification.

firstly, I created all api related for gpio.c to gpioer.c (each function with __USER_TEXT). let user/apps/gpioer/main.c call gpioer.c from user space.

secondly, the memory access fault because gpioer.c api access the following address

RCC_AHB1ENR, GPIO_MODER(port); GPIO_OTYPER(port) GPIO_OSPEEDR(port) GPIO_PUPDR(port) GPIO_MODER(port) GPIO_AFRL(port) GPIO_AFRH(port) GPIO_ODR(port) Do you have any suggestion about memory permission ? Should I grant all of the memory address to allow userspace gpioer app read/wrte? if doing by this way, how about the security control?

benwei commented 10 years ago

update gpioer sample code which access AHB1_1DEV from user space directly. because RCC_AHB1ENR(0x40023830) will be accessed, memory.c was modified with AHB1_1DEV's upbound range from 0x40022400 to 0x40023c00.

benwei commented 10 years ago

Thank for info. I referred the student code. That's great way to avoid hacking root_thread.c, I fixed code and remove duplicated code and put gpio.c to user mode. I extended the Kconfig for Applications to make default build original apps.

jserv commented 10 years ago

@benwei, please rebase to master.

In addition, @georgekang is going to revise the interrupt handling, and my student is working on the new driver model. We expect to make it fairly functioned next week.

jserv commented 10 years ago

WIP: user_interrupt branch

jserv commented 10 years ago

Cc. @slpbaby , who is working on STM32F429 Discovery platform support. Cc. @rampant1018 , who is expected to revise further design of programming model and corresponding APIs.

jserv commented 10 years ago

Deprecated since we should always follow principle of least privilege (POLA).

ab1aw commented 5 years ago

I am trying to build an F9 image that can flash the LEDs on the STM32F407 Discovery board. I find that the forked repository of benwei does not build. I merged the benwei gpio code into my fork of latest f9-kernel. It builds successfully but does not run. Is there any successful code demonstration of flashing the LEDs? Thank you.